Skip to main content

AVxcelerate Simulation Framework 2025 R2 SP02

simulation_framework::core::lifecycle::BaseActivity Class Reference

Last update: 19.09.2025

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. More...

#include <base_activity.h>

Inheritance diagram for simulation_framework::core::lifecycle::BaseActivity:
Collaboration diagram for simulation_framework::core::lifecycle::BaseActivity:

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.

#include "core/lifecycle/activity/base_activity.h"
#include "my_logic.h"
class MyActivity : public BaseActivity
{
public:
MyActivity(const std::string& name,
std::shared_ptr<CommunicationManager> communication_manager_ptr,
void AddPublisherAndSubscriber() override
{
"TopicToBePublished", [&]() { return msg_pub_; }
);
"TopicSubscribingOn", [&](const MyMessageType_Sub& msg) { msg_sub_ = msg; }
);
}
void ExecuteStep() override
{
my_logic_.DoSomething();
msg_pub_ = my_logic_.GetUpdatedMsg(msg_sub_);
}
private:
MyLogic my_logic_;
MyMessageType_Sub msg_sub_{};
MyMessageType_Pub msg_pub_{};
};
This is the concrete Topic class that can be used for creation of a communication channel with given ...
Definition topic.h:38
This is the basic implementation of IActivity interface. Inheriting classes, i.e. a concrete simulati...
The namespace for all core functionalities under namespace simulation_framework.

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_namea unique name of activity in string, which is used as identifier for connections
communication_manager_ptrcommunication manager interface to enable activity join in the com-channel
scheduler_clientthe 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_namea unique name of activity in string, which is used as identifier for connections
communication_manager_ptrcommunication manager interface to enable activity join in the com-channel
scheduler_clientthe client which receives event from scheduler server
timeouttimeout 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_nameA unique name of activity in string, which is used as identifier for connections
topicsTopics 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_nameA unique name of activity in string, which is used as identifier for connections
topicsTopics which this activity want to interact with, i.e. subscribe on or publish to
timeoutTimeout in millisecond to wait until an event successfully received or sent

Member Function Documentation

◆ AddPublisher()

template<typename Topic >
void simulation_framework::core::lifecycle::BaseActivity::AddPublisher ( const core::TopicId &  topic_id,
typename Topic::PublisherCallback  callback 
)
protected

Template method which allows user to add one publisher pushing message to the given Topic.

Parameters
topic_idthe name of Topic in string
callbackpublisher callback function

◆ AddPublisherAndSubscriber()

virtual void simulation_framework::core::lifecycle::BaseActivity::AddPublisherAndSubscriber ( )
protectedpure virtual

Addition of Pub/Sub into a concrete activity.

Implemented in simulation_framework::core::lifecycle::FmuBaseActivity.

◆ AddSubscriber()

template<typename Topic >
void simulation_framework::core::lifecycle::BaseActivity::AddSubscriber ( const core::TopicId &  topic_id,
typename Topic::SubscriberMessageCallback  callback 
)
protected

Template method which allows user to add one subscriber receiving message to the given Topic.

Parameters
topic_idthe name of Topic in string
callbacksubscriber callback function

◆ ExecuteStep()

virtual void simulation_framework::core::lifecycle::BaseActivity::ExecuteStep ( )
protectedpure virtual

Core operation of customer logic in a concrete activity.

Implemented in simulation_framework::core::lifecycle::FmuBaseActivity.

◆ GetCurrentTimestamp()

time::Timestamp simulation_framework::core::lifecycle::BaseActivity::GetCurrentTimestamp ( ) const
finalvirtual

Get current simulation timestamp.

Returns
The current simulation timestamp

Implements simulation_framework::core::lifecycle::IActivity.

◆ GetCustomizedParameters()

const SimulationParameters::CustomizedParameters & simulation_framework::core::lifecycle::BaseActivity::GetCustomizedParameters ( ) const
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()

std::chrono::milliseconds simulation_framework::core::lifecycle::BaseActivity::GetCycleTime ( ) const
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()

std::string simulation_framework::core::lifecycle::BaseActivity::GetName ( ) const
overridevirtual
Returns
the name of this activity

Implements simulation_framework::core::lifecycle::IActivity.

◆ GetSimulationOutputDirectory()

std::string simulation_framework::core::lifecycle::BaseActivity::GetSimulationOutputDirectory ( ) const
finalvirtual

Return output directory of simulation as string.

Returns
The output directory of simulation

Implements simulation_framework::core::lifecycle::IActivity.

◆ Init()

void simulation_framework::core::lifecycle::BaseActivity::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.

177{}

◆ SetSimulationSettings()

void simulation_framework::core::lifecycle::BaseActivity::SetSimulationSettings ( const scheduling::SimulationSettings &  sim_settings)
finalvirtual

Set the simulation settings for this activity.

Parameters
sim_settingsThe simulation settings struct

Implements simulation_framework::core::lifecycle::IActivity.

◆ SetUpCommunication()

void simulation_framework::core::lifecycle::BaseActivity::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()

void simulation_framework::core::lifecycle::BaseActivity::Shutdown ( )
finalvirtual

Active shutdown the simulation. Simulation will finish planned events before this and shutdown gracefully

Implements simulation_framework::core::lifecycle::IActivity.

◆ Step()

void simulation_framework::core::lifecycle::BaseActivity::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:

Connect with Ansys