Dynamic Neural Field Composer 0.0.0
A C++20 library and interactive application for building and simulating Dynamic Neural Field (DNF) architectures.
Loading...
Searching...
No Matches
simulation_recorder.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <fstream>
6
10
11namespace dnf_composer
12{
13 class Simulation;
14
18
32 {
33 public:
42 void startRecording(const std::string& simName,
43 const std::string& elementId,
44 const std::string& componentName,
45 int sampleInterval,
47
52 void stopRecording(const std::string& elementId, const std::string& componentName);
53
55 void stopAll();
56
60 void update(const Simulation& sim);
61
68 void takeSnapshot(const std::string& simName,
69 const std::string& elementId,
70 const std::string& componentName,
71 const Simulation& sim);
72
74 bool isRecording(const std::string& elementId, const std::string& componentName) const;
75
77 bool hasActiveRecordings() const;
78
79 private:
80 struct Session
81 {
82 std::string elementId;
83 std::string componentName;
84 int sampleInterval;
86 std::ofstream file;
87 double nextSampleAt;
88 };
89
90 std::vector<Session> sessions;
91
94 static void writeHeader(std::ofstream& file, size_t componentSize,
95 int sizeX = 1, int sizeY = 1);
96 static void writeRow(std::ofstream& file, int ticks, double ms,
97 const std::vector<double>& component);
98 };
99}
Manages ongoing time-series recordings and snapshot exports of element component data for a simulatio...
Definition simulation_recorder.h:32
void stopRecording(const std::string &elementId, const std::string &componentName)
Stop the recording for a specific element/component pair. The CSV file is closed and the session is r...
Definition simulation_recorder.cpp:95
void stopAll()
Stop all active recordings and close all open files.
Definition simulation_recorder.cpp:115
bool hasActiveRecordings() const
Return true if at least one recording session is active.
Definition simulation_recorder.cpp:236
bool isRecording(const std::string &elementId, const std::string &componentName) const
Return true if a recording is currently active for the given pair.
Definition simulation_recorder.cpp:227
void startRecording(const std::string &simName, const std::string &elementId, const std::string &componentName, int sampleInterval, RecordingIntervalUnit unit)
Start a new continuous recording for the given element/component pair. Creates data/<simName>/recordi...
Definition simulation_recorder.cpp:55
void takeSnapshot(const std::string &simName, const std::string &elementId, const std::string &componentName, const Simulation &sim)
Write a single-row snapshot CSV for the given element/component. Output path: data/<simName>/exports/...
Definition simulation_recorder.cpp:181
void update(const Simulation &sim)
Called each simulation step to append rows to active recordings. Ticks are derived from sim....
Definition simulation_recorder.cpp:123
Manages the element registry and drives the simulation loop.
Definition simulation.h:39
RecordingIntervalUnit
Unit for the recording sample interval.
Definition simulation_recorder.h:17
Definition application.h:20