Mutually Exclusive With Arrays
rolo
Junior Member
I have a button array and a device array.
In this particular case , these buttons are for navigation between rooms.
Obviously I cannot have 2 rooms selected at once on a panel.
My statement will read something like this...
DEFINE_DEVICE
dvTP_1=128:1:1
DEFINE_CONSTANT
INTEGER nBtnArray_RoomNav[]={3001,3002} //Array For Navigation Button Numbers
DEV dvAllTP[]={dvTP_1} //Array For Touchpanels
DEFINE_EVENT
BUTTON_EVENT [dvAllTP,nBtnArray_RoomNav]
{
Push:
{
Do Whatever
}
}
How do I define the arrays' buttons as mutually exclusive?
Thanks
Rolo
In this particular case , these buttons are for navigation between rooms.
Obviously I cannot have 2 rooms selected at once on a panel.
My statement will read something like this...
DEFINE_DEVICE
dvTP_1=128:1:1
DEFINE_CONSTANT
INTEGER nBtnArray_RoomNav[]={3001,3002} //Array For Navigation Button Numbers
DEV dvAllTP[]={dvTP_1} //Array For Touchpanels
DEFINE_EVENT
BUTTON_EVENT [dvAllTP,nBtnArray_RoomNav]
{
Push:
{
Do Whatever
}
}
How do I define the arrays' buttons as mutually exclusive?
Thanks
Rolo
Comments
-
One way:
BUTTON_EVENT [dvAllTP,nBtnArray_RoomNav] { Push: { STACK_VAR INTEGER nIND STACK_VAR INTEGER nBTN nIND = GET_LAST(dvAllTP) nBTN = GET_LAST(nBtnArray_RoomNav) ON[dvAllTP[nIND],nBtnArray_RoomNav[nBTN]] } }And then set up your MUTUALLY_EXCLUSIVE.DEFINE_MUTUALLY_EXCLUSIVE ([dvAllTP[1],nBtnArray_RoomNav[1]]..[dvAllTP[1],nBtnArray_RoomNav[LENGTH_ARRAY(nBtnArray_RoomNav)]])
But I personally wouldn't even go that route. I would set up a variable that kept track of which room the panel was on, then set the feedback down in DEFINE_PROGRAM. You could easily do something like this:DEFINE_VARIABLE nCUR_ROOM[x] // x = THE NUMBER OF TOUCH PANELS DEFINE_EVENT BUTTON_EVENT [dvAllTP,nBtnArray_RoomNav] { Push: { STACK_VAR INTEGER nIND STACK_VAR INTEGER nBTN nIND = GET_LAST(dvAllTP) nBTN = GET_LAST(nBtnArray_RoomNav) nCUR_ROOM[nIND] = nBTN // DO REST OF BUTTON PUSH STUFF } } DEFINE_PROGRAM [dvAllTP[1],nBtnArray_RoomNav[1]] = (nCUR_ROOM = 1) [dvAllTP[1],nBtnArray_RoomNav[2]] = (nCUR_ROOM = 2)
This way, if you ever need to know which room a panel is controlling, you can run conditionals / evaluations, etc. on this information. -
This also works, using the buttons themselves as feedback:
BUTTON_EVENT[dvaTPs,nNavBtns] // Navigation { PUSH: { STACK_VAR INTEGER nPnlIdx ; STACK_VAR INTEGER nBtnIdx ; STACK_VAR INTEGER nLoop ; nPnlIdx = GET_LAST( dvaTPs ) nBtnIdx = GET_LAST( nNavBtns ) FOR(nLoop = 1; nLoop <= LENGTH_STRING( nNavBtns ); nLoop++) OFF[dvaTPs[nPnlIdx],nNavBtns[nLoop]] ON[dvaTPs[nPnlIdx],nNavBtns[nBtnIdx]] } }
But like James said it's nice to have a var tracking your selections because the buttons will turn off if the panel goes offline (which is actually a benefit in some situations).
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums