sclward Posted August 25, 2009 Share Posted August 25, 2009 I'm new to DAQFactory and am wanting to log machine data within a specified period of time. I wish to begin logging at 7AM and end at 7PM each day. I then export this file into an Excel spreadsheet for reporting purposes. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
AzeoTech Posted August 25, 2009 Share Posted August 25, 2009 Create a sequence that runs forever. It'll look something like this: private nexttime = floor(systime() / 86400) * 86400 // midnight last night // step forward to the 7am/pm that is next in future: while (nexttime < systime()) nexttime += 43200 endwhile while(1) logging.mylogging.strFileName = "c:\data\myfile_" + formatDateTime("%y%m%d_%H",systime()) + ".csv" waituntil(nexttime) nexttime += 43200 endwhile The complicated part is actually just figuring out when the next 7am/pm point is, though really its not the hard. Then we just loop, changing the filename every 12 hours. We could also do this with a single line in the event for one of your channels: logging.mylogging.strFileName = "c:\data\myfile_" + formatDateTime("%y%m%d_%p",systime() - 7*3600) + ".csv" Just put that line of script in the event of the channel that gets queried the most often (just one channel if more than one are being polled at the same rate). This version uses the same technique as changing the file name every day. However, in this case, we add the %p which adds AM or PM to the file so the file name changes twice a day. Since we want 7am/7pm not 12am/12pm, we subtract 7 hours from the system time when figuring out the filename, so at 7am, the filename is "...._AM", and 7pm its "...._PM". Link to comment Share on other sites More sharing options...
sclward Posted August 27, 2009 Author Share Posted August 27, 2009 Well, help me out here. I don't recognize an events section within any of my channels and I don't think that the 'action' parameter within the variable value component would be the right place. Thanks. Link to comment Share on other sites More sharing options...
AzeoTech Posted August 27, 2009 Share Posted August 27, 2009 Click on the + next to CHANNELS: in the workspace to expand it, then click on the desired channel. This shows the channel view. Then click on the Event tab. Link to comment Share on other sites More sharing options...
ngoodman Posted February 17, 2010 Share Posted February 17, 2010 Can this be done with alarm logging also? Link to comment Share on other sites More sharing options...
AzeoTech Posted February 17, 2010 Share Posted February 17, 2010 Not with the built in alarm logging. If you want more flexibility with alarm logging you are going to have to do the logging in script. I'd create a function (sequence) called AlarmLog(message), and then in each of your alarms, in their events, call this function with the desired message. Then in the AlarmLog sequence you could write to disk however you wanted. Link to comment Share on other sites More sharing options...
Jefflewcock Posted April 19, 2010 Share Posted April 19, 2010 Hi I have tried adding the line Export.MyExportSet.strFileName = "MyData_" + FormatDateTime("%y_%m_%d.csv",SysTime()) To a channel event but when I begin logging I get an error 04/19/10 13:09:33.952 C1013 Problem logging to data file: Any Ideas ? Thanks Jeff Link to comment Share on other sites More sharing options...
AzeoTech Posted April 19, 2010 Share Posted April 19, 2010 There wasn't anything else? You might try fully specifying your path: "c:\mydata\MyData_" + ... it might be a security issue on windows. For example, it doesn't really like you writing files into Program Files directory without admin privileges. Link to comment Share on other sites More sharing options...
jcallen1 Posted November 19, 2012 Share Posted November 19, 2012 In #2 regarding "Logging f4rom 7AM to 7PM, what is the charater before "3600" in the first line of the second example. My eyes are no so good anymore but I assume it is an "*", is that right? Thanks Link to comment Share on other sites More sharing options...
AzeoTech Posted November 19, 2012 Share Posted November 19, 2012 It is an asterix: * which means times or multiplication. 3600 is the number of seconds in an hour, and so 7 * 3600 is the number of seconds since midnight for 7 AM. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.