SMACC2
Loading...
Searching...
No Matches
cl_mission_tracker::CpDecisionManager Class Reference

Component that manages mission decision state. More...

#include <cp_decision_manager.hpp>

Inheritance diagram for cl_mission_tracker::CpDecisionManager:
Inheritance graph
Collaboration diagram for cl_mission_tracker::CpDecisionManager:
Collaboration graph

Public Member Functions

 CpDecisionManager ()=default
 
virtual ~CpDecisionManager ()=default
 
void onInitialize () override
 
int getDecisionCounter () const
 Get the current decision counter value.
 
int nextDecision ()
 Increment the decision counter and return the previous value.
 
void resetDecisionCounter ()
 Reset the decision counter to zero.
 
void setDecisionCounter (int value)
 Set the decision counter to a specific value.
 
- Public Member Functions inherited from smacc2::ISmaccComponent
 ISmaccComponent ()
 
virtual ~ISmaccComponent ()
 
virtual std::string getName () const
 

Private Attributes

std::mutex mutex_
 
int decisionCounter_ = 0
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccComponent
template<typename TOrthogonal , typename TClient >
void onComponentInitialization ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
template<typename TComponent >
void requiresComponent (TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename TComponent >
void requiresComponent (std::string name, TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename TClient >
void requiresClient (TClient *&requiredClientStorage)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger () const
 
ISmaccStateMachinegetStateMachine ()
 
- Protected Attributes inherited from smacc2::ISmaccComponent
ISmaccStateMachinestateMachine_
 
ISmaccClientowner_
 

Detailed Description

Component that manages mission decision state.

This component tracks the decision counter for mission sequencing. It provides thread-safe access to decision state, separating mission logic from the client orchestrator.

Definition at line 36 of file cp_decision_manager.hpp.

Constructor & Destructor Documentation

◆ CpDecisionManager()

cl_mission_tracker::CpDecisionManager::CpDecisionManager ( )
default

◆ ~CpDecisionManager()

virtual cl_mission_tracker::CpDecisionManager::~CpDecisionManager ( )
virtualdefault

Member Function Documentation

◆ getDecisionCounter()

int cl_mission_tracker::CpDecisionManager::getDecisionCounter ( ) const
inline

Get the current decision counter value.

Returns
Current decision count

Definition at line 49 of file cp_decision_manager.hpp.

50 {
51 std::lock_guard<std::mutex> lock(mutex_);
52 return decisionCounter_;
53 }

References decisionCounter_, and mutex_.

◆ nextDecision()

int cl_mission_tracker::CpDecisionManager::nextDecision ( )
inline

Increment the decision counter and return the previous value.

Returns
Decision count before incrementing

Definition at line 59 of file cp_decision_manager.hpp.

60 {
61 std::lock_guard<std::mutex> lock(mutex_);
62 int current = decisionCounter_;
64 RCLCPP_INFO_STREAM(
65 getLogger(), "[CpDecisionManager] Decision " << current << " -> " << decisionCounter_);
66 return current;
67 }
rclcpp::Logger getLogger() const

References decisionCounter_, smacc2::ISmaccComponent::getLogger(), and mutex_.

Referenced by cl_mission_tracker::CbBatteryDecission::onOrthogonalAllocation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onInitialize()

void cl_mission_tracker::CpDecisionManager::onInitialize ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccComponent.

Definition at line 43 of file cp_decision_manager.hpp.

43{ RCLCPP_INFO(getLogger(), "[CpDecisionManager] Initialized"); }

References smacc2::ISmaccComponent::getLogger().

Here is the call graph for this function:

◆ resetDecisionCounter()

void cl_mission_tracker::CpDecisionManager::resetDecisionCounter ( )
inline

Reset the decision counter to zero.

Definition at line 72 of file cp_decision_manager.hpp.

73 {
74 std::lock_guard<std::mutex> lock(mutex_);
76 RCLCPP_INFO(getLogger(), "[CpDecisionManager] Decision counter reset");
77 }

References decisionCounter_, smacc2::ISmaccComponent::getLogger(), and mutex_.

Here is the call graph for this function:

◆ setDecisionCounter()

void cl_mission_tracker::CpDecisionManager::setDecisionCounter ( int value)
inline

Set the decision counter to a specific value.

Parameters
valueNew counter value

Definition at line 83 of file cp_decision_manager.hpp.

84 {
85 std::lock_guard<std::mutex> lock(mutex_);
86 decisionCounter_ = value;
87 RCLCPP_INFO_STREAM(getLogger(), "[CpDecisionManager] Decision counter set to " << value);
88 }

References decisionCounter_, smacc2::ISmaccComponent::getLogger(), and mutex_.

Here is the call graph for this function:

Member Data Documentation

◆ decisionCounter_

int cl_mission_tracker::CpDecisionManager::decisionCounter_ = 0
private

◆ mutex_

std::mutex cl_mission_tracker::CpDecisionManager::mutex_
mutableprivate

The documentation for this class was generated from the following file: