|
SMACC2
|
Component that polls Google Calendar and parses event data. More...
#include <cp_calendar_poller.hpp>


Public Member Functions | |
| CpCalendarPoller () | |
| virtual | ~CpCalendarPoller ()=default |
| void | onInitialize () override |
| bool | refreshAgenda () |
| Force an immediate agenda refresh. | |
| std::vector< CalendarEvent > | getEvents () const |
| Get cached list of calendar events. | |
| std::vector< CalendarEvent > | findEvents (const std::string &pattern, bool use_regex=false) const |
| Get events matching a title pattern. | |
| std::vector< CalendarEvent > | getEventsInWindow (std::chrono::system_clock::time_point start, std::chrono::system_clock::time_point end) const |
| Get events happening within a time window. | |
| std::vector< CalendarEvent > | getActiveEvents () const |
| Get currently active events. | |
| std::chrono::system_clock::time_point | getLastPollTime () const |
| Get the time of the last successful poll. | |
| template<typename T > | |
| smacc2::SmaccSignalConnection | onAgendaUpdated (void(T::*callback)(const std::vector< CalendarEvent > &), T *object) |
| template<typename TOrthogonal , typename TSourceObject > | |
| void | onStateOrthogonalAllocation () |
| Template method for type-safe event posting setup. | |
Public Member Functions inherited from smacc2::ISmaccComponent | |
| ISmaccComponent () | |
| virtual | ~ISmaccComponent () |
| virtual std::string | getName () const |
Public Member Functions inherited from smacc2::ISmaccUpdatable | |
| ISmaccUpdatable () | |
| ISmaccUpdatable (rclcpp::Duration duration) | |
| void | executeUpdate (rclcpp::Node::SharedPtr node) |
| void | setUpdatePeriod (rclcpp::Duration duration) |
Public Attributes | |
| smacc2::SmaccSignal< void(const std::vector< CalendarEvent > &)> | onAgendaUpdated_ |
| std::function< void(const std::vector< CalendarEvent > &)> | postAgendaUpdatedEvent_ |
Protected Member Functions | |
| void | update () override |
| Periodic update for polling (called by SignalDetector) | |
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 |
| ISmaccStateMachine * | getStateMachine () |
Protected Member Functions inherited from smacc2::ISmaccUpdatable | |
Private Member Functions | |
| std::vector< CalendarEvent > | parseTsvOutput (const std::string &output) |
| Parse TSV output into CalendarEvent structures. | |
| std::optional< CalendarEvent > | parseTsvLine (const std::string &line) |
| Parse a single TSV line into a CalendarEvent. | |
| std::optional< std::chrono::system_clock::time_point > | parseDateTime (const std::string &date_str, const std::string &time_str) |
| Parse date and time strings into time_point. | |
| std::string | generateEventId (const CalendarEvent &event) |
| Generate a unique ID for an event. | |
Private Attributes | |
| CpGcalcliConnection * | connection_ |
| std::vector< CalendarEvent > | cached_events_ |
| std::chrono::system_clock::time_point | last_poll_time_ |
| std::chrono::steady_clock::time_point | last_poll_attempt_ |
| bool | initialized_ |
| std::mutex | events_mutex_ |
Additional Inherited Members | |
Protected Attributes inherited from smacc2::ISmaccComponent | |
| ISmaccStateMachine * | stateMachine_ |
| ISmaccClient * | owner_ |
Component that polls Google Calendar and parses event data.
This component periodically fetches the agenda from Google Calendar using gcalcli's TSV output format and parses it into CalendarEvent structures.
TSV Format: Start_Date | Start_Time | End_Date | End_Time | Title | Location | Description | Calendar
Definition at line 43 of file cp_calendar_poller.hpp.
| cl_gcalcli::CpCalendarPoller::CpCalendarPoller | ( | ) |
Definition at line 24 of file cp_calendar_poller.cpp.
|
virtualdefault |
| std::vector< CalendarEvent > cl_gcalcli::CpCalendarPoller::findEvents | ( | const std::string & | pattern, |
| bool | use_regex = false ) const |
Get events matching a title pattern.
| pattern | Pattern to match (regex or exact based on use_regex) |
| use_regex | If true, use regex matching |
Definition at line 109 of file cp_calendar_poller.cpp.
References cached_events_, events_mutex_, and smacc2::ISmaccComponent::getLogger().

|
private |
Generate a unique ID for an event.
Definition at line 384 of file cp_calendar_poller.cpp.
References cl_gcalcli::CalendarEvent::start_time.
Referenced by parseTsvLine().

