simulation_framework::core::lifecycle::BaseActivity Class Reference
Last update: 16.07.2025This is the basic implementation of IActivity interface. Inheriting classes, i.e. a concrete simulation activity, should implement their logic in ExecuteStep() and add needed pub/sub in AddPublisherAndSubscriber() method. More...
#include <base_activity.h>


Public Member Functions | |
| BaseActivity (const std::string &activity_name, std::shared_ptr< core::CommunicationManager > communication_manager_ptr, std::unique_ptr< scheduling::ISchedulerClient > scheduler_client) | |
| BaseActivity (const std::string &activity_name, std::shared_ptr< core::CommunicationManager > communication_manager_ptr, std::unique_ptr< scheduling::ISchedulerClient > scheduler_client, std::chrono::milliseconds timeout) | |
| BaseActivity (const std::string &activity_name, const Topics &topics) | |
| BaseActivity (const std::string &activity_name, const Topics &topics, std::chrono::milliseconds timeout) | |
| virtual | ~BaseActivity () |
| std::string | GetName () const override |
| void | SetUpCommunication () final |
| void | Step () final |
| void | Shutdown () final |
| time::Timestamp | GetCurrentTimestamp () const final |
| std::chrono::milliseconds | GetCycleTime () const final |
| std::string | GetSimulationOutputDirectory () const final |
| std::vector< File > | GetInputFiles () const final |
Public Member Functions inherited from simulation_framework::core::lifecycle::IActivity | |
| virtual | ~IActivity ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
Protected Member Functions | |
| virtual void | Init () |
| virtual void | ExecuteStep ()=0 |
| virtual void | AddPublisherAndSubscriber ()=0 |
| template<typename Topic > | |
| void | AddPublisher (const core::TopicId &topic_id, typename Topic::PublisherCallback callback) |
| template<typename Topic > | |
| void | AddSubscriber (const core::TopicId &topic_id, typename Topic::SubscriberMessageCallback callback) |
Detailed Description
This is the basic implementation of IActivity interface. Inheriting classes, i.e. a concrete simulation activity, should implement their logic in ExecuteStep() and add needed pub/sub in AddPublisherAndSubscriber() method.
To join the simulation, an activity is basic component which can publish/subscribe message through communication channel and be scheduled by user config as desired. This class is the base class for any other customized activity.
Example of creating inherited 'MyActivity' using 'MyLogic' library This activity is listening to the Topic 'TopicSubscribingOn' and providing Topic 'TopicToBePublished', with corresponding underlying message type MyMessageType_Sub and MyMessageType_Pub.
Definition at line 77 of file base_activity.h.
Constructor & Destructor Documentation
◆ BaseActivity() [1/4]
| simulation_framework::core::lifecycle::BaseActivity::BaseActivity | ( | const std::string & | activity_name, |
| std::shared_ptr< core::CommunicationManager > | communication_manager_ptr, | ||
| std::unique_ptr< scheduling::ISchedulerClient > | scheduler_client | ||
| ) |
Construct an BaseActivity to join simulation
- Parameters
-
activity_name a unique name of activity in string, which is used as identifier for connections communication_manager_ptr communication manager interface to enable activity join in the com-channel scheduler_client the client which receives event from scheduler server
◆ BaseActivity() [2/4]
| simulation_framework::core::lifecycle::BaseActivity::BaseActivity | ( | const std::string & | activity_name, |
| std::shared_ptr< core::CommunicationManager > | communication_manager_ptr, | ||
| std::unique_ptr< scheduling::ISchedulerClient > | scheduler_client, | ||
| std::chrono::milliseconds | timeout | ||
| ) |
Construct an BaseActivity to join simulation
- Parameters
-
activity_name a unique name of activity in string, which is used as identifier for connections communication_manager_ptr communication manager interface to enable activity join in the com-channel scheduler_client the client which receives event from scheduler server timeout timeout in milliseconds for event handling
◆ BaseActivity() [3/4]
| simulation_framework::core::lifecycle::BaseActivity::BaseActivity | ( | const std::string & | activity_name, |
| const Topics & | topics | ||
| ) |
Construct an BaseActivity using RTIDDS communication to join simulation
- Parameters
-
activity_name A unique name of activity in string, which is used as identifier for connections topics Topics which this activity want to interact with, i.e. subscribe on or publish to
◆ BaseActivity() [4/4]
| simulation_framework::core::lifecycle::BaseActivity::BaseActivity | ( | const std::string & | activity_name, |
| const Topics & | topics, | ||
| std::chrono::milliseconds | timeout | ||
| ) |
Construct an BaseActivity using RTIDDS communication to join simulation
- Parameters
-
activity_name A unique name of activity in string, which is used as identifier for connections topics Topics which this activity want to interact with, i.e. subscribe on or publish to timeout Timeout in millisecond to wait until an event successfully received or sent
◆ ~BaseActivity()
|
virtual |
Destructor of an BaseActivity class
Member Function Documentation
◆ AddPublisher()
◆ AddPublisherAndSubscriber()
|
protectedpure virtual |
Addition of Pub/Sub into a concrete activity
Implemented in simulation_framework::core::lifecycle::FmuBaseActivity.
◆ AddSubscriber()
◆ ExecuteStep()
|
protectedpure virtual |
Core operation of customer logic in a concrete activity
Implemented in simulation_framework::core::lifecycle::FmuBaseActivity.
◆ GetCurrentTimestamp()
|
finalvirtual |
Get current simulation timestamp
Implements simulation_framework::core::lifecycle::IActivity.
◆ GetCycleTime()
|
finalvirtual |
- Returns
- Return cycle time of this activity
Implements simulation_framework::core::lifecycle::IActivity.
◆ GetInputFiles()
|
finalvirtual |
- Returns
- Return list of input files for simulation
Implements simulation_framework::core::lifecycle::IActivity.
◆ GetName()
|
overridevirtual |
- Returns
- the name of this activity
Implements simulation_framework::core::lifecycle::IActivity.
◆ GetSimulationOutputDirectory()
|
finalvirtual |
- Returns
- Return output directory of simulation
Implements simulation_framework::core::lifecycle::IActivity.
◆ Init()
Initialize this activity with customized action
Implements simulation_framework::core::lifecycle::IActivity.
Reimplemented in simulation_framework::core::lifecycle::FmuBaseActivity.
Definition at line 168 of file base_activity.h.
◆ SetUpCommunication()
|
finalvirtual |
Register this activity's bounding communications, managed by higher level. Modifying by inheriting classes is NOT allowed.
Implements simulation_framework::core::lifecycle::IActivity.
◆ Shutdown()
|
finalvirtual |
Active shutdown the simulation. Simulation will finish planned events before this and shutdown gracefully
Implements simulation_framework::core::lifecycle::IActivity.
◆ Step()
|
finalvirtual |
Calls the ExecuteStep() for internal logic and send/receive message from corresponding pub/sub, managed by higher level. Modifying by inheriting classes is NOT allowed.
Implements simulation_framework::core::lifecycle::IActivity.
The documentation for this class was generated from the following file:
Public Member Functions inherited from