2 #ifndef SYDEVS_SYSTEMS_INTERACTIVE_SYSTEM_H_
3 #define SYDEVS_SYSTEMS_INTERACTIVE_SYSTEM_H_
48 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
80 duration macro_initialization_event();
84 void macro_finalization_event(
duration elapsed_dt);
86 virtual duration macro_initialization_update(InjData& injection) = 0;
87 virtual void micro_planned_update(
const AgentID& agent_id,
duration elapsed_dt) = 0;
88 virtual duration macro_planned_update(
duration elapsed_dt,
const InjData& injection, ObsData& observation) = 0;
89 virtual void macro_finalization_update(
duration elapsed_dt) = 0;
95 std::unique_ptr<interaction_data> interaction_data_;
99 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
104 InjData& injection();
105 const ObsData& observation();
111 ObsData& observation_;
115 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
118 return std::move(interaction_data_);
122 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
129 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
136 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
139 if (this->external_IO().flow_input_port_count() != 0 ||
140 this->external_IO().message_input_port_count() != 0 ||
141 this->external_IO().message_output_port_count() != 0 ||
142 this->external_IO().flow_output_port_count() != 0) {
143 throw std::invalid_argument(
"Interactive node (" + this->full_name() +
") must have no ports");
148 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
161 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
164 planned_dt_ = macro_initialization_update(injection_);
169 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
170 duration interactive_system<AgentID, Node, InjData, ObsData>::macro_unplanned_event(
duration elapsed_dt)
176 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
177 duration interactive_system<AgentID, Node, InjData, ObsData>::micro_planned_event(
const AgentID& agent_id,
duration elapsed_dt)
179 micro_planned_update(agent_id, elapsed_dt);
180 planned_dt_ -= elapsed_dt;
185 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
186 duration interactive_system<AgentID, Node, InjData, ObsData>::macro_planned_event(
duration elapsed_dt)
189 planned_dt_ = macro_planned_update(elapsed_dt, injection_, observation_);
190 if (planned_dt_ <= 0
_s)
throw std::logic_error(
"Planned duration between interact events in interactive system (" + this->full_name() +
") must be positive.");
195 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
196 void interactive_system<AgentID, Node, InjData, ObsData>::macro_finalization_event(
duration elapsed_dt)
198 macro_finalization_update(elapsed_dt);
202 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
209 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
216 template<
typename AgentID,
typename Node,
typename InjData,
typename ObsData>
const std::string & node_name() const
Returns the name of the node.
Definition: system_node.h:135
const ObsData & observation()
Definition: interactive_system.h:210
std::unique_ptr< interaction_data > acquire_interaction_data()
Transfers ownership of the interaction data object to the caller.
Definition: interactive_system.h:116
interactive_system(const std::string &node_name, const node_context &external_context)
Constructs an interactive_system node.
Definition: interactive_system.h:149
virtual ~interactive_system()=default
Destructor.
duration planned_duration() const
Returns the planned duration until the next frame is to be processed.
Definition: interactive_system.h:130
constexpr auto _s
Definition: units.h:128
InjData injection_type
Definition: interactive_system.h:52
int64 frame_index() const
Returns the index of the most recently processed frame.
Definition: interactive_system.h:123
Definition: node_context.h:16
A base class template for all collection nodes.
Definition: collection_node.h:55
quantity< seconds > duration
Definition: quantity.h:1006
Definition: interactive_system.h:100
InjData & injection()
Definition: interactive_system.h:203
A base class template for all interactive closed system nodes intended to be used at the highest leve...
Definition: interactive_system.h:49
ObsData observation_type
Definition: interactive_system.h:53