| std::vector< CalendarEvent > cl_gcalcli::CpCalendarPoller::getActiveEvents | ( | ) | const |
Get currently active events.
Definition at line 166 of file cp_calendar_poller.cpp.
References cached_events_, and events_mutex_.
| std::vector< CalendarEvent > cl_gcalcli::CpCalendarPoller::getEvents | ( | ) | const |
Get cached list of calendar events.
Definition at line 103 of file cp_calendar_poller.cpp.
References cached_events_, and events_mutex_.
| std::vector< CalendarEvent > cl_gcalcli::CpCalendarPoller::getEventsInWindow | ( | std::chrono::system_clock::time_point | start, |
| std::chrono::system_clock::time_point | end ) const |
Get events happening within a time window.
Definition at line 148 of file cp_calendar_poller.cpp.
References cached_events_, and events_mutex_.
| std::chrono::system_clock::time_point cl_gcalcli::CpCalendarPoller::getLastPollTime | ( | ) | const |
Get the time of the last successful poll.
Definition at line 182 of file cp_calendar_poller.cpp.
References events_mutex_, and last_poll_time_.
|
inline |
Definition at line 90 of file cp_calendar_poller.hpp.
References smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccComponent::getStateMachine().
Referenced by cl_gcalcli::CpCalendarEventListener::onInitialize().


|
overridevirtual |
Reimplemented from smacc2::ISmaccComponent.
Definition at line 26 of file cp_calendar_poller.cpp.
References connection_, smacc2::ISmaccComponent::getLogger(), initialized_, last_poll_attempt_, and smacc2::ISmaccComponent::requiresComponent().

|
inline |
Template method for type-safe event posting setup.
Definition at line 103 of file cp_calendar_poller.hpp.
References postAgendaUpdatedEvent_, and smacc2::ISmaccComponent::postEvent().

|
private |
Parse date and time strings into time_point.
| date_str | Date string (MM/DD/YYYY or similar) |
| time_str | Time string (HH:MM or similar) |
Definition at line 296 of file cp_calendar_poller.cpp.
References smacc2::ISmaccComponent::getLogger().
Referenced by parseTsvLine().


|
private |
Parse a single TSV line into a CalendarEvent.
Definition at line 235 of file cp_calendar_poller.cpp.
References generateEventId(), smacc2::ISmaccComponent::getLogger(), and parseDateTime().
Referenced by parseTsvOutput().


|
private |
Parse TSV output into CalendarEvent structures.
Definition at line 211 of file cp_calendar_poller.cpp.
References parseTsvLine().
Referenced by refreshAgenda().


| bool cl_gcalcli::CpCalendarPoller::refreshAgenda | ( | ) |
Force an immediate agenda refresh.
Definition at line 45 of file cp_calendar_poller.cpp.
References cached_events_, connection_, events_mutex_, cl_gcalcli::CpGcalcliConnection::executeGcalcli(), cl_gcalcli::CpGcalcliConnection::getConfig(), smacc2::ISmaccComponent::getLogger(), cl_gcalcli::CpGcalcliConnection::isConnected(), last_poll_time_, onAgendaUpdated_, parseTsvOutput(), and postAgendaUpdatedEvent_.
Referenced by update().


|
overrideprotectedvirtual |
Periodic update for polling (called by SignalDetector)
Implements smacc2::ISmaccUpdatable.
Definition at line 188 of file cp_calendar_poller.cpp.
References connection_, cl_gcalcli::CpGcalcliConnection::getConfig(), initialized_, cl_gcalcli::CpGcalcliConnection::isConnected(), last_poll_attempt_, and refreshAgenda().

|
private |
Definition at line 144 of file cp_calendar_poller.hpp.
Referenced by findEvents(), getActiveEvents(), getEvents(), getEventsInWindow(), and refreshAgenda().
|
private |
Definition at line 143 of file cp_calendar_poller.hpp.
Referenced by onInitialize(), refreshAgenda(), and update().
|
mutableprivate |
Definition at line 149 of file cp_calendar_poller.hpp.
Referenced by findEvents(), getActiveEvents(), getEvents(), getEventsInWindow(), getLastPollTime(), and refreshAgenda().
|
private |
Definition at line 147 of file cp_calendar_poller.hpp.
Referenced by onInitialize(), and update().
|
private |
Definition at line 146 of file cp_calendar_poller.hpp.
Referenced by onInitialize(), and update().
|
private |
Definition at line 145 of file cp_calendar_poller.hpp.
Referenced by getLastPollTime(), and refreshAgenda().
| smacc2::SmaccSignal<void(const std::vector<CalendarEvent> &)> cl_gcalcli::CpCalendarPoller::onAgendaUpdated_ |
Definition at line 86 of file cp_calendar_poller.hpp.
Referenced by refreshAgenda().
| std::function<void(const std::vector<CalendarEvent> &)> cl_gcalcli::CpCalendarPoller::postAgendaUpdatedEvent_ |
Definition at line 97 of file cp_calendar_poller.hpp.
Referenced by onStateOrthogonalAllocation(), and refreshAgenda().