1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
18 * 3. Neither the name of the copyright holder nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * Common trailer for all RPP S-Functions.
43 #ifndef S_FUNCTION_NAME
44 #error 'Please include this file inside an S-Function implementation.'
48 /* Function: mdlInitializeSizes ================================================
50 * The sizes information is used by Simulink to determine the S-function
51 * block's characteristics (number of inputs, outputs, states, etc.).
53 #ifdef UNUSED_MDLINITIALIZESIZES
54 static void mdlInitializeSizes(SimStruct *S)
61 /* Function: mdlInitializeSampleTimes ==========================================
63 * This function is used to specify the sample time(s) for your
64 * S-function. You must register the same number of sample times as
65 * specified in ssSetNumSampleTimes.
67 #ifdef UNUSED_MDLINITIALIZESAMPLETIMES
68 static void mdlInitializeSampleTimes(SimStruct *S)
75 #ifdef COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
76 static void mdlInitializeSampleTimes(SimStruct *S)
78 ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
79 ssSetOffsetTime(S, 0, 0.0);
80 #if defined(ssSetModelReferenceSampleTimeDefaultInheritance)
81 ssSetModelReferenceSampleTimeDefaultInheritance(S);
87 /* Function: mdlOutputs ========================================================
89 * In this function, you compute the outputs of your S-function
90 * block. Generally outputs are placed in the output vector(s),
91 * ssGetOutputPortSignal.
93 #ifdef UNUSED_MDLOUTPUTS
94 static void mdlOutputs(SimStruct *S, int_T tid)
97 UNUSED_PARAMETER(tid);
102 /* Function: mdlTerminate ======================================================
104 * In this function, you should perform any actions that are necessary
105 * at the termination of a simulation.
107 #ifdef UNUSED_MDLTERMINATE
108 static void mdlTerminate(SimStruct *S)
115 /* Function: mdlCheckParameters ================================================
117 * mdlCheckParameters verifies new parameter settings whenever parameter
118 * change or are re-evaluated during a simulation. When a simulation is
119 * running, changes to S-function parameters can occur at any time during
120 * the simulation loop.
122 * Note: this an optional function for S-Function, in contrast to the ones
123 * above. This is here just because header.c declares
124 * checkParametersMismatch() that uses this function in order to
125 * refactor that commonly used block of code.
127 #ifdef UNUSED_MDLCHECKPARAMETERS
128 static void mdlCheckParameters(SimStruct *S)
136 * Required S-function trailer
138 #ifdef MATLAB_MEX_FILE
139 # include "simulink.c"
141 # include "cg_sfun.h"