Class TriggerManager#
Defined in File trigger_manager.hpp
Inheritance Relationships#
Base Type#
public QObject
Class Documentation#
-
class TriggerManager : public QObject#
Central trigger coordinator — aggregates events from all sources into a single signal and delegates to the CSV recorder.
TriggerManager is owned by Application for the full application lifetime. It manages:
Keyboard triggers — application-level event filters that fire on configured key sequences.
Parallel port triggers — InpOut32-based bit-edge detection (Windows), receiving external pulses (e.g. an EEG amplifier’s trigger-out cable), and optionally sending a recording start/stop marker back out on the same port’s Control register (see ParallelPortConfig::sendRecordingMarker).
TriggerRecorder — writes every TriggerEvent to
trigger.csv.
Call reload() whenever TriggerSettings change (e.g. the user edits key bindings in the UI) to rebuild all sources from the current settings.
See also
TriggerEvent, KeyboardTrigger, ParallelPortTrigger
- Thread safety
event_received() and on_trigger_fired() are always invoked on the main thread (keyboard filters use Qt::QueuedConnection).
Public Functions
-
explicit TriggerManager(TriggerSettings &settings, QObject *parent = nullptr)#
- Parameters:
settings – Trigger settings (key bindings, serial/parallel ports). Held by reference — must outlive this object.
parent – Qt parent object.
-
~TriggerManager() override#
-
void reload()#
Rebuilds all trigger sources to match the current TriggerSettings.
Tears down existing sources, then re-creates keyboard triggers and parallel-port pollers from the current state of TriggerSettings. Call this after the user changes key bindings or parallel-port configuration in the settings UI.
-
void start_recording(const QString &csvPath)#
Opens the CSV output file and starts recording trigger events.
Also drives high any parallel port configured with ParallelPortConfig::sendRecordingMarker, so an EEG amplifier (or any other device listening on that port’s Control-register INIT pin) sees a rising edge marking the start of this recording.
- Parameters:
csvPath – Absolute path for the output
trigger.csv.
-
void stop_recording()#
Flushes and closes the CSV file.
Also drives low any parallel port configured with ParallelPortConfig::sendRecordingMarker (falling edge marking the end of this recording).
-
bool is_recording() const#
- Returns:
truewhile the CSV output file is open.
-
int keyboard_trigger_count() const#
- Returns:
The number of active keyboard trigger event filters.
-
QObject *keyboard_trigger_at(int index) const#
- Parameters:
index – Zero-based index.
- Returns:
The KeyboardTrigger at
indexas aQObject*so the settings panel can connect to itscount_changed()signal without including the private header. Returnsnullptrifindexis out of range.
Signals
-
void event_received(mosaic::TriggerEvent event)#
Emitted on the main thread for every trigger event, regardless of source. Connect to this signal to react to events in real time.
- Parameters:
event – A copy of the TriggerEvent (source, label, value, timestamp, action).
-
void action_requested(mosaic::TriggerAction action, mosaic::TriggerEvent event)#
Emitted when a trigger fires with action StartRecording or StopRecording. Application connects this to RecordManager::start() / stop().
- Parameters:
action – The action requested (Start or Stop).
event – The trigger event that caused the action.