How would I rename or move a file on the controller?
Here is the context. I would continually be writing to a file called “cloud_data.txt” with different charts. Every once in a while I would want to send the data in the file to a web server. I want to rename the file to something like “cloud_data_processing.txt”. The charts would notice that there was no longer a “cloud_data.txt” file (because it had been renamed), create it and continue writing any new data to it.
I would have a separate subroutine that would process through “cloud_data_processing.txt” sending it to my web server and then delete it.
This would insure that I grab the current data set within “cloud_data.txt” without missing any other data that might be written to it while I’m processing it.
There’s not actually a “rename” command, but you can copy/delete using ftp or file comm handles. Check out the SendCommunicationHandleCommand options for ftp & file.
The thing that I worry about with that method is that if there is a lag time between when I copy the file and when I delete it, I could loose data if it is written to the original file within that lag time.
Do you have any thoughts on that?
I strongly recommend having a look at this document, form 1642 (with lovely illustrations) and the corresponding example for your [URL=“http://www.opto22.com/site/downloads/dl_drilldown.aspx?aid=2980”]Learning Center. There’s also this [URL=“http://www.opto22.com/site/downloads/dl_drilldown.aspx?aid=3614”]FTP and Data Logging example which I suspect you can borrow heavily from and save yourself some coding.
Essentially, the data to log is cached in a persistent table (rather than a temporary file). Note that persistent tables will keep their data in the event of a power cycle (your temp file won’t, unless you write it to flash, which you don’t want to do TOO regularly).
Hope that helps!
-OptoMary
Your first link did not link to a document (with lovely illustrations). It linked to the same thing that your 3rd link (FTP and Data Logging example) did.
Why do I not want to write to my flash TOO regularly and by “flash” do you mean the MicroSD card?
Oops, try that link again, I think I fixed it.
There is that MicroSD card option, but there’s also some flash memory in the PAC itself, see this form (1646), also with lovely illustrations. To write to the MicroSD card, you’d just use the file and ftp comm handle commands (with the appropriate subdirectory and 8.3 file name limitations).
To save a file on the PAC itself to the on-board Flash “User File Storage” area (in yellow in the lovely illustration mentioned above), you can use the PAC Control “Control Engine” command called “Save Files to Permanent Storage”. Neat-o.