vle  2.0.0-alpha2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
vle::devs::Dynamics Class Reference

Dynamics class represent a part of the DEVS simulator. This class must be inherits to build simulation components. More...

#include <vle/devs/Dynamics.hpp>

Public Member Functions

 Dynamics (const DynamicsInit &init, const InitEventList &events)
 Constructor of Dynamics for an atomic model. More...
 
virtual ~Dynamics ()
 Destructor (nothing to do) More...
 
ExternalEventbuildEvent (const std::string &portName) const
 
virtual void confluentTransitions (Time time, const ExternalEventList &extEventlist)
 Process the confluent transition, by default, confluentTransitions call internalTransition and externalTransition but this function can be overidden to develop its own dynamics. More...
 
utils::ContextPtr context () const noexcept
 
virtual void externalTransition (const ExternalEventList &, Time)
 Process an external transition: compute the new state of the model when an external event occurs. More...
 
virtual void finish ()
 When the simulation of the atomic model is finished, the finish method is invoked. More...
 
const vle::vpz::AtomicModelgetModel () const
 Return a reference of the atomic model to which belongs the dynamics. More...
 
const std::string & getModelName () const
 
std::string getPackageDataDir () const
 Get the data package directory. More...
 
std::string getPackageDataFile (const std::string &name) const
 Get the path of a data package file. More...
 
std::string getPackageDir () const
 Get the package directory. More...
 
std::string getPackageDocDir () const
 Get the document package directory. More...
 
std::string getPackageDocFile (const std::string &name) const
 Get the path of a document package file. More...
 
std::string getPackageExpDir () const
 Get the experiment package directory. More...
 
std::string getPackageExpFile (const std::string &name) const
 Get the path of an experiment package file. More...
 
std::string getPackageFile (const std::string &name) const
 Get the path of a package file. More...
 
std::string getPackageLibFile (const std::string &name) const
 Get the path of a library package file. More...
 
std::string getPackageSimulatorDir () const
 Get the library package directory. More...
 
std::string getPackageSrcDir () const
 Get the source package directory. More...
 
std::string getPackageSrcFile (const std::string &name) const
 Get the path of a source package file. More...
 
virtual Time init (Time)
 Process the initialization of the model by initializing the initial state and return the duration (or timeAdvance) of the initial state. More...
 
virtual void internalTransition (Time)
 Process an internal transition: compute the new state of the model with the internal transition function. More...
 
virtual bool isExecutive () const
 If this function return true, then a cast to an Executive object is produce and the set_coordinator function is call. Executive permit to manipulate vpz::CoupledModel and devs::Coordinator at runtime of the simulation. More...
 
virtual bool isWrapper () const
 If this function return true, then a cast to a DynamicsWrapper object is produce and the set_model and set_library function are call. More...
 
virtual std::unique_ptr
< vle::value::Value
observation (const ObservationEvent &) const
 Process an observation event: compute the current state of the model at a specified time and for a specified port. More...
 
virtual void output (Time, ExternalEventList &) const
 Process the output function: compute the output function. More...
 
virtual Time timeAdvance () const
 Process the time advance function: compute the duration of the current state. More...
 

Private Attributes

utils::ContextPtr m_context
 < A reference to the context. More...
 
const vpz::AtomicModelm_model
 An iterator to std::set of the vle::utils::PackageTable. More...
 
PackageId m_packageid
 

Detailed Description

Dynamics class represent a part of the DEVS simulator. This class must be inherits to build simulation components.

Definition at line 80 of file Dynamics.hpp.

Constructor & Destructor Documentation

vle::devs::Dynamics::Dynamics ( const DynamicsInit init,
const InitEventList events 
)

Constructor of Dynamics for an atomic model.

Parameters
initThe initialiser of Dynamics.
eventsThe parameter from the experimental frame.

Definition at line 41 of file Dynamics.cpp.

virtual vle::devs::Dynamics::~Dynamics ( )
inlinevirtual

Destructor (nothing to do)

