13#ifndef GUARDIAN_STATE_MACHINE_HPP
14#define GUARDIAN_STATE_MACHINE_HPP
153 std::function<void()> onFreezeCallback;
154 std::function<void()> onClearFreezeCallback;
161 void logAction(
const std::string& action);
FrameStatus
Per-frame safety classification delivered by vision.
@ FRAME_BAD
Frame classified as unsafe.
@ FRAME_GOOD
Frame classified as safe.
GuardianEvent
Events consumed by the FSM transition logic.
@ OPERATOR_ACK
Operator/manual acknowledge event.
GuardianState
Internal FSM states.
@ SAFE_MONITORING
Normal operation; monitoring incoming frame status.
@ RESET_PENDING
Operator acknowledged; waiting for stable good frames.
@ FROZEN_UNSAFE
Unsafe condition latched; motion remains blocked.
GuardianAction
Side effects emitted by transitions.
@ CLEAR_FREEZE
Clear freeze and allow motion.
@ NONE
No hardware action required.
@ FREEZE_NOW
Immediate freeze/block action.
Event-driven safety state machine with callback hooks.
std::string getCurrentStateString() const
Return readable string for current state.
void operatorAcknowledge()
Inject an operator acknowledge event.
bool isMotionAllowed() const
True when motion is currently allowed.
int getBadCount() const
Get current consecutive bad-frame count.
void setOnStateChangeCallback(std::function< void(GuardianState, GuardianState)> callback)
Register callback fired on state transitions.
void processEvent(GuardianEvent event)
Process an explicit FSM event.
void setOnClearFreezeCallback(std::function< void()> callback)
Register callback fired when freeze is cleared.
GuardianState getState() const
Get current FSM state.
std::string stateToString(GuardianState state) const
Convert a state enum to a readable string.
void setOnFreezeCallback(std::function< void()> callback)
Register callback fired when freeze is commanded.
void processFrame(FrameStatus status)
Convenience wrapper that maps frame status to an FSM event.
void printStatus() const
Print a status snapshot for debugging.
int getGoodCount() const
Get current consecutive good-frame count.
bool isMotionBlocked() const
True when guardian currently blocks motion.