Saving graphic resource on the master
felixmoldovan
Posts: 197
First, sorry for asking something that might have been answered... The forum search is really annoying.
Question: How do you "save" a graphic resource, or any file for that matter onto the master? Download it, basically, and being able to specify a name for it.
I am using iRidium and the Dynamic Graphic resource does not get parsed from the existing HTTP response, and I would like to attempt saving it onto the master, and then referring to a physical jpg file.
LE: via code.
Thanks.
Question: How do you "save" a graphic resource, or any file for that matter onto the master? Download it, basically, and being able to specify a name for it.
I am using iRidium and the Dynamic Graphic resource does not get parsed from the existing HTTP response, and I would like to attempt saving it onto the master, and then referring to a physical jpg file.
LE: via code.
Thanks.
0
Comments
FTP.
Paul
But anyway, that would still be a dynamic image, just in a new location, as seen by the touch panel. If the Iridium panel can't do dynamic images, having it on the NetLinx won't help much. If it's just the URL being indistinct, it might help having it locally... and might not.
But try TP CONTROL, you can verify if it will work during your free demo period. It does dynamic images quite well. It costs more because it does more because AMX is behind it.
Let's forget I said iridium, so we don't get into another debate. My question still stands and the product choice is only the next stage of the decision.
I would like to have the respective graphic resource locally as [url]FTP://127.0.0.1/image.jpg[/url] instead of a queried http://myserver/getimage.aspx?params=xyz.
And yes, tpcontrol parses this response well, and yes, iridium does have dynamic image, but doesn't like this one.
Thanks guys.
But getting the netlinx to understand and fetch and save that asp resource is going to be a neat trick if even possible at all.
Of course, it assumes your target supports those commands ... but G4 touch panels do.
And, as an aside, touch panels have no problem with CGI, so I image they can handle asp. Those are both server-side scripts, as far as I understand it, it's just a file name and parameters to the panel. The server handles the rest.
Well, since an image file is just really a bunch of 1s and 0s at the end of the day, it should not be too difficult to get the data from the web page and then save it to a file. The limiting factors are going to be the amount of memory you have to work with, and how easy it is to get to the actual image file data. You don't need to processor the image data, you just need to use the following commands:
You will need to strip any encapsulating code from the incoming data and save only the actual image file data, but this should work. You might also need to decode the data if it is encoded as base64 or some sort of MIME encoding... now that I think about it.
Jeff
Do it all the time saving Google Charts for displaying dynamically on touch panels. Overcomes two big problems: 200 character command string limit to the panel (I've got a couple of charts that are over 500 characters long) and the use of the pipe '|' character in the URL string which the panel sees as an escape character.
Would you be willing to share some code examples? I have a client requesting a chart showing HVAC history and google charts is one of the services I was going to look into using.
Thanks. Feel free to pm me if you don't want to share it with everyone.
Thanks Jeff. I don't know if this is leading me to any results. If anybody wants to have a look, attached are the actual HTTP response, and the actual image (changed jpg to txt).
There are similarities, but also a whole bunch of dots... Which, I am probably supposed to connect somehow :-)
The JFIF header is telling you that the file is an image file and you can find the end of the file using the data fields and APP0 marker. Wikipedia has more details, but its pretty easy to parse a image file and save it to the flash drive for later use.
Paul
I can grab the image file and write it (minus the header) to the master, but the writing process is doing something nasty and I can't quite work out what. Opening the two files (original and AMX'ed version) in Notepad shows that they are identical, however opening them both in Sublime shows a very different picture ....
Sending the incoming strings to diagnostics shows that the string coming in is correct - the FILE_WRITE is just doing something odd.
Any ideas?
Thanks
Simon
Are you A) appending incoming data to a buffer before writing it out to file and is the image over 16kB in size?
If so you are likely running into an issue with the lengths of strings which can be appended using string3 = "string1, string2" type concatenation.
Two options exist if this is the case:
Parse the header information and then write out the incoming image data straight to file (better) or do a search on the forums for string_append and use that function to concatenate the incoming data into the buffer. The latter is a bit ugly because it will require a buffer in memory as large as the image file could be (several MB potentially).
Lastly, when you're transferring the file to your PC from the master via FTP for viewing, make sure that you are transferring it as a binary file, otherwise your FTP client could be converting line ending characters embedded in the file (LF) to DOS line endings (CRLF).
Thanks
Simon
I opened the incorrect file in a proper hex editor and bingo.
Thanks for your advice - put me on the right track at least!
Simon