SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Attributes | List of all members
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 void onInitialize ()
 
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 25 of file cl_keyboard.cpp.

25{}

Member Function Documentation

◆ onInitialize()

void cl_keyboard::ClKeyboard::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccClient.

Definition at line 27 of file cl_keyboard.cpp.

28{
29 SmaccSubscriberClient<std_msgs::msg::UInt16>::onInitialize();
30
31 if (!this->initialized_)
32 {
34 this->initialized_ = true;
35 }
36}
void onKeyboardMessage(const std_msgs::msg::UInt16 &unicode_keychar)
Definition: cl_keyboard.cpp:38
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 38 of file cl_keyboard.cpp.

39{
40 postEventKeyPress(unicode_keychar);
41}
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::*)(char keypress)  callback,
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')
193 this->postKeyEvent<EvKeyPressA<ClKeyboard, TOrthogonal>>();
194 else if (character == 'b')
195 this->postKeyEvent<EvKeyPressB<ClKeyboard, TOrthogonal>>();
196 else if (character == 'c')
197 this->postKeyEvent<EvKeyPressC<ClKeyboard, TOrthogonal>>();
198 else if (character == 'd')
199 this->postKeyEvent<EvKeyPressD<ClKeyboard, TOrthogonal>>();
200 else if (character == 'e')
201 this->postKeyEvent<EvKeyPressE<ClKeyboard, TOrthogonal>>();
202 else if (character == 'f')
203 this->postKeyEvent<EvKeyPressF<ClKeyboard, TOrthogonal>>();
204 else if (character == 'g')
205 this->postKeyEvent<EvKeyPressG<ClKeyboard, TOrthogonal>>();
206 else if (character == 'h')
207 this->postKeyEvent<EvKeyPressH<ClKeyboard, TOrthogonal>>();
208 else if (character == 'y')
209 this->postKeyEvent<EvKeyPressI<ClKeyboard, TOrthogonal>>();
210 else if (character == 'j')
211 this->postKeyEvent<EvKeyPressJ<ClKeyboard, TOrthogonal>>();
212 else if (character == 'k')
213 this->postKeyEvent<EvKeyPressK<ClKeyboard, TOrthogonal>>();
214 else if (character == 'l')
215 this->postKeyEvent<EvKeyPressL<ClKeyboard, TOrthogonal>>();
216 else if (character == 'm')
217 this->postKeyEvent<EvKeyPressM<ClKeyboard, TOrthogonal>>();
218 else if (character == 'n')
219 this->postKeyEvent<EvKeyPressN<ClKeyboard, TOrthogonal>>();
220 else if (character == 'o')
221 this->postKeyEvent<EvKeyPressO<ClKeyboard, TOrthogonal>>();
222 else if (character == 'p')
223 this->postKeyEvent<EvKeyPressP<ClKeyboard, TOrthogonal>>();
224 else if (character == 'q')
225 this->postKeyEvent<EvKeyPressQ<ClKeyboard, TOrthogonal>>();
226 else if (character == 'r')
227 this->postKeyEvent<EvKeyPressR<ClKeyboard, TOrthogonal>>();
228 else if (character == 's')
229 this->postKeyEvent<EvKeyPressS<ClKeyboard, TOrthogonal>>();
230 else if (character == 't')
231 this->postKeyEvent<EvKeyPressT<ClKeyboard, TOrthogonal>>();
232 else if (character == 'u')
233 this->postKeyEvent<EvKeyPressU<ClKeyboard, TOrthogonal>>();
234 else if (character == 'v')
235 this->postKeyEvent<EvKeyPressV<ClKeyboard, TOrthogonal>>();
236 else if (character == 'w')
237 this->postKeyEvent<EvKeyPressW<ClKeyboard, TOrthogonal>>();
238 else if (character == 'x')
239 this->postKeyEvent<EvKeyPressX<ClKeyboard, TOrthogonal>>();
240 else if (character == 'y')
241 this->postKeyEvent<EvKeyPressY<ClKeyboard, TOrthogonal>>();
242 else if (character == 'z')
243 this->postKeyEvent<EvKeyPressZ<ClKeyboard, TOrthogonal>>();
244 OnKeyPress_(character); /* */
245 };
246 }
rclcpp::Logger getLogger()

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

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(), and smacc2::ISmaccClient::getLogger().

Here is the call 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: