DO_PUSH & DEVICE ARRAYS
I'm adapting some existing code to some new equipment and have run into an issue with DO_PUSH
Generally I find I can use a Device Array in any situation that calls for a device; e.g. Button_events.
So,
BUTTON_EVENT[DEVICE_ARRAY, 10] can replace BUTTON_EVENT[DEVICE,10], with the former effecting each member of the device array.
However, if I try: DO_PUSH(DEVICE_ARRAY,10), I get dimension mismatch compilier errors.
Substituting DO_PUSH(DEVICE_ARRAY[],10) eliminates the compilier errors.
I'm not sure its a great idea to use DO_PUSH this way and may just rewrite that section of the old code, but I'm curious what causes this behavior. Does anyone know?
Thanks,
Rich Abel
ACE Programmer
Cello Technologies
Seattle
Generally I find I can use a Device Array in any situation that calls for a device; e.g. Button_events.
So,
BUTTON_EVENT[DEVICE_ARRAY, 10] can replace BUTTON_EVENT[DEVICE,10], with the former effecting each member of the device array.
However, if I try: DO_PUSH(DEVICE_ARRAY,10), I get dimension mismatch compilier errors.
Substituting DO_PUSH(DEVICE_ARRAY[],10) eliminates the compilier errors.
I'm not sure its a great idea to use DO_PUSH this way and may just rewrite that section of the old code, but I'm curious what causes this behavior. Does anyone know?
Thanks,
Rich Abel
ACE Programmer
Cello Technologies
Seattle
0
Comments
you cannot use a dev array in a do_push as you describe. However, there is another way to do it.
do_push(dev_tp[1],100) works.
So if you throw the whole thing in a for loop you can get it done easy enough.
local_var integer nloop for(nloop=TP_Count ; nloop>0 ; nloop--) { do_push(devTPs[nloop],100) }something like that...
Thanks Eric.
You can also create a virtual TP and include that in your TP array so it works in all your button event handlers just like all the real TPs and any time you need to use a do_push you can do it on the virtual.
That won't always work will if there are variables that get set from the pushes since the code will run immediately but the button events get queued up and then executed (in your case every 5/10ths sec).
Do you really need to push a button on every touch panel? There is usually a way to avoid using do_push if you find it irksome.
Paul
Do_push is one of those strange commands that can seem a bit hard to get your head around. I do use it. I've even used it as you described. I had an audio switcher that didn't have an 'all zones off' command. It was easier to make a slow loop that hit all the 'zone off' buttons in the program since there was a whole bunch of condition already built into those.
Perhaps you could let us know what you're trying to do and we can suggest an alternative. while what I showed you will work, perhaps there's a better way of doing it. There doesn't seem to be a need to slam on all those buttons that fast. As a_riot suggests, it can have some sloppy results
only problem is...
"error: SYMBOL DO_PUSH NOT DEFINED."
eh?
here's the code
DEV devTP_PAINS[] = { TP_PAIns, TP_PAIn2, TP_PAIn3 } BUTTON_EVENT[devTP_PAINS, 201] //MUTE/UNMUTE ALL GROUND BUTTON_EVENT[devTP_PAINS, 202] //MUTE/UNMUTE ALL FIRST BUTTON_EVENT[devTP_PAINS, 203] //RESET PA ZONE MASTER LEVELS TO DEFAULT { PUSH: { SWITCH (BUTTON.INPUT.CHANNEL) { CASE 201: { DO_PUSH [devTP_PAINS[1], 606] DO_PUSH [devTP_PAINS[2], 606] DO_PUSH [devTP_PAINS[3], 606] } CASE 202: { // IF ABOVE WORKS EVENTUALLY ILL COPASTE HERE AND EDIT ACCORDINGLY } CASE 203: { // RESET PA ZONES TO DEFAULT LEVELS } } }Where Button 606 is part of a larger array thus:
// PA MUSIC INPUT MUTE BUTTONS INTEGER PAINMUSICMUTES[] = { (*0, 0, 0, 0,*) 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, // MAIN BGM (*0, 0, 0, 0,*) 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, // PATCH 8 (*0, 0, 0, 0,*) 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648 // iPOD } //and the muting is done within this B_E combined with a similar L_E BUTTON_EVENT[devTP_PAINS, PAINMUSICMUTES] { PUSH: { STACK_VAR INTEGER nBtnIdx nBtnIdx = GET_LAST(PAINMUSICMUTES) { RESTOREPAINMUSICLEVEL[nBtnIdx] = CURRENTPAINMUSICLEVEL[nBtnIdx]//VARIABLE TO KEEP CURRENT LEVEL INTACT IF(!PAINMUSICMUTED[nBtnIdx]) { SEND_LEVEL devTOUCHPANELS, (BUTTON.INPUT.CHANNEL- 100),-60// on[devTP_PAINS, BUTTON.INPUT.CHANNEL] } ELSE { SEND_LEVEL devTOUCHPANELS, (BUTTON.INPUT.CHANNEL- 100), RESTOREPAINMUSICLEVEL[nBtnIdx]// // SEND_COMMAND devTOUCHPANELS, "'^TXT-',ITOA (BUTTON.INPUT.CHANNEL+1000),',0,',ITOA (RESTOREPAINMUSICLEVEL[nBtnIdx])" off[devTP_PAINS, BUTTON.INPUT.CHANNEL] } PAINMUSICMUTED[nBtnIdx] = !PAINMUSICMUTED[nBtnIdx] } } }OR am I interpreting the use of DO-PUSH completely wrongly?
Do_Push uses '( )' not '[ ]'
it should be
there ya go.
e
DEFINE_FUNCTION fnMUTE_ALL_MUSIC_GROUND() { IF ( !PAINMUSICMUTED[2] ) { DO_PUSH (vdv_PAINS, 606) } wait 1 IF ( !PAINMUSICMUTED[3] ) { DO_PUSH (vdv_PAINS, 607) } wait 2 IF ( !PAINMUSICMUTED[4] ) { DO_PUSH (vdv_PAINS, 608) } wait 3 IF ( !PAINMUSICMUTED[5] ) { DO_PUSH (vdv_PAINS, 609) } } BUTTON_EVENT[devTP_PAINS, 201] //MUTE/UNMUTE ALL GROUND BUTTON_EVENT[devTP_PAINS, 202] //MUTE/UNMUTE ALL FIRST BUTTON_EVENT[devTP_PAINS, 203] //RESET PA ZONE MASTER LEVELS TO DEFAULT { HOLD [10]: { SWITCH (BUTTON.INPUT.CHANNEL) { CASE 201: { fnMUTE_ALL_MUSIC_GROUND() } CASE 202: { // fnMUTE_ALL_MUSIC_FIRST() } CASE 203: { SEND_STRING dvESP88_PA, "'SS0A', $0D" // RESET PA ZONES TO DEFAULT LEVELS } } } RELEASE: { SWITCH (BUTTON.INPUT.CHANNEL) { CASE 201: { UNCOMBINE_DEVICES (vdv_PAINS) COMBINE_DEVICES (vdv_PAINS, devTP_PAINS) } CASE 202: { UNCOMBINE_DEVICES (vdv_PAINS) COMBINE_DEVICES (vdv_PAINS, devTP_PAINS) } CASE 203: { fnCHECK_PA_ZONE_LEVELS() fnBGM_PAGING_STATUS() } } } }compiles OK....I'll let you know in the morning if it works. I'm sure if I wasn't as tired as I am I'd be able to shorten it but I was up watching the Ashes! B-)
Legendary cricket contest between England and Australia. Australia usually win it. England won it this time! 2-1 out of 5-match series.
wiki it!
Worked...kinda! I ended up having to take it out of the function and putting it directly in the button event, and also removed the IFs and WAITs, just stacked the DO_PUSHes, and it also didnt work with the virtual (probably my coding) so I used BUTTON.INPUT.DEVICE - I didnt have much time on site so I left it at that.