Event stacking
Is it possible to stack devchans with regard to button or channel events? I have several, identically-sized devchans created for the purposes of tracking which input/output buttons have been selected: devchan1 has buttons 1,3,5,7,9 in it, devchan2 has buttons 2,4,6,8,10 in it, and devchan3 has buttons 22,23,26,28,30 in it. What I WANT to do is to be able to stack the devchan button events for the purposes of tracking 1) which devchan was selected last, and 2) which item in that devchan was selected. However, I don't know if it can be done, since even though the devchans are named in numerical order, it seems that the button event looks for a unique devchan name, instead of being able to do this: button_event[devchan(i)]. Am I even on the right path for what I want to do? My gut tells me that I can't stack devchans like this.
Comments
DEVCHAN dcSwitcherOut1 [] = { //inputs available for output 1 {dvTPswitch,1},{dvTPswitch,2},{dvTPswitch,3},{dvTPswitch,4} } DEVCHAN dcSwitcherOut2 [] = { //inputs available for output 2 {dvTPswitch,5},{dvTPswitch,6},{dvTPswitch,7},{dvTPswitch,8} } DEVCHAN dcSwitcherOut3 [] = { //inputs available for output 3 {dvTPswitch,9},{dvTPswitch,10},{dvTPswitch,11},{dvTPswitch,12} } DEVCHAN dcSwitcherOut4 [] = { //inputs available for output 4 {dvTPswitch,13},{dvTPswitch,14},{dvTPswitch,15},{dvTPswitch,16} } DEFINE_VARIABLE NON_VOLATILE INTEGER nInputValue[4] //variable array tracks which devchan selected which input DEFINE_EVENT BUTTON_EVENT[dcSwitcherOut1] { PUSH: { nInputValue[1] = GET_LAST(dcSwitcherOut1) } } BUTTON_EVENT[dcSwitcherOut2] { PUSH: { nInputValue[2] = GET_LAST(dcSwitcherOut2) } } BUTTON_EVENT[dcSwitcherOut3] { PUSH: { nInputValue[3] = GET_LAST(dcSwitcherOut3) } } BUTTON_EVENT[dcSwitcherOut4] { PUSH: { nInputValue[4] = GET_LAST(dcSwitcherOut4) } }So at this point, I can definitely track when nInputValue's array values change based on the individual button press. I was hoping, however, to be able to stack the button events, and use a FOR loop to propagate the values here, but I still don't know entirely what I am doing, nor if it is even possible, based on the use of DEVCHAN arrays. Obviously I will also need to create a data event for this so that I can send the string to the switcher, but that's additional research that I haven't started yet.The FOR loop is probably what you're looking for. Of course - this is just one way of doing what you're trying to achieve, but hopefully this will give you some ideas. (See attached code.)