Home AMX User Forum NetLinx Studio

Channel_event. Off for all channel

Hello!

I have the following code:


Integer SourceBtn[] = {11,12,13,14}

channel_event [dvRemote, SourceBtn[] {

On : {switch (channel.channel){
case 11 : do something
Case 12: do something
Etc.}}
Off: {switch (channel.channel){
case 11:
Case 12:
Ets.}}
}

How can I perform the necessary action to me, only when all channels are switched off in this array?

Comments

  • nickmnickm Posts: 152
    Run a check on all channels whenever any of them causes the event.
    CHANNEL_EVENT [dvRemote,SourceBtn] {
      ON : {
    
      }
      OFF : {
        IF(![dvRemote,SourceBtn[1]] && ![dvRemote,SourceBtn[2]] && ![dvRemote,SourceBtn[4]] && ![dvRemote,SourceBtn[4]]) {
          // do something
        }
      }
    }
    
  • I am assuming that these are source selection buttons. Do you really want to use a CHANNEL_EVENT here instead of a BUTTON_EVENT?

    How are you handling OFF or source=0? Tracking the currently selected source (including OFF) would be cleaner for panel button feedback.

    I think we need to know more about the scenario than you have provided in the original post. Based on what I think you are doing, this is the approach I would use.
    DEFINE_DEVICE
    dvRemoteZone1 = 10001:1:0
    
    DEFINE_CONSTANT
    INTEGER nNumAVZones = 1
    INTEGER nTPBtn_SourceSelect[] = 
    {
        10,  //OFF
        11, //Source 1
        12, //Source 2
        13, //Source 3
        14  //Source 4
    }
    
    DEV dvRemoteControls [] =
    {
     dvRemoteZone1
    }
    
    DEFINE_VARIABLE
    INTEGER nCurrentSource [nNumAVZones] //track who is doing what - suggest using a structure and capture more info on the zone, but this is a quick example.
    
    DEFINE_EVENT
    BUTTON_EVENT [dvRemoteControls, nTPBtn_SourceSelect] //using the array instead of a single remote - project could grow and this is approach is easier to maintain
     {
         PUSH:
         {
            SWITCH (GET_LAST(nTPBtn_SourceSelect))
            {
              CASE 1: {do something} //Zone Off
              CASE 2: {do something} //Source 1
            }
           //Update Tracking (would be fake and suggest getting it from the switcher feedback)
           nCurrentSource [GET_LAST(dvRemoteControls)] = GET_LAST(nTPBtn_SourceSelect)
          }
    }
    
     
    
  • yes, you're right! it is the source button. besides, they are mutually exclusive.)) here I do not follow the device is turned. but I know that it wants to include relying on the state of the channel)

    and to disable all I perform total_off ... and as soon as all the channels is disabled, you need to send a shutdown command to the devices) bad idea?
  • Is this for your programming practical exam or a deployed project?

    If the project requirement has you acting on channel feedback, then Nick has provided an answer that will work for your needs. For me, I still need more information because I find the question to be out of context, and the additional details would aid me in providing a better and more complete answer.

    Maybe others can chime in.
  • this is a working project of multiroom, if I may say so. I will later laptop will show you the full text of this piece of code and try to explain in detail what I wanted)
Sign In or Register to comment.