TP OFFLINE => LEVEL_EVENT?
felixmoldovan
Posts: 197
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.
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!
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!
0
Comments
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.
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 :-)
Do we know that the button event always occurs before the level event?
dvTP = 10001:1:0
vdvTP = 33001:1:0
define_combine
(vdvTP,dvTP )
Then run your level_event off of the vdvTP.
http://amxforums.com/showthread.php?t=3461&highlight=wifi+active+bargraph
Yes it does....
Good to know! 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.
Jeff, gave it another thought... Your solution will also work if I raise the flag every time before the SEND_LEVEL. Right?
Something like
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!
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.
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
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
It appears that the level is received by the master AFTER the OFFLINE status, so the IF clause won't pass.
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:
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.
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...
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.
This method is what I do and it works well.