National-instruments AutoCode NI MATRIX Manuale Utente Pagina 142

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 250
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 141
Chapter 5 Generated Code Architecture
AutoCode Reference 5-34 ni.com
Example 5-14 BlockScript Block Example with Updating of a Parameter
Inputs: u;
Outputs: y;
Environment: (OUTPUT, INIT);
Parameters: total;
float u,y,total;
if OUTPUT then
if !INIT then
total = total + u;
else
total = u;
endif;
y = total;
endif;
Notice that you also must prevent an update during the Init phase, which
requires the use of the nested IF statement. Also, the nested IF statement is
used to ensure that the SystemBuild Simulator updates the parameter only
during the Output phase and not the Init phase.
Caution Failure to properly guard the update of the parameter data will cause the
parameter to update more frequently than intended.
Example 5-15 Generated Code for Example 5-14
void subsys_1(U, Y)
struct _Sys_ExtIn *U;
struct _Subsys_1_out *Y;
{
static RT_FLOAT total = 0.0;
static RT_INTEGER INIT;
if (SUBSYS_PREINIT[1]) {
INIT = 1;
return;
}
/***** Output Update. *****/
/* ------------------------------ BlockScript Block */
/* (bsb..22) */
if (!INIT) {
total = total + U->bsb_1;
}
Vedere la pagina 141
1 2 ... 137 138 139 140 141 142 143 144 145 146 147 ... 249 250

Commenti su questo manuale

Nessun commento