]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/sfunction_sdrw.c
Change the license from GPL to proprietary
[pes-rpp/rpp-simulink.git] / rpp / blocks / sfunction_sdrw.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 : sfunction_sdrw.c
12  * Abstract:
13  *     C-MEX S-function block for RPP SD-RAM log write.
14  *
15  * References:
16  *     header.c
17  *     trailer.c
18  *
19  * Compile with:
20  *     <matlabroot>/bin/mex sfunction_sdrw.c
21  */
22
23
24 #define S_FUNCTION_NAME sfunction_sdrw
25 #include "header.c"
26
27
28 static void mdlInitializeSizes(SimStruct *S)
29 {
30     /*
31      * Configure parameters: 2
32      *  - Block ID.
33      *  - Printf format [setting].
34      */
35     if(!rppSetNumParams(S, 2)) {
36         return;
37     }
38
39     /*
40      * Configure input ports: 1
41      *  - Data.
42      */
43     if(!ssSetNumInputPorts(S, 1)) {
44         return;
45     }
46     rppAddInputPort(S, 0, SS_DOUBLE);
47
48     /*
49      * Configure output ports: 1
50      *  - Error flag.
51      */
52     if(!ssSetNumOutputPorts(S, 1)) {
53         return;
54     }
55     rppAddOutputPort(S, 0, SS_BOOLEAN);
56
57     /* Set standard options for this block */
58     rppSetStandardOptions(S);
59 }
60
61
62 #ifdef MATLAB_MEX_FILE
63 #define MDL_CHECK_PARAMETERS
64 static void mdlCheckParameters(SimStruct *S)
65 {
66     /* Check the parameter 1 */
67     if(!rppValidParamRange(S, 0, 0, 255)) {
68         return;
69     }
70 }
71 #endif
72
73
74 #ifdef MATLAB_MEX_FILE
75 #define MDL_SET_WORK_WIDTHS
76 static void mdlSetWorkWidths(SimStruct *S)
77 {
78     /* Set number of run-time parameters */
79     if(!ssSetNumRunTimeParams(S, 1)) {
80         return;
81     }
82
83     /* Register the run-time parameter 1 */
84     ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
85 }
86 #endif
87
88
89 #ifdef MATLAB_MEX_FILE
90 #define MDL_RTW
91 static void mdlRTW(SimStruct* S)
92 {
93     /* Register parameter 2 as a parameter setting */
94     static char_T str[128];
95     mxGetString(ssGetSFcnParam(S, 1), (char*)&str, sizeof(str)); /* Get string */
96     if(!ssWriteRTWParamSettings(S, 1,
97             SSWRITE_VALUE_QSTR, "PrintfFormat", (const char_T*)&str)) {
98         /* An error ocurred */
99         return;
100     }
101 }
102 #endif
103
104
105 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
106 #define UNUSED_MDLOUTPUTS
107 #define UNUSED_MDLTERMINATE
108 #include "trailer.c"