]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/sfunction_tror.c
48f0fae36cb69b190929fd7e0874f9f6b612bcba
[pes-rpp/rpp-simulink.git] / rpp / blocks / sfunction_tror.c
1 /* Copyright (C) 2013, 2014 Czech Technical University in Prague
2  *
3  * Authors:
4  *
5  * This document contains proprietary information belonging to Czech
6  * Technical University in Prague. Passing on and copying of this
7  * document, and communication of its contents is not permitted
8  * without prior written authorization.
9  *
10  * File : sfunction_tror.c
11  * Abstract:
12  *     C-MEX S-function block for RPP overrun.
13  *
14  * References:
15  *     header.c
16  *     trailer.c
17  *
18  * Compile with:
19  *     <matlabroot>/bin/mex sfunction_tror.c
20  */
21
22 /*
23 %YAML 1.2
24 ---
25 Name: Overrun Detection
26 Category: Trigger blocks
27 Header: No header
28 Mnemonic: TROR
29
30 Inputs:
31
32 Outputs:
33
34 Parameters:
35
36 # Description and Help is in Markdown mark-up
37 Description: &desc |
38
39   This block triggers the connected function subsystems in case of
40   overrun, i.e. when execution of the previous loop iteration took
41   more time than the sampling period.
42
43 Help: *desc
44
45 Status: Stable
46
47 RPP API functions used:
48
49 Relevant demos:
50 ...
51 */
52
53 #define S_FUNCTION_NAME sfunction_tror
54 #include "header.c"
55
56
57 static void mdlInitializeSizes(SimStruct *S)
58 {
59     /*
60      * Configure parameters: 0
61      */
62     if (!rppSetNumParams(S, 0)) {
63         return;
64     }
65
66     /*
67      * Configure input ports: 0
68      */
69     if (!ssSetNumInputPorts(S, 0)) {
70         return;
71     }
72
73     /*
74      * Configure output ports: 1
75      *  - Owerrun.
76      */
77     if (!ssSetNumOutputPorts(S, 1)) {
78         return;
79     }
80         rppAddOutputPort(S, 0, SS_FCN_CALL);
81
82     /* Set standard options for this block */
83     rppSetStandardOptions(S);
84 }
85
86
87 static void mdlInitializeSampleTimes(SimStruct *S)
88 {
89     ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
90     ssSetOffsetTime(S, 0, 0.0);
91     #if defined(ssSetModelReferenceSampleTimeDefaultInheritance)
92     ssSetModelReferenceSampleTimeDefaultInheritance(S);
93     #endif
94
95     ssSetCallSystemOutput(S,0);
96 }
97
98
99 #define UNUSED_MDLCHECKPARAMETERS
100 #define UNUSED_MDLOUTPUTS
101 #define UNUSED_MDLTERMINATE
102 #include "trailer.c"