Home AMX User Forum AMX General Discussion

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

Comments

  • ericmedleyericmedley Posts: 4,177
    Rich Abel wrote: »
    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

    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...
  • Rich AbelRich Abel Posts: 104
    do_push and Dev arrays

    Thanks Eric.
  • viningvining Posts: 4,368
    A do_push is meant to trigger a device by simulating a push of a TP's button so I normally just use TP1 or dvTPArray[1] to do this. Otherwise if it were possible to do push a TP array or if you loop through a TP array you'd end up sending that same command over and over again. Sometimes you may find a reason to do that but normally just pushing 1 TP's button to issue a command will suffice.

    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.
  • a_riot42a_riot42 Posts: 1,624
    ericmedley wrote: »
    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...

    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
  • ericmedleyericmedley Posts: 4,177
    Rich Abel wrote: »
    Thanks Eric.

    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
  • trying a similar thing myself, retro-ing a change where they want an all zones mute on their TPs, controlling 2x DSPs, and i don't want to start f-ing around in the DSP file creating new presets for all mute, or sending more redundant strings than I need.

    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?
  • ericmedleyericmedley Posts: 4,177
    CASE 201:
    {
    DO_PUSH [devTP_PAINS[1], 606]
    DO_PUSH [devTP_PAINS[2], 606]
    DO_PUSH [devTP_PAINS[3], 606]

    }

    Do_Push uses '( )' not '[ ]'

    it should be
    DO_PUSH (devTP_PAINS[1], 606)
    

    there ya go.
    e
  • Cheers 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-)
  • viningvining Posts: 4,368
    trustworthy
    I was up watching the Ashes!
    Sorry but this needs an explanation. I don't know if I'm too old, too dumb or just too far out of touch with reality but I don't have a clue as to what this means and now I'm curious.
  • Ashes

    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!
  • DOH!_PUSH

    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.
  • ericmedleyericmedley Posts: 4,177
    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!
    being a fearce Douglas Adams fan, I knew exactly what you meant. Don't Panic!
Sign In or Register to comment.