DiffEq - Modern C++ ODE Integration Library 1.0.0
High-performance C++ library for solving ODEs with async signal processing
Loading...
Searching...
No Matches
diffeq::core::composable::EventDecorator< S, T > Class Template Reference

Event decorator - adds event-driven feedback capabilities to any integrator. More...

#include <event_decorator.hpp>

Inheritance diagram for diffeq::core::composable::EventDecorator< S, T >:
Collaboration diagram for diffeq::core::composable::EventDecorator< S, T >:

Public Member Functions

 EventDecorator (std::unique_ptr< AbstractIntegrator< S, T > > integrator, EventConfig config={})
 Construct event decorator.
 
 ~EventDecorator ()
 Destructor ensures proper cleanup.
 
void step (typename IntegratorDecorator< S, T >::state_type &state, T dt) override
 Override step to handle events during integration.
 
void integrate (typename IntegratorDecorator< S, T >::state_type &state, T dt, T end_time) override
 Override integrate to handle events during integration.
 
void register_event_handler (EventTrigger trigger, std::function< void(S &, T)> handler)
 Register event handler for specific trigger type.
 
void trigger_event (const std::string &event_id, EventPriority priority, std::function< void(S &, T)> handler, std::vector< uint8_t > data={})
 Trigger custom event.
 
void submit_sensor_data (const std::string &sensor_id, const std::vector< double > &values, double confidence=1.0)
 Submit sensor data.
 
void submit_control_feedback (const std::string &control_id, const S &target_state, const S &current_state)
 Submit control feedback.
 
void set_state_condition (std::function< bool(const S &, T)> condition, std::function< void(S &, T)> handler, EventPriority priority=EventPriority::NORMAL)
 Set state-based event condition.
 
void set_threshold_event (size_t state_index, double threshold, bool crossing_direction, std::function< void(S &, T)> handler)
 Set threshold crossing event.
 
const EventStatsget_statistics () const
 Get event statistics.
 
void reset_statistics ()
 Reset event statistics.
 
const std::vector< Event< S, T > > & get_event_history () const
 Get event history.
 
void clear_event_history ()
 Clear event history.
 
std::map< std::string, SensorData< T > > get_sensor_data () const
 Get current sensor data.
 
std::map< std::string, ControlFeedback< S, T > > get_control_feedback () const
 Get current control feedback.
 
EventConfigconfig ()
 Access and modify event configuration.
 
const EventConfigconfig () const
 
- Public Member Functions inherited from diffeq::core::composable::IntegratorDecorator< S >
 IntegratorDecorator (std::unique_ptr< base_type > integrator)
 Construct decorator wrapping another integrator.
 
virtual ~IntegratorDecorator ()=default
 Virtual destructor for proper cleanup.
 
void step (state_type &state, time_type dt) override
 
void integrate (state_type &state, time_type dt, time_type end_time) override
 
time_type current_time () const override
 
void set_time (time_type t) override
 
void set_system (system_function sys) override
 
base_typewrapped ()
 Access to wrapped integrator for advanced use.
 
const base_typewrapped () const
 
bool has_wrapped_integrator () const
 Check if wrapped integrator exists.
 
- Public Member Functions inherited from diffeq::core::AbstractIntegrator< S >
 AbstractIntegrator (system_function sys)
 
time_type current_time () const
 
void set_time (time_type t)
 
void set_system (system_function sys)
 

Additional Inherited Members

- Public Types inherited from diffeq::core::composable::IntegratorDecorator< S >
using base_type = AbstractIntegrator< S >
 
using state_type = typename base_type::state_type
 
using time_type = typename base_type::time_type
 
using system_function = typename base_type::system_function
 
- Public Types inherited from diffeq::core::AbstractIntegrator< S >
using state_type = S
 
using time_type = typename S::value_type
 
using value_type = typename S::value_type
 
using system_function = std::function< void(time_type, const state_type &, state_type &)>
 
- Protected Member Functions inherited from diffeq::core::AbstractIntegrator< S >
void advance_time (time_type dt)
 
- Protected Attributes inherited from diffeq::core::composable::IntegratorDecorator< S >
std::unique_ptr< base_typewrapped_integrator_
 
- Protected Attributes inherited from diffeq::core::AbstractIntegrator< S >
system_function sys_
 
time_type current_time_
 

Detailed Description

template<system_state S, can_be_time T = double>
class diffeq::core::composable::EventDecorator< S, T >

Event decorator - adds event-driven feedback capabilities to any integrator.

This decorator provides comprehensive event-driven capabilities with the following features:

  • Multiple event trigger types (time, state, sensor, control)
  • Priority-based event processing
  • Real-time constraints and timing guarantees
  • Sensor data integration and validation
  • Control loop feedback mechanisms
  • Asynchronous event processing

Key Design Principles:

  • Single Responsibility: ONLY handles event-driven feedback
  • Real-time: Designed for robotics and control applications
  • Flexible: Multiple trigger types and processing modes
  • Robust: Timeout handling and error recovery

Definition at line 237 of file event_decorator.hpp.

Constructor & Destructor Documentation

◆ EventDecorator()

