beautypg.com

Echelon i.LON SmartServer 2.0 User Manual

Page 264

background image

250

Appendix D – i.LON SmartServer Software License Agreement

void CUFPTfpmTempController::Initialize()]
{]
// Determine FB index by looking at one of the NVs name, [index]
char * nv_name =

(char *)nviTemp.GetDpPropertyAsString(FPM::Dp::cfgUCPTname);

// get NV name


// Get FB index number from name
char * tmp_name;
tmp_name = strtok(nv_name,"[");
tmp_name = strtok(NULL,"]");
iFbNumber = strtol(tmp_name, NULL,10); // convert String to int

printf("UFPTfpmTempController[%i]::Initialize() \n",*iFbNumber);

//enter comment in work routine to indicate when nviTemp is changed

void CUFPTfpmTempController::work()
{
if(Changed(nviTemp))
{
printf("UFPTfpmTempController[%i]::Work()- nviTemp =
*iFbNumber,

*nviTemp);

}
}

42. What is the difference between Local and Global FPM variables?

Local variables are defined and used differently then global variables.

• FPM local variables are local to a FB instance.

o

NVs and CPs are always local variables.

o

A local integer variable named iFbNumber would be defined as:

DECLARE_FB_INSTANCE_LOCAL(int, iFbNumber); // local variable

Each FB instance will have its own iFbNumber that only it can read or write.

• FPM global variables are accessible by all FB instances.

o

All FB instances for a FPM can read and write to this variable.

o

FPM global variables are defined as normal C/CC+ variables and are used by all FB
instances of the FPM. A global integer variable named iCount would be defined as:

int iCount;

// global variable

• You should use local variables whenever the data is FB instance related (e.g., FB instance index

number, state information, timer information).

• Always design your FPM assuming that it will be used with multiple FBs.
• If you see erratic behavior from a FB, this may mean that you are using a global variable when

you should be using a local variable.

• See the Echelon Knowledge Base web site for examples.

43. Can a FPM driver have NVs and CPs?