Fawkes API  Fawkes Development Version
fawkes::SwitchInterface Class Reference

SwitchInterface Fawkes BlackBoard Interface. More...

#include <>>

Inheritance diagram for fawkes::SwitchInterface:

Classes

class  DisableSwitchMessage
 DisableSwitchMessage Fawkes BlackBoard Interface Message. More...
 
class  EnableDurationMessage
 EnableDurationMessage Fawkes BlackBoard Interface Message. More...
 
class  EnableSwitchMessage
 EnableSwitchMessage Fawkes BlackBoard Interface Message. More...
 
class  SetMessage
 SetMessage Fawkes BlackBoard Interface Message. More...
 

Public Member Functions

virtual bool message_valid (const Message *message) const
 Check if message is valid and can be enqueued. More...
 
bool is_enabled () const
 Get enabled value. More...
 
void set_enabled (const bool new_enabled)
 Set enabled value. More...
 
size_t maxlenof_enabled () const
 Get maximum length of enabled value. More...
 
float value () const
 Get value value. More...
 
void set_value (const float new_value)
 Set value value. More...
 
size_t maxlenof_value () const
 Get maximum length of value value. More...
 
float history () const
 Get history value. More...
 
void set_history (const float new_history)
 Set history value. More...
 
size_t maxlenof_history () const
 Get maximum length of history value. More...
 
uint32_t short_activations () const
 Get short_activations value. More...
 
void set_short_activations (const uint32_t new_short_activations)
 Set short_activations value. More...
 
size_t maxlenof_short_activations () const
 Get maximum length of short_activations value. More...
 
uint32_t long_activations () const
 Get long_activations value. More...
 
void set_long_activations (const uint32_t new_long_activations)
 Set long_activations value. More...
 
size_t maxlenof_long_activations () const
 Get maximum length of long_activations value. More...
 
uint32_t activation_count () const
 Get activation_count value. More...
 
void set_activation_count (const uint32_t new_activation_count)
 Set activation_count value. More...
 
size_t maxlenof_activation_count () const
 Get maximum length of activation_count value. More...
 
virtual Messagecreate_message (const char *type) const
 Create message based on type name. More...
 
virtual void copy_values (const Interface *other)
 Copy values from other interface. More...
 
virtual const char * enum_tostring (const char *enumtype, int val) const
 Convert arbitrary enum value to string. More...
 
- Public Member Functions inherited from fawkes::Interface
virtual ~Interface ()
 Destructor. More...
 
bool oftype (const char *interface_type) const
 Check if interface is of given type. More...
 
const void * datachunk () const
 Get data chunk. More...
 
unsigned int datasize () const
 Get data size. More...
 
const char * type () const
 Get type of interface. More...
 
const char * id () const
 Get identifier of interface. More...
 
const char * uid () const
 Get unique identifier of interface. More...
 
unsigned short serial () const
 Get instance serial of interface. More...
 
unsigned int mem_serial () const
 Get memory serial of interface. More...
 
bool operator== (Interface &comp) const
 Check equality of two interfaces. More...
 
const unsigned char * hash () const
 Get interface hash. More...
 
size_t hash_size () const
 Get size of interface hash. More...
 
const char * hash_printable () const
 Get printable interface hash. More...
 
bool is_writer () const
 Check if this is a writing instance. More...
 
void set_validity (bool valid)
 Mark this interface invalid. More...
 
bool is_valid () const
 Check validity of interface. More...
 
const char * owner () const
 Get owner of interface. More...
 
void set_from_chunk (void *chunk)
 Set from a raw data chunk. More...
 
void resize_buffers (unsigned int num_buffers)
 Resize buffer array. More...
 
unsigned int num_buffers () const
 Get number of buffers. More...
 
void copy_shared_to_buffer (unsigned int buffer)
 Copy data from private memory to buffer. More...
 
void copy_private_to_buffer (unsigned int buffer)
 Copy data from private memory to buffer. More...
 
void read_from_buffer (unsigned int buffer)
 Copy data from buffer to private memory. More...
 
