Echelon LonTal Stack Manuel d'utilisateur Page 131

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 247
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 130
LonTalk Stack Developer’s Guide 119
extern void myController(void);
void LonNvUpdateCompleted(unsigned index, const LonBool
success) {
switch (index) {
case LonNvIndexNviAmpere: /* fall through */
case LonNvIndexNviVolt:
myController();
break;
default:
/* handle other NV updates (if any) */
}
}
In your application source file:
#include "FtxlDev.h"
void myController(void) {
// nvoWatt = nviAmpere * nviVolt;
LON_SET_UNSIGNED_WORD(nvoWatt,
LON_GET_UNSIGNED_WORD(nviAmpere)
* LON_GET_UNSIGNED_WORD(nviVolt));
if (LonPropagateNv(LonNvIndexNvoWatt) != LonApiNoError)
{
// handle propagation error here
...
}
}
This modification calls the myController() function defined in the example in
the previous section,
Sending a Network Variable Update. Because network
variable types are defined as type LonWord, this example uses the
LON_GET_UNSIGNED_WORD macros to get the nviAmpere and nviVolt
network variable values, and LON_SET_UNSIGNED_WORD to set the value
for the nvoWatt network variable.
Example 2:
This example adds a configuration network variable to Example 1. A SCPTgain
configuration property is added to the device interface in the model file:
network input SNVT_amp nviAmpere;
network input SNVT_volt nviVolt;
network output SNVT_power nvoWatt;
network input cp SCPTgain nciGain;
fblock UFPTpowerConverter {
nvoWatt implements nvoPower;
nviAmpere implements nviCurrent;
nviVolt implements nviVoltage;
} powerConverter fb_properties {
nciGain
};
You can enhance the myController() function to implement the new gain factor:
void myController(void)
Vue de la page 130
1 2 ... 126 127 128 129 130 131 132 133 134 135 136 ... 246 247

Commentaires sur ces manuels

Pas de commentaire