SMACC
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Attributes | List of all members
cl_keyboard::ClKeyboard Class Reference

#include <cl_keyboard.h>

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

Public Member Functions

template<typename T >
void OnKeyPress (void(T::*callback)(char keypress), T *object)
 
 ClKeyboard ()
 
virtual ~ClKeyboard ()
 
virtual void initialize () override
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
void onKeyboardMessage (const std_msgs::UInt16 &unicode_keychar)
 
template<typename TEv >
void postKeyEvent ()
 
- Public Member Functions inherited from smacc::client_bases::SmaccSubscriberClient< std_msgs::UInt16 >
 SmaccSubscriberClient ()
 
 SmaccSubscriberClient (std::string topicname)
 
virtual ~SmaccSubscriberClient ()
 
boost::signals2::connection onMessageReceived (void(T::*callback)(const std_msgs::UInt16 &), T *object)
 
boost::signals2::connection onFirstMessageReceived (void(T::*callback)(const std_msgs::UInt16 &), T *object)
 
void onOrthogonalAllocation ()
 
virtual void initialize ()
 
- Public Member Functions inherited from smacc::ISmaccClient
 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
virtual void initialize ()
 
virtual std::string getName () const
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (std::string name)
 
virtual smacc::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)
 

Public Attributes

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

Private Attributes

bool initialized_
 

Additional Inherited Members

- Public Types inherited from smacc::client_bases::SmaccSubscriberClient< std_msgs::UInt16 >
typedef std_msgs::UInt16 TMessageType
 
- Protected Member Functions inherited from smacc::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)
 
void setStateMachine (ISmaccStateMachine *stateMachine)
 
void setOrthogonal (ISmaccOrthogonal *orthogonal)
 
- Protected Attributes inherited from smacc::client_bases::SmaccSubscriberClient< std_msgs::UInt16 >
ros::NodeHandle nh_
 
- Protected Attributes inherited from smacc::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc::ISmaccComponent > > components_
 

Detailed Description

Definition at line 148 of file cl_keyboard.h.

Constructor & Destructor Documentation

◆ ClKeyboard()

cl_keyboard::ClKeyboard::ClKeyboard ( )

◆ ~ClKeyboard()

cl_keyboard::ClKeyboard::~ClKeyboard ( )
virtual

Definition at line 9 of file cl_keyboard.cpp.

10{
11
12}

Member Function Documentation

◆ initialize()

void cl_keyboard::ClKeyboard::initialize ( )
overridevirtual

Reimplemented from smacc::client_bases::SmaccSubscriberClient< std_msgs::UInt16 >.

Definition at line 14 of file cl_keyboard.cpp.

14 {
15
16 SmaccSubscriberClient<std_msgs::UInt16>::initialize();
17
18 if (!this->initialized_) {
20 this->initialized_ = true;
21 }
22}
void onKeyboardMessage(const std_msgs::UInt16 &unicode_keychar)
Definition: cl_keyboard.cpp:24
boost::signals2::connection onMessageReceived(void(T::*callback)(const std_msgs::UInt16 &), T *object)

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

Here is the call graph for this function:

◆ onKeyboardMessage()

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

Definition at line 24 of file cl_keyboard.cpp.

24 {
25
26 postEventKeyPress(unicode_keychar);
27}
std::function< void(std_msgs::UInt16)> postEventKeyPress
Definition: cl_keyboard.h:166

References postEventKeyPress.

Referenced by initialize().

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 154 of file cl_keyboard.h.

155 {
156 //this->connectSignal(OnKeyPress_, callback, object);
157 this->getStateMachine()->createSignalConnection(OnKeyPress_, callback, object);
158 }
smacc::SmaccSignal< void(char keypress)> OnKeyPress_
Definition: cl_keyboard.h:151
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)

References smacc::ISmaccStateMachine::createSignalConnection(), and smacc::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 169 of file cl_keyboard.h.

