SMACC2
Loading...
Searching...
No Matches
cl_gcalcli::CbStatus Class Reference

Sync behavior that retrieves current calendar status. More...

#include <cb_status.hpp>

Inheritance diagram for cl_gcalcli::CbStatus:
Inheritance graph
Collaboration diagram for cl_gcalcli::CbStatus:
Collaboration graph

Public Member Functions

 CbStatus ()=default
 
virtual ~CbStatus ()=default
 
void onEntry () override
 
ConnectionState getConnectionState () const
 Get the connection state captured on entry.
 
bool isConnected () const
 Check if connected.
 
std::vector< CalendarEventgetEvents () const
 Get events captured on entry.
 
std::vector< CalendarEventgetActiveEvents () const
 Get currently active events.
 
- Public Member Functions inherited from smacc2::SmaccClientBehavior
virtual ~SmaccClientBehavior ()
 
void onEntry () override
 
void onExit () override
 
- Public Member Functions inherited from smacc2::ISmaccClientBehavior
 ISmaccClientBehavior ()
 
virtual ~ISmaccClientBehavior ()
 
ISmaccStateMachinegetStateMachine ()
 
std::string getName () const
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
template<typename SmaccComponentType >
void requiresComponent (SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
virtual void executeOnEntry ()
 
virtual void executeOnExit ()
 

Private Attributes

ClGcalcliclient_
 
ConnectionState connection_state_
 
std::vector< CalendarEventevents_
 
std::vector< CalendarEventactive_events_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccClientBehavior
virtual void runtimeConfigure ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
ISmaccStategetCurrentState ()
 
virtual void dispose ()
 
virtual rclcpp::Node::SharedPtr getNode () const
 
virtual rclcpp::Logger getLogger () const
 

Detailed Description

Sync behavior that retrieves current calendar status.

This behavior provides a snapshot of the current connection state and calendar events. Use it to check system status on state entry.

Definition at line 33 of file cb_status.hpp.

Constructor & Destructor Documentation

◆ CbStatus()

cl_gcalcli::CbStatus::CbStatus ( )
default

◆ ~CbStatus()

virtual cl_gcalcli::CbStatus::~CbStatus ( )
virtualdefault

Member Function Documentation

◆ getActiveEvents()

std::vector< CalendarEvent > cl_gcalcli::CbStatus::getActiveEvents ( ) const
inline

Get currently active events.

Definition at line 59 of file cb_status.hpp.

59{ return active_events_; }
std::vector< CalendarEvent > active_events_
Definition cb_status.hpp:65

References active_events_.

◆ getConnectionState()

ConnectionState cl_gcalcli::CbStatus::getConnectionState ( ) const
inline

Get the connection state captured on entry.

Definition at line 44 of file cb_status.hpp.

44{ return connection_state_; }
ConnectionState connection_state_
Definition cb_status.hpp:63

References connection_state_.

◆ getEvents()

std::vector< CalendarEvent > cl_gcalcli::CbStatus::getEvents ( ) const
inline

Get events captured on entry.

Definition at line 54 of file cb_status.hpp.

54{ return events_; }
std::vector< CalendarEvent > events_
Definition cb_status.hpp:64

References events_.

◆ isConnected()

bool cl_gcalcli::CbStatus::isConnected ( ) const
inline

Check if connected.

Definition at line 49 of file cb_status.hpp.

References cl_gcalcli::CONNECTED, and connection_state_.

◆ onEntry()

void cl_gcalcli::CbStatus::onEntry ( )
overridevirtual

Reimplemented from smacc2::ISmaccClientBehavior.

Definition at line 20 of file cb_status.cpp.

21{
23
24 if (!client_)
25 {
26 RCLCPP_ERROR(getLogger(), "[CbStatus] ClGcalcli client not available");
28 return;
29 }
30
31 auto * connection = client_->getConnection();
32 auto * poller = client_->getPoller();
33
34 if (connection)
35 {
36 connection_state_ = connection->getConnectionState();
37 }
38 else
39 {
41 }
42
43 if (poller)
44 {
45 events_ = poller->getEvents();
46 active_events_ = poller->getActiveEvents();
47 }
48
49 RCLCPP_INFO(
50 getLogger(), "[CbStatus] Connection: %s, Events: %zu, Active: %zu",
54 : "ERROR",
55 events_.size(), active_events_.size());
56}
ClGcalcli * client_
Definition cb_status.hpp:62
CpGcalcliConnection * getConnection()
CpCalendarPoller * getPoller()
virtual rclcpp::Logger getLogger() const
void requiresClient(SmaccClientType *&storage)

References active_events_, cl_gcalcli::AUTHENTICATING, client_, cl_gcalcli::CONNECTED, connection_state_, cl_gcalcli::DISCONNECTED, cl_gcalcli::ERROR, events_, cl_gcalcli::ClGcalcli::getConnection(), smacc2::ISmaccClientBehavior::getLogger(), cl_gcalcli::ClGcalcli::getPoller(), and smacc2::ISmaccClientBehavior::requiresClient().

Here is the call graph for this function:

Member Data Documentation

◆ active_events_

std::vector<CalendarEvent> cl_gcalcli::CbStatus::active_events_
private

Definition at line 65 of file cb_status.hpp.

Referenced by getActiveEvents(), and onEntry().

◆ client_

ClGcalcli* cl_gcalcli::CbStatus::client_
private

Definition at line 62 of file cb_status.hpp.

Referenced by onEntry().

◆ connection_state_

ConnectionState cl_gcalcli::CbStatus::connection_state_
private

Definition at line 63 of file cb_status.hpp.

Referenced by getConnectionState(), isConnected(), and onEntry().

◆ events_

std::vector<CalendarEvent> cl_gcalcli::CbStatus::events_
private

Definition at line 64 of file cb_status.hpp.

Referenced by getEvents(), and onEntry().


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