Text Input To Touch Panel From an Http Interface Device

Hi,
Have a Good Day

I am new to Amx Programming. I am Using MST-1001 G4 Touch Panel. I am Using One Device Its working Under HTTP Software based Device. I want to Get an Text From that Device into my Touch Panel .

This is the URL i sent to that device using my browser:

http://10.81.254.55:8890/CoCon/Meeting_Agenda/GetAgendaItemById/?Id=1

it will Come Like as a Output From that Device

"{\"GetAgendaItemById\":{\"AgendaItem\":{\"Id\":\"1\",\"Title\":\"Introduction\",\"Description\":\"\",\"Type\":\"AgendaItem\",\"State\":\"notstarted\",}"

In This i want Title alone to display in my Touch Panel.

I used this comment to that device in the netlinx Its Responded Well in that device.

SEND_STRING Dv_Televic_PC," ' GET /Cocon//Meeting_Agenda/GetAgendaItemById/?Id=1 HTTP/1.1',$0D,$0A,'Host : localhost',$0D,$0A,$0D,$0A"

//

I created an button in my touch panel and gave address code as : 20 and Address Port :1

Agenda3_Name= 20 ;

DATA_EVENT[Dv_Televic_PC]
{
Online:
{
SEND_COMMAND dvTP," '^TXT-',itoa(Agenda3_Name),',0,', ' GET /Cocon/Meeting_Agenda/GetAgendaItemById/Title/?Id=1 HTTP/1.1',$0D,$0A,'Host : localhost',$0D,$0A,$0D,$0A ";
}
}

//

I used this Comment But it didn't help me.

How can i Send get an Text into my Touch Panel.. Please Help me to rectify my mistake in my comments .