Definition at line 94 of file Dynamics.hpp.

Member Function Documentation

ExternalEvent* vle::devs::Dynamics::buildEvent ( const std::string &  portName) const

Build an event list with a single event on a specified port at a specified time

Parameters
portNamethe name of port where the event will post
Returns
the event list with the event
virtual void vle::devs::Dynamics::confluentTransitions ( Time  time,
const ExternalEventList extEventlist 
)
inlinevirtual

Process the confluent transition, by default, confluentTransitions call internalTransition and externalTransition but this function can be overidden to develop its own dynamics.

Parameters
timethe time of the simulation.
extEventlistthe external events list.

Reimplemented in Confluent_transitionD, Confluent_transitionB, Confluent_transitionA, ObservationModel, AdaptativeQuantifier, Integrator, Exe, Mult, Adder, vle::devs::DynamicsObserver, ModelDbg, vle::devs::DynamicsDbg, DynamicObs, and Model.

Definition at line 216 of file Dynamics.hpp.

utils::ContextPtr vle::devs::Dynamics::context ( ) const
inlinenoexcept
virtual void vle::devs::Dynamics::externalTransition ( const ExternalEventList ,
Time   
)
inlinevirtual

Process an external transition: compute the new state of the model when an external event occurs.

Parameters
eventthe external event with of the port.
timethe date of occurrence of this event.
//
// externalTransition method's body examples
// to get the content of an event
//
...
vle::devs::ExternalEventList::const_iterator
it = events.begin();
while (it != events.end()) {
// to get a double
if (it->attributes()->isDouble()) {
Double aDouble = it->getDouble().value();
// to get a integer
} else if (it->attributes()->isInteger()) {
Int aInteger = it->getInteger().value();
// to get a string
} else if (it->attributes()->isString()) {
std::string aString = it->getString().value();
// to get a map and inside values
} else if (it->attributes()->isMap()) {
const value::Map& attrs = it->getMap();
std::string aString = attrs.getString("name").value();
double aDouble = attrs.getDouble("value").value();
...
} else {
...
}
}
...

Reimplemented in Confluent_transitionD, Confluent_transitionB, Confluent_transitionA, Transform, ObservationModel, Plot, DeleteConnection, Exe, Counter, vle::devs::DynamicsObserver, ModelDbg, Mult, Adder, vle::devs::DynamicsDbg, Transform, AdaptativeQuantifier, DynamicObs, Integrator, and Model.

Definition at line 204 of file Dynamics.hpp.

virtual void vle::devs::Dynamics::finish ( )
inlinevirtual

When the simulation of the atomic model is finished, the finish method is invoked.

Reimplemented in Plot, ObservationModel, Exe, Mult, Adder, vle::devs::DynamicsObserver, ModelDbg, vle::devs::DynamicsDbg, and Model.

Definition at line 263 of file Dynamics.hpp.

const vle::vpz::AtomicModel& vle::devs::Dynamics::getModel ( ) const
inline

Return a reference of the atomic model to which belongs the dynamics.

Returns
pointer on the atomic model

Definition at line 302 of file Dynamics.hpp.

Referenced by AdaptativeQuantifier::AdaptativeQuantifier(), Adder::Adder(), vle::devs::View::addObservable(), Constant::Constant(), Generator::Generator(), Integrator::Integrator(), Mult::Mult(), and vle::devs::View::run().

const std::string& vle::devs::Dynamics::getModelName ( ) const
inline
std::string vle::devs::Dynamics::getPackageDataDir ( ) const

Get the data package directory.

Returns
The data package path.