int compare_buffers (unsigned int buffer)
 Compare buffer to private memory. More...
 
Time buffer_timestamp (unsigned int buffer)
 Get time of a buffer. More...
 
void buffer_timestamp (unsigned int buffer, Time *timestamp)
 Get time of a buffer. More...
 
void read ()
 Read from BlackBoard into local copy. More...
 
void write ()
 Write from local copy into BlackBoard memory. More...
 
bool has_writer () const
 Check if there is a writer for the interface. More...
 
unsigned int num_readers () const
 Get the number of readers. More...
 
std::string writer () const
 Get owner name of writing interface instance. More...
 
std::list< std::string > readers () const
 Get owner names of reading interface instances. More...
 
bool changed () const
 Check if data has been changed. More...
 
const Timetimestamp () const
 Get timestamp of last write. More...
 
void set_auto_timestamping (bool enabled)
 Enable or disable automated timestamping. More...
 
void set_timestamp (const Time *t=NULL)
 Set timestamp. More...
 
void set_clock (Clock *clock)
 Set clock to use for timestamping. More...
 
void mark_data_changed ()
 Mark data as changed. More...
 
std::list< const char * > get_message_types ()
 Obtain a list of textual representations of the message types available for this interface. More...
 
unsigned int msgq_enqueue (Message *message)
 Enqueue message at end of queue. More...
 
unsigned int msgq_enqueue_copy (Message *message)
 Enqueue copy of message at end of queue. More...
 
void msgq_remove (Message *message)
 Remove message from queue. More...
 
void msgq_remove (unsigned int message_id)
 Remove message from queue. More...
 
unsigned int msgq_size ()
 Get size of message queue. More...
 
void msgq_flush ()
 Flush all messages. More...
 
void msgq_lock ()
 Lock message queue. More...
 
bool msgq_try_lock ()
 Try to lock message queue. More...
 
void msgq_unlock ()
 Unlock message queue. More...
 
void msgq_pop ()
 Erase first message from queue. More...
 
Messagemsgq_first ()
 Get the first message from the message queue. More...
 
bool msgq_empty ()
 Check if queue is empty. More...
 
void msgq_append (Message *message)
 Enqueue message. More...
 
template<class MessageType >
bool msgq_first_is ()
 Check if first message has desired type. More...
 
template<class MessageType >
MessageType * msgq_first ()
 Get first message casted to the desired type. More...
 
template<class MessageType >
MessageType * msgq_first (MessageType *&msg)
 Get first message casted to the desired type. More...
 
template<class MessageType >
MessageType * msgq_first_safe (MessageType *&msg) throw ()
 Get first message casted to the desired type without exceptions. More...
 
MessageQueue::MessageIterator msgq_begin ()
 Get start iterator for message queue. More...
 
MessageQueue::MessageIterator msgq_end ()
 Get end iterator for message queue. More...
 
InterfaceFieldIterator fields ()
 Get iterator over all fields of this interface instance. More...
 
InterfaceFieldIterator fields_end ()
 Invalid iterator. More...
 
unsigned int num_fields ()
 Get the number of fields in the interface. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from fawkes::Interface
static void parse_uid (const char *uid, std::string &type, std::string &id)
 Parse UID to type and ID strings. More...
 
- Protected Member Functions inherited from fawkes::Interface
 Interface ()
 Constructor. More...
 
void set_hash (unsigned char *ihash)
 Set hash. More...
 
