SM_ADC  1.0
Приём данных АЦП через разделяемую память
mdldefinitions.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //
3 // This file is part of easyLink Library.
4 //
5 // Copyright (c) 2014 FEMTO-ST, ENSMM, UFC, CNRS.
6 //
7 // License: GNU General Public License 3
8 // Author: Guillaume J. Laurent
9 //
10 //------------------------------------------------------------------------------
11 
12 //------------------------------------------------------------------------------
13 #define MDL_CHECK_PARAMETERS
14 static void mdlCheckParameters(SimStruct *S)
15 {
16 #ifdef __TEST__
17  printf("easyLink test message: entering mdlCheckParameters ------------------------------\n");
18 #endif
19  try
20  {
23  }
24  catch (exception const& e)
25  {
26  strcpy(ERROR_MSG_BUFFER,e.what());
27  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
28  return;
29  }
30 }
31 
32 //------------------------------------------------------------------------------
33 #define MDL_INITIALIZE_SIZES
34 static void mdlInitializeSizes(SimStruct *S)
35 {
36 #ifdef __TEST__
37  printf("easyLink test message: entering mdlInitializeSizes ------------------------------\n");
38 #endif
39  try
40  {
47  ssSetNumRWork(S, 0);
48  ssSetNumIWork(S, 0);
49  ssSetNumPWork(S, 1);
52  }
53  catch (exception const& e)
54  {
55  strcpy(ERROR_MSG_BUFFER,e.what());
56  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
57  return;
58  }
59 }
60 
61 //---------------------------------------------------------------------------
62 #define MDL_SET_INPUT_PORT_DIMENSION_INFO
63 static void mdlSetInputPortDimensionInfo(SimStruct *S,int port,const DimsInfo_T *dimsInfo)
64 {
65 #ifdef __TEST__
66  printf("easyLink test message: entering mdlSetInputPortDimensionInfo --------------------\n");
67 #endif
68  try
69  {
71  Block::setInputPortDimensionInfo(port,dimsInfo);
72  }
73  catch (exception const& e)
74  {
75  strcpy(ERROR_MSG_BUFFER,e.what());
76  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
77  return;
78  }
79 
80 }
81 
82 //---------------------------------------------------------------------------
83 #define MDL_SET_OUTPUT_PORT_DIMENSION_INFO
84 static void mdlSetOutputPortDimensionInfo(SimStruct *S,int port,const DimsInfo_T *dimsInfo)
85 {
86 #ifdef __TEST__
87  printf("easyLink test message: entering mdlSetOutputPortDimensionInfo -------------------\n");
88 #endif
89  try
90  {
92  Block::setOutputPortDimensionInfo(port,dimsInfo);
93  }
94  catch (exception const& e)
95  {
96  strcpy(ERROR_MSG_BUFFER,e.what());
97  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
98  return;
99  }
100 }
101 
102 //------------------------------------------------------------------------------
103 #define MDL_INITIALIZE_SAMPLE_TIME
104 static void mdlInitializeSampleTimes(SimStruct *S)
105 {
106 #ifdef __TEST__
107  printf("easyLink test message: entering mdlInitializeSampleTimes ------------------------\n");
108 #endif
109  try
110  {
113  }
114  catch (exception const& e)
115  {
116  strcpy(ERROR_MSG_BUFFER,e.what());
117  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
118  return;
119  }
120 }
121 
122 //------------------------------------------------------------------------------
123 #define MDL_START
124 static void mdlStart(SimStruct *S)
125 {
126 #ifdef __TEST__
127  printf("easyLink test message: entering mdlStart ----------------------------------------\n");
128 #endif
129  Block *block=new Block;
130  ssGetPWork(S)[0] = (void *) block;
131  try
132  {
134  block->start();
135  }
136  catch (exception const& e)
137  {
138  strcpy(ERROR_MSG_BUFFER,e.what());
139  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
140  return;
141  }
142 }
143 
144 //------------------------------------------------------------------------------
145 #define MDL_OUTPUTS
146 static void mdlOutputs(SimStruct *S, int tid)
147 {
148 #ifdef __TEST__
149  printf("easyLink test message: entering mdlOutputs at time %f ---------------------------\n",Block::getCurrentTime());
150 #endif
151  Block *block = (Block *) ssGetPWork(S)[0];
152  try
153  {
155  block->outputs();
156  }
157  catch (exception const& e)
158  {
159  strcpy(ERROR_MSG_BUFFER,e.what());
160  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
161  return;
162  }
163 }
164 
165 //------------------------------------------------------------------------------
166 #define MDL_DERIVATIVES
167 static void mdlDerivatives(SimStruct *S)
168 {
169 #ifdef __TEST__
170  printf("easyLink test message: entering mdlDerivatives ----------------------------------\n");
171 #endif
172  Block *block = (Block *) ssGetPWork(S)[0];
173  try
174  {
176  block->derivatives();
177  }
178  catch (exception const& e)
179  {
180  strcpy(ERROR_MSG_BUFFER,e.what());
181  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
182  return;
183  }
184 }
185 
186 //------------------------------------------------------------------------------
187 #define MDL_ZERO_CROSSINGS
188 static void mdlZeroCrossings(SimStruct *S)
189 {
190 #ifdef __TEST__
191  printf("easyLink test message: entering mdlZeroCrossings --------------------------------\n");
192 #endif
193  Block *block = (Block *) ssGetPWork(S)[0];
194  try
195  {
197  block->zeroCrossings();
198  }
199  catch (exception const& e)
200  {
201  strcpy(ERROR_MSG_BUFFER,e.what());
202  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
203  return;
204  }
205 }
206 
207 //------------------------------------------------------------------------------
208 #define MDL_UPDATE
209 static void mdlUpdate(SimStruct *S, int tid)
210 {
211 #ifdef __TEST__
212  printf("easyLink test message: entering mdlUpdate ---------------------------------------\n");
213 #endif
214  Block *block = (Block *) ssGetPWork(S)[0];
215  try
216  {
218  block->update();
219  }
220  catch (exception const& e)
221  {
222  strcpy(ERROR_MSG_BUFFER,e.what());
223  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
224  return;
225  }
226 }
227 
228 //------------------------------------------------------------------------------
229 #define MDL_TERMINATE
230 static void mdlTerminate(SimStruct *S)
231 {
232 #ifdef __TEST__
233  printf("easyLink test message: entering mdlTerminate ------------------------------------\n");
234 #endif
235  Block *block = (Block *) ssGetPWork(S)[0];
236  try
237  {
239  block->terminate();
240  delete block;
241  }
242  catch (exception const& e)
243  {
244  strcpy(ERROR_MSG_BUFFER,e.what());
245  ssSetErrorStatus(S,ERROR_MSG_BUFFER);
246  return;
247  }
248 #ifdef __TEST__
249  printf("easyLink test message: allocation number = %i.\n",Array::allocationNumber);
250 #endif
251 }
252 
253 //------------------------------------------------------------------------------
254 #ifdef MATLAB_MEX_FILE
255 #include "simulink.c"
256 #else
257 #include "cg_sfun.h"
258 #endif
259 //------------------------------------------------------------------------------
static void mdlOutputs(SimStruct *S, int tid)
static void mdlStart(SimStruct *S)
static void mdlTerminate(SimStruct *S)
static void initializeOptions()
Definition: baseblock.h:162
static void mdlSetInputPortDimensionInfo(SimStruct *S, int port, const DimsInfo_T *dimsInfo)
static void initializeNumberSampleTimes()
Definition: baseblock.h:148
void update()
Definition: baseblock.h:307
static void initializeOutputPortSizes()
Definition: baseblock.h:116
static void initializeStatePortSizes()
Definition: baseblock.h:133
static void setSimStruct(SimStruct *S)
Definition: baseblock.h:58
static char ERROR_MSG_BUFFER[512]
Definition: utils.h:30
void outputs()
Definition: sm_adc.cpp:92
void start()
Definition: sm_adc.cpp:14
void terminate()
Definition: sm_adc.cpp:260
static void mdlZeroCrossings(SimStruct *S)
static void initializeInputPortSizes()
Definition: baseblock.h:95
static void mdlUpdate(SimStruct *S, int tid)
static void setOutputPortDimensionInfo(int port, const DimsInfo_T *dimsInfo)
Definition: baseblock.h:183
S-Function sm_adc.mex64w.
Definition: sm_adc.h:104
static time_T getCurrentTime()
Definition: baseblock.h:596
static void mdlCheckParameters(SimStruct *S)
static void mdlInitializeSampleTimes(SimStruct *S)
static void initializeParameterPortSizes()
Definition: baseblock.h:73
void derivatives()
Definition: baseblock.h:279
static void mdlInitializeSizes(SimStruct *S)
static void mdlSetOutputPortDimensionInfo(SimStruct *S, int port, const DimsInfo_T *dimsInfo)
static void initializeSampleTimes()
Definition: baseblock.h:243
void zeroCrossings()
Definition: baseblock.h:292
static void checkParameters()
Definition: baseblock.h:201
static void setInputPortDimensionInfo(int port, const DimsInfo_T *dimsInfo)
Definition: baseblock.h:172
static void mdlDerivatives(SimStruct *S)