Logging File Creation


DAQUSERatNDCPower

Recommended Posts

Hello,

I am having trouble understanding when a logging file is actually created. My logging parameters are set as follows:

ASCII Delimeted

Fixed Interval

Snapshot mode

Both the File Name and Interval Time are dynamically set within a sequence and the logging is started within the sequence using the ".Begin()" function.

I am logging 8 Test channels. The problem I am having is that data is being lost at the beginning of the test. For this reason I would like to know when the new file is actually created for the logged data. It seems as though the new file gets created at different times every time I run the sequence.

I would like to create a while loop that periodically checks to see if the file has been created using the "File.GetFileExists(filename)" command. If I go with this method, I must add junk data to the channels until the while loop condition clears. This isn't optimal but could work.

I also thought it would be nice to just manually create the file with "File.Open(filename,read,write,append,text)" then use the Handle variable to manipulate the file and force it to write the initial data using the ".Flush()" command.

I would appreciate some direction, thanks...

Link to comment
Share on other sites

Logging sets are really more designed to start and run all the time. Trying to get them to capture just some subset of data in time is not reliable as you've seen. If you are doing snapshot, you are better off using the file.open() method as you suggested. Not only will it work the way you want in terms of timing, but you'll also get a lot more control over the format of the logging set. Also, you'll actually be able to close the file, where a logging set will keep a file open in readonly mode until either the filename changes or DAQFactory quits, even if you stop the logging set.

Link to comment
Share on other sites

Would an export set work for you?

You can call exports from sequence with -


BeginExport(ExportName)
[/CODE]

Then you could wait for some variables in a loop -

[CODE]
while(1)
WaitFor(Variable1 != Variable2, 5)
BeginExport(ExportName)
//do a bunch more stuff
endwhile
[/CODE]

HTH

Link to comment
Share on other sites

Export set will only log existing values. They are used in one of two ways typically:

1) to log data that has accumulated over time. This would be called at the end of a routine, not the beginning. The risk here is that the logging doesn't occur until the end, so if something happens midway, you lose all the data

2) to log a single line of data. This is similar to the file.open() technique, and requires you to call the export set at some interval to log multiple lines of data. The advantage of file.open / write, etc. is that you can format the data however you want. The disadvantage is that its more script than an export set.

Link to comment
Share on other sites

  • 10 months later...

I tried setting up a little export test and didn't get anything written to disk. What's wrong with this test?

 

Have a test sequence run as follows:

 

while(1)
   beginexport(ExportSet1)
   delay(60)
endwhile

 

ExportSet1 is setup as a binary 32 bit floating point. Filename is ExportSet1.dat. All data points aligned. Align threshold 0, Duplicate last value. Time format is DAQFactory Time. Expressions are with Figs: all set to 6.

 

Zero  0 * Systime()

One  1 * Systime()

Two  2 * Systime()

Three 3 * Systime()

 

What is the Figs: column for? Didn't see it mentioned in the documentation.

Link to comment
Share on other sites

Figs is significant figures.

 

Its not clear exactly what your expressions are.  Maybe a screenshot of the export set screen, or the .ctl doc?  My guess is that you are either logging something without data, or something without time.  Certainly 3 * systime() is a scalar without time, so won't log.

 

Note that doing:

 

global x = 3 * systime()

 

and then exporting x will work because time is automatically assigned when you assign a value to a variable, but if you just have the scalar direct in the export set, there is no time.  With no time, there's nothing to align.  Also, I recommend using Snapshot for export sets, especially if you are trying to log just one line of data with each export set call.

Link to comment
Share on other sites

Guess that was the problem, but now I'm confused about exporting. Thought exporting was for expressions, and the result of an expression is a scalar value. So I was expecting export to put the current time in the first column, calculate the result of the expressions and put the results in the other columns. Are you saying the expression needs to be global x = 3 * systime() ? So all the expressions need to assign their results to a variable and the value of the variable gets saved in the export file. But isn't the only time the variable value (expression) calculated when you call BeginExport? If not, then what triggers the expression to calculate?

 

This brings up another question about variables. I was thinking simple variables (not arrays) like x were just always stored as an 8 byte floating point value and strings variables like string y were pointers to a chunk of memory holding the string. Based on what you said above sounds like there are no simple, one-value variables. They are always stored with two 8 byte values - one for time and one for the value. Is this right? What about strings are they stored as two 8 byte values as well - one for time and one as a pointer to the string memory?

 

What about local class variables? How are they stored? What about private sequence variables - all stored with a time component?

Link to comment
Share on other sites

Export sets were actually designed to allow you to export data that you had already acquired.  So, logging sets log in-situ, but export sets are for after the fact.  For example, if you took data for some experiment, then did a little data processing, then you wanted to dump the data.  Expressions can easily result in arrays.  Even just "myChannel" without the quotes could be an array if myChannel had any history.  When you want to log just one line of data, you use Snapshot mode.  Then time doesn't play into it quite the same way.

 

And, no the expression should not be global x = 3 * systime().  For one, that's not an expression, that's a statement.  An expression would just be the part after the =.  You can use inserttime() to put a timestamp in there:  

 

insertTime(3 * systime(), systime, 0)

 

But I'm not sure that's required in Snapshot mode.

 

As to the data storage, the details of how the data is stored shouldn't matter that much to you since you can't directly manipulate that memory.  Simple variables, even scalars, are usually stored with time, so yes, 2 double precision floating point values.  Strings are stored as internal string objects in an array, with an additional 8 bytes for the time stamp.  Note that there is only a time stamp in the first dimension of the array, so a 2x2 array (i.e. 4 total elements) would only take up 48 bytes, not 64.  Also, just as a side note, DAQFactory is a 32 bit app, so a pointer to string memory, if that was what were doing, would only be 4 bytes.

 

local class as well as privates are all stored the same way.

Link to comment
Share on other sites

Archived

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