CH2014 Posted June 25, 2014 Share Posted June 25, 2014 Hi, Further to my previous post. I seem to have found a solution by using the execute command e.g. global string Sensor = "SensorA" filename = FormatDateTime("%a-%m-%Y", Systime()) execute("page." +Sensor+ ".Component.OldGraph.SaveToFile('C:\GraphSaves\" +Sensor+ "\" +filename+ "')") Although I had to replace the " with ' in the directory path. Does this seem okay? Link to comment Share on other sites More sharing options...
AzeoTech Posted June 26, 2014 Share Posted June 26, 2014 That was exactly what I was going to suggest. You could have left the " and simply enclosed every thing else in '. DAQFactory allows you to use " and ' interchangeably provided they match up (i.e. you can't do: "some string') Link to comment Share on other sites More sharing options...
CH2014 Posted June 26, 2014 Author Share Posted June 26, 2014 Thank you Link to comment Share on other sites More sharing options...
CH2014 Posted June 28, 2014 Author Share Posted June 28, 2014 Further to the previous posts. Initially I set up a test program to automatically save 2 graphs every hour (note: eventually it will be 50 graphs). This seemed to work fine initially but then I noticed the 2nd graph file was failing to save. I have stripped things back to basics (as per test code below) and it now seems to reliable save both files by putting the delay(10) in between. Does this make sense or do you think the problem is elsewhere? //This is in a startup file global string filename //SaveGraphSequence while(1) filename = FormatDateTime("Min%M-Hour%H-%a-%m-%Y", Systime()) page.sensor1.Component.MyGraph.SaveToFile("C:\HMI_DATA\GraphSaves\sensor1\" +filename) delay(10) page.sensor2.Component.MyGraph.SaveToFile("C:\HMI_DATA\GraphSaves\sensor2\" +filename) delay(10) delay(600) endwhile Link to comment Share on other sites More sharing options...
CH2014 Posted June 28, 2014 Author Share Posted June 28, 2014 Further to my previous post. After stopping and restarting the program the 2nd file is failing to save again? Any ideas? I am using the latest DAQFACTORY on Windows 7. Link to comment Share on other sites More sharing options...
CH2014 Posted June 28, 2014 Author Share Posted June 28, 2014 Further to last post. I seem to have found a solution by putting the savetofile() in separate sequences. Link to comment Share on other sites More sharing options...
SteveMyres Posted July 1, 2014 Share Posted July 1, 2014 Are the two graph components actually named the same, or is that just for purposes of posting here? Have no idea if that's your saving problem but I don't believe that's a good idea (having components on different pages with the same name). Link to comment Share on other sites More sharing options...
CH2014 Posted July 1, 2014 Author Share Posted July 1, 2014 Hi Steve, The problem occurs even when the graph components have different names. See the attached test program. graph.zip Link to comment Share on other sites More sharing options...
CH2014 Posted July 2, 2014 Author Share Posted July 2, 2014 The solution I came up of putting the savetofile() in separate sequences doesn't work either. It works once and then fails when the program is stopped and restarted. The program only seems to successfully save the first graph savetofile() operation. Link to comment Share on other sites More sharing options...
AzeoTech Posted July 2, 2014 Share Posted July 2, 2014 It works fine for me in the example you provided. The only thing is that I viewed both graph pages before running the sequence. This is a requirement to properly initialize the graphs. You have to view any graph you want to manipulate (using capture(), savetoFile(), printpdf(), through the web, etc) at least once at startup before calling these commands. You can do this easily in script by just jumping to the page for 0.1 seconds then moving on to the next one. Link to comment Share on other sites More sharing options...
CH2014 Posted July 2, 2014 Author Share Posted July 2, 2014 Thank you, I should have thought of that. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.