Comments

  • fogled@mizzou[email protected] h4x354x0r Posts: 547

    I think you'll need to move the data acquisition to a separate function (which usually needs several discreet steps of opening the connection, sending the request, then capturing the data returend), you'll need to parse the results coming back from the HTTP query, store it, then use that data to send to your control panel.

  • KarthikKarthik Posts: 24
    edited February 12

    Yes. This only am Expecting to do.I didn't know the Comment and Syntax For it. Can you please Help me If you know it.

  • HARMAN_icraigieHARMAN_icraigie Technical Trainer II, Harman Professional University Posts: 454

    There is a section in the on demand CP131: AMX Programmer 1 | Introduction to Netlinx Programming (Lesson 10) that covers string parsing and setting text in the touch panel. Access from the training site https://training.harmanpro.com/#/dashboard

  • KarthikKarthik Posts: 24

    Thanks. It Will Help me .But am Using Doing like this for 10-15 Buttons .

    This is the URL i sent to that device using my browser For ID-1 :

    http://10.81.254.55:8890/CoCon/Meeting_Agenda/GetAgendaItemById/?Id=1

    it will Come Like as a Output From that Device

    "{\"GetAgendaItemById\":{\"AgendaItem\":{\"Id\":\"1\",\"Title\":\"Introduction\",\"Description\":\"\",\"Type\":\"AgendaItem\",\"State\":\"notstarted\",}"

    Like this I want to get information for another ids.

    How it is possible? by using Same data_event command for all Input buttons.

  • KarthikKarthik Posts: 24
    edited February 12

    I can able to use Symbols In String Parsing Keywords?

    Like this

    STRING:
    {
    send_string dvTp,"'RX: ',REMOVE_STRING(data.text," : ",1)"
    }

    This is correct comment for getting statement Text From Http/Json Based System. Please Tell in Which i made Mistake

  • fogled@mizzou[email protected] h4x354x0r Posts: 547

    That's the general idea, but if you're doing this for multiple buttons, you'll need to keep them all sorted out somehow. Either create that many discreet separate IP ports and connections, and a separate data_event tree for each, or, create and pass a token around with each request, so you know which button to send the reply to when it comes back on a single IP connection & data_event tree.

    For the record, creating discreet separate IP connections and data_event trees for each button is utter programming insanity, but should technically work.

  • KarthikKarthik Posts: 24
    edited February 12

    Thanks. I am Using Seperate button with different Address Code for it..but You Telling For every Buttons i want to use the same data event and Find_String statement ? .

    Because Input From that device having same Heading as " TITLE" with different ID .

  • fogled@mizzou[email protected] h4x354x0r Posts: 547

    As long as the return string contains an ID that you can parse out and determine the button number from, you should be good. The syntax in your first post looks correct. Try substituting fixed text for the GET string in that statement, you should at least see the button address element populate with the data you're sending it. That will confirm you're getting text to the panel OK. The rest will be the procedure of creating the IP connection, waiting until it connects, sending the GET statement to the connection, then getting the data back and parsing that, so then you have the right data to send to the right address on the panel.

    Sending the data to the panel is (or should be) trivial, compared to the whole IP request, transaction, and result parsing process.

  • fogled@mizzou[email protected] h4x354x0r Posts: 547

    Here's a copy of a Panasonic camera command that shows the process of opening an IP connection, waiting until it's open, and sending the request. Note I'm using buffer processing; pushing a button just drops a command into the buffer, and this code (set inside a ~200ms timeline loop) runs anytime it finds anything in that buffer.

    while(find_string(rm[1].d[9].buffout,"'res=1'",1)&&!timeline_active(1093)) { //command in buffer
    timeline_create(1093,cmd[rm[1].d[9].type].commtimeout,1,timeline_absolute,timeline_once) // response limit timer144
    //    call 'debug' ("'Processing Camera Control Command RM:2 DID:26 CAM:1 Buffer:',rm[1].d[26].buffout")
    rm[1].d[9].ipdone = 0 
    rm[1].d[9].lastacmd = remove_string(rm[1].d[9].buffout,"'res=1'",1) 
    call 'debug' ("'Camera IP Port Open: RM:1 DID:9 IPADDR:',rm[1].d[9].ipcomm[1].ipaddr,' IPPORT:',itoa(rm[1].d[9].ipcomm[1].ipport)")
    ip_client_open( rm[1].d[9].devid.port , rm[1].d[9].ipcomm[1].ipaddr , 80,1)//80=port,1=TCP
    call 'debug' ("'Opening Campera IP Connection...'")
    wait_until(rm[1].d[9].ipconnect==1) { //set to 1 in online data event, 0 in offline event
        call 'debug' ("'Camera connection opened, Sending Control String: RM:1 DID:9 Request: GET /cgi-bin/aw_ptz?cmd=#',rm[1].d[9].lastacmd,
        ' HTTP/1.0',$0D,$0A,
        'Host: ',rm[1].d[8].ipcomm[1].ipaddr,$0D,$0A,
        'Connection: close',$0D,$0A,
        $0D,$0A")
    
        send_string dvcam_f,"'GET /cgi-bin/aw_ptz?cmd=#',rm[1].d[9].lastacmd,
        ' HTTP/1.0',$0D,$0A,
        'Host: ',rm[1].d[9].ipcomm[1].ipaddr,$0D,$0A,
        'Connection: close',$0D,$0A,
        $0D,$0A"
    
    //  call 'debug' ("'Cam Command Submit: ','GET /cgi-bin/aw_ptz?cmd=#',rm[1].d[26].lastacmd,$0D,$0A")
    }
    }
    
    
    //   THIS WORKS IN BROWSER
    //   http://10.200.133.114/cgi-bin/aw_ptz?cmd=%23P50&res=1
    
    
    
    while( length_string( rm[1].d[9].buffin ) > 0 && rm[1].d[9].ipconnect == 0 ) { 
    //    call 'debug' ("'Cam Response Processing, Original Command: ', rm[1].d[26].lastacmd ") 
    call 'camresponseparser' ( 1, 9, "rm[1].d[9].buffin" ) 
    rm[1].d[9].buffin = "''"
    rm[1].d[9].ipdone = 1 
    timeline_kill(1093) // 
    }
    

    Here's the Data_Event handler, you can see it sets and clears a connection value, and takes any returned string and drops it into another buffer for further processing / parsing (but in this case I don't need to parse any response, I just need to know I got one).

    data_event[d_all] { //All COMM Devices
    online: { //All devices come online
    stack_var integer this_rm
    stack_var integer this_did

    this_rm = rlookup[data.device.port].rm 
    this_did = rlookup[data.device.port].d 
    
    call 'debug' ("'DEV Number: ',itoa(data.device.number)")
    call 'debug' ("'DEV Port: ',itoa(data.device.port)")
    rm[this_rm].d[this_did].errorcount = 0 
    call 'debug' ("'Error Count: ',itoa(rm[this_rm].d[this_did].errorcount)")
    
    call 'debug' ("'DEVICE ONLINE: RM:',itoa(this_rm),' DID:',itoa(this_did)")
    
    if(this_did==8||this_did==9) { //Cam1 Serial Init
        call 'debug' ("'Camera Connection Open: RM:',itoa(this_rm),' DID:',itoa(this_did)")
        rm[this_rm].d[this_did].ipconnect = 1
    }
    

    }
    string: {
    stack_var integer this_rm
    stack_var integer this_did

    this_rm = rlookup[data.device.port].rm 
    this_did = rlookup[data.device.port].d 
    
    call 'debug' ("'Raw DEV Port: ',itoa(data.device.port)")
    call 'debug' ("'Managed DID Number: ',itoa(this_did)")
    
    call 'debug' ("'Data From Device: RM:',itoa(this_rm),' DID:',itoa(this_did),' Port:',itoa(data.device.port),' - ',data.text")
    
    call 'debug' ("'Adding Data to Buffer: RM:',itoa(this_rm),' DID:',itoa(this_did),' Data:',data.text")
    
    call 'debug' ("'Buffer Before:',rm[this_rm].d[this_did].buffin")
    rm[this_rm].d[this_did].buffin = "rm[this_rm].d[this_did].buffin,data.text"
    call 'debug' ("'Buffer After:',rm[this_rm].d[this_did].buffin")
    
    }
    

    }

    You can see I've got a ton of "Debug" statements in there, those just go to a virtual device so I can read them out in the Notifications window in Netlinx Studio. I use structures to store device state data, buffer contents, etc.

    You probably don't need all the complexity of the buffer processing part; you should be able to cut that out and simplify the process and your code just a bit.

    Hope that helps.

  • KarthikKarthik Posts: 24

    Thanks . Now i got what i wanted .

  • KarthikKarthik Posts: 24
    edited February 13

    Hi,

    I am getting the string in diagnostic .

    If i used this command

    SEND_STRING Dv_Televic_PC," ' GET /Cocon//Meeting_Agenda/GetAgendaItemById/?Id=3 HTTP/1.1',$0D,$0A,'Host : localhost',$0D,$0A,$0D,$0A"

    I will give output as

    "{\"GetAgendaItemById\":{\"AgendaItem\":{\"Id\":\"3\",\"Title\":\"Introduction\",\"Description\":\"\",\"Type\":\"AgendaItem\",\"State\":\"notstarted\",}"

    and i used "Find_String(Data.text,'title',7)"

    .but its showing as

    \"Introduction\",\"Description\":\"\",\"Type\":\"AgendaItem\",\"State\":\"notstarted\",}"

    I want only 'INTRODUCTION" want to display .

    Introduction Title is dynamic . I can use 'n' number of characters in title .

    Where i did Mistake in comment?

  • fogled@mizzou[email protected] h4x354x0r Posts: 547
    edited February 13

    You just need more parsing code. Just take another run at the string you've got so far, find the Description position, and use that to isolate and extract the text prior to that. Left, right, and position text functions are your friends.

Sign In or Register to comment.