Daily Logging File


sclward

Recommended Posts

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

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

  • 5 months later...

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

  • 2 months later...

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

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

  • 2 years later...

Archived

This topic is now archived and is closed to further replies.