Home AMX User Forum NetLinx Studio

TP OFFLINE => LEVEL_EVENT?

This gives me more hard time than I initially thought. I am letting the user to select the ON level for his lights with an active bar-graph, I am storing this as an integer and then use the stored value for Lights ON (instead of 100%).
Easy said, but...

The variable gets initialized or modified when a LEVEL_EVENT from the bar-graph is detected.
DEFINE_CONSTANT 
INTEGER BargraphChannel = 1

DEFINE_VARIABLE
INTEGER LightsOnLevel

LEVEL_EVENT [dvTP, BargraphChannel]
{
     LightsOnLevel = LEVEL.VALUE
}

PROBLEM: Every time this panel goes OFFLINE, the system understands this as a LEVEL_EVENT with value = 0, therefore making the associated variable 0. And suddenly turning the lights ON actually switches them OFF.

QUESTION: Is there any way of avoiding that the OFFLINE event triggers a LEVEL_EVENT as well?
I would not be very excited about an invisible button overlay solution (as recommended in other threads here) since I want to adjust the slider with SEND_LEVEL too, and, in that case, it must update the variable. Just as well, if using a virtual TP combined on that particular channel, won't that still react when the physical device triggers a BUTTON_EVENT?

Thanks!

Comments

  • AMXJeffAMXJeff Posts: 450
    This gives me more hard time than I initially thought.

    You should make the level only change if the bargraph is being touched. So assign a button number to the bargraph. Use a button event to set a flag.
    BUTTON_EVENT[dvTP,1] // Bargraph Button
    {
         PUSH:
              bBargraph_Inuse = true;
         RELEASE:
              bBargraph_Inuse = false;
    }
    
    DATA_EVENT[dvTP]
    {
        ONLINE:
        {
             // Set Level Event to last value
             SEND_LEVEL dvTP, BargraphChannel, LightsOnLevel 
        }
    }
    
    LEVEL_EVENT [dvTP, BargraphChannel]
    {
         IF (bBargraph_Inuse == true)
             LightsOnLevel = LEVEL.VALUE
    }
    
    
  • Thanks

    Jeff, your solution won't let me adjust the level with a SEND_LEVEL, will it? That's why I tried to exclude this from the very start (as initially said).
    If nothing, but tricking the panel will do it, then I seem to like more Matt's solution. No offence :-)
  • AMXJeffAMXJeff Posts: 450
    None Taken!
  • TurnipTruckTurnipTruck Posts: 1,485
    AMXJeff wrote: »
    You should make the level only change if the bargraph is being touched. So assign a button number to the bargraph. Use a button event to set a flag.

    Do we know that the button event always occurs before the level event?
  • Try combining with a VirtualTP that always stays online.

    dvTP = 10001:1:0
    vdvTP = 33001:1:0

    define_combine
    (vdvTP,dvTP )

    Then run your level_event off of the vdvTP.
  • AMXJeffAMXJeff Posts: 450
    Do we know that the button event always occurs before the level event?


    Yes it does....
  • TurnipTruckTurnipTruck Posts: 1,485
    AMXJeff wrote: »
    Yes it does....

    Good to know! Thanks!
  • kbeattyAMX wrote: »
    Try combining with a VirtualTP that always stays online.

    dvTP = 10001:1:0
    vdvTP = 33001:1:0

    define_combine
    (vdvTP,dvTP )

    Then run your level_event off of the vdvTP.

    This is the other solution I was sceptical in considering.
    If the two devices are combined (NOT COMBINE_CHANNEL, right?), there will still be a LEVEL_EVENT happening at the physical device, and will be mirrored on the virtual device since the LEVELS are also combined... Am I not just where I was? Just now having two devices getting the LEVEL_EVENT to 0 when the physical one goes offline.

    Jeff, gave it another thought... Your solution will also work if I raise the flag every time before the SEND_LEVEL. Right?
    Something like
    AMXJeff wrote: »
    .
    DATA_EVENT[dvTP]
    {
        ONLINE:
        {
             [b] bBargraph_Inuse = true    // EDITED[/b]
             // Set Level Event to last value
             SEND_LEVEL dvTP, BargraphChannel, LightsOnLevel
             [b] WAIT SomeMaybe bBargraph_Inuse = false   //EDITED[/b]
        }
    }
    

    And lastly, Dmytri, you know it's always frustrating when your 50 cent is still too much for what I can afford. Meaning when the link redirects me to a page that tells me that I am not big enough for the whole truth... Thanks!
  • This is the other solution I was sceptical in considering.
    If the two devices are combined (NOT COMBINE_CHANNEL, right?), there will still be a LEVEL_EVENT happening at the physical device, and will be mirrored on the virtual device since the LEVELS are also combined... Am I not just where I was? Just now having two devices getting the LEVEL_EVENT to 0 when the physical one goes offline.
    If the Virtual TP is the first TP in the combine, the vTP is all that the program sees. All references to the actual TP is changed to the vTP. Since the vTP does not go to sleep and cannot be unplugged the level event never changes. When the actual TP comes online it syncs with the vTP and you do not see the Level 0 and once online the bargraph on the TP returns to it's previous level. I tried it and it works fine.

    That's one of the main reasons you have virtual devices. It's a device that is always online and will maintain level and channel feedback.
  • JeffJeff Posts: 374
    Just my .03, but I've pretty much given up on Active Bargraphs except for certain situations. For graphs like the one you're describing, I use a combination of two graphs, layered on top of eachother.

    The first bargraph is active, but all of the graphics are transparent. The second bargraph is Display, and has the visible bargraph I want to show. Then, in code, I have the button event suggested by AMXJeff (because apparently Jeff's have to stick together) parse the input and send_level the displayed level back to the graph.

    This is useful for several things, none the least of which is being able to easily change what is visible without worrying about creating superfluous level events. It also solves your problem the way AMXJeff suggested earlier, which I was hesitant about at first but after using really liked. It has the added advantage of the level not moving when the panel isn't connected, which I like. I want the panel to appear completely dead when the connection is gone, so people don't think they're doing things when they aren't, but thats just my preference.

    J
  • Thanks Ken, but learning is asking, so I'll dare one more

    Down to the very basics, it's either, or:
    1. a LEVEL_EVENT on the physical TP will create the same level event in the combined vTP => when going OFFLINE, the variable will reset anyway even if only manipulated in LEVEL_EVENT [vTP]

    2. a LEVEL_EVENT on the physical TP does NOT create the same level event on the vTP => the variable inside the LEVEL_EVENT [vTP] will not get updated even when the user wants so.

    I tend to understand that things are rather case number one. Please clarify...

    On the other hand, what I needed was also the least laborious of them all as I have some 40 sliders and just as many LEVEL_EVENTS.
    Finally, I got myself going with flagging the ONLINE/OFFLINE status of the device (already there for other reasons) and giving go to the level event only if the flag is up.

    Something like
    LEVEL_EVENT [dvTP]
    {
         IF (FlagUpDeviceOnline)
         {
               LevelVar = LEVEL.VALUE
         }
    }
    

    It appears that the level is received by the master AFTER the OFFLINE status, so the IF clause won't pass.
  • kbeattyAMX wrote: »
    Try combining with a VirtualTP that always stays online.

    dvTP = 10001:1:0
    vdvTP = 33001:1:0

    define_combine
    (vdvTP,dvTP )

    Then run your level_event off of the vdvTP.

    You would not run a level_event on the physical TP. The level_event would be on the vTP. If you don't want to rewrite code do this:
    vdvTP = 10001:1:0 //This is not really the virtual the device but the real device
    dvTP = 33001:1:0  //just did this so no program modification is necessary
    
    integer bargraph_value[10]
    
    define_combine
    (dvTP,vdvTP )  //the virtual device should always be the first in the list!
    //if 10 levels ranging 1-10
    level_event[dvTP,0]  //now is actually the virtual device
    {
      bargraph_value[level,input.level] = level.value
    }
    

    This would work for 10 bargraphs

    This would keep you from having to rename all of the dvTP in your system to vdvTP. The magic is in the DEFINE_COMBINE. This causes the Netlinx to only see the real TPs throught the vTP.
    Down to the very basics, it's either, or:
    1. a LEVEL_EVENT on the physical TP will create the same level event in the combined vTP => when going OFFLINE, the variable will reset anyway even if only manipulated in LEVEL_EVENT [vTP]

    It's number one but when the real TP goes off line it does not effect the level on the vTP. And when the real TP comes online, the real TP is updated with the values of the vTP.

    I hope this helps...
  • kbeattyAMX wrote: »
    when the real TP goes off line it does not effect the level on the vTP

    Great observation. Still, my humble opinion is that if the TP does not report the level change to the vTP (when going offline), it should not be interpreted as a LEVEL_EVENT by the master either. It's just gone offline, and the master knows that by then...
    Never mind, I tested it, it's working and it all across my 40+ sliders. Many thanks.
  • Glad it works!
  • TurnipTruckTurnipTruck Posts: 1,485
    Jeff wrote: »
    The first bargraph is active, but all of the graphics are transparent. The second bargraph is Display, and has the visible bargraph I want to show.

    This method is what I do and it works well.
Sign In or Register to comment.