]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/trailer.c
Change license to MIT
[pes-rpp/rpp-simulink.git] / rpp / blocks / trailer.c
1 /* Copyright (C) 2013 Czech Technical University in Prague
2  *
3  * Authors:
4  *     - Carlos Jenkins <carlos@jenkins.co.cr>
5  *
6  * Permission is hereby granted, free of charge, to any person
7  * obtaining a copy of this software and associated documentation
8  * files (the "Software"), to deal in the Software without
9  * restriction, including without limitation the rights to use,
10  * copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * File : trailer.c
28  * Abstract:
29  *     Common trailer for all RPP S-Functions. 
30  *     This file is included at the tail of each S-Function file. It includes refactored and
31  *     commonly repeated structures that pollute S-Functions implementations. It includes basic
32  *     includes, required definitions, macro definitions, common functions implementations and
33  *     documentation on optional functions and commented prototypes for optional model calls/hooks.
34  *
35  * References:
36  *     header.c
37  */
38
39
40 #ifndef S_FUNCTION_NAME
41 #error 'Please include this file inside an S-Function implementation.'
42 #endif
43
44
45 /* Function: mdlInitializeSizes ================================================
46  * Abstract:
47  *     The sizes information is used by Simulink to determine the S-function
48  *     block's characteristics (number of inputs, outputs, states, etc.).
49  */
50 #ifdef UNUSED_MDLINITIALIZESIZES
51 static void mdlInitializeSizes(SimStruct *S)
52 {
53     UNUSED_PARAMETER(S);
54 }
55 #endif
56
57
58 /* Function: mdlInitializeSampleTimes ==========================================
59  * Abstract:
60  *     This function is used to specify the sample time(s) for your
61  *     S-function. You must register the same number of sample times as
62  *     specified in ssSetNumSampleTimes.
63  */
64 #ifdef UNUSED_MDLINITIALIZESAMPLETIMES
65 static void mdlInitializeSampleTimes(SimStruct *S)
66 {
67     UNUSED_PARAMETER(S);
68 }
69 #endif
70
71
72 #ifdef COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
73 static void mdlInitializeSampleTimes(SimStruct *S)
74 {
75     ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
76     ssSetOffsetTime(S, 0, 0.0);
77     #if defined(ssSetModelReferenceSampleTimeDefaultInheritance)
78     ssSetModelReferenceSampleTimeDefaultInheritance(S);
79     #endif
80 }
81 #endif
82
83
84 /* Function: mdlOutputs ========================================================
85  * Abstract:
86  *     In this function, you compute the outputs of your S-function
87  *     block. Generally outputs are placed in the output vector(s),
88  *     ssGetOutputPortSignal.
89  */
90 #ifdef UNUSED_MDLOUTPUTS
91 static void mdlOutputs(SimStruct *S, int_T tid)
92 {
93     UNUSED_PARAMETER(S);
94     UNUSED_PARAMETER(tid);
95 }
96 #endif
97
98
99 /* Function: mdlTerminate ======================================================
100  * Abstract:
101  *     In this function, you should perform any actions that are necessary
102  *     at the termination of a simulation.
103  */
104 #ifdef UNUSED_MDLTERMINATE
105 static void mdlTerminate(SimStruct *S)
106 {
107     UNUSED_PARAMETER(S);
108 }
109 #endif
110
111
112 /* Function: mdlCheckParameters ================================================
113  * Abstract:
114  *     mdlCheckParameters verifies new parameter settings whenever parameter
115  *     change or are re-evaluated during a simulation. When a simulation is
116  *     running, changes to S-function parameters can occur at any time during
117  *     the simulation loop.
118  *
119  *     Note: this an optional function for S-Function, in contrast to the ones
120  *           above. This is here just because header.c declares
121  *           checkParametersMismatch() that uses this function in order to
122  *           refactor that commonly used block of code.
123  */
124 #ifdef UNUSED_MDLCHECKPARAMETERS
125 static void mdlCheckParameters(SimStruct *S)
126 {
127     UNUSED_PARAMETER(S);
128 }
129 #endif
130
131
132 /*
133  * Required S-function trailer
134  */
135 #ifdef MATLAB_MEX_FILE
136 # include "simulink.c"
137 #else
138 # include "cg_sfun.h"
139 #endif
140