Events Mirroring
Fov
Posts: 26
Hello)
I have a newbie problem
There is a Virtual Device. I want the following:
PUSH(vdvButton) --> BUTTON_EVENT[vdv] ---> <Do something>
In vdv module I use DO_PUSH()/DO_RELEASE() for buttons and ON/OFF for channels, assuming buttons and channels can have IDs 1-255.
In mainline I write the following:
DEFINE_VARIABLE
INTEGER BtnCodes[255]
DEFINE START
// Filling BtnCodes array...
// for (i=1;i<-255; i++) BtnCodes=i
BUTTON_EVENT[vdv, BtnCodes]
{
PUSH:
{
Send_String 0, "'Button #',ITOA(BUTTON.INPUT.Channel),' PUSH'"
}
RELEASE:
{
Send_String 0, "'Button #',ITOA(BUTTON.INPUT.Channel),' RELEASE'"
}
}
But this Button_Event never activates. I expected DO_PUSH/RELEASE would generate BUTTON_EVENT with same button code as in DO_PUSH/RELEASE.
Thanks in advance.
I have a newbie problem
There is a Virtual Device. I want the following:
PUSH(vdvButton) --> BUTTON_EVENT[vdv] ---> <Do something>
In vdv module I use DO_PUSH()/DO_RELEASE() for buttons and ON/OFF for channels, assuming buttons and channels can have IDs 1-255.
In mainline I write the following:
DEFINE_VARIABLE
INTEGER BtnCodes[255]
DEFINE START
// Filling BtnCodes array...
// for (i=1;i<-255; i++) BtnCodes=i
BUTTON_EVENT[vdv, BtnCodes]
{
PUSH:
{
Send_String 0, "'Button #',ITOA(BUTTON.INPUT.Channel),' PUSH'"
}
RELEASE:
{
Send_String 0, "'Button #',ITOA(BUTTON.INPUT.Channel),' RELEASE'"
}
}
But this Button_Event never activates. I expected DO_PUSH/RELEASE would generate BUTTON_EVENT with same button code as in DO_PUSH/RELEASE.
Thanks in advance.
0
Comments
HTH
DEFINE_START
for (cnt = 1; cnt<=255; cnt++)
{
BtnID[cnt]=cnt
ChlID[cnt]=cnt
}
SET_LENGTH_ARRAY(BtnID, 255)
SET_LENGTH_ARRAY(ChlID, 255)
...
BUTTON_EVENT[vdvSCTPServer, BtnID]
{
PUSH:
{
SEND_STRING 0, "'[!] SCTP to Mainline: Button PUSH: #',ITOA(BUTTON.INPUT.CHANNEL)"
}
RELEASE:
{
SEND_STRING 0, "'[!] SCTP to Mainline: Button RELEASE: #',ITOA(BUTTON.INPUT.CHANNEL)"
}
}
BUTTON_EVENT still never activates...
A part of vdv Module Code
MODULE_NAME='SCTP_Comm'( DEV vdvSCTPServer, DEV dvSCTPServer, INTEGER nSCTPPort)
DATA_EVENT[dvSCTPServer]
{
STRING:
{
// Parsing DATA.TEXT to get Button ID to push/release
DO_PUSH(vdvSCTPServer, Parsed_Button_ID)
...
}
}
A part of Mainline Code
BUTTON_EVENT[vdvSCTPServer, BtnID]
{
PUSH:
{
SEND_STRING 0, "'[!] SCTP to Mainline: Button PUSH: #',ITOA(BUTTON.INPUT.CHANNEL)"
}
RELEASE:
{
SEND_STRING 0, "'[!] SCTP to Mainline: Button RELEASE: #',ITOA(BUTTON.INPUT.CHANNEL)"
}
}
I call DO_PUSH when i get DATA_EVENT(vdv): STRING. It "pushes" a button on a Virtual Device. I want feedback for this event in mainline
1) How are the two DEVs defined?
2) Do you know a STRING is coming in at dvSCTPServer? You can verify that by doing a send_string 0 in the STRING handler for dvSCTPServer
3) How are you calculating Parsed_Button_ID? Are you sure it's an integer?
Diag says, virtual Button actually pushes so the trouble is in mainline BUTTON_EVENT.
Answers:
1)
DEFINE_DEVICE
vdvSCTPServer = 34999:1:0
dvSCTPServer = 0:2:0
2) Sure thing.
3) Absolutely sure.
in the module i have somewhere
do_push(vdvDev,1);
turn messages on and i see the result
(0000132575) push
(0000133072) release
fire up Diag again and check that your variable BtnID has what you are expecting.
Enable Push message display so you can see whats going on.
Can I take a look at your code?)
Filpee:
The problem isn't to write BUTTON_EVENT(dv, StaticID), but BUTTON_EVENT(dv, Array_of_IDs) instead.
Main program code:
Module code:
Output when I use Emulate a Device and send a string to dvComm:
BUTTON_EVENT with statically specified Button ID works for me, for you and for all.
I virtually 'push/release' buttons on vdv. I assume it can have a maximum of 255 buttons.
When I call DO_PUSH/RELEASE, I specify Button ID. I want only ONE BUTTON_EVENT in mainline that could process a PUSH/RELEASE of ANY of 255 virtual buttons
Main program:
Module:
Output when using Emulate a Device to send a string to dvComm
INTEGER nSomeButtons[] = {11,12,13,14,15}
But how to do the same thing with { 1, ... , 255 } ?
Sure, I don't want to write scary things like { 1,2,3,4,5,6,7,8,9,10,11,12 ... 100,101,102,103... 255}
When I try to fill array in loop, it doesn't work somehow
Like this:
As further explanation, the event table is built at compile time before your button array is initialized which is why the events weren't firing. That's why you need to use REBUILD_EVENT() so the event table can get reconstructed.
Also if you want to use more than 255 buttons just use SET_VIRTUAL_CHANNEL() in the ONLINE handler for the virtual device. For example if you want 1000 buttons you can do this:
SET_VIRTUAL_CHANNEL_COUNT(vdvSCTPServer,1000)
Have fun.
You almost got it. You want to use the REBUILD_EVENT() function.
Here is an example from NetLinx Help.
DEFINE_DEVICE
dvTP = 10001:1:0
DEFINE_VARIABLE
INTEGER X // loop counter
INTEGER nBTNS[4000]
DEFINE_START
FOR (X = 1; X <= 4000; X++)
{
nBtns[X] = X
}
// the braces below enclose a variable update and
// rebuild_event statement in a single block
{
SET_LENGTH_ARRAY(nBtns,4000)
REBUILD_EVENT()
}
BUTTON_EVENT[dvTP,nBtns]
{
PUSH:
{
// ...
}
}
// end