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
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.
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.
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
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.
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
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.
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 .
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.
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.
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
}
string: {
stack_var integer this_rm
stack_var integer this_did
}
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.
Thanks . Now i got what i wanted .
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)"
\"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?
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.