Definition at line 89 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getDataDir(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageDataFile ( const std::string &  name) const

Get the path of a data package file.

Parameters
nameThe name of the file.
Returns
The patch of the file.

Definition at line 163 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getDataFile(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageDir ( ) const

Get the package directory.

Returns
The package path.

Definition at line 49 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getDir(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageDocDir ( ) const

Get the document package directory.

Returns
The document package path.

Definition at line 101 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getDocDir(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageDocFile ( const std::string &  name) const

Get the path of a document package file.

Parameters
nameThe name of the file.
Returns
The patch of the file.

Definition at line 175 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getDocFile(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageExpDir ( ) const

Get the experiment package directory.

Returns
The experiment package path.

Definition at line 113 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getExpDir(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageExpFile ( const std::string &  name) const

Get the path of an experiment package file.

Parameters
nameThe name of the file.
Returns
The patch of the file.

Definition at line 187 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getExpFile(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageFile ( const std::string &  name) const

Get the path of a package file.

Parameters
nameThe name of the file.
Returns
The patch of the file.

Definition at line 127 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getFile(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageLibFile ( const std::string &  name) const

Get the path of a library package file.

Parameters
nameThe name of the file.
Returns
The patch of the file.

Definition at line 139 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getLibFile(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageSimulatorDir ( ) const

Get the library package directory.

Returns
The library package path.

Definition at line 63 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getPluginSimulatorDir(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageSrcDir ( ) const

Get the source package directory.

Returns
The source package path.

Definition at line 77 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getSrcDir(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

std::string vle::devs::Dynamics::getPackageSrcFile ( const std::string &  name) const

Get the path of a source package file.

Parameters
nameThe name of the file.
Returns
The patch of the file.

Definition at line 151 of file Dynamics.cpp.

References _, vle::utils::Package::existsBinary(), vle::utils::Package::getSrcFile(), m_context, m_packageid, vle::utils::PKG_BINARY, and str.

virtual Time vle::devs::Dynamics::init ( Time  )
inlinevirtual

Process the initialization of the model by initializing the initial state and return the duration (or timeAdvance) of the initial state.

Parameters
timethe time of the creation of this model.
Returns
duration of the initial state.

Reimplemented in Root, Leaf, GenExecutive, Confluent_transitionD, Confluent_transitionC, Confluent_transitionB, Confluent_transitionA, Transform, Plot, ObservationModel, DeleteConnection, GraphGenerator, Exe, Counter, ModelDbg, Branch, vle::devs::DynamicsObserver, Transform, AdaptativeQuantifier, Mult, vle::devs::DynamicsDbg, Adder, Generator, MyBeep, DynamicObs, Integrator, Beep, Model, and Constant.

Definition at line 109 of file Dynamics.hpp.

Referenced by GraphGenerator::init(), and Plot::init().

virtual void vle::devs::Dynamics::internalTransition ( Time  )
inlinevirtual

Process an internal transition: compute the new state of the model with the internal transition function.

Parameters
timethe date of occurence of this event.

Reimplemented in Root, GenExecutive, Confluent_transitionD, Confluent_transitionC, Confluent_transitionB, Confluent_transitionA, Transform, ObservationModel, DeleteConnection, AdaptativeQuantifier, Exe, Counter, ModelDbg, vle::devs::DynamicsObserver, Mult, Adder, Branch, Integrator, vle::devs::DynamicsDbg, Transform, Generator, DynamicObs, Constant, and Model.

Definition at line 162 of file Dynamics.hpp.

virtual bool vle::devs::Dynamics::isExecutive ( ) const
inlinevirtual

If this function return true, then a cast to an Executive object is produce and the set_coordinator function is call. Executive permit to manipulate vpz::CoupledModel and devs::Coordinator at runtime of the simulation.

Returns
false if Dynamics is not an Executive.

Reimplemented in vle::devs::Executive, vle::devs::DynamicsObserver, and vle::devs::DynamicsDbg.

Definition at line 278 of file Dynamics.hpp.

virtual bool vle::devs::Dynamics::isWrapper ( ) const
inlinevirtual

If this function return true, then a cast to a DynamicsWrapper object is produce and the set_model and set_library function are call.

Returns
false if Dynamics is not a DynamicsWrapper.

Reimplemented in vle::devs::DynamicsObserver, vle::devs::DynamicsWrapper, and vle::devs::DynamicsDbg.

Definition at line 288 of file Dynamics.hpp.

virtual std::unique_ptr<vle::value::Value> vle::devs::Dynamics::observation ( const ObservationEvent ) const
inlinevirtual

Process an observation event: compute the current state of the model at a specified time and for a specified port.

Parameters
eventthe state event with of the port
Returns
the value of state variable
//
// observation method's body example
// to observe different Types of values
//
...
const std::string& port = event.getPortName();
if (port == "doubleObservablePort") {
} else if (port == "integerObservablePort") {
} else if (port == "stringObservablePort") {
return value::String::create("a string");
} else if (port == "setObservablePort") {
std::unique_ptr<value::Set> set(new vle::value::Set());
set->add(value::Integer::create(1));
set->add(value::String::create("a string"));
...
return set;
}
...

Reimplemented in GenExecutive, Confluent_transitionB, Confluent_transitionA, Transform, ObservationModel, AdaptativeQuantifier, Integrator, Exe, Counter, Mult, Adder, vle::devs::DynamicsObserver, ModelDbg, vle::devs::DynamicsDbg, Transform, Generator, DynamicObs, and Model.

Definition at line 253 of file Dynamics.hpp.

Referenced by GenExecutive::observation(), and vle::devs::View::run().

virtual void vle::devs::Dynamics::output ( Time  ,
ExternalEventList  
) const
inlinevirtual

Process the output function: compute the output function.

Parameters
timethe time of the occurrence of output function.
outputthe list of external events (output parameter).
//
// output method's body examples
// filling events
//
...
// send an empty event to the "output" port
output.emplace_back("output");
// send a string event to the "outputString" port
output.emplace_back("outputString");
output.back().addString("a String");
// send a double event
output.emplace_back("outputDouble");
output.back().addDouble(.0);
// send a map event
output.emplace_back("outputMap");
value::Map& m = output.back().addMap();
m.addString("name",it->first);
m.addDouble("value", it->second);
...

Reimplemented in Leaf, Confluent_transitionC, Confluent_transitionB, Confluent_transitionA, Transform, AdaptativeQuantifier, ObservationModel, Exe, Counter, Integrator, Branch, ModelDbg, Transform, vle::devs::DynamicsObserver, DynamicObs, vle::devs::DynamicsDbg, Mult, Adder, Generator, MyBeep, Beep, Constant, and Model.

Definition at line 143 of file Dynamics.hpp.

virtual Time vle::devs::Dynamics::timeAdvance ( ) const
inlinevirtual

Process the time advance function: compute the duration of the current state.

Returns
duration of the current state.

Reimplemented in Root, Leaf, GenExecutive, Confluent_transitionD, Confluent_transitionC, Confluent_transitionB, Confluent_transitionA, Plot, Transform, AdaptativeQuantifier, ObservationModel, DeleteConnection, Exe, Integrator, Counter, ModelDbg, vle::devs::DynamicsObserver, Mult, Branch, Adder, Generator, vle::devs::DynamicsDbg, Transform, MyBeep, DynamicObs, Beep, Constant, and Model.

Definition at line 152 of file Dynamics.hpp.

Member Data Documentation

utils::ContextPtr vle::devs::Dynamics::m_context
private

< A reference to the context.

A constant reference to the atomic model node of the graph.

Definition at line 419 of file Dynamics.hpp.

Referenced by getPackageDataDir(), getPackageDataFile(), getPackageDir(), getPackageDocDir(), getPackageDocFile(), getPackageExpDir(), getPackageExpFile(), getPackageFile(), getPackageLibFile(), getPackageSimulatorDir(), getPackageSrcDir(), and getPackageSrcFile().

const vpz::AtomicModel& vle::devs::Dynamics::m_model
private

An iterator to std::set of the vle::utils::PackageTable.

Definition at line 422 of file Dynamics.hpp.

PackageId vle::devs::Dynamics::m_packageid
private

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