reading the status of pushed channel by DO_PUSH (new)
moty66
Posts: 31
Hello
Is is possible to read the status of a virtual channel if it was pushed or not
I used DO_PUSH(myVirtualDev,1) to do the push
and it seems that IF([myVirtualDev,1]) does not return the correct status of the channel
I can save all the pushed channels inside an array, but what if I have lot of channels to work with or even dynamic channels ?
any idea ?
Is is possible to read the status of a virtual channel if it was pushed or not
I used DO_PUSH(myVirtualDev,1) to do the push
and it seems that IF([myVirtualDev,1]) does not return the correct status of the channel
I can save all the pushed channels inside an array, but what if I have lot of channels to work with or even dynamic channels ?
any idea ?
0
Comments
For example, if you have a physical panel with a button on it [dvPhysicalPanel,1] and someone presses that button on a panel, the feedback status (what you check when you check [dvPhysicalPanel,1] ) doesn't change unless you turn it on or off or use a to[] or whatever.
this may be very simple to accomplish. In the button event you might just change the status in the push: handler:
I don't want to use the feedback
Becasue when the DO_PUSH_TIMED() function release the push the feedback will not be updated
Good, I used do_push_timed with very infinite push constant
but How can I read later if this channel is pushed or not ?
How can I use on off ?? and can I read them later ??
On(myDev,myChan) ?
thanks
OFF[dev,chan]
IF([dev,chan]) should work when using the on/off but maybe not when using do_push. I rarely check channel states myself so I'm somewhat ignorant on their usage but it might be do_push affects input channels and on/off affects feedback channels. Since I don't really use these I never gave it much thought but there has been discussions about feedback vs input channels that you may be able to find. Maybe I should have read them.
Thanks again
Yes, I guess that ON/OFF works for the feedback, I will do some test and I will leave a message when I am done
Regards
So, when you evaluate a button, you are not checking to see if it is currently pushed, you are not checking to see if it has been pushed, you are checking to see what the state of it's feedback is, and you control that in the code in any manner you desire -- typically in response to a button press or in response to a channel feedback state, or an IO state or a string received from a device or whatever.
but ...
From the Netlinx Language Reference
As you see, AMX says that IF the channel is allready ON, no event is generated ! I really don't understand how can they check if a Channel is ON / OFF.
I didn't describe will my issue, i try now
I am translating a protocol from RS232 -> Virulent device Channel Events
The protocol sends to me the address from 0x00 to 0xFF I call it RS_ADDRESS, and a Time out: RS_TIMEOUT, and Action RS_ACTION (01-ON/10-OFF/11-CHANGE_STATE)
I have no problems with ON OFF and I do it in this way
FOR ON: DO_PUSH_TIMED(vDEV,RS_ADDRESS,(RS_TIMEOUT /10)
FOR OFF: DO_RELEASE(vDEV,RS_ADDRESS)
But my problem is the TOGGLE (change state), so what I need is to check if the channel is already ON then I call the DO_RELEASE function otherwise I call the DO_PUSH / DO_PUSH_TIMES
Thank you guys for the help
To understand this better, look at the following code:
Monitor your diagnostics and debug watching nTestdvSer1Chan1 and use diagnostics/emulate a device to "push" and hold 5001:1:0 and then release it. Do you see how [dvser1,1] never changes?
Now try the following code instead:
You can trigger the button event of interest either directly or with the do_push and the behavior is as expected. If you want to monitor the status of an input (i.e. whether a button push is engaged), you need to turn something on in the push handler and turn it off in the release handler. That is, you need to control the feedback, which you can monitor in code, and not try to monitor the input, which you can't.
Alternatively, since you are dealing with virtual devices and not physical touch panels, instead of do_push(), you can just manipulate the channels and use channel events instead of button events. That is, instead of do_push() and do_release(), just turn the channel on and off with the desired timing. Depending on how your device is behaving, this may not be practical without using a timeline because I don't think you can use a wait with a variable delay.
added: of course, rather than turning the channel on and off you can use to[devchan]
Good idea, but using on is not the same as using do_push, because if u turn on a devicechan it will not be off after the time out ! so this is not suitable for what I need
I will do some tests and I will be back with my results
Regards
M.
1. Input - These are pushes. If the button is being pushed then the input is on.
2. Output - This is controlled by the programmer e.g. ON[5001:8:0, 1] would turn the output on (relay 1 on a NI-3100).
3. Feedback - This is what the AMX master thinks the channel is. Generally if you turn a channel on then it's feedback will be on. Under certain circumstances the channel will be off but the feedback will be on i.e. if you have a relay in a mutually exclusive group and you pulse it, the channel will say it's off but feedback will say it's on.
For on you could do this;
ON[vDEV,RS_ADDRESS]
WAIT RS_TIMEOUT/10 OFF[vDEV,RS_ADDRESS]
For off;
OFF[vDEV,RS_ADDRESS]
For toggle;
[vDEV,RS_ADDRESS] = ![vDEV,RS_ADDRESS]
Then your if([vDEV,RS_ADDRESS]) would produce an accurate result.
but I don't use ON / OFF
I still use DO_PUSH and DO_RELEASE
at the same time I update the feedback
I don't have the original code now, so maybe there are some errors in my code
I don't know what you're actually trying to accomplish or if the module is open but I would probably set the devchan feedback in the module and in the push do ON[dev,chan] and then in the release do the OFF[dev,chan].