simulation_framework::core::lifecycle::BaseActivity Class Reference
Last update: 19.09.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) | |
| Construct an BaseActivity to join simulation. | |
| 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. | |
| BaseActivity (const std::string &activity_name, const Topics &topics) | |
| Construct an BaseActivity using RTIDDS communication to join simulation. | |
| BaseActivity (const std::string &activity_name, const Topics &topics, std::chrono::milliseconds timeout) | |
| Construct an BaseActivity using RTIDDS communication to join simulation. | |
| virtual | ~BaseActivity () |
| Destructor of an BaseActivity class. | |
| std::string | GetName () const override |
| void | SetUpCommunication () final |
| Register this activity's bounding communications, managed by higher level. Modifying by inheriting classes is NOT allowed. | |
| void | Step () final |
| 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. | |
| void | Shutdown () final |
| time::Timestamp | GetCurrentTimestamp () const final |
| Get current simulation timestamp. | |
| std::chrono::milliseconds | GetCycleTime () const final |
| Return cycle time of this activity as duration in milliseconds. | |
| std::string | GetSimulationOutputDirectory () const final |
| Return output directory of simulation as string. | |
| const SimulationParameters::CustomizedParameters & | GetCustomizedParameters () const final |
| Retrieves the customized parameters for the activity. | |
| void | SetSimulationSettings (const scheduling::SimulationSettings &sim_settings) final |
| Set the simulation settings for this activity. | |
Public Member Functions inherited from simulation_framework::core::lifecycle::IActivity | |
| virtual | ~IActivity ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
Protected Member Functions | |
| void | Init () override |
| Initialize this activity with customized action. | |
| virtual void | ExecuteStep ()=0 |
| Core operation of customer logic in a concrete activity. | |
| virtual void | AddPublisherAndSubscriber ()=0 |
| Addition of Pub/Sub into a concrete activity. | |
| template<typename Topic > | |
| void | AddPublisher (const core::TopicId &topic_id, typename Topic::PublisherCallback callback) |
| Template method which allows user to add one publisher pushing message to the given Topic. | |
| template<typename Topic > | |
| void | AddSubscriber (const core::TopicId &topic_id, typename Topic::SubscriberMessageCallback callback) |
| Template method which allows user to add one subscriber receiving message to the given Topic. | |
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 75 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
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.
- Returns
- The current simulation timestamp
Implements simulation_framework::core::lifecycle::IActivity.
◆ GetCustomizedParameters()
|
finalvirtual |
Retrieves the customized parameters for the activity.
- Returns
- A map of customized parameters. key is the name of the customized parameter, value is the value of the customized parameter in type of
std::string.
Implements simulation_framework::core::lifecycle::IActivity.
◆ GetCycleTime()
|
finalvirtual |
Return cycle time of this activity as duration in milliseconds.
- Returns
- The cycle time of this activity as duration in milliseconds
Implements simulation_framework::core::lifecycle::IActivity.
◆ GetName()
|
overridevirtual |
- Returns
- the name of this activity
Implements simulation_framework::core::lifecycle::IActivity.
◆ GetSimulationOutputDirectory()
|
finalvirtual |
Return output directory of simulation as string.
- Returns
- The output directory of simulation
Implements simulation_framework::core::lifecycle::IActivity.
◆ Init()
|
inlineoverrideprotectedvirtual |
Initialize this activity with customized action.
Implements simulation_framework::core::lifecycle::IActivity.
Reimplemented in simulation_framework::core::lifecycle::FmuBaseActivity.
Definition at line 177 of file base_activity.h.
◆ SetSimulationSettings()
|
finalvirtual |
Set the simulation settings for this activity.
- Parameters
-
sim_settings The simulation settings struct
Implements simulation_framework::core::lifecycle::IActivity.
◆ 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