1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * This document contains proprietary information belonging to Czech
7 * Technical University in Prague. Passing on and copying of this
8 * document, and communication of its contents is not permitted
9 * without prior written authorization.
13 * Common trailer for all RPP S-Functions.
14 * This file is included at the tail of each S-Function file. It includes refactored and
15 * commonly repeated structures that pollute S-Functions implementations. It includes basic
16 * includes, required definitions, macro definitions, common functions implementations and
17 * documentation on optional functions and commented prototypes for optional model calls/hooks.
24 #ifndef S_FUNCTION_NAME
25 #error 'Please include this file inside an S-Function implementation.'
29 /* Function: mdlInitializeSizes ================================================
31 * The sizes information is used by Simulink to determine the S-function
32 * block's characteristics (number of inputs, outputs, states, etc.).
34 #ifdef UNUSED_MDLINITIALIZESIZES
35 static void mdlInitializeSizes(SimStruct *S)
42 /* Function: mdlInitializeSampleTimes ==========================================
44 * This function is used to specify the sample time(s) for your
45 * S-function. You must register the same number of sample times as
46 * specified in ssSetNumSampleTimes.
48 #ifdef UNUSED_MDLINITIALIZESAMPLETIMES
49 static void mdlInitializeSampleTimes(SimStruct *S)
56 #ifdef COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
57 static void mdlInitializeSampleTimes(SimStruct *S)
59 ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
60 ssSetOffsetTime(S, 0, 0.0);
61 #if defined(ssSetModelReferenceSampleTimeDefaultInheritance)
62 ssSetModelReferenceSampleTimeDefaultInheritance(S);
68 /* Function: mdlOutputs ========================================================
70 * In this function, you compute the outputs of your S-function
71 * block. Generally outputs are placed in the output vector(s),
72 * ssGetOutputPortSignal.
74 #ifdef UNUSED_MDLOUTPUTS
75 static void mdlOutputs(SimStruct *S, int_T tid)
78 UNUSED_PARAMETER(tid);
83 /* Function: mdlTerminate ======================================================
85 * In this function, you should perform any actions that are necessary
86 * at the termination of a simulation.
88 #ifdef UNUSED_MDLTERMINATE
89 static void mdlTerminate(SimStruct *S)
96 /* Function: mdlCheckParameters ================================================
98 * mdlCheckParameters verifies new parameter settings whenever parameter
99 * change or are re-evaluated during a simulation. When a simulation is
100 * running, changes to S-function parameters can occur at any time during
101 * the simulation loop.
103 * Note: this an optional function for S-Function, in contrast to the ones
104 * above. This is here just because header.c declares
105 * checkParametersMismatch() that uses this function in order to
106 * refactor that commonly used block of code.
108 #ifdef UNUSED_MDLCHECKPARAMETERS
109 static void mdlCheckParameters(SimStruct *S)
117 * Required S-function trailer
119 #ifdef MATLAB_MEX_FILE
120 # include "simulink.c"
122 # include "cg_sfun.h"