Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Best Practices - Sensor & Data Logging

Greetings,

What is the best least painful approach for logging data acquired from sensors when using the AF?

Currently, I have a parent, "Sensor Actor" which contains a COM Port and a base file path in it's private data. A more specific sensor "Range Sensor Actor" inherits from the parent Actor and has methods/messages for configuring the sensor and taking a single measurement. I need to be able to measure and log the sensor at 1Hz, continuously when instructed to do so by my main application.

Would it be appropriate to use a parallel loop in the more specific sensor's Actor Core which handles data logging and use a standard Queue in the sensor's private data? I originally attempted to create a Log Data method and corresponding Message that was called when the main application's front panel indicator was updated but am concerned that it might miss some data values.

Another solution I've been considering is launching a nested actor, something like "Datalogger Actor" which opens a log file and waits for messages containing data to arrive from my "Range Sensor Actor". I'll be logging data from multiple sensors with varying interfaces and think this may be better from a code re-use standpoint. Thanks in advance, I appreciate any insight from the community.


Regards,
Winston

0 Kudos
Message 1 of 5
(4,923 Views)

I would recommend a data logger actor. I have one and the message interface is something like "Log Double" "Log String" "Log Time" "Log Boolean" "Log Double Array" etc.

I launch my data logger at the start of my application, but I don't give it to every sensor actor. I log the data as an aggregate at a higher (subsystem or system) level. This allows me an entry for all sensors (I log about 200 channels) at 5Hz. I have a CSV version and a TDMS version of my logger. I use the TDMS version for my sensor data.

Since AF is asynchronous I would recommend capturing a timestamp when you read the sensor and logging that with the sensor data. Then you can post process if needed to determine some level of timing. So you would have a data and time pairing in your log.

***********************************************************

A side note about TDMS and writing individual values: You will want to use the "NI Set Minimum Buffer Size" for each channel so that the index file isn't huge. TDMS is more efficient when it writes an array than a single value because each write it performs it adds to the index file. Setting the buffer causes an interval array to be built and then the data written when the buffer size is reached. The index file is only hit every "buffer size" element rather than every element.

************************************************************

Casey

Casey Lamers


Phoenix, LLC


casey.lamers@phoenixwi.com


CLA, LabVIEW Champion


Check Out the Software Engineering Processes, Architecture, and Design track at NIWeek. 2018 I guarantee you will learn things you can use daily! I will be presenting!

Message 2 of 5
(3,893 Views)

Thanks for the reply Casey, that's the road I'll now head down. Wish me luck!

Cheers,

Winston

0 Kudos
Message 3 of 5
(3,893 Views)

I also did a data logger actor. It does one thing and it does it well.

0 Kudos
Message 4 of 5
(3,893 Views)

What Casey said.

CLAD
0 Kudos
Message 5 of 5
(3,893 Views)