Home AMX User Forum AMX General Discussion

What are channel_events used for?

It's been a while, so please bear with me: What are channel events used for? I am THINKING that they are used to provide feedback to a particular button based on the execution of that channel event's associated set of code.

Comments

  • ericmedleyericmedley Posts: 4,177
    vegastech wrote: »
    It's been a while, so please bear with me: What are channel events used for? I am THINKING that they are used to provide feedback to a particular button based on the execution of that channel event's associated set of code.

    Just as when someone or something pushes/releases a button it generates a button event, so it is with a channel. So, if a device's channel turns on or off it generates a channel event.

    and example of a way this can be used is.

    Power state of a TV turns on channel 255 of a virtual device.

    If you tie the power button's feedback on a touch panel to the channel of the virtual device the TP's button feedback will match the power state of the TV.

    You can also put a channel event in code to use the channel state.

    For example...

    a TV lift that brings a TV out of a cabinet when the power is on.

    So,
    data_event[dv_TV_Serial_Port]
    {
    string:
      {
      if(find_string(whatever the tv on stirng is)
        {
        on[vdv_TV_Virt_Device,255]
        } 
      if(find_string(whatever the tv off stirng is)
        {
        off[vdv_TV_Virt_Device,255]
        } 
      }
      }
    }
    
    
    // then  
    
    Channel_Event[vdv_TV_Virt_Device,255]
    {
    on:
      {
      pulse[dv_Lift_Relays,1] 
      }
    off:
      {
      pulse[dv_Lift_Relays,2]
      }
    }
    
    
  • Another use is to use the power on channel event on the virtual device of a device module to initialize the device; for instance switching a projector to the required input for the currently selected source once its powered up - beats the heck out of standing there counting steamboats and finessing a wait or timeline that is started with the on command.
  • vegastechvegastech Posts: 369
    That helps quite a bit - especially the projector part! What about with other devices, like IR-only TVs? Would the channel-event be best used with a power sensor to determine the state of the device, and then once it is on (which I think a channel event would be set to ON if the power sensor sensed power(if that made sense), then a subsequent IR command could be sent?
  • truetrue Posts: 307
    vegastech wrote: »
    That helps quite a bit - especially the projector part! What about with other devices, like IR-only TVs? Would the channel-event be best used with a power sensor to determine the state of the device, and then once it is on (which I think a channel event would be set to ON if the power sensor sensed power(if that made sense), then a subsequent IR command could be sent?

    Yeah, you could do that. I have a power timeout module that works exactly that way, but with a virtual device instead of real hardware. (basically it tracks power by sending it power on or off commands. it then sets channel 27 or 28 depending on what it needs to do without repeating commands, and I use a channel_event[] on these.)
  • ipssheldonipssheldon Posts: 106
    Similar to the projector power status monitoring, using channels is essentially a way to interrupt your program when a particular variable's state changes. It could be anything. Instead of watching for a boolean variable's value to become true, simply use a channel on a virtual device. Then create a channel event for that device,channel pair. Instead of setting the variable to true, turn the channel ON. Likewise, you can monitor the OFF (or false) state in the same way. In this way, your program will never process this event unless or until the channel turns on or off. If you want to process an integer variable only when that variable changes, you can do the same thing. In your code, when you change the state, pulse the channel. In the channel event's ON event, read the new value and perform the necessary functionality. In this way, it can make your program more efficient rather than adding code in mainline to always check the state over and over again, even when you know it hasn't changed.
  • you can also use channel events with the I/O ports - e.g. if the I/o port is on or pulsed, do something, if its off, do something else. some examples: for Evac/EWIS relays that can then cut all your audio so the Fire anouncement can be heard; contact closures for partition walls, garage doors etc etc; induction loop relays/vehicle detection boards for....pretty much anything! Gate entry/exit, auto doors, even drive-thru alerts. The possibilities are, as they say, endless.
  • DHawthorneDHawthorne Posts: 4,584
    If it helps you to think of it this way, a CHANNEL_EVENT is used to detect the change in state of an object. It's an alternative to the rather cludgy stop-gap of continually testing something for a state, tracking what it used to be, and doing something if it changes. With a channel event, its all done on the firmware level.
Sign In or Register to comment.