170 {
171 // call to the base configuration to properly handling the message and initial message smacc events
173
174 postEventKeyPress = [=](auto unicode_keychar) {
175 char character = (char)unicode_keychar.data;
176 ROS_WARN("detected keyboard: %c", character);
177
178 if (character == 'a')
179 this->postKeyEvent<EvKeyPressA<ClKeyboard, TOrthogonal>>();
180 else if (character == 'b')
181 this->postKeyEvent<EvKeyPressB<ClKeyboard, TOrthogonal>>();
182 else if (character == 'c')
183 this->postKeyEvent<EvKeyPressC<ClKeyboard, TOrthogonal>>();
184 else if (character == 'd')
185 this->postKeyEvent<EvKeyPressD<ClKeyboard, TOrthogonal>>();
186 else if (character == 'e')
187 this->postKeyEvent<EvKeyPressE<ClKeyboard, TOrthogonal>>();
188 else if (character == 'f')
189 this->postKeyEvent<EvKeyPressF<ClKeyboard, TOrthogonal>>();
190 else if (character == 'g')
191 this->postKeyEvent<EvKeyPressG<ClKeyboard, TOrthogonal>>();
192 else if (character == 'h')
193 this->postKeyEvent<EvKeyPressH<ClKeyboard, TOrthogonal>>();
194 else if (character == 'y')
195 this->postKeyEvent<EvKeyPressI<ClKeyboard, TOrthogonal>>();
196 else if (character == 'j')
197 this->postKeyEvent<EvKeyPressJ<ClKeyboard, TOrthogonal>>();
198 else if (character == 'k')
199 this->postKeyEvent<EvKeyPressK<ClKeyboard, TOrthogonal>>();
200 else if (character == 'l')
201 this->postKeyEvent<EvKeyPressL<ClKeyboard, TOrthogonal>>();
202 else if (character == 'm')
203 this->postKeyEvent<EvKeyPressM<ClKeyboard, TOrthogonal>>();
204 else if (character == 'n')
205 this->postKeyEvent<EvKeyPressN<ClKeyboard, TOrthogonal>>();
206 else if (character == 'o')
207 this->postKeyEvent<EvKeyPressO<ClKeyboard, TOrthogonal>>();
208 else if (character == 'p')
209 this->postKeyEvent<EvKeyPressP<ClKeyboard, TOrthogonal>>();
210 else if (character == 'q')
211 this->postKeyEvent<EvKeyPressQ<ClKeyboard, TOrthogonal>>();
212 else if (character == 'r')
213 this->postKeyEvent<EvKeyPressR<ClKeyboard, TOrthogonal>>();
214 else if (character == 's')
215 this->postKeyEvent<EvKeyPressS<ClKeyboard, TOrthogonal>>();
216 else if (character == 't')
217 this->postKeyEvent<EvKeyPressT<ClKeyboard, TOrthogonal>>();
218 else if (character == 'u')
219 this->postKeyEvent<EvKeyPressU<ClKeyboard, TOrthogonal>>();
220 else if (character == 'v')
221 this->postKeyEvent<EvKeyPressV<ClKeyboard, TOrthogonal>>();
222 else if (character == 'w')
223 this->postKeyEvent<EvKeyPressW<ClKeyboard, TOrthogonal>>();
224 else if (character == 'x')
225 this->postKeyEvent<EvKeyPressX<ClKeyboard, TOrthogonal>>();
226 else if (character == 'y')
227 this->postKeyEvent<EvKeyPressY<ClKeyboard, TOrthogonal>>();
228 else if (character == 'z')
229 this->postKeyEvent<EvKeyPressZ<ClKeyboard, TOrthogonal>>();
230 OnKeyPress_(character); /* */
231 };
232 }

References OnKeyPress_, and postEventKeyPress.

◆ postKeyEvent()

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

Definition at line 237 of file cl_keyboard.h.

238 {
239 ROS_WARN("ClKeyboard ev: %s", smacc::demangleSymbol(typeid(TEv).name()).c_str());
240 this->postEvent<TEv>();
241 }
std::string demangleSymbol()
Definition: introspection.h:75

References smacc::introspection::demangleSymbol().

Here is the call graph for this function:

Member Data Documentation

◆ initialized_

bool cl_keyboard::ClKeyboard::initialized_
private

Definition at line 244 of file cl_keyboard.h.

Referenced by ClKeyboard(), and initialize().

◆ OnKeyPress_

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

Definition at line 151 of file cl_keyboard.h.

Referenced by onOrthogonalAllocation().

◆ postEventKeyPress

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

Definition at line 166 of file cl_keyboard.h.

Referenced by onKeyboardMessage(), and onOrthogonalAllocation().


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