$darkmode
Public Member Functions | |
| MinimatorSimulator (const std::string &name, const MinimatorConfiguration &c) | |
| virtual | ~MinimatorSimulator () noexcept=default |
| void | connect () final |
| void | disconnect () final |
| void | reset () final |
| void | abort () final |
| void | enroll (cloe::Registrar &r) final |
| size_t | num_vehicles () const final |
| std::shared_ptr< cloe::Vehicle > | get_vehicle (size_t i) const final |
| std::shared_ptr< cloe::Vehicle > | get_vehicle (const std::string &key) const final |
| cloe::Duration | process (const cloe::Sync &sync) final |
Public Member Functions inherited from cloe::Model | |
| virtual | ~Model () noexcept=default |
| virtual Duration | resolution () const |
| virtual bool | is_connected () const |
| virtual bool | is_operational () const |
| virtual void | start (const Sync &) |
| virtual void | pause (const Sync &) |
| virtual void | resume (const Sync &) |
| virtual void | stop (const Sync &) |
| Entity (std::string name) | |
| Entity (std::string name, std::string desc) | |
Public Member Functions inherited from cloe::Entity | |
| Entity (std::string name) | |
| Entity (std::string name, std::string desc) | |
| const std::string & | name () const |
| void | set_name (std::string name) |
| const std::string & | description () const |
| void | set_description (std::string desc) |
Friends | |
| void | to_json (cloe::Json &j, const MinimatorSimulator &b) |
Additional Inherited Members | |
Protected Member Functions inherited from cloe::Entity | |
| virtual Logger | logger () const |
Protected Attributes inherited from cloe::Model | |
| bool | connected_ {false} |
| bool | operational_ {false} |
Protected Attributes inherited from cloe::Entity | |
| std::string | name_ |
| std::string | desc_ |
MinimatorSimulator binds all the above classes together in a coherent structure.
It receives the configuration, creates and provides vehicles, and maintains the connection to the underlying simulator (if any).
This class implements the Simulator and the Model interfaces, which are very well documented. Have a look!
|
inline |
Construct a MinimatorSimulator instance with the given name and configuration.
This signature is required by the factory class at the end of this file. Having any additional signatures is not really needed by Cloe; the only reason you might have additional ones is for testing or if you want to implement the factory make method yourself. See end of this file for the macro calls that define the factory and the make method.
|
virtualdefaultnoexcept |
Destruct a MinimatorSimulator instance.
We're not doing anything special, so the default will do just fine.
|
inlinefinalvirtual |
Abort the simulator.
This method may be called asynchronously. See the documentation of the interface for more on this. It may also be called while a connect is still in progress. The idea is that calling abort should somehow cause this simulator binding to exit out of some waiting state it might be in.
Have a look at the VTD simulator plugin for how we make use of the AbortFlag if this is relevant to your plugin.
Reimplemented from cloe::Model.
|
inlinefinalvirtual |
Initiate a connection to the simulator and initialize all data.
We're not actually connecting to some other simulator, so all we will do here is create some vehicles and make these available to the simulation.
If you need to make use of a TCP connection, have a look at the TcpTransceiver class. If this method makes any use of I/O, it is also expected that a call to abort will let us cleanly exit out. The TcpTransceiverFactory class aids us in this by using the AbortFlag type as a way to prematurely exit.
Reimplemented from cloe::Model.
|
inlinefinalvirtual |
Tear down the connection to the simulator and remove all data.
This is effectively the reverse action to a connect.
Reimplemented from cloe::Model.
|
inlinefinalvirtual |
Register any events, actions, or handlers with the registrar.
Events and Actions are part of the trigger framework in Cloe. These let the user specify event-action pairs to dynamically affect the simulation. If there are any events or actions that a Simulator may want to expose, this is the place to do it.
Handlers are HTTP handlers that can simply expose data or provide hooks for changing the simulation. It is not recommended for handlers to have side-effects however, as these are not tracked by Cloe for ensuring a reproducible simulation. Actions are a much better solution for this.
Reimplemented from cloe::Model.
|
inlinefinalvirtual |
|
inlinefinalvirtual |
Return the vehicle specified.
Implements cloe::Simulator.
|
inlinefinalvirtual |
Return the number of vehicles that are available.
This only needs to work after a connect.
Implements cloe::Simulator.
|
inlinefinalvirtual |
Process everything up until the time given in sync.
This is where all the step-for-step work in the simulator binding will occur. When the work is done, the new simulation time should be returned. This indicates that this model has reached that point in time with its processing. Because Vehicle::process is also called, it may not be necessary for this method to do much work.
If a scenario or some other user interaction in the simulator causes the simulator to stop, the operational_ boolean can be toggled.
Implements cloe::Simulator.
|
inlinefinalvirtual |
Reset the simulator.
This is useful for use-cases such as machine-learning where we want to restart the simulation, but not necessarily change the scenario or have to completely stop and start the simulation.
This method does not need to be implemented. The default implementation will throw a ModelError notifying the simulation that this operation is not supported. But it's fairly simple for us to implement it, so we will.
Reimplemented from cloe::Model.
|
friend |
Serialize MinimatorSimulator into JSON.
This is required for the ToJson handler that is used in the enroll method.