Logging with variables in the filename


jhorne

Recommended Posts

Hi,

This seems like a rather straightforward problem but I cant seem to figure it out. I am a beginner with DAQFactory, and i am using a Labjack U6 device to record data.

I am able to log channels correctly and I followed a couple examples here in the forum for creating a Button that automatically starts logging while renaming the file based on the time (see code below)

if (logging.mylog.running)
endlogging(mylog)
else
logging.mylog.strFileName = "C:\Desktop\DAQ\log_" + formatdatetime("%y%m%d_%H%M%S",systime()) + ".csv"
beginlogging(mylog)
endif

as well as a Variable Value component that lets you change the file save location 

private string path = File.FileSaveDialog(logging.mylog.strFileName)
if (!IsEmpty(path))
logging.mylog.strFileName = path
endif

 

What I would like to do now is instead of saving as "log_DATEANDTIME" I have a few combo boxes where the user selects options based on the test configuration. All options are numeric, for example the number of nozzles, the size, and flowrate. I would like to save them as variable so that the filename can be more descriptive, for example:

"log_DATEANDTIME_1_3_30" for 1 nozzle, size #3, at 30 litres per minute

 

Any help is appreciated.

Jono

Link to comment
Share on other sites

You just want to use some variables.  For example, in an auto-start sequence declare and initialize some variables to defaults:

global numNozzles = 1

global nozzleSize = 3

global flowRate = 30

Then, simply change your script that starts the logging set to incorporate that:

logging.mylog.strFileName = "C:\Desktop\DAQ\log_" + formatdatetime("%y%m%d_%H%M%S",systime()) + "_" + numNozzles + "_" + nozzleSize + "_" + flowRate + ".csv"

Link to comment
Share on other sites

Archived

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