void add_fieldinfo (interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
 Add an entry to the field info list. More...
 
void add_messageinfo (const char *name)
 Add an entry to the message info list. More...
 
- Protected Attributes inherited from fawkes::Interface
void * data_ptr
 Pointer to local memory storage. More...
 
unsigned int data_size
 Minimal data size to hold data storage. More...
 
bool data_changed
 Indicator if data has changed. More...
 
interface_data_ts_tdata_ts
 Pointer to data casted to timestamp struct. More...
 

Detailed Description

SwitchInterface Fawkes BlackBoard Interface.

This interface provides access to LEDs. The interface controls an intensity value between 0.0 (off) and 1.0 (on, max intensity). LEDs that do not support intensity setting can only be set to on and off.

Definition at line 33 of file SwitchInterface.h.

Member Function Documentation

◆ activation_count()

uint32_t fawkes::SwitchInterface::activation_count ( ) const

Get activation_count value.

Number that is to be incremented whenever a short or long activation happened. Can be used to decide if a change in status happened.

Returns
activation_count value

Definition at line 277 of file SwitchInterface.cpp.

Referenced by NaoQiButtonThread::loop(), and NaoGuiGtkWindow::~NaoGuiGtkWindow().

◆ copy_values()

void fawkes::SwitchInterface::copy_values ( const Interface other)
virtual

Copy values from other interface.

Parameters
otherother interface to copy values from

Implements fawkes::Interface.

Definition at line 329 of file SwitchInterface.cpp.

References fawkes::Message::type(), and fawkes::Interface::type().

◆ create_message()

Message * fawkes::SwitchInterface::create_message ( const char *  type) const
virtual

Create message based on type name.

This will create a new message of the given type. The type must be given without the InterfaceName:: prefix but just the plain class name of the message.

Parameters
typemessage type
Returns
message of the given type, empty
Exceptions
UnknownTypeExceptionthrown if this interface cannot create a message of the given type.

Implements fawkes::Interface.

Definition at line 308 of file SwitchInterface.cpp.

◆ enum_tostring()

const char * fawkes::SwitchInterface::enum_tostring ( const char *  enumtype,
int  val 
) const
virtual

Convert arbitrary enum value to string.

Given the string representation of the enum type and the value this method returns the string representation of the specific value, or the string UNKNOWN if the value is not defined. An exception is thrown if the enum type is invalid.

Parameters
enumtypeenum type as string
valvalue to convert
Returns
string representation of value
Exceptions
UnknownTypeExceptionthrown if enumtype is not specified for interface.

Implements fawkes::Interface.

Definition at line 340 of file SwitchInterface.cpp.

◆ history()

float fawkes::SwitchInterface::history ( ) const

Get history value.

This value records the number of seconds a switch has been enabled continuously – or not. The time is recorded in seconds. A positive value indicates time the switch was turned on, a negative value indicates the time (when converted to the absolute value) the button has not been pressed. Zero means "just initialized".

Returns
history value

Definition at line 162 of file SwitchInterface.cpp.

Referenced by NaoQiButtonThread::loop(), and NaoGuiGtkWindow::~NaoGuiGtkWindow().

◆ is_enabled()

bool fawkes::SwitchInterface::is_enabled ( ) const

◆ long_activations()

uint32_t fawkes::SwitchInterface::long_activations ( ) const

Get long_activations value.

Number of consecutive short clicks (turned on). Can be used to recognize patterns of clicks. This is an optional field.

Returns
long_activations value

Definition at line 240 of file SwitchInterface.cpp.

Referenced by NaoQiButtonThread::loop(), and NaoGuiGtkWindow::~NaoGuiGtkWindow().

◆ maxlenof_activation_count()

size_t fawkes::SwitchInterface::maxlenof_activation_count ( ) const

Get maximum length of activation_count value.

Returns
length of activation_count value, can be length of the array or number of maximum number of characters for a string

Definition at line 287 of file SwitchInterface.cpp.

◆ maxlenof_enabled()

size_t fawkes::SwitchInterface::maxlenof_enabled ( ) const

Get maximum length of enabled value.

Returns
length of enabled value, can be length of the array or number of maximum number of characters for a string

Definition at line 93 of file SwitchInterface.cpp.

◆ maxlenof_history()

size_t fawkes::SwitchInterface::maxlenof_history ( ) const

Get maximum length of history value.

Returns
length of history value, can be length of the array or number of maximum number of characters for a string

Definition at line 172 of file SwitchInterface.cpp.

◆ maxlenof_long_activations()

size_t fawkes::SwitchInterface::maxlenof_long_activations ( ) const

Get maximum length of long_activations value.

Returns
length of long_activations value, can be length of the array or number of maximum number of characters for a string

Definition at line 250 of file SwitchInterface.cpp.

◆ maxlenof_short_activations()

size_t fawkes::SwitchInterface::maxlenof_short_activations ( ) const

Get maximum length of short_activations value.

Returns
length of short_activations value, can be length of the array or number of maximum number of characters for a string

Definition at line 213 of file SwitchInterface.cpp.

◆ maxlenof_value()

size_t fawkes::SwitchInterface::maxlenof_value ( ) const

Get maximum length of value value.

Returns
length of value value, can be length of the array or number of maximum number of characters for a string

Definition at line 130 of file SwitchInterface.cpp.

◆ message_valid()

bool fawkes::SwitchInterface::message_valid ( const Message message) const
virtual

Check if message is valid and can be enqueued.

Parameters
messageMessage to check
Returns
true if the message is valid, false otherwise.

Implements fawkes::Interface.

Definition at line 713 of file SwitchInterface.cpp.

◆ set_activation_count()

void fawkes::SwitchInterface::set_activation_count ( const uint32_t  new_activation_count)

Set activation_count value.

Number that is to be incremented whenever a short or long activation happened. Can be used to decide if a change in status happened.

Parameters
new_activation_countnew activation_count value

Definition at line 300 of file SwitchInterface.cpp.

References fawkes::Interface::data_changed.

Referenced by NaoQiButtonThread::loop().

◆ set_enabled()

◆ set_history()

void fawkes::SwitchInterface::set_history ( const float  new_history)

Set history value.

This value records the number of seconds a switch has been enabled continuously – or not. The time is recorded in seconds. A positive value indicates time the switch was turned on, a negative value indicates the time (when converted to the absolute value) the button has not been pressed. Zero means "just initialized".

Parameters
new_historynew history value

Definition at line 189 of file SwitchInterface.cpp.

References fawkes::Interface::data_changed.

Referenced by NaoQiButtonThread::loop().

◆ set_long_activations()

void fawkes::SwitchInterface::set_long_activations ( const uint32_t  new_long_activations)

Set long_activations value.

Number of consecutive short clicks (turned on). Can be used to recognize patterns of clicks. This is an optional field.

Parameters
new_long_activationsnew long_activations value

Definition at line 263 of file SwitchInterface.cpp.

References fawkes::Interface::data_changed.

Referenced by NaoQiButtonThread::loop().

◆ set_short_activations()

void fawkes::SwitchInterface::set_short_activations ( const uint32_t  new_short_activations)

Set short_activations value.

Number of consecutive short clicks (turned on). Can be used to recognize patterns of clicks. This is an optional field.

Parameters
new_short_activationsnew short_activations value

Definition at line 226 of file SwitchInterface.cpp.

References fawkes::Interface::data_changed.

Referenced by NaoQiButtonThread::loop().

◆ set_value()

void fawkes::SwitchInterface::set_value ( const float  new_value)

Set value value.

If switches support multiple states these can be indicated with this value. For example for a switch that notes the intensity it could be a value in the valid range.

Parameters
new_valuenew value value

Definition at line 144 of file SwitchInterface.cpp.

References fawkes::Interface::data_changed.

Referenced by NaoQiButtonThread::loop().

◆ short_activations()

uint32_t fawkes::SwitchInterface::short_activations ( ) const

Get short_activations value.

Number of consecutive short clicks (turned on). Can be used to recognize patterns of clicks. This is an optional field.

Returns
short_activations value

Definition at line 203 of file SwitchInterface.cpp.

Referenced by NaoQiButtonThread::loop(), and NaoGuiGtkWindow::~NaoGuiGtkWindow().

◆ value()

float fawkes::SwitchInterface::value ( ) const

Get value value.

If switches support multiple states these can be indicated with this value. For example for a switch that notes the intensity it could be a value in the valid range.

Returns
value value

Definition at line 120 of file SwitchInterface.cpp.

Referenced by NaoGuiGtkWindow::~NaoGuiGtkWindow().


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