SMACC2
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)
 
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{
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_, smacc2::client_bases::SmaccSubscriberClient< std_msgs::msg::UInt16 >::onInitialize(), 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);
176 }
smacc2::SmaccSignal< void(char keypress)> OnKeyPress_
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
void callback(const image_tools::ROSCvMatContainer &img)

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

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

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 258 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: