National-instruments AutoCode NI MATRIX Manuel d'utilisateur Page 142

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 250
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 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;
}
Vue de la page 141
1 2 ... 137 138 139 140 141 142 143 144 145 146 147 ... 249 250

Commentaires sur ces manuels

Pas de commentaire