SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
smacc2::state_reactors::SrEventCountdown Class Reference

#include <sr_event_countdown.hpp>

Inheritance diagram for smacc2::state_reactors::SrEventCountdown:
Inheritance graph
Collaboration diagram for smacc2::state_reactors::SrEventCountdown:
Collaboration graph

Public Member Functions

 SrEventCountdown (int eventCount)
 
virtual void onInitialized () override
 
virtual void onEventNotified (const std::type_info *eventType) override
 
virtual bool triggers () override
 
- Public Member Functions inherited from smacc2::StateReactor
 StateReactor ()
 
virtual ~StateReactor ()
 
virtual void onInitialized ()
 
virtual void onEntry ()
 
virtual void onExit ()
 
virtual void onEventNotified (const std::type_info *eventType)
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename T , typename TClass >
void createEventCallback (void(TClass::*callback)(T *), TClass *object)
 
template<typename T >
void createEventCallback (std::function< void(T *)> callback)
 
void update ()
 
virtual bool triggers ()=0
 
template<typename TEv >
void addInputEvent ()
 
template<typename TEv >
void setOutputEvent ()
 
void initialize (ISmaccState *ownerState)
 
rclcpp::Node::SharedPtr & getNode ()
 
rclcpp::Logger getLogger ()
 

Private Attributes

std::map< const std::type_info *, booltriggeredEvents
 
int eventCount_
 

Additional Inherited Members

- Public Attributes inherited from smacc2::StateReactor
ISmaccStateownerState
 
std::function< void()> postEventFn
 
std::vector< const std::type_info * > eventTypes
 
std::map< const std::type_info *, std::function< void(void *)> > eventCallbacks_
 

Detailed Description

Definition at line 32 of file sr_event_countdown.hpp.

Constructor & Destructor Documentation

◆ SrEventCountdown()

smacc2::state_reactors::SrEventCountdown::SrEventCountdown ( int  eventCount)

Definition at line 24 of file sr_event_countdown.cpp.

Member Function Documentation

◆ onEventNotified()

void smacc2::state_reactors::SrEventCountdown::onEventNotified ( const std::type_info *  eventType)
overridevirtual

Reimplemented from smacc2::StateReactor.

Definition at line 34 of file sr_event_countdown.cpp.

35{
37 RCLCPP_INFO_STREAM(
38 getLogger(), "SB COUNTDOWN (" << eventCount_ << ") RECEIVED EVENT OF TYPE:"
39 << demangleSymbol(eventType->name()));
40
41 // RCLCPP_INFO_STREAM(getLogger(),"SB ALL RECEIVED EVENT OF TYPE:" << demangleSymbol(eventType->name()));
42 // triggeredEvents[eventType] = true;
43
44 // for (auto &entry : triggeredEvents)
45 // {
46 // RCLCPP_INFO_STREAM(getLogger(),demangleSymbol(entry.first->name()) << " = " << entry.second);
47 // }
48}
rclcpp::Logger getLogger()
std::string demangleSymbol()

References smacc2::introspection::demangleSymbol(), eventCount_, and smacc2::StateReactor::getLogger().

Here is the call graph for this function:

◆ onInitialized()

void smacc2::state_reactors::SrEventCountdown::onInitialized ( )
overridevirtual

Reimplemented from smacc2::StateReactor.

Definition at line 26 of file sr_event_countdown.cpp.

27{
28 for (auto type : eventTypes)
29 {
30 triggeredEvents[type] = false;
31 }
32}
std::vector< const std::type_info * > eventTypes
std::map< const std::type_info *, bool > triggeredEvents

References smacc2::StateReactor::eventTypes, and triggeredEvents.

◆ triggers()

bool smacc2::state_reactors::SrEventCountdown::triggers ( )
overridevirtual

Implements smacc2::StateReactor.

Definition at line 50 of file sr_event_countdown.cpp.

51{
52 if (eventCount_ == 0)
53 {
54 RCLCPP_INFO_STREAM(getLogger(), "SB COUNTDOWN (" << eventCount_ << ") TRIGGERS!");
55 return true;
56 }
57 else
58 {
59 return false;
60 }
61
62 // RCLCPP_INFO(getLogger(),"SB All TRIGGERS?");
63 // for (auto &entry : triggeredEvents)
64 // {
65 // if (!entry.second)
66 // return false;
67 // }
68 // RCLCPP_INFO(getLogger(),"SB ALL TRIGGERED");
69 // return true;
70}

References eventCount_, and smacc2::StateReactor::getLogger().

Here is the call graph for this function:

Member Data Documentation

◆ eventCount_

int smacc2::state_reactors::SrEventCountdown::eventCount_
private

Definition at line 36 of file sr_event_countdown.hpp.

Referenced by onEventNotified(), and triggers().

◆ triggeredEvents

std::map<const std::type_info *, bool> smacc2::state_reactors::SrEventCountdown::triggeredEvents
private

Definition at line 35 of file sr_event_countdown.hpp.

Referenced by onInitialized().


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