Home AMX User Forum NetLinx Studio

DATA.TEXT INPUT?

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

Comments

  • [Deleted User][Deleted User] Harman Integrated Technologies Group (ITG) Posts: 0
    Three quick notes:
    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.
  • danlee20danlee20 Posts: 31
    Thanks. I am using Debug and nothing is being assigned to it. When I monitor the notifications I see that the command is being sent and I get lamp-196 back for lamp hours which is correct. The command the module uses to request lamp hours is correct. Still I get nothing assigned tot he variable nHOURS.

    Thoughts?? suggestions??
  • ericmedleyericmedley Posts: 4,177
    Data.text is going to be a string. You need to convert the string to an integer.
  • HedbergHedberg Posts: 671
    ericmedley wrote: »
    Data.text is going to be a string. You need to convert the string to an integer.

    Normally, that sort of type mismatch (actually an array size mismatch, I suppose) will throw a warning. For example,
    LOCAL_VAR INTEGER nHOURS
    local_var char sNumby[50]
    
    sNumby = '1234'
    nHours = snumby
    

    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.
  • [Deleted User][Deleted User] Harman Integrated Technologies Group (ITG) Posts: 0
    I would also suggest you widen your remove_string to include the '-'.

    If you truly receive 'lamp-196' as you indicated above, it will fail because your code is looking for a case sensitive 'LAMP-196'.
  • danlee20danlee20 Posts: 31
    HERE IS A NOTIFICATION IM GETTING BACK:

    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)"
    }

    }
  • [Deleted User][Deleted User] Harman Integrated Technologies Group (ITG) Posts: 0
    danlee20 wrote: »
    Line 132 (15:41:18):: [bold]Command From[/bold] [41001:1:1]-[LAMPTIME-200]

    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
  • Answered by Chris - nevermind.
  • danlee20danlee20 Posts: 31
    Thank You so Much!!!!!!!!!!!!!!! You guys are awesome. I cant tell you how much I appreciate your help!!! Chris how does the send string 0,'text' command work? sounds like it would be very useful.

    Thank you again to all of you. Chris it worked like a charm.
  • danlee20danlee20 Posts: 31
    Another question I have is how I would use (2) of the same projectors with the same module. I should be able to change the virtual device name and port number to match the external device. Is this correct?
  • viningvining Posts: 4,368
    danlee20 wrote: »
    Another question I have is how I would use (2) of the same projectors with the same module. I should be able to change the virtual device name and port number to match the external device. Is this correct?
    You need a 2nd DEV DPS, a 2nd VIRTUAL DPS and a 2nd instance of the module using a different identifier (name). Then it depends on how the module was written cuz you might need and 2nd UI module instance and maybe a complete duplicate set of UI pages using a 2nd UI port address. That's a bit old school so hopefully there's no UI module at all.
  • I have created a 2nd device and a 2nd virtual device. I am using the same module but renamed and Im getting this error message:
    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)
  • Your issue is here. You've changed the Module Name, not the instance identifier...
    danlee20 wrote: »
    DEFINE_MODULE 'NEC_NPPA600X_Comm_dr1_0_0' comm(vdvNECNPPA600X, dvNECRIGHT)
    DEFINE_MODULE 'NECPROJ2' comm (vdvNECNPPA600X2,dvNECLEFT)
    

    It should be like this:
    DEFINE_MODULE 'NEC_NPPA600X_Comm_dr1_0_0' comm1 (vdvNECNPPA600X, dvNECRIGHT)
    DEFINE_MODULE 'NEC_NPPA600X_Comm_dr1_0_0' comm2 (vdvNECNPPA600X2,dvNECLEFT)
    
  • Thank you. Worked like a charm.
Sign In or Register to comment.