|
adevs
|
A model in the simulation. More...
#include <adevs_base.h>
Public Member Functions | |
| virtual TimeType | init (SimEnv< DataType, TimeType > *env)=0 |
| Called when the model is added to the simulation. More... | |
| virtual void | fini (TimeType now)=0 |
| Called after the model has been removed from the simulation. More... | |
| virtual TimeType | update (SimEnv< DataType, TimeType > *env, std::vector< DataType > &x)=0 |
| Called to assign a new state to the model at now() when input is present. More... | |
| virtual TimeType | update (SimEnv< DataType, TimeType > *env)=0 |
| Called to assign a new state to the model at now(). More... | |
| virtual std::pair< Model< DataType, TimeType > *, DataType > | relay (Model< DataType, TimeType > *src, DataType x) |
| Relay a message to another model. More... | |
| virtual std::string | name () |
| Return a name for this model. More... | |
| virtual | ~Model () |
| Destructor. | |
| void | reset () |
| Reset simulation support to reuse the model in a new simulation context. More... | |
Friends | |
| class | Simulator< DataType, TimeType > |
A model in the simulation.
The template argument is the data type to be communicated between models.
|
pure virtual |
Called after the model has been removed from the simulation.
The model is being removed from a running simulation and has ceased to exist as an entity at time now().
| now | The time at which the object no longer exists. |
Implemented in adevs::Network< DataType, TimeType >, adevs::Network< port_value< DataType >, TimeType >, and adevs::Atomic< DataType, TimeType >.
Referenced by adevs::Simulator< DataType, TimeType >::exec_next_event().
|
pure virtual |
Called when the model is added to the simulation.
The model has been added to a simulation by calling the SimEnv::add(Model*) method. The effect of calling init() should be to assign an initial state at time now and return the time of its event.
| env | The simulation context |
Implemented in adevs::Network< DataType, TimeType >, adevs::Network< port_value< DataType >, TimeType >, and adevs::Atomic< DataType, TimeType >.
Referenced by adevs::Simulator< DataType, TimeType >::add().
|
inlinevirtual |
Return a name for this model.
This is intended solely to facility debugging when ADEVS_ERROR_CHECK is enabled. The default implementation returns an empty string.
|
inlinevirtual |
Relay a message to another model.
When a message is sent to the model, its relay method is called immediately. If the method returns NULL then the message is discarded. If the method returns this then the message is delivered to this model. Otherwise, relay may return a model that will receive message as if send(this,relay(),msg) had been called at at the current time. The relay method will be called repeatedly with the same source and data until this or NULL is returned. the default behavior is to return this.
| src | The model that sent this data. |
| x | The data. |
Reimplemented in adevs::Network< DataType, TimeType >, and adevs::Network< port_value< DataType >, TimeType >.
Referenced by adevs::Network< port_value< DataType >, TimeType >::fini(), and adevs::Simulator< DataType, TimeType >::send().
|
inline |
Reset simulation support to reuse the model in a new simulation context.
Resets the internally used simulation variables as though the constructor had been called. Do this only if you want to reuse the model in a second, new simulation. You will probably use this rarely, if ever.
|
pure virtual |
Called to assign a new state to the model at now() when input is present.
Assign a state to the model at time now() and return the time of its next new state. Note that the input was generated in the previous simulation instant and so this calculates the new state using state information from the previous instant.
| env | The simulation context. |
| x | Messages sent to the model. |
Implemented in adevs::Network< DataType, TimeType >, adevs::Network< port_value< DataType >, TimeType >, and adevs::Atomic< DataType, TimeType >.
Referenced by adevs::Simulator< DataType, TimeType >::exec_next_event().
|
pure virtual |
Called to assign a new state to the model at now().
Assign a state to the model at time now() and return the time of its next new state. An update() will occur at most once per instant of simulation time.
| env | The simulation context. |
Implemented in adevs::Network< DataType, TimeType >, adevs::Network< port_value< DataType >, TimeType >, and adevs::Atomic< DataType, TimeType >.
1.8.13