template<system_state S, can_be_time T = double>
diffeq::core::composable::EventDecorator< S, T >::EventDecorator ( std::unique_ptr< AbstractIntegrator< S, T > >  integrator,
EventConfig  config = {} 
)
inlineexplicit

Construct event decorator.

Parameters
integratorThe integrator to wrap
configEvent configuration (validated on construction)
Exceptions
std::invalid_argumentif config is invalid

Definition at line 270 of file event_decorator.hpp.

◆ ~EventDecorator()

Destructor ensures proper cleanup.

Definition at line 289 of file event_decorator.hpp.

Member Function Documentation

◆ clear_event_history()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::clear_event_history ( )
inline

Clear event history.

Definition at line 474 of file event_decorator.hpp.

◆ config() [1/2]

template<system_state S, can_be_time T = double>
EventConfig & diffeq::core::composable::EventDecorator< S, T >::config ( )
inline

Access and modify event configuration.

Definition at line 497 of file event_decorator.hpp.

◆ config() [2/2]

template<system_state S, can_be_time T = double>
const EventConfig & diffeq::core::composable::EventDecorator< S, T >::config ( ) const
inline

Definition at line 498 of file event_decorator.hpp.

◆ get_control_feedback()

template<system_state S, can_be_time T = double>
std::map< std::string, ControlFeedback< S, T > > diffeq::core::composable::EventDecorator< S, T >::get_control_feedback ( ) const
inline

Get current control feedback.

Definition at line 489 of file event_decorator.hpp.

◆ get_event_history()

template<system_state S, can_be_time T = double>
const std::vector< Event< S, T > > & diffeq::core::composable::EventDecorator< S, T >::get_event_history ( ) const
inline

Get event history.

Definition at line 467 of file event_decorator.hpp.

◆ get_sensor_data()

template<system_state S, can_be_time T = double>
std::map< std::string, SensorData< T > > diffeq::core::composable::EventDecorator< S, T >::get_sensor_data ( ) const
inline

Get current sensor data.

Definition at line 481 of file event_decorator.hpp.

◆ get_statistics()

template<system_state S, can_be_time T = double>
const EventStats & diffeq::core::composable::EventDecorator< S, T >::get_statistics ( ) const
inline

Get event statistics.

Definition at line 452 of file event_decorator.hpp.

◆ integrate()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::integrate ( typename IntegratorDecorator< S, T >::state_type &  state,
dt,
end_time 
)
inlineoverride

Override integrate to handle events during integration.

Definition at line 314 of file event_decorator.hpp.

◆ register_event_handler()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::register_event_handler ( EventTrigger  trigger,
std::function< void(S &, T)>  handler 
)
inline

Register event handler for specific trigger type.

Parameters
triggerEvent trigger type
handlerEvent handler function

Definition at line 330 of file event_decorator.hpp.

Here is the caller graph for this function:

◆ reset_statistics()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::reset_statistics ( )
inline

Reset event statistics.

Definition at line 459 of file event_decorator.hpp.

◆ set_state_condition()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::set_state_condition ( std::function< bool(const S &, T)>  condition,
std::function< void(S &, T)>  handler,
EventPriority  priority = EventPriority::NORMAL 
)
inline

Set state-based event condition.

Parameters
conditionFunction that returns true when event should trigger
handlerEvent handler function
priorityEvent priority

Definition at line 408 of file event_decorator.hpp.

Here is the call graph for this function:

◆ set_threshold_event()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::set_threshold_event ( size_t  state_index,
double  threshold,
bool  crossing_direction,
std::function< void(S &, T)>  handler 
)
inline

Set threshold crossing event.

Parameters
state_indexIndex of state variable to monitor
thresholdThreshold value
crossing_directiontrue for upward crossing, false for downward
handlerEvent handler function

Definition at line 426 of file event_decorator.hpp.

Here is the call graph for this function:

◆ step()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::step ( typename IntegratorDecorator< S, T >::state_type &  state,
dt 
)
inlineoverride

Override step to handle events during integration.

Definition at line 297 of file event_decorator.hpp.

◆ submit_control_feedback()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::submit_control_feedback ( const std::string &  control_id,
const S &  target_state,
const S &  current_state 
)
inline

Submit control feedback.

Parameters
control_idControl identifier
target_stateTarget state
current_stateCurrent state

Definition at line 387 of file event_decorator.hpp.

Here is the call graph for this function:

◆ submit_sensor_data()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::submit_sensor_data ( const std::string &  sensor_id,
const std::vector< double > &  values,
double  confidence = 1.0 
)
inline

Submit sensor data.

Parameters
sensor_idSensor identifier
valuesSensor values
confidenceConfidence level (0.0 to 1.0)

Definition at line 363 of file event_decorator.hpp.

Here is the call graph for this function:

◆ trigger_event()

template<system_state S, can_be_time T = double>
void diffeq::core::composable::EventDecorator< S, T >::trigger_event ( const std::string &  event_id,
EventPriority  priority,
std::function< void(S &, T)>  handler,
std::vector< uint8_t >  data = {} 
)
inline

Trigger custom event.

Parameters
event_idUnique event identifier
priorityEvent priority
handlerEvent handler function
dataOptional event data

Definition at line 341 of file event_decorator.hpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: