]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/trailer.c
Large changes in documentation, still some parts and correcture missing
[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  * 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.
10  *
11  * File : trailer.c
12  * Abstract:
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.
18  *
19  * References:
20  *     header.c
21  */
22
23
24 #ifndef S_FUNCTION_NAME
25 #error 'Please include this file inside an S-Function implementation.'
26 #endif
27
28
29 /* Function: mdlInitializeSizes ================================================
30  * Abstract:
31  *     The sizes information is used by Simulink to determine the S-function
32  *     block's characteristics (number of inputs, outputs, states, etc.).
33  */
34 #ifdef UNUSED_MDLINITIALIZESIZES
35 static void mdlInitializeSizes(SimStruct *S)
36 {
37     UNUSED_PARAMETER(S);
38 }
39 #endif
40
41
42 /* Function: mdlInitializeSampleTimes ==========================================
43  * Abstract:
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.
47  */
48 #ifdef UNUSED_MDLINITIALIZESAMPLETIMES
49 static void mdlInitializeSampleTimes(SimStruct *S)
50 {
51     UNUSED_PARAMETER(S);
52 }
53 #endif
54
55
56 #ifdef COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
57 static void mdlInitializeSampleTimes(SimStruct *S)
58 {
59     ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
60     ssSetOffsetTime(S, 0, 0.0);
61     #if defined(ssSetModelReferenceSampleTimeDefaultInheritance)
62     ssSetModelReferenceSampleTimeDefaultInheritance(S);
63     #endif
64 }
65 #endif
66
67
68 /* Function: mdlOutputs ========================================================
69  * Abstract:
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.
73  */
74 #ifdef UNUSED_MDLOUTPUTS
75 static void mdlOutputs(SimStruct *S, int_T tid)
76 {
77     UNUSED_PARAMETER(S);
78     UNUSED_PARAMETER(tid);
79 }
80 #endif
81
82
83 /* Function: mdlTerminate ======================================================
84  * Abstract:
85  *     In this function, you should perform any actions that are necessary
86  *     at the termination of a simulation.
87  */
88 #ifdef UNUSED_MDLTERMINATE
89 static void mdlTerminate(SimStruct *S)
90 {
91     UNUSED_PARAMETER(S);
92 }
93 #endif
94
95
96 /* Function: mdlCheckParameters ================================================
97  * Abstract:
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.
102  *
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.
107  */
108 #ifdef UNUSED_MDLCHECKPARAMETERS
109 static void mdlCheckParameters(SimStruct *S)
110 {
111     UNUSED_PARAMETER(S);
112 }
113 #endif
114
115
116 /*
117  * Required S-function trailer
118  */
119 #ifdef MATLAB_MEX_FILE
120 # include "simulink.c"
121 #else
122 # include "cg_sfun.h"
123 #endif
124