Mutually exclusive trick
George Krietsepis
Posts: 284
Dear All,
I have 7 buttons and 6 of them are needed to be mutually exclusive. That 6 ones are the 1,2,3,4,5,7 while the 6th works independently. I would put them in the proper section as a range of buttons but don't like to include the 6th button:
DEFINE_MUTUALLY_EXCLUSIVE
([dvTP,1]..[dvTP,7])
A way to override it would be to set a range from btn1 to btn5 and then any button from this range to be mutually exclusive with btn7. But in case I have a longer range and many panels, that would be very hard. Is there any trick to make this work with no so many lines and combinations?
DEFINE_MUTUALLY_EXCLUSIVE
([dvTP,1]..[dvTP,5])
([dvTP,1],[dvTP,7])
([dvTP,2],[dvTP,7])
([dvTP,3],[dvTP,7])
([dvTP,4],[dvTP,7])
([dvTP,5],[dvTP,7])
Also, can I put a devices array instead of a single device ?
dev dvTPs[] = { dvTP1,dvTP2,dvTP3,dvTP4,dvTP5}
DEFINE_MUTUALLY_EXCLUSIVE
([dvTPs,1]..[dvTPs,5])
Thanks,
George
I have 7 buttons and 6 of them are needed to be mutually exclusive. That 6 ones are the 1,2,3,4,5,7 while the 6th works independently. I would put them in the proper section as a range of buttons but don't like to include the 6th button:
DEFINE_MUTUALLY_EXCLUSIVE
([dvTP,1]..[dvTP,7])
A way to override it would be to set a range from btn1 to btn5 and then any button from this range to be mutually exclusive with btn7. But in case I have a longer range and many panels, that would be very hard. Is there any trick to make this work with no so many lines and combinations?
DEFINE_MUTUALLY_EXCLUSIVE
([dvTP,1]..[dvTP,5])
([dvTP,1],[dvTP,7])
([dvTP,2],[dvTP,7])
([dvTP,3],[dvTP,7])
([dvTP,4],[dvTP,7])
([dvTP,5],[dvTP,7])
Also, can I put a devices array instead of a single device ?
dev dvTPs[] = { dvTP1,dvTP2,dvTP3,dvTP4,dvTP5}
DEFINE_MUTUALLY_EXCLUSIVE
([dvTPs,1]..[dvTPs,5])
Thanks,
George
0
Comments
([dvTP,1]..[dvTP,5],[dvTP,7])
Eric showed you how to set that up in his post, but I'd thought I'd mention using device arrays in the mutex block may lead to undefined behavior from what I've found. I've experimented with it and had it working, but then would see odd behavior, so I don't do that anymore. It would be nice to be able to just do ([dvTPs, iChanArray[1]]..[dvTPs, iChanArray[length_array(iChanArray)]]) so that the channels in iChanArray were mutexed for each dvTP, but I seem to recall that it didn't work correctly, and acted on all TPs as a group rather than individually, so I now do
([dvTP1, iChanArray[1]]..[dvTP1, iChanArray[length_array(iChanArray)]])
([dvTP2, iChanArray[1]]..[dvTP2, iChanArray[length_array(iChanArray)]])
...
Paul
I agree. I don?t use Mutually Exclusive myself.
Does work great for motor controls.
I use mutexes in all my projects both main code and modules and in 12 years have only had an issue when trying to use device arrays in them. As long as you define them with one device per line, they seem to work just fine for me. I don't use combine or define_program though so maybe they can interfere with how they work. I also use total_off when necessary.
Paul