Home AMX User Forum NetLinx Studio
Options

Mutually exclusive trick

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

Comments

  • Options
    ericmedleyericmedley Posts: 4,177
    DEFINE_MUTUALLY_EXCLUSIVE

    ([dvTP,1]..[dvTP,5],[dvTP,7])

  • Options
    a_riot42a_riot42 Posts: 1,624
    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

    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
  • Options
    I'd advise NOT using the define_mutually_exclusive section for enforcing that relationship for touch panel feedback - there are much better and more robust techniques available. As mentioned above it may also lead to "undefined behavior" which is from that fact that you can't fully turn off the feedback of all the elements in a mutex block without implementing the total_off[] directive.
  • Options
    ericmedleyericmedley Posts: 4,177
    icraigie wrote: »
    I'd advise NOT using the define_mutually_exclusive section for enforcing that relationship for touch panel feedback - there are much better and more robust techniques available. As mentioned above it may also lead to "undefined behavior" which is from that fact that you can't fully turn off the feedback of all the elements in a mutex block without implementing the total_off[] directive.

    I agree. I don?t use Mutually Exclusive myself.
  • Options
    ericmedley wrote: »

    I agree. I don?t use Mutually Exclusive myself.

    Does work great for motor controls.
  • Options
    A data container, especially a numeric one, can/should only hold one value at a time. I.E., the classic "Input Selection." That's the mechanism I've always used to enforce mutual exclusivity among a group. The rest of the logic and UI presentation derive from that value in that container, or threshold events, when the value changes, (or more technically, when someone indicates they would like to change the value, usually by pressing a button), or some device polling or event notification process. I got the memo not to trust MutEx in Netlinx very early in my programming career, thus have never used it.
  • Options
    a_riot42a_riot42 Posts: 1,624
    A data container, especially a numeric one, can/should only hold one value at a time. I.E., the classic "Input Selection." That's the mechanism I've always used to enforce mutual exclusivity among a group. The rest of the logic and UI presentation derive from that value in that container, or threshold events, when the value changes, (or more technically, when someone indicates they would like to change the value, usually by pressing a button), or some device polling or event notification process. I got the memo not to trust MutEx in Netlinx very early in my programming career, thus have never used it.

    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
  • Options
    JasonSJasonS Posts: 229
    I know that Mutually Exclusive does not work properly in multiple master systems. I was advised by Tech support not to use them long ago.
Sign In or Register to comment.