Basic Starting And Stopping Of Logging


cadcoke5

Recommended Posts

Sorry, but the manual is confusing about this.  There seem to be two areas where this is discussed.

 

One area says;

All are accessed using either Logging.LoggingSetName. or Export.ExportSetName.

.Start(): starts the set.  If the set is already started, nothing happens..

 

.Stop(): stops the set.  If the set is already stopped, nothing happens

But, I am not clear if the proper format is Logging.LoggingSetName.Start() or Start().Logging.LoggingSetName

 

Another part of the manual describes using this other command;

 

beginlogging(MyLoggingSet),

 

But, it returns the following error;

 

"C1013 Problem logging to data file".

 

 Note that I already created the directory, and set the file name using;

 

Logging.LoggingSetName.FileName = "c:\Data_Log\Pressure.csv"

 

 

Are there any examples I can see about logging data?

 

-Joe

Link to comment
Share on other sites

beginLogging(myLoggingSet) 

 

and 

 

logging.myLoggingSet.start()

 

do the exact same thing.  The first version is from very old versions of DAQFactory and kept for backwards compatibility.  The second version is more consistent with the rest of DAQFactory scripting.

 

As for the error, my guess is that you have the file open in Excel or some other program and its being locked by the operating system against writes.

Link to comment
Share on other sites

I tried the following commands directly from the command prompt.

 

Logging.LoggingSetName.FileName = "c:\Data_Log\Pressure.csv"

 

 

logging.Pressure_Test_Log.Start()

 

[below is what started appearing on the screen]

04/22/14 20:20:55.859

C1013 Problem logging to data file: 

04/22/14 20:20:56.859

C1013 Problem logging to data file: 

04/22/14 20:20:57.859

...

The following command successfully stopped it.

logging.Pressure_Test_Log.Stop()

 

Note that the file  "c:\Data_Log\Pressure.csv" was not created, and that directory is empty.  Perhaps there is some command I must use to get the file to be created?

Note that on the logging set, there is no file name.  I had tried use the browse button, which allows me to browse around, but apparently it is expecting you to choose a file. Just browsing to a directory is not sufficient.

 

So, I created a text file in that directory using Explorer, by right-clicking in that folder, and selecting "create new text file".  Then, I named that file "temp.csv".  Then I edited the Logging Set and browsed to that file. Finally, I ran the same sequence of commands as I showed above. The results opened in Excel just fine, though I did need to format the date column using a custom number format to allow for decimal seconds, m/d/yyyy h:mm:ss.00, which showed it as something like, 4/22/2014  8:28:47.25 PM

 

And while the above does work, I would rather start a new log file each time I start logging.  I understand that I can specify a file name formatted something like this, 

Logging.LoggingSetName.FileName = "c:\Data_Log\Pressure%y-%m-%d at %h-%m.csv"

But, that won't work, since the file must already exist.

 

I wish I could find where all this is explained, rather than figuring out things here on the forum, and by trial and error.

 

-Joe

Link to comment
Share on other sites

The problem is its "strFileName", not "FileName".  The intellisense dropdown should be the give-away.  When you type "logging.Pressure_Test_Log." you should see a list of all the member functions and variables.  FileName is not listed there.  strFileName is.

 

As for the docs, that variable and all the others for the logging set are described in 9.8 of the user's guide.  In general, most all the member variables and functions for built objects are at the end, or towards the end of the chapter on the subject.  The ones for screen components are described at the end of the page on the particular component.  For example, the ones for PID are described in 10.5, the last section of the chapter on PID, and the ones for alarming in 11.5, the last section for alarming (not counting examples).  Global system functions and events are described in the last two sections of the Sequences chapter, 5.27 and 5.28.

Link to comment
Share on other sites

The manual may have an error.  It says,

======

.strFileName: changing the file name while the logging or export set is running will close the current file and open the new file.

 

Application: if you are logging batch data and wish to start logging to a different file, simply set this variable to your new file name.  You can use an edit box component or any of the components with actions, specifying Logging.LoggingSetName.FileName as the action/set channel or use a sequence with assignment: Logging.LoggingSetName.FileName = "c:\newfile"

======

Note that in the above example it says, Logging.LoggingSetName.FileName = "c:\newfile" wihout the str prefixed to the word Filename.

 

I also just realized a misunderstanding I had. I thought the phrase "LoggingSetName" was to be typed exactly as it was. I see now that I should have substituted the actual name of the Logging Set.  Perhaps it would be better to change the font to Italics for when the user is expected to substitute their own names.

 

The logging procedure is working now, as long as my file name is without the time and date functions included.  The following sequence placed in the command window causes DAQFactory to crash

 

Logging.Pressure_Test_Log.strFileName = "c:\Data_Log\Pressure%y-%m-%d at %h-%m.csv"

logging.Pressure_Test_Log.Start()

 

DAQFactory then immediately crashes.

 

Thank you for the help.

-Joe

Link to comment
Share on other sites

Do this instead:

 

Logging.pressure_test_log.strFileName = "c:\Data_Log\Pressure" + formatDateTime("%y-%m-%d at %H-%M", systime()) + ".csv"

 

It appears that DAQFactory doesn't like it when you put %h instead of %H.  We'll get that fixed.

Link to comment
Share on other sites

Archived

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