AuxDataStorage
AuxDataStorage collects auxiliary time-series data during an experiment.
It accumulates scalar readings from pressure sensors, flow controllers,
temperature monitors, and any other hardware that contributes periodic
measurements, and serializes them to BC::CSV::auxFile at each time step.
Experiment owns an AuxDataStorage instance; unlike the
DataStorageBase hierarchy, AuxDataStorage is not a
DataStorageBase subclass and its lifecycle is managed directly by the
acquisition system.
Keys are declared before acquisition begins by calling registerKey for
each hardware object and value combination. The compound key format is
"ObjKey.ValueKey", produced by the makeKey static helper using
BC::Aux::keyTemplate. During acquisition, hardware objects call
addDataPoints to merge fresh readings into the current time point;
startNewPoint is called periodically to seal the current point, append it
to BC::CSV::auxFile, and advance the timestamp. The savedData
accessor returns all sealed points in chronological order.
Two construction paths are provided. The default constructor creates a
detached instance with d_number set to -1; no file I/O is performed
until a valid experiment number is assigned. The (BlackchirpCSV*, number,
path) constructor loads the full time series from an existing
BC::CSV::auxFile, making it available immediately through savedData.
AuxDataMap is registered with the Qt meta-object system via
Q_DECLARE_METATYPE so that instances can be transported through
QVariant and signal-slot connections.
For the file layout and delimiter conventions used when reading and writing
the auxiliary data file, see BlackchirpCSV.
API Reference
-
class AuxDataStorage
Collects auxiliary time-series data during an experiment.
Owned directly by
Experiment; not aDataStorageBasesubclass. Hardware objects register their keys viaregisterKey, push readings viaaddDataPoints, and the acquisition system seals each point viastartNewPoint, which appends a row toBC::CSV::auxFile.Public Types
-
using AuxDataMap = std::map<QString, QVariant, std::less<>>
Map from compound key to scalar value, keyed transparently on
QStringView.
Public Functions
-
inline AuxDataStorage()
Constructs a default instance with no experiment association.
Used when constructing an
Experimentthat has not yet been assigned a number. No file I/O is performed untilstartNewPointis called on a properly initialized instance.
-
AuxDataStorage(BlackchirpCSV *csv, int number, const QString &path = {})
Constructs an instance by loading saved auxiliary data from disk.
Reads
BC::CSV::auxFilefrom the experiment directory and populatesd_savedDatawith the full time series. The column headers are used to reconstruct the key ordering.- Parameters:
csv – Pointer to the experiment’s
BlackchirpCSVinstance, used to tokenize lines with the correct delimiter.number – Experiment number.
path – Optional base path override. When empty,
SettingsStorageprovides the application data path.
-
void registerKey(const QString &objKey, const QString &key)
Registers a key as a valid receiver of auxiliary data.
Only keys registered before acquisition begins appear as columns in
BC::CSV::auxFile. Calls toaddDataPointsthat supply unregistered keys are silently ignored.- Parameters:
objKey – Object key identifying the hardware source.
key – Value key identifying the individual reading.
-
void addDataPoints(AuxDataMap &m)
Merges a map of new readings into the current time point.
Called by hardware objects whenever fresh readings are available. Multiple calls between successive
startNewPointcalls accumulate additively into the current point.- Parameters:
m – Map of compound keys to new values. Keys absent from the registered set are ignored.
-
void startNewPoint()
Seals the current time point and appends it to the output file.
On the very first call, writes the column-header row to
BC::CSV::auxFile. On subsequent calls, serializes the accumulated readings for the point that was started by the previous call, then advances the current point timestamp toQDateTime::currentDateTime. Ifd_numberis negative or the allowed-key set is empty, no I/O is performed.
-
inline QDateTime currentPointTime() const
Returns the timestamp of the current (unsealed) time point.
- Returns:
QDateTimeof the point in progress, or a nullQDateTimeif no point has been started.
-
std::vector<std::pair<QDateTime, AuxDataMap>> savedData() const
Returns the full list of sealed time points.
When constructed from a saved experiment, this vector is populated from the file; during live acquisition it grows as each point is sealed.
- Returns:
Vector of (timestamp, value map) pairs in chronological order.
Public Members
-
int d_number = {-1}
Experiment number;
-1for a detached (unsaved) instance.
-
QString d_path = {""}
Base data path used to locate the experiment directory.
Public Static Functions
-
static inline QString makeKey(const QString &s1, const QString &s2)
Composes a compound key from an object key and a value key.
- Parameters:
s1 – Object key (typically the hardware object’s settings key).
s2 – Value key (the individual reading name within that object).
- Returns:
Compound key in the form
"s1.s2", as defined byBC::Aux::keyTemplate.
Private Members
-
std::set<QString> d_allowedKeys
-
TimePointData d_currentPoint
-
QDateTime d_startTime
-
std::vector<std::pair<QDateTime, AuxDataMap>> d_savedData
-
struct TimePointData
A single sealed time point consisting of a timestamp and a map of values.
Public Members
-
QDateTime dateTime
Timestamp at which this point was sealed.
-
AuxDataMap map
Values contributed to this point, keyed by compound key.
-
QDateTime dateTime
-
using AuxDataMap = std::map<QString, QVariant, std::less<>>