WAIT and TIMED_WAIT_UNTIL
I have the need, in a recursive routine, to use a unique WAIT name:
WAIT nTimeOut "'Timed Wait - ', Zone[nZone].name"
Something along those lines. The WAIT requires a literal string which disallows this from being stated. Is there another way of doing this that I am just unaware of ?
WAIT nTimeOut "'Timed Wait - ', Zone[nZone].name"
Something along those lines. The WAIT requires a literal string which disallows this from being stated. Is there another way of doing this that I am just unaware of ?
0
Comments
Typically what I would do is just do a switch case:
SWITCH(Zone[nZone].name) { CASE 'Bedroom 1': { WAIT nTimeOut 'Bedroom 1' { // Do something... } } CASE 'Bedroom 2': { WAIT nTimeOut 'Bedroom 2' { // Do something... } } }Perhaps you could do this with a Timeline instead.
Something like this. I did an old fashioned button stack for the example. You could do it just about any way you like.
button_event[vdv_time_out,1] button_event[vdv_time_out,2] button_event[vdv_time_out,3] button_event[vdv_time_out,4] { push: { timeline_create(BUTTON.INPUT.CHANNEL, Test_1,4, timeline_absolute,timeline_once) } }I would try a switch case like in the code below.
DEFINE_CONSTANT CHAR ZONE_NAME_ARRY[5][6]= { 'ZONE_1', 'ZONE_2', 'ZONE_3', 'ZONE_4', 'ZONE_5' } DEFINE_FUNCTION fnTestWaits(INTEGER iZone) { if(iZone <= LENGTH_ARRAY(ZONE_NAME_ARRY)) { SWITCH(iZone) { CASE 1: { SEND_STRING dvMaster,"'PRE-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; WAIT 20 'ZONE_1' { SEND_STRING dvMaster,"'POST-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; iZone ++ ; fnTestWaits(iZone) ; } } CASE 2: { SEND_STRING dvMaster,"'PRE-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; WAIT 20 'ZONE_2' { SEND_STRING dvMaster,"'POST-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; iZone ++ ; fnTestWaits(iZone) ; } } CASE 3: { SEND_STRING dvMaster,"'PRE-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; WAIT 20 'ZONE_3' { SEND_STRING dvMaster,"'POST-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; iZone ++ ; fnTestWaits(iZone) ; } } CASE 4: { SEND_STRING dvMaster,"'PRE-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; WAIT 20 'ZONE_4' { SEND_STRING dvMaster,"'POST-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; iZone ++ ; fnTestWaits(iZone) ; } } CASE 5: { SEND_STRING dvMaster,"'PRE-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; WAIT 20 'ZONE_5' { SEND_STRING dvMaster,"'POST-WAIT ZONE = ',ZONE_NAME_ARRY[iZone]" ; iZone ++ ; fnTestWaits(iZone) ; } } } } RETURN ; } DEFINE_START WAIT 600 { fnTestWaits(1) ; }Diagnostics window:
this is a classic example of an asyncronous two-way conversation. I used to write them almost exlusively with a Data_Event and a seriers of conditionals with waits in the DEF_PROGRAM section. While Timelines do add some complexity to the structure of the async loop w/conditionals, it does allow for a lot more flexibility in the end.
And since the Timeline identification uses a numberic id, it is easy to track and tie to other things.