$darkmode
#include <component.hpp>
Public Member Functions | |
| Component (const std::string &name, const std::string &description="") | |
| Component (std::string &&name, std::string &&description="") | |
| uint64_t | id () const |
| template<typename T > | |
| T * | as () |
| virtual fable::Json | active_state () const =0 |
| Duration | process (const Sync &sync) override |
| void | reset () override |
| void | abort () override |
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 | connect () |
| virtual void | disconnect () |
| virtual void | enroll (Registrar &) |
| 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 (fable::Json &j, const Component &c) |
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_ |
A Component is a sensor or actuator that is part of a vehicle. Components can be used by controllers for reading and writing.
Generally, one does not directly inherit from Component when creating a new component plugin. Instead, an intermediate interface is created, such as EgoSensor, which is then used as the base class. This allows multiple implementations and proxies to augment components transparently. As such, the interface provided by the Component class is quite slim.
Note: If you are creating a Component and it is not a standard CloeComponent, it is recommended to create a static method
static const char* default_name()
that returns a unique identifier (e.g. with namespace and so on).
Make sure to implement the following methods from the Model interface:
Duration resolution() constbool is_connected() constbool is_operational() constvoid connect()void disconnect()void enroll(Registrar&)void start(const Sync&)Duration process(const Sync&) = 0void pause(const Sync&)void resume(const Sync&)void stop(const Sync&)void reset()void abort()See the documentation for the Model class for information on when these methods are called in a simulation.
The following methods are specific to the Component interface:
uint64_t id() constT* as()fable::Json active_state() const = 0
|
inlineoverridevirtual |
Implement Model::abort by default.
Reimplemented from cloe::Model.
|
pure virtual |
Return the JSON representation of the component.
Implemented in Speedometer, cloe::WheelSensor, cloe::VehicleStateModel, cloe::SteeringSensor, cloe::PowertrainSensor, cloe::ObjectSensor, cloe::LatLongActuator, cloe::LaneBoundarySensor, cloe::EgoSensor, cloe::DriverRequest, cloe::BrakeSensor, cloe::Actuator< T >, cloe::Actuator< double >, cloe::Actuator< PedalRequest >, cloe::Actuator< SteeringRequest >, and cloe::Actuator< GearboxRequest >.
|
inline |
Attempt to cast this component to a sub-type.
|
inline |
Return the unique numeric ID of this component.
This numeric ID should be unique across all components in a simulation. There is no guarantee however, that the component will receive the same ID in any future simulation. Numeric IDs start with 1; 0 is not a valid ID.
Clear any cache that may be accumulated during a step.
Implements cloe::Model.
Reimplemented in cloe::Actuator< double >, cloe::Actuator< PedalRequest >, cloe::Actuator< SteeringRequest >, and cloe::Actuator< GearboxRequest >.
|
inlineoverridevirtual |
Implement Model::reset by default.
Reimplemented from cloe::Model.
Reimplemented in cloe::Actuator< double >, cloe::Actuator< PedalRequest >, cloe::Actuator< SteeringRequest >, and cloe::Actuator< GearboxRequest >.