Technical information
Multiple RMS Instances
111
RMS NetLinx Programmer’s Guide
Stacking Events and Handling Them
Because the rest of the code (common include, and others) is single instance
driven, there is a switch going on for every event. Determine who is raising the
event and then switch the global RMSEngine to the engine the event is coming
from. The example uses a shared function SetEngine(engine instance) to do the
dirty work. Each event checks to see who raised it and sets the correct instance
for the rest of the work. Example is below:
(*******************************************)
(* DATA: Main Touch Panel *)
(* DATA: TP Battery Level *)
(*******************************************)
DATA_EVENT[dvTPMain_1]
DATA_EVENT[dvTPMain_2]
DATA_EVENT[dvTPMain_3]
DATA_EVENT[dvTPMain_4]
{
ONLINE:
{
STACK_VAR INTEGER nInstance
// set the current RMS engine instance based on the TP device
IF(DATA.DEVICE = dvTPMain_1)
SetEngine(vdvRMSEngine_1)
ELSE IF(DATA.DEVICE = dvTPMain_2)
SetEngine(vdvRMSEngine_2)
ELSE IF(DATA.DEVICE = dvTPMain_3)
SetEngine(vdvRMSEngine_3)
ELSE IF(DATA.DEVICE = dvTPMain_4)
SetEngine(vdvRMSEngine_4)
// get the current RMS engine instance index
nInstance = GetRMSEngineInstance()
}
}