SyDEVS
v0.6.7
Multiscale Simulation and Systems Modeling Library
|
A base class template for all interactive closed system nodes intended to be used at the highest level of a real time simulation model. More...
#include <interactive_system.h>
Inherits sydevs::systems::collection_node< int64, Node >.
Classes | |
class | interaction_data |
Public Types | |
using | injection_type = InjData |
using | observation_type = ObsData |
Public Member Functions | |
virtual | ~interactive_system ()=default |
Destructor. More... | |
std::unique_ptr< interaction_data > | acquire_interaction_data () |
Transfers ownership of the interaction data object to the caller. More... | |
int64 | frame_index () const |
Returns the index of the most recently processed frame. More... | |
duration | planned_duration () const |
Returns the planned duration until the next frame is to be processed. More... | |
Public Member Functions inherited from sydevs::systems::collection_node< int64, Node > | |
collection_node (const std::string &node_name, const node_context &external_context) | |
Constructs a collection_node . More... | |
virtual | ~collection_node ()=default |
Destructor. More... | |
void | print_on_elapsed_duration (bool flag=true) const |
If flag is true , all elapsed durations are printed for this node. More... | |
void | print_on_planned_duration (bool flag=true) const |
If flag is true , all planned durations are printed for this node. More... | |
duration | handle_initialization_event () |
Invoked at the beginning of a simulation; calls macro_initialization_event . More... | |
duration | handle_unplanned_event (duration elapsed_dt) |
Invoked whenever a message is received; calls macro_unplanned_event . More... | |
duration | handle_planned_event (duration elapsed_dt) |
Invoked when the planned duration elapses for either an agent or the overall collection; calls micro_planned_event or macro_planned_event . More... | |
void | handle_finalization_event (duration elapsed_dt) |
Invoked at the end of a simulation; calls macro_finalization_event . More... | |
Public Member Functions inherited from sydevs::systems::collection_node_base | |
virtual | ~collection_node_base ()=default |
Destructor. More... | |
data_mode | node_dmode () const |
Returns message for all collection nodes. More... | |
Public Member Functions inherited from sydevs::systems::system_node | |
system_node (const system_node &)=delete | |
No copy constructor. More... | |
system_node & | operator= (const system_node &)=delete |
No copy assignment. More... | |
system_node (system_node &&)=delete | |
No move constructor. More... | |
system_node & | operator= (system_node &&)=delete |
No move assignment. More... | |
virtual | ~system_node ()=default |
Destructor. More... | |
const std::string & | node_name () const |
Returns the name of the node. More... | |
const std::string & | full_name () const |
Returns the full name of the node, including parent nodes. More... | |
int64 | node_index () const |
Returns the index of the node within the parent node. More... | |
const node_interface & | external_interface () const |
Returns the object responsible for exchanging information between the node and its surrounding context. More... | |
const timer & | event_timer () const |
Returns the object that accumulated wallclock event durations. More... | |
template<typename T > | |
void | print (const T &X) |
Prints X while indicating the simulation time and node. More... | |
void | print (const char *raw_text) |
Prints raw_text while indicating the simulation time and node. More... | |
void | print (const std::string &text) |
Prints text while indicating the simulation time and node. More... | |
void | print_on_event (bool flag=true) const |
If flag is true , all event types are printed for this node. More... | |
void | adopt_print_flags (const system_node &node) const |
Adopts the print flags of node . More... | |
virtual scale | time_precision () const =0 |
Returns the time precision associated with the node, or no_scale . More... | |
duration | process_initialization_event () |
Processes an initialization event; returns a planned duration. More... | |
duration | process_unplanned_event (duration elapsed_dt) |
Processes an unplanned event after an elapsed duration elapsed_dt ; returns a planned duration. More... | |
duration | process_planned_event (duration elapsed_dt) |
Processes a planned event after an elapsed duration elapsed_dt ; returns a planned duration. More... | |
void | process_finalization_event (duration elapsed_dt) |
Processes a finalization event after an elapsed duration elapsed_dt . More... | |
Protected Member Functions | |
interactive_system (const std::string &node_name, const node_context &external_context) | |
Constructs an interactive_system node. More... | |
Protected Member Functions inherited from sydevs::systems::collection_node< int64, Node > | |
bool | transmitted (const port< message, output, T > &prototype_port) |
Returns true if a message was transmitted by an agent on the port corresponding to prototype_port . More... | |
flow_port_proxy< T > | access (const port< flow, input, T > &prototype_port) |
Returns a proxy of the flow input port prototype_port , allowing its value to be modified. More... | |
message_port_proxy< T > | access (const port< message, input, T > &prototype_port) |
Returns a proxy of the message input port prototype_port , allowing its value to be modified. More... | |
const T & | access (const port< message, output, T > &prototype_port) |
Returns the value transmitted by an agent on the message output port corresponding to prototype_port . More... | |
const T & | access (const port< flow, output, T > &prototype_port) |
Return the value output by an agent on the flow output port corresponding to prototype_port . More... | |
void | create_agent (const int64 &agent_id) |
Creates a new agent of type AgentNode. More... | |
void | create_agent (const int64 &agent_id) |
Creates a new agent. More... | |
void | affect_agent (const int64 &agent_id) |
Sends a message to an agent. More... | |
void | remove_agent (const int64 &agent_id) |
Finalizes and removes an agent. More... | |
void | invoke_agent (const int64 &agent_id) |
Creates, invokes, and removes an agent. More... | |
bool | agent_exists (const int64 &agent_id) |
Returns true if an agent with ID agent_id currently exists. More... | |
int64 | agent_count () |
Returns the current number of agents. More... | |
const_iterator | agent_begin () |
Returns an iterator pointing to the oldest agent. More... | |
const_iterator | agent_end () |
Returns an iterator pointing beyond the newest agent. More... | |
Protected Member Functions inherited from sydevs::systems::collection_node_base | |
collection_node_base (const std::string &node_name, const node_context &external_context) | |
Constructs a collection_node_base . More... | |
const node_context & | prototype_context () |
Returns a const reference to the prototype node's context object. More... | |
node_structure & | prototype_structure () |
Returns a non-const reference to the prototype node's encompassing structure object. More... | |
Protected Member Functions inherited from sydevs::systems::system_node | |
system_node (const std::string &node_name, const node_context &external_context) | |
Constructs a system_node . More... | |
node_interface & | external_IO () const |
Returns a non-const reference to the node's external interface. More... | |
timer & | ET () const |
Returns a non-const reference to the node's event timer. More... | |
duration | scale_planned_dt (duration planned_dt) const |
Adjusts the planned duration obtained from other nodes' event handlers. More... | |
Additional Inherited Members | |
Public Attributes inherited from sydevs::systems::collection_node< int64, Node > | |
const Node | prototype |
A node that serves as a proxy for all agent nodes. More... | |
Protected Attributes inherited from sydevs::systems::system_node | |
std::mt19937 & | rng |
Reference to the random number generator. More... | |
Static Protected Attributes inherited from sydevs::systems::collection_node< int64, Node > | |
static const int64 | macro_event_id |
The index used to schedule macro events; it must not conflict with any of the agent indices. More... | |
A base class template for all interactive closed system nodes intended to be used at the highest level of a real time simulation model.
The interactive_system
abstract base class is inherited by classes that represent a system that interacts with either a user or a process external to the model hierarchy. Interaction is facilitated by an interaction_data
object. This object supports the injection of information into the simulation model via an instance of type InjData
. It also supports observations of the simulation model via an instance of type ObsData
.
The class inherits from the collection_node
. This provides macro-level behavior supporting interaction and frames, and micro-level behavior represented by one (or possibly more) agents of type Node
.
Concrete derived classes must implement the following pure virtual member functions:
time_precision
, which indicates the time quantum that must evenly divide all planned and elapsed durations associated with the node (the time precision should not be no_scale
, since the intent is that a frame is produced whenever the planned duration elapses);macro_initialization_update
, which is called at the beginning of a simulation;micro_planned_update
, which is called whenever an agent sends a message;macro_planned_update
, which is called when the planned duration elapses;macro_finalization_update
, which is called at the end of a simulation.Each transition to the next frame at the macro-level is associated with the macro-level planned duration, which is returned from the macro_initialization_update
and macro_planned_update
member functions. The micro_planned_update
member function does not return a planned duration because it is assumed that micro-level events should not directly affect the frame rate established at the macro level of the interactive system node.
using sydevs::systems::interactive_system< AgentID, Node, InjData, ObsData >::injection_type = InjData |
using sydevs::systems::interactive_system< AgentID, Node, InjData, ObsData >::observation_type = ObsData |
|
virtualdefault |
Destructor.
|
protected |
Constructs an interactive_system
node.
Constructs the interactive system node and associates it with the surrounding context. An exception is thrown if the node has any ports.
node_name | The name of the node within the encompassing context. |
external_context | The context in which the node is constructed. |
std::unique_ptr< typename interactive_system< AgentID, Node, InjData, ObsData >::interaction_data > sydevs::systems::interactive_system< AgentID, Node, InjData, ObsData >::acquire_interaction_data | ( | ) |
Transfers ownership of the interaction data object to the caller.
int64 sydevs::systems::interactive_system< AgentID, Node, InjData, ObsData >::frame_index | ( | ) | const |
Returns the index of the most recently processed frame.
duration sydevs::systems::interactive_system< AgentID, Node, InjData, ObsData >::planned_duration | ( | ) | const |
Returns the planned duration until the next frame is to be processed.