feat(streamhub): wire BinaryRecorder into UDPSourceSession

Each session owns a BinaryRecorder. The receive thread configures the
recorder layout at CONFIG time and captures each data packet; the push
thread performs all file I/O via RecorderFlushTick. WS subset overrides
are adopted through an epoch-deferred handoff mirroring the trigger path.
Arm/disarm/flush/info are exposed for StreamHub-level control.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Martino Ferrari
2026-06-25 01:10:27 +02:00
parent 0ae35d11ff
commit 93fc11c88f
3 changed files with 152 additions and 2 deletions
@@ -19,6 +19,7 @@
#include "SignalRingBuffer.h"
#include "UDPSourceStats.h"
#include "TriggerEngine.h"
#include "BinaryRecorder.h"
#include <string.h>
namespace StreamHub {
@@ -161,8 +162,40 @@ public:
*/
void SetTriggerEngine(TriggerEngine *engine);
/* ---- Binary recorder control -------------------------------------- */
/** @brief Set the recorder configuration; initialises the recorder when
* enabled. Must be called before Start(). */
void SetRecorderConfig(const RecorderConfig &cfg);
/** @brief Override the recorded signal subset for this run (any thread).
* Adopted on the receive thread via an epoch check. */
void SetRecorderSignals(const char *spec);
/** @brief Arm the recorder (any thread). */
void RequestRecArm();
/** @brief Disarm the recorder (any thread). */
void RequestRecDisarm();
/** @brief Drive recorder disk I/O (push thread). */
void RecorderFlushTick(uint32 nowSec);
/** @brief Recorder status snapshot (push thread). */
void GetRecorderInfo(bool &recording, char *file, uint32 fileSz,
uint64 &bytesWritten, uint64 &rowsWritten,
uint64 &droppedRows, uint64 &freeMB) const;
/** @return true if the recorder is enabled for this session. */
bool IsRecorderEnabled() const { return recCfg_.enabled; }
private:
/** @brief Build the per-signal include mask from a subset spec
* ("all" or comma-separated "src:sig" keys). Receive thread only. */
void ComputeIncludeMask(const UDPSSignalDescriptor *descs, uint32 n,
const char *spec, bool *maskOut);
/* DATA payload parsing */
void ParseConfigPayload(const uint8 *payload, uint32 size);
void ParseDataPayload(const uint8 *payload, uint32 size);
@@ -293,6 +326,15 @@ private:
uint32 trigEpochSeen_; ///< Last resolved trigger config epoch
MARTe::int32 trigSigIdx_; ///< Watched signal index (-1 = none)
MARTe::int32 trigElemIdx_; ///< Watched element index (-1 = all)
/* Binary recorder (capture on receive thread, I/O on push thread). */
BinaryRecorder recorder_;
RecorderConfig recCfg_; ///< Recorder config (enabled flag gates use)
mutable FastPollingMutexSem recSpecMutex_;
char recPendingSpec_[1024]; ///< Subset spec awaiting adoption
char recActiveSpec_[1024]; ///< Currently applied subset spec
volatile uint32 recPendingEpoch_; ///< Bumped when the spec changes
uint32 recSeenEpoch_; ///< Last spec epoch adopted (receive thread)
};
} /* namespace StreamHub */