Home AMX User Forum NetLinx Studio

Help With Command Data Event on Virtual Device

First of all, let me say that this is my first post on this forum although I browse it fairly often. Also, I will say up front that my question is related to my Programmer 2 Practical exam. However, I am not looking for someone to just give me the answer. I have contacted AMX support to ask about my code and they say it should be correct, I also have contacted my trainer days ago and he hasn't responded at all.

Anyways, my question is about using a duet module, virtual device. I send a preset command to the virtual device, and then the virtual device is supposed to respond with a from command. I want to analyze the response coming back from the virtual device and then turn a channel on for button feedback. Below is my code.

(***********************************************************)
(* DEVICE NUMBER DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_DEVICE

#IF_NOT_DEFINED dvCAMERA
dvCAMERA = 5001:4:0 //CAMERA ON PORT 4 OF RS-232
#END_IF

#IF_NOT_DEFINED vdCAMERA
vdCAMERA = 41001:1:0 //MODULE FOR CAMERA
#END_IF

#IF_NOT_DEFINED vdCAMERA2
vdCAMERA2 = 41001:2:0 //USED FOR PRESET COMMANDS
#END_IF

#IF_NOT_DEFINED dvTPCAMERA
dvTPCAMERA = 10001:10:0 //CAMERA CONTROL BUTTONS
#END_IF

(***********************************************************)
(* THE EVENTS GO BELOW *)
(***********************************************************)
DEFINE_EVENT

BUTTON_EVENT [dvTPCAMERA,nCAMERACTRLBTNS]
{
PUSH:
{
SWITCH (GET_LAST (nCAMERACTRLBTNS))
{
CASE 1: //CAMERA UP
{
ON [vdCAMERA,132]
}
CASE 2: //CAMERA DOWN
{
ON [vdCAMERA,133]
}
CASE 3: //CAMERA LEFT
{
ON [vdCAMERA,134]
}
CASE 4: //CAMERA RIGHT
{
ON [vdCAMERA,135]
}
CASE 5: //CAMERA ZOOM OUT
{
ON [vdCAMERA,158]
}
CASE 6: //CAMERA ZOOM IN
{
ON [vdCAMERA,159]
}
CASE 7: //PRESET 1
{
SEND_COMMAND vdCAMERA2, 'CAMERAPRESET-1'
}
}

DATA_EVENT [vdCAMERA2]
{
COMMAND:
{
SELECT
{
ACTIVE (FIND_STRING(DATA.TEXT,'CAMERAPRESET-1',1)):
{
ON [vdCAMERA,261]
}
}
}
}

(***********************************************************)
(* THE ACTUAL PROGRAM GOES BELOW *)
(***********************************************************)
DEFINE_PROGRAM

[dvTPCAMERA,132]=[vdCAMERA,132]
[dvTPCAMERA,133]=[vdCAMERA,133]
[dvTPCAMERA,134]=[vdCAMERA,134]
[dvTPCAMERA,135]=[vdCAMERA,135]
[dvTPCAMERA,158]=[vdCAMERA,158]
[dvTPCAMERA,159]=[vdCAMERA,159]
[dvTPCAMERA,261]=[vdCAMERA,261]


Any help you guys can offer will be appreciated. Also in the device notifications window, i look at commands going to and coming from device 41001 port 1 and port 2 and when i press the preset 1 button, i see the command being sent and then it responds showing me the command coming back so i'm trying to look for that command turn the channel on, which will turn the button on.

Comments

  • The issue isn't with the command response from the module, the issue is with the channel you are turning on. Duet virtual devices don't react like regular Netlinx virtual devices, so you can't turn on a channel and use it for feedback the way you might be able to. I am willing to bet that if you turned on diagnostics and watched what happens when you press your preset button you would see the duet module throw an error, since the SNAPI doesn't have channel 261 defined.

    With the way you want to do this, I would suggest parsing out the preset number and storing it in a variable, then turning the preset button on depending on what value that variable holds. Hope that helps.
Sign In or Register to comment.