Button.Input.Device & Waits
jwells
Posts: 25
Hi,
I'm implementing a system based on 8 x DMS Keypads in a residential app. After looking thought the AMX DMS&AS16 Demo sheet it states a 10th of a sec wait should be implemented prior to issuing a page flip (apparently to reduce the risk of lockup).
The code below shows what I am trying to do but it obviously does not run correctly as after the wait the button.input.device is empty and does not resolve correctly.
Does anyone have any good ideas about another way to get around this problem, without adding a button event for every keypad. I've tried STACK_VAR, but this has the same problem as the button.input.device
BUTTON_EVENT [Vol_Buttons]
{
PUSH:
{
SEND_LEVEL button.input.device,1,((Room_Status[(button.input.device.number - 33100)].Start_Vol*100)/255)
Wait 1
{
SEND_COMMAND Room_Status[(button.input.device.number - 33100)].Keypad, "'PAGE-Volume'" // button.input.device is empty
}
}
}
I'm implementing a system based on 8 x DMS Keypads in a residential app. After looking thought the AMX DMS&AS16 Demo sheet it states a 10th of a sec wait should be implemented prior to issuing a page flip (apparently to reduce the risk of lockup).
The code below shows what I am trying to do but it obviously does not run correctly as after the wait the button.input.device is empty and does not resolve correctly.
Does anyone have any good ideas about another way to get around this problem, without adding a button event for every keypad. I've tried STACK_VAR, but this has the same problem as the button.input.device
BUTTON_EVENT [Vol_Buttons]
{
PUSH:
{
SEND_LEVEL button.input.device,1,((Room_Status[(button.input.device.number - 33100)].Start_Vol*100)/255)
Wait 1
{
SEND_COMMAND Room_Status[(button.input.device.number - 33100)].Keypad, "'PAGE-Volume'" // button.input.device is empty
}
}
}
0
Comments
BUTTON_EVENT [Vol_Buttons]
{
PUSH:
{
LOCAL_VAR INTEGER idx;
idx = button.input.device.number - 33110;
SEND_LEVEL button.input.device,1,((Room_Status[idx].Start_Vol*100)/255);
Wait 1
{
SEND_COMMAND Room_Status[idx].Keypad, "'PAGE-Volume'";
}
}
}
I believe the problem is that, when you're in the WAIT, the predefined stuff won't work. STACK_VAR variables don't carry into WAITs either. But a LOCAL_VAR should.
Try that, let me know if it works.
-- Jeff
One solution is to use a global as JEFF proposes to "remember the context", i.e. which panel should be moved to the volume page. The problem of the solution is if 2 keypads use the volume function during the delay, the first one will be forgotten by the code, and only the second keypad will change page. Events are stacked BTW so if the master is busy, any 2 keypresses sent during the busy time will be fired one after the other.
Something safer might be to keep a global array, that is, one variable for each panel. The wait code then walks the array and moves all needed panels to the volume page (resetting the array in the process).
Fred
This is a classic Netlinx issue/problem - the inability to specify variable data for a WAIT handler except through the use of a global variable. It is not limited to DMS keypads but extends to any device or code thread that needs to delay an action but where all of the commands for the WAIT can not be explicitly specified without the use of any variable. As Fred points out, the use of a global variable only offers a limited solution and in cases will yield results that are undesirable and very hard to determine exactly what happened.
I generally do not use WAITs for these reasons. I dislike storing WAIT data in a global variable since this does not always work correctly. Instead, I use TIMELINEs for wait processing. In the case of a system with multiple DMS for instance, I would define a TIMELINE ID for each of the DMS keypads along with a structure that contains commands/data for each DMS that need to be executed in a delayed fashion (such as ONLINE actions, Page flips, Level actions, ...). When a WAIT/delay action is required, I create the TIMELINE with an ID specific to that DMS device, populate the global structure fields indexed by the DMS identifier, and then when the TIMELINE fires the data is used to perform the action. Since the command/data structure can contain multiple elements per DMS (essentially an array of structures), I can stack WAIT/delay processing for a device and handle them all in a TIMELINE. As one action is completed, the other actions in the structure are moved up in the structure and the TIMELINE is reset to trigger based on the required WAIT/delay time for the next structure entry.
I find that TIMELINEs and a WAIT/delay data structure for each device is a more flexible solution that anything else I have tried so far. It would be great if Netlinx could make copies of temporary data specified in a WAIT statement thereby avoiding the problem but in the meantime, TIMELINEs or WAITs associated with global variables for data storage are just a few of the available options.
Reese
I?ve ended up implementing the time line event control as this has an added advantage of controlling some other page flips actions.
Cheers.
I have exactly this issue right now with a ton of DMSs in a system. Can you show code on this?