]> rtime.felk.cvut.cz Git - socketcan-simulink.git/blob - blocks/trailer.c
Use .gitignore for demo to exclude generated files.
[socketcan-simulink.git] / blocks / trailer.c
1 /* Copyright (C) 2013 Czech Technical University in Prague
2  *
3  * Authors:
4  *     - Carlos Jenkins <carlos@jenkins.co.cr>
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
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
16  *    distribution.
17  *
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.
21  *
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.
33  *
34  * File : trailer.c
35  * Abstract:
36  *     Common trailer for all RPP S-Functions.
37  *
38  * References:
39  *     header.c
40  */
41
42
43 #ifndef S_FUNCTION_NAME
44 #error 'Please include this file inside an S-Function implementation.'
45 #endif
46
47
48 /* Function: mdlInitializeSizes ================================================
49  * Abstract:
50  *     The sizes information is used by Simulink to determine the S-function
51  *     block's characteristics (number of inputs, outputs, states, etc.).
52  */
53 #ifdef UNUSED_MDLINITIALIZESIZES
54 static void mdlInitializeSizes(SimStruct *S)
55 {
56     UNUSED_PARAMETER(S);
57 }
58 #endif
59
60
61 /* Function: mdlInitializeSampleTimes ==========================================
62  * Abstract:
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.
66  */
67 #ifdef UNUSED_MDLINITIALIZESAMPLETIMES
68 static void mdlInitializeSampleTimes(SimStruct *S)
69 {
70     UNUSED_PARAMETER(S);
71 }
72 #endif
73
74
75 #ifdef COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
76 static void mdlInitializeSampleTimes(SimStruct *S)
77 {
78     ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
79     ssSetOffsetTime(S, 0, 0.0);
80     #if defined(ssSetModelReferenceSampleTimeDefaultInheritance)
81     ssSetModelReferenceSampleTimeDefaultInheritance(S);
82     #endif
83 }
84 #endif
85
86
87 /* Function: mdlOutputs ========================================================
88  * Abstract:
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.
92  */
93 #ifdef UNUSED_MDLOUTPUTS
94 static void mdlOutputs(SimStruct *S, int_T tid)
95 {
96     UNUSED_PARAMETER(S);
97     UNUSED_PARAMETER(tid);
98 }
99 #endif
100
101
102 /* Function: mdlTerminate ======================================================
103  * Abstract:
104  *     In this function, you should perform any actions that are necessary
105  *     at the termination of a simulation.
106  */
107 #ifdef UNUSED_MDLTERMINATE
108 static void mdlTerminate(SimStruct *S)
109 {
110     UNUSED_PARAMETER(S);
111 }
112 #endif
113
114
115 /* Function: mdlCheckParameters ================================================
116  * Abstract:
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.
121  *
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.
126  */
127 #ifdef UNUSED_MDLCHECKPARAMETERS
128 static void mdlCheckParameters(SimStruct *S)
129 {
130     UNUSED_PARAMETER(S);
131 }
132 #endif
133
134
135 /*
136  * Required S-function trailer
137  */
138 #ifdef MATLAB_MEX_FILE
139 # include "simulink.c"
140 #else
141 # include "cg_sfun.h"
142 #endif
143