Start/stop Stream


frozen

Recommended Posts

I use DAQ Factory Express in conjunction with Labjack U3-HV to stream three channels at 2500Hz. It all goes very well, thanks to a lot of help from Guru. I have a button to start the stream, and a second button to stop it. Once enough data is logged to the history (no more than 6 sec), I stop the stream via the stop buttlon, and then export the accumulated data to a file.

 

Is it possible to have the same button to start and stop the stream? I.e. one click to start and the second click to stop? Or to keep the mouse button down to start the stream, and let go to stop? Since I need to opreate the machine with at the same time, one button would be much better, so that there is no need to pay attention to the mouse and the computer screen. It seems there is an option to have a start/stop logging button, but I do not log, only export the data wnen done.

 

Thanks in advance

A

Link to comment
Share on other sites

Sure.  Just use a flag.  First declare it in an auto start sequence:

 

global isStreaming = 0

 

Then in the action for the button put:

 

if (isStreaming)

   stopStreaming()

else

  startStreaming()

endif

 

Assuming of course that you have sequences called stopStreaming and startStreaming.

 

As for pressing the button down to start, and releasing to stop, you can do that too.  Just create two actions for the button and mark one of them "On Mouse Down".  Its a check box just above the quick sequence action script.

Link to comment
Share on other sites

I tried the second option and it works perfectly! Thanks again.

 

Another one: the csv files are exported with a date/time in consecutive order as created. Is there a way to have the files numbered (a number appended to the name of file) instead? I could not find an example in the guide. Sorry for my ignorance.

 

A

Link to comment
Share on other sites

I have a quick sentence in the "export" button:

 

export.forceexport.strFileName = "C:\Users\adam\Desktop\flight_tests\bow_" + formatdatetime("%y%m%d_%H%M%S",systime()) + ".csv"
beginexport(forceexport)

 

Thanks

A

Link to comment
Share on other sites

OK, you just need a counter then.  Consider using the registry to track the counter.

 

export.forceexport.strFileName = "C:\Users\adam\Desktop\flight_tests\bow_" + registry.exportCounter + ".csv"

registry.exportCounter++

beginexport(forceexport)

 

Registry.exportcounter will default to 0 if it doesn't exist yet, so the first file will have #0, but after that it will count up to a little over 4 billion and not lose count if you restart DAQFactory.  If you want to set the value to some starting value, just do:

 

registry.exportCounter = 1000

 

at the command / alert window to, in this example, set the count to 1000.

Link to comment
Share on other sites

Archived

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