SMACC2
Loading...
Searching...
No Matches
cl_keyboard::ClKeyboard Class Reference

#include <cl_keyboard.hpp>

Inheritance diagram for cl_keyboard::ClKeyboard:
Inheritance graph
Collaboration diagram for cl_keyboard::ClKeyboard:
Collaboration graph

Public Member Functions

 ClKeyboard ()
 
virtual ~ClKeyboard ()
 
virtual void onInitialize () override
 
template<typename T >
void OnKeyPress (void(T::*callback)(char keypress), T *object)
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
void onKeyboardMessage (const std_msgs::msg::UInt16 &unicode_keychar)
 
template<typename TEv >
void postKeyEvent ()
 
- Public Member Functions inherited from smacc2::client_bases::SmaccSubscriberClient< std_msgs::msg::UInt16 >
 SmaccSubscriberClient ()
 
 SmaccSubscriberClient (std::string topicname)
 
virtual ~SmaccSubscriberClient ()
 
boost::signals2::connection onMessageReceived (void(T::*callback)(const std_msgs::msg::UInt16 &), T *object)
 
boost::signals2::connection onFirstMessageReceived (void(T::*callback)(const std_msgs::msg::UInt16 &), T *object)
 
void onOrthogonalAllocation ()
 
- Public Member Functions inherited from smacc2::ISmaccClient
 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
virtual std::string getName () const
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (std::string name)
 
template<typename TComponent >
TComponent * getComponent (int index)
 
virtual smacc2::introspection::TypeInfo::Ptr getType ()
 
ISmaccStateMachinegetStateMachine ()
 
template<typename TSmaccSignal , typename T >
void connectSignal (TSmaccSignal &signal, void(T::*callback)(), T *object)
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
void getComponents (std::vector< std::shared_ptr< ISmaccComponent > > &components)
 
const std::vector< std::shared_ptr< ISmaccComponent > > & iterateComponents () const
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 

Public Attributes

smacc2::SmaccSignal< void(char keypress)> OnKeyPress_
 
std::function< void(std_msgs::msg::UInt16)> postEventKeyPress
 
- Public Attributes inherited from smacc2::client_bases::SmaccSubscriberClient< std_msgs::msg::UInt16 >
std::optional< std::string > topicName
 
std::optional< int > queueSize
 
smacc2::SmaccSignal< void(const std_msgs::msg::UInt16 &)> onFirstMessageReceived_
 
smacc2::SmaccSignal< void(const std_msgs::msg::UInt16 &)> onMessageReceived_
 
std::function< void(const std_msgs::msg::UInt16 &)> postMessageEvent
 
std::function< void(const std_msgs::msg::UInt16 &)> postInitialMessageEvent
 

Private Attributes

bool initialized_
 

Additional Inherited Members

- Public Types inherited from smacc2::client_bases::SmaccSubscriberClient< std_msgs::msg::UInt16 >
typedef std_msgs::msg::UInt16 TMessageType
 
- Protected Member Functions inherited from smacc2::client_bases::SmaccSubscriberClient< std_msgs::msg::UInt16 >
void onInitialize () override
 
- Protected Member Functions inherited from smacc2::ISmaccClient
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 
- Protected Attributes inherited from smacc2::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc2::ISmaccComponent > > components_
 

Detailed Description

Definition at line 162 of file cl_keyboard.hpp.

Constructor & Destructor Documentation

◆ ClKeyboard()

cl_keyboard::ClKeyboard::ClKeyboard ( )

◆ ~ClKeyboard()

cl_keyboard::ClKeyboard::~ClKeyboard ( )
virtual

Definition at line 31 of file cl_keyboard.cpp.

31{}

Member Function Documentation

◆ onInitialize()

void cl_keyboard::ClKeyboard::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccClient.

Definition at line 33 of file cl_keyboard.cpp.

34{
35 SmaccSubscriberClient<std_msgs::msg::UInt16>::onInitialize();
36
37 if (!this->initialized_)
38 {
40 this->initialized_ = true;
41 }
42}
void onKeyboardMessage(const std_msgs::msg::UInt16 &unicode_keychar)
boost::signals2::connection onMessageReceived(void(T::*callback)(const std_msgs::msg::UInt16 &), T *object)

References initialized_, onKeyboardMessage(), and smacc2::client_bases::SmaccSubscriberClient< std_msgs::msg::UInt16 >::onMessageReceived().

Here is the call graph for this function:

◆ onKeyboardMessage()

void cl_keyboard::ClKeyboard::onKeyboardMessage ( const std_msgs::msg::UInt16 & unicode_keychar)

Definition at line 44 of file cl_keyboard.cpp.

45{
46 postEventKeyPress(unicode_keychar);
47}
std::function< void(std_msgs::msg::UInt16)> postEventKeyPress

References postEventKeyPress.

Referenced by onInitialize().

Here is the caller graph for this function:

◆ OnKeyPress()

template<typename T >
void cl_keyboard::ClKeyboard::OnKeyPress ( void(T::* callback )(char keypress),
T * object )
inline

Definition at line 172 of file cl_keyboard.hpp.

173 {
174 //this->connectSignal(OnKeyPress_, callback, object);
175 this->getStateMachine()->createSignalConnection(OnKeyPress_, callback, object);
176 }
smacc2::SmaccSignal< void(char keypress)> OnKeyPress_
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)

References smacc2::ISmaccStateMachine::createSignalConnection(), and smacc2::ISmaccClient::getStateMachine().

Referenced by cl_keyboard::CbDefaultKeyboardBehavior::onEntry().

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

◆ onOrthogonalAllocation()

template<typename TOrthogonal , typename TSourceObject >
void cl_keyboard::ClKeyboard::onOrthogonalAllocation ( )
inline

Definition at line 181 of file cl_keyboard.hpp.

182 {
183 // call to the base configuration to properly handling the message and initial message smacc events
185 TOrthogonal, TSourceObject>();
186
187 postEventKeyPress = [=](auto unicode_keychar)
188 {
189 char character = (char)unicode_keychar.data;
190 RCLCPP_WARN(getLogger(), "detected keyboard: %c", character);
191
192 if (character == 'a')
194 else if (character == 'b')
196 else if (character == 'c')
198 else if (character == 'd')
200 else if (character == 'e')
202 else if (character == 'f')
204 else if (character == 'g')
206 else if (character == 'h')
208 else if (character == 'y')
210 else if (character == 'j')
212 else if (character == 'k')
214 else if (character == 'l')
216 else if (character == 'm')
218 else if (character == 'n')
220 else if (character == 'o')
222 else if (character == 'p')
224 else if (character == 'q')
226 else if (character == 'r')
228 else if (character == 's')
230 else if (character == 't')
232 else if (character == 'u')
234 else if (character == 'v')
236 else if (character == 'w')
238 else if (character == 'x')
240 else if (character == 'y')
242 else if (character == 'z')
244 OnKeyPress_(character); /* */
245 };
246 }
rclcpp::Logger getLogger()

References smacc2::ISmaccClient::getLogger(), OnKeyPress_, postEventKeyPress, and postKeyEvent().

Here is the call graph for this function:

◆ postKeyEvent()

template<typename TEv >
void cl_keyboard::ClKeyboard::postKeyEvent ( )
inline

Definition at line 251 of file cl_keyboard.hpp.

252 {
253 RCLCPP_WARN(
254 getLogger(), "ClKeyboard ev: %s", smacc2::demangleSymbol(typeid(TEv).name()).c_str());
255 this->postEvent<TEv>();
256 }
std::string demangleSymbol()

References smacc2::introspection::demangleSymbol(), smacc2::ISmaccClient::getLogger(), and smacc2::ISmaccClient::postEvent().

Referenced by onOrthogonalAllocation().

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

Member Data Documentation

◆ initialized_

bool cl_keyboard::ClKeyboard::initialized_
private

Definition at line 259 of file cl_keyboard.hpp.

Referenced by ClKeyboard(), and onInitialize().

◆ OnKeyPress_

smacc2::SmaccSignal<void(char keypress)> cl_keyboard::ClKeyboard::OnKeyPress_

Definition at line 169 of file cl_keyboard.hpp.

Referenced by onOrthogonalAllocation().

◆ postEventKeyPress

std::function<void(std_msgs::msg::UInt16)> cl_keyboard::ClKeyboard::postEventKeyPress

Definition at line 178 of file cl_keyboard.hpp.

Referenced by onKeyboardMessage(), and onOrthogonalAllocation().


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