DATA.TEXT INPUT?
danlee20
Posts: 31
I am trying to get lamp hours from an NEC projector. I am using the Duet module provided by AMX. I have posted my DEFINE_EVENT below:
DATA_EVENT[vdvNECNPPA600X]
{
ONLINE:
{
SEND_COMMAND vdvNECNPPA600X,'PROPERTY-BAUD_RATE,38400' //SETS BAUD RATE TO 34800
SEND_COMMAND vdvNECNPPA600X,"'RXON'" //RECEOVE LIGHT IS TURNED ON
SEND_COMMAND vdvNECNPPA600X,"'?LAMPTIME'"
}
STRING:
{
LOCAL_VAR INTEGER nHOURS
IF(FIND_STRING(DATA.TEXT,'LAMP',1))
{
REMOVE_STRING(DATA.TEXT,'LAMP',1)
nHOURS = (DATA.TEXT)
}
SEND_COMMAND dvTPMAIN,"'^TXT-1,0, ',(nHOURS)"
}
}
What am I missing???? My button on my touch panel is at address code 1:1
DATA_EVENT[vdvNECNPPA600X]
{
ONLINE:
{
SEND_COMMAND vdvNECNPPA600X,'PROPERTY-BAUD_RATE,38400' //SETS BAUD RATE TO 34800
SEND_COMMAND vdvNECNPPA600X,"'RXON'" //RECEOVE LIGHT IS TURNED ON
SEND_COMMAND vdvNECNPPA600X,"'?LAMPTIME'"
}
STRING:
{
LOCAL_VAR INTEGER nHOURS
IF(FIND_STRING(DATA.TEXT,'LAMP',1))
{
REMOVE_STRING(DATA.TEXT,'LAMP',1)
nHOURS = (DATA.TEXT)
}
SEND_COMMAND dvTPMAIN,"'^TXT-1,0, ',(nHOURS)"
}
}
What am I missing???? My button on my touch panel is at address code 1:1
0
Comments
1) Use debug to track your nHours variable and observe what is getting assigned there.
2) You will most likely need to convert your integer to ascii in your send command statement - "'^TXT-1,0, ',ITOA(nHOURS)"
3) When you store the value, the source data is ascii, so ATOI conversion is needed there.
If you don't need the integer value, you could change nHours from an integer into a char and skip the conversions. However, you may need this value in integer form to perform evaluations like if nHours is greater than 2000, send a popup.
Thoughts?? suggestions??
Normally, that sort of type mismatch (actually an array size mismatch, I suppose) will throw a warning. For example,
gives the expected converting a string to an integer warning. I guess that the compiler is not sufficiently clever to figure out that data.text is a string variable.
In any event, I believe Chris has the correct solution to this problem above.
If you truly receive 'lamp-196' as you indicated above, it will fail because your code is looking for a case sensitive 'LAMP-196'.
Line 130 (15:41:18):: String To [5001:1:1]-[$03$8C$00$00$00$8F]
Line 131 (15:41:18):: String From [5001:1:1]-[#$8C$01$80$10$14$FF$0A$00$00$00$00$00@T$89$00$80$D2$8E$00Z]
Line 132 (15:41:18):: Command From [41001:1:1]-[LAMPTIME-200]
IM ALSO GETTING THIS BACK:
Line 26 (15:40:44):: Level Size [41001:1:1] - Level 1 Supported Types=BYTE,LONG,FLOAT
Line 27 (15:40:44):: Command To [41001:1:1]-[?LAMPTIME]
Line 28 (15:40:44):: Command From [41001:1:1]-[?LAMPTIME]
Line 29 (15:40:44):: Level Size [41001:1:1] - Level 2 Supported Types=BYTE,LONG,FLOAT
Line 30 (15:40:44):: Command From [41001:1:1]-[LAMPTIME--2147483648]
What am I doing wrong?????? my code is below
DEFINE_DEVICE
dvNECNPPA600X = 5001:1:0
vdvNECNPPA600X = 41001:1:0
dvTPMAIN = 10001:1:0
dvTP_PROJ = 10001:2:0
DEFINE_EVENT
DATA_EVENT[vdvNECNPPA600X]
{
ONLINE:
{
SEND_COMMAND vdvNECNPPA600X,'PROPERTY-BAUD_RATE,38400' //SETS BAUD RATE TO 34800
SEND_COMMAND vdvNECNPPA600X,"'RXON'" //RECEOVE LIGHT IS TURNED ON
SEND_COMMAND vdvNECNPPA600X,"'?LAMPTIME'"
}
STRING:
{
LOCAL_VAR INTEGER nHOURS
IF(FIND_STRING(DATA.TEXT,'LAMP-',1))
{
REMOVE_STRING(DATA.TEXT,'LAMP-',1)
nHOURS = ATOI(DATA.TEXT)
}
SEND_COMMAND dvTPMAIN,"'^TXT-1,0,HOURS ',ITOA(nHOURS)"
}
}
Your code is looking for LAMP-, but you are receiving LAMPTIME-
What happens if you change your FIND_STRING to be 'LAMPTIME-', and your REMOVE_STRING to be 'LAMPTIME-'?
Additionally, you will note that you are receiving this back in code as a COMMAND FROM, but you are looking for it as a STRING FROM, so move this into COMMAND: and not STRING: under the data_event.
A SEND_STRING 0 would be a good tool to use when troubleshooting something like this in code,
SEND_STRING 0, 'Made it this far...' //let's see if we even hit this section of code
Thank you again to all of you. Chris it worked like a charm.
ERROR: C:\AMX\Projects\atlantaFed\AtlantaFed.tko(64): L20218: Missing valid AMX module reference for [NECPROJ2.jar]
here is some of my code:
dvNECRIGHT = 5001:1:0
dvNECLEFT = 5001:2:0
dvPANASONIC = 5001:3:0
vdvNECNPPA600X = 41001:1:0
vdvNECNPPA600X2 = 41001:2:0
dvTPMAIN = 10001:1:0
dvTP_PROJ = 10001:2:0
DEFINE_COMBINE
(***********************************************************)
(* CONSTANT DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_CONSTANT
BUTTON1 = 1
BUTTON2 = 2
BUTTON3 = 3
BUTTON4 = 4
BUTTON5 = 5
BUTTON6 = 6
BUTTON7 = 7
BUTTON8 = 8
BUTTON9 = 9
BUTTON0 = 0
(***********************************************************)
(* DATA TYPE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_TYPE
(***********************************************************)
(* VARIABLE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_VARIABLE
VOLATILE INTEGER nPROJSTAT_RT
VOLATILE INTEGER nPROJSTAT_LT
VOLATILE INTEGER nFLASH
//schedule variables
DEFINE_START
DEFINE_MODULE 'NEC_NPPA600X_Comm_dr1_0_0' comm(vdvNECNPPA600X, dvNECRIGHT)
DEFINE_MODULE 'NECPROJ2' comm (vdvNECNPPA600X2,dvNECLEFT)
It should be like this: