Home AMX User Forum NetLinx Studio

Saving graphic resource on the master

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.

Comments

  • truetrue Posts: 307
    Is it static? If so, upload it to the master. It will be found at http://master/doc:user/path/to/file.jpg - how to upload it, I'm not sure, as the times I have done this is when data has been created or downloaded by a module and saved to the filesystem. I've done this for images displayed on touchpanels.
  • a_riot42a_riot42 Posts: 1,624
    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.

    FTP.
    Paul
  • John NagyJohn Nagy Posts: 1,742
    I think he means to emulate dynamic images by programmatically fetching an image off the web somewhere on cue (live) and saving it in the NetLinx, then having the panel show that image. Just saying "FTP" doesn't help him understand how to accomplish it in programming.

    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.
  • Well, Well....
    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.
  • John NagyJohn Nagy Posts: 1,742
    Not bashing Iridium... just advancing to solutions. If Iridium gets that close to working, submit this corner case as an issue to them, it's said they have been responsive (I don't know personally). Better to get the product right than to invest in workarounds that are unnecessary for a native panel.

    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.
  • DHawthorneDHawthorne Posts: 4,584
    You can create dynamic images on the fly in code (^RAF), as well as change the parameters of existing ones (^RMF), and assign them to buttons (^BBR). That may work when defining it in the panel file does not.

    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.
  • Spire_JeffSpire_Jeff Posts: 1,917
    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.

    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:
    slFile = FILE_OPEN(sFileName, FILE_RW_NEW);
    while(length_array(incomingData) > 0){
      FILE_WRITE(slFile, GET_BUFFER_STRING(incomingData,128),128); //or whatever size of data chunk you want to use.
    }
    

    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
  • 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.

    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.
  • the8thstthe8thst Posts: 470
    icraigie wrote: »
    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.
  • Spire_Jeff wrote: »
    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.

    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 :-)
  • a_riot42a_riot42 Posts: 1,624
    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 know this is an old thread, but I am trying to do the same thing and wondered if you have solved it?

    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
  • AuserAuser Posts: 506
    sling100 wrote: »
    Sending the incoming strings to diagnostics shows that the string coming in is correct - the FILE_WRITE is just doing something odd.

    Are you A) appending incoming data to a buffer before writing it out to file and B) 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).
  • sling100sling100 Posts: 123
    It's definitely not a size issue - the file is only 7 or 8Kb and the buffer is currently a max of 10Kb. It is writing the file completely as I can compare it to the 'real' one. The FTP issue is interesting though, I'll check that as that may well be the issue. I guess if I set up a dynamic image on a panel and point it that should verify that?

    Thanks

    Simon
  • sling100sling100 Posts: 123
    Solved it - I wasn't parsing the header properly before saving it to the master. To then make matters worse opening it in a text editor was changing all of the $00 values to $20 (ie an ACSII 'space').

    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
Sign In or Register to comment.