#include <interface/interface.h>
Inheritance diagram for fawkes::Interface:
Public Member Functions | |
virtual | ~Interface () |
Destructor. | |
bool | oftype (const char *interface_type) const |
Check if interface is of given type. | |
const void * | datachunk () const |
Get data chunk. | |
unsigned int | datasize () const |
Get data size. | |
const char * | type () const |
Get type of interface. | |
const char * | id () const |
Get identifier of interface. | |
const char * | uid () const |
Get unique identifier of interface. | |
unsigned short | serial () const |
Get instance serial of interface. | |
unsigned int | mem_serial () const |
Get memory serial of interface. | |
bool | operator== (Interface &comp) const |
Check equality of two interfaces. | |
const unsigned char * | hash () const |
Get interface hash. | |
size_t | hash_size () const |
Get size of interface hash. | |
const char * | hash_printable () const |
Get printable interface hash. | |
bool | is_writer () const |
Check if this is a writing instance. | |
void | set_validity (bool valid) |
Mark this interface invalid. | |
bool | is_valid () const |
Check validity of interface. | |
void | set_from_chunk (void *chunk) |
Set from a raw data chunk. | |
virtual Message * | create_message (const char *type) const =0 |
Create message based on type name. | |
virtual void | copy_values (const Interface *interface)=0 |
Copy values from another interface. | |
virtual const char * | enum_tostring (const char *enumtype, int val) const =0 |
Convert arbitrary enum value to string. | |
void | read () |
Read from BlackBoard into local copy. | |
void | write () |
Write from local copy into BlackBoard memory. | |
bool | has_writer () const |
Check if there is a writer for the interface. | |
unsigned int | num_readers () const |
Get the number of readers. | |
bool | changed () const |
Check if data has been changed. | |
const Time * | timestamp () const |
Get timestamp of last write. | |
void | set_auto_timestamping (bool enabled) |
Enable or disable automated timestamping. | |
void | set_timestamp (const Time *t=NULL) |
Set timestamp. | |
void | set_clock (Clock *clock) |
Set clock to use for timestamping. | |
std::list< const char * > | get_message_types () |
Obtain a list of textual representations of the message types available for this interface. | |
unsigned int | msgq_enqueue (Message *message) |
Enqueue message at end of queue. | |
unsigned int | msgq_enqueue_copy (Message *message) |
Enqueue copy of message at end of queue. | |
void | msgq_remove (Message *message) |
Remove message from queue. | |
void | msgq_remove (unsigned int message_id) |
Remove message from queue. | |
unsigned int | msgq_size () |
Get size of message queue. | |
void | msgq_flush () |
Flush all messages. | |
void | msgq_lock () |
Lock message queue. | |
bool | msgq_try_lock () |
Try to lock message queue. | |
void | msgq_unlock () |
Unlock message queue. | |
void | msgq_pop () |
Erase first message from queue. | |
Message * | msgq_first () |
Get the first message from the message queue. | |
bool | msgq_empty () |
Check if queue is empty. | |
template<class MessageType> | |
bool | msgq_first_is () |
Check if first message has desired type. | |
template<class MessageType> | |
MessageType * | msgq_first () |
Get first message casted to the desired type. | |
template<class MessageType> | |
MessageType * | msgq_first (MessageType *&msg) |
Get first message casted to the desired type. | |
MessageQueue::MessageIterator | msgq_begin () |
Get start iterator for message queue. | |
MessageQueue::MessageIterator | msgq_end () |
Get end iterator for message queue. | |
InterfaceFieldIterator | fields () |
Get iterator over all fields of this interface instance. | |
InterfaceFieldIterator | fields_end () |
Invalid iterator. | |
unsigned int | num_fields () |
Get the number of fields in the interface. | |
Static Public Member Functions | |
static void | parse_uid (const char *uid, char **type, char **id) |
Parse UID to type and ID strings. | |
Protected Member Functions | |
Interface () | |
Constructor. | |
virtual bool | message_valid (const Message *message) const =0 |
Check if the message is valid and can be enqueued. | |
void | set_hash (unsigned char *ihash) |
Set hash. | |
void | add_fieldinfo (interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0) |
Add an entry to the field info list. | |
void | add_messageinfo (const char *name) |
Add an entry to the message info list. | |
Protected Attributes | |
void * | data_ptr |
Pointer to local memory storage. | |
unsigned int | data_size |
Minimal data size to hold data storage. | |
bool | data_changed |
Indicator if data has changed. | |
interface_data_ts_t * | data_ts |
Pointer to data casted to timestamp struct. | |
Friends | |
class | BlackBoardInterfaceManager |
class | BlackBoardInstanceFactory |
class | BlackBoardMessageManager |
class | BlackBoardInterfaceProxy |
Classes | |
struct | interface_data_ts_t |
Timestamp data, must be present and first entries for each interface data structs! This leans on timeval struct. More... | |
struct | interface_messageinfo_t |
Message info list. More... |
Never use directly. Use interface generator to create interfaces.
Interfaces are identified by a type and an ID. The type is just a textual representation of the class name. The ID identifies a specific instance of this interface type. Additionally each interface has a hash. The hash is an MD5 digest of the XML config file that was fed to the interface generator to create the interface. It is used to detect incompatible versions of the same interface type.
An interface has an internal timestamp. This timestamp indicates when the data in the interface has been modified last. The timestamp is usually automatically updated. But it some occasions the writer may choose to provide its own timestamp data. This can be useful for example for an interface providing hardware data to give the exact capture time. In the automatic case nothing has to be done manually. The timestamp is updated automatically by calling the write() method if and only if the data in the interface has actually been modified. The reader can call changed() to see if the data changed. In the non-automatic case the writer must first disable automatic timestamping using set_auto_timestamping(). Then it must provide a timestamp everytime before calling write(). Note that setting the timestamp already marks the interface as having changed. So set the timestamp only if the data has changed and the readers should see this.
Definition at line 79 of file interface.h.
fawkes::Interface::~Interface | ( | ) | [virtual] |
Destructor.
Definition at line 221 of file interface.cpp.
References fawkes::Interface::interface_messageinfo_t::next, fawkes::interface_fieldinfo_t::next, and fawkes::RefCount::unref().
fawkes::Interface::Interface | ( | ) | [protected] |
Constructor.
Definition at line 196 of file interface.cpp.
References data_changed, data_ptr, data_size, and fawkes::Clock::instance().
void fawkes::Interface::add_fieldinfo | ( | interface_fieldtype_t | type, | |
const char * | name, | |||
size_t | length, | |||
void * | value, | |||
const char * | enumtype = 0 | |||
) | [protected] |
Add an entry to the field info list.
Never use directly, use the interface generator instead. The info list is used for introspection purposes to allow for iterating over all fields of an interface.
type | field type | |
name | name of the field, this is referenced, not copied | |
length | length of the field | |
value | pointer to the value in the data struct | |
enumtype | name of the enum type, valid only if type == IFT_ENUM. |
Definition at line 289 of file interface.cpp.
References fawkes::interface_fieldinfo_t::enumtype, fawkes::interface_fieldinfo_t::length, fawkes::interface_fieldinfo_t::name, fawkes::interface_fieldinfo_t::next, fawkes::interface_fieldinfo_t::type, and fawkes::interface_fieldinfo_t::value.
void fawkes::Interface::add_messageinfo | ( | const char * | type | ) | [protected] |
Add an entry to the message info list.
Never use directly, use the interface generator instead. The info list is used for introspection purposes to allow for iterating over all message types of an interface.
type | the type of the message |
Definition at line 324 of file interface.cpp.
References fawkes::Interface::interface_messageinfo_t::next, and fawkes::Interface::interface_messageinfo_t::type.
bool fawkes::Interface::changed | ( | ) | const |
Check if data has been changed.
Note that if the data has been modified this method will return true at least until the next call to read. From then on it will return false if the data has not been modified between the two read() calls and still true otherwise.
Definition at line 687 of file interface.cpp.
void fawkes::Interface::copy_values | ( | const Interface * | interface | ) | [pure virtual] |
Copy values from another interface.
The operation will only succeed if the supplied interface is of the same type as this instance.
interface | interface to copy from |
Implemented in fawkes::BatteryInterface, fawkes::FacerInterface, fawkes::FacialExpressionInterface, fawkes::GameStateInterface, fawkes::HumanoidMotionInterface, fawkes::JoystickInterface, fawkes::KatanaInterface, fawkes::KickerInterface, fawkes::Laser360Interface, fawkes::Laser720Interface, fawkes::LedInterface, fawkes::LocalizerControlInterface, fawkes::MotorInterface, fawkes::NavigatorInterface, fawkes::ObjectPositionInterface, fawkes::PanTiltInterface, fawkes::Position2DTrackInterface, fawkes::SkillerDebugInterface, fawkes::SkillerInterface, fawkes::SoccerPenaltyInterface, fawkes::SpeechRecognitionInterface, fawkes::SpeechSynthInterface, fawkes::SwitchInterface, fawkes::TestInterface, and fawkes::VisualDisplay2DInterface.
Referenced by WorldModelSingleCopyFuser::fuse(), and WorldModelSingleCopyFuser::WorldModelSingleCopyFuser().
bool fawkes::Interface::create_message | ( | const char * | type | ) | const [pure 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.
type | message type |
UnknownTypeException | thrown if this interface cannot create a message of the given type. |
Implemented in fawkes::BatteryInterface, fawkes::FacerInterface, fawkes::FacialExpressionInterface, fawkes::GameStateInterface, fawkes::HumanoidMotionInterface, fawkes::JoystickInterface, fawkes::KatanaInterface, fawkes::KickerInterface, fawkes::Laser360Interface, fawkes::Laser720Interface, fawkes::LedInterface, fawkes::LocalizerControlInterface, fawkes::MotorInterface, fawkes::NavigatorInterface, fawkes::ObjectPositionInterface, fawkes::PanTiltInterface, fawkes::Position2DTrackInterface, fawkes::SkillerDebugInterface, fawkes::SkillerInterface, fawkes::SoccerPenaltyInterface, fawkes::SpeechRecognitionInterface, fawkes::SpeechSynthInterface, fawkes::SwitchInterface, fawkes::TestInterface, and fawkes::VisualDisplay2DInterface.
Referenced by fawkes::BlackBoardInterfaceProxy::process_interface_message().
const void * fawkes::Interface::datachunk | ( | ) | const |
Get data chunk.
Use sparsely
Definition at line 380 of file interface.cpp.
References data_ptr.
Referenced by fawkes::BlackBoardInterfaceProxy::notify_of_data_change().
unsigned int fawkes::Interface::datasize | ( | ) | const |
Get data size.
Definition at line 475 of file interface.cpp.
References data_size.
Referenced by fawkes::BlackBoardInterfaceProxy::BlackBoardInterfaceProxy(), BBLoggerThread::init(), and fawkes::BlackBoardInterfaceProxy::notify_of_data_change().
const char * fawkes::Interface::enum_tostring | ( | const char * | enumtype, | |
int | val | |||
) | const [pure 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.
enumtype | enum type as string | |
val | value to convert |
UnknownTypeException | thrown if enumtype is not specified for interface. |
Implemented in fawkes::BatteryInterface, fawkes::FacerInterface, fawkes::FacialExpressionInterface, fawkes::GameStateInterface, fawkes::HumanoidMotionInterface, fawkes::JoystickInterface, fawkes::KatanaInterface, fawkes::KickerInterface, fawkes::Laser360Interface, fawkes::Laser720Interface, fawkes::LedInterface, fawkes::LocalizerControlInterface, fawkes::MotorInterface, fawkes::NavigatorInterface, fawkes::ObjectPositionInterface, fawkes::PanTiltInterface, fawkes::Position2DTrackInterface, fawkes::SkillerDebugInterface, fawkes::SkillerInterface, fawkes::SoccerPenaltyInterface, fawkes::SpeechRecognitionInterface, fawkes::SpeechSynthInterface, fawkes::SwitchInterface, fawkes::TestInterface, and fawkes::VisualDisplay2DInterface.
Referenced by fawkes::InterfaceFieldIterator::get_value_string().
InterfaceFieldIterator fawkes::Interface::fields | ( | ) |
Get iterator over all fields of this interface instance.
Definition at line 1043 of file interface.cpp.
Referenced by XabslEngineThread::init(), and BBLogFile::print_entry().
InterfaceFieldIterator fawkes::Interface::fields_end | ( | ) |
Invalid iterator.
Definition at line 1053 of file interface.cpp.
Referenced by XabslEngineThread::init(), and BBLogFile::print_entry().
std::list< const char * > fawkes::Interface::get_message_types | ( | ) |
Obtain a list of textual representations of the message types available for this interface.
Definition at line 350 of file interface.cpp.
References fawkes::Interface::interface_messageinfo_t::next, and fawkes::Interface::interface_messageinfo_t::type.
bool fawkes::Interface::has_writer | ( | ) | const |
Check if there is a writer for the interface.
Use this method to determine if there is any open instance of the interface that is writing to the interface. This can also be the queried interface instance.
Definition at line 717 of file interface.cpp.
References fawkes::InterfaceMediator::exists_writer().
Referenced by LaserDrawingArea::draw_persons_legs(), LaserDrawingArea::draw_segments(), LuaAgentExecutionThread::finalize(), WorldModelSingleCopyFuser::fuse(), WorldModelObjPosMajorityFuser::fuse(), LaserDeadSpotCalibrator::LaserDeadSpotCalibrator(), WorldModelThread::loop(), RefBoxCommThread::loop(), LaserHtSensorProcThread::loop(), and LaserDrawingArea::on_expose_event().
const unsigned char * fawkes::Interface::hash | ( | ) | const |
Get interface hash.
The interface is a unique version identifier of an interface. It is the has of the input XML file during the generation of the interface. It is meant to be used to ensure that all sides are using the exact same version of an interface.
Definition at line 249 of file interface.cpp.
Referenced by fawkes::BlackBoardInterfaceProxy::BlackBoardInterfaceProxy(), fawkes::BlackBoardNetworkHandler::loop(), fawkes::BlackBoardInterfaceManager::open_for_reading(), fawkes::BlackBoardInterfaceManager::open_for_writing(), fawkes::BlackBoardInterfaceManager::open_multiple_for_reading(), and BBLogFile::set_interface().
const char * fawkes::Interface::hash_printable | ( | ) | const |
Get printable interface hash.
Definition at line 259 of file interface.cpp.
size_t fawkes::Interface::hash_size | ( | ) | const |
Get size of interface hash.
Returns the size in bytes of the interface hash. This depends on the used hash.
Definition at line 369 of file interface.cpp.
Referenced by fawkes::BlackBoardInterfaceManager::open_for_reading(), fawkes::BlackBoardInterfaceManager::open_for_writing(), and fawkes::BlackBoardInterfaceManager::open_multiple_for_reading().
const char * fawkes::Interface::id | ( | ) | const |
Get identifier of interface.
Definition at line 586 of file interface.cpp.
Referenced by WorldModelObjPosMajorityFuser::bb_interface_created(), BBLogFile::BBLogFile(), fawkes::BlackBoardInterfaceProxy::BlackBoardInterfaceProxy(), BBLogFile::set_interface(), and fawkes::BlackBoardMessageManager::transmit().
bool fawkes::Interface::is_valid | ( | ) | const |
Check validity of interface.
Reimplemented in fawkes::ObjectPositionInterface, and fawkes::Position2DTrackInterface.
Definition at line 415 of file interface.cpp.
Referenced by RemoteBlackBoardRefBoxProcessor::check_connection(), FawkesBeepDaemon::loop(), and RemoteBlackBoardRefBoxProcessor::refbox_process().
bool fawkes::Interface::is_writer | ( | ) | const |
Check if this is a writing instance.
Definition at line 390 of file interface.cpp.
Referenced by fawkes::LuaInterfaceImporter::add_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_message_interface(), fawkes::BlackBoardInterfaceListener::bbil_remove_message_interface(), fawkes::BlackBoardNetHandlerInterfaceListener::BlackBoardNetHandlerInterfaceListener(), fawkes::InterfaceDispatcher::InterfaceDispatcher(), and fawkes::BlackBoardInterfaceProxy::process_interface_message().
unsigned int fawkes::Interface::mem_serial | ( | ) | const |
Get memory serial of interface.
Definition at line 620 of file interface.cpp.
bool fawkes::Interface::message_valid | ( | const Message * | message | ) | const [protected, pure virtual] |
Check if the message is valid and can be enqueued.
message | The message to check |
Implemented in fawkes::BatteryInterface, fawkes::FacerInterface, fawkes::FacialExpressionInterface, fawkes::GameStateInterface, fawkes::HumanoidMotionInterface, fawkes::JoystickInterface, fawkes::KatanaInterface, fawkes::KickerInterface, fawkes::Laser360Interface, fawkes::Laser720Interface, fawkes::LedInterface, fawkes::LocalizerControlInterface, fawkes::MotorInterface, fawkes::NavigatorInterface, fawkes::ObjectPositionInterface, fawkes::PanTiltInterface, fawkes::Position2DTrackInterface, fawkes::SkillerDebugInterface, fawkes::SkillerInterface, fawkes::SoccerPenaltyInterface, fawkes::SpeechRecognitionInterface, fawkes::SpeechSynthInterface, fawkes::SwitchInterface, fawkes::TestInterface, and fawkes::VisualDisplay2DInterface.
Referenced by msgq_enqueue(), and msgq_enqueue_copy().
MessageQueue::MessageIterator fawkes::Interface::msgq_begin | ( | ) |
Get start iterator for message queue.
Not that you must have locked the queue before this operation! This can only be called on a writing interface instance.
NotLockedException | thrown if message queue is not locked during this operation. |
Definition at line 980 of file interface.cpp.
References fawkes::MessageQueue::begin().
bool fawkes::Interface::msgq_empty | ( | ) |
Check if queue is empty.
This can only be called on a writing interface instance.
Definition at line 897 of file interface.cpp.
References fawkes::MessageQueue::empty().
Referenced by RefBoxCommThread::loop(), AgentControlThread::loop(), PanTiltSonyEviD100PThread::loop(), PanTiltRX28Thread::loop(), PanTiltDirectedPerceptionThread::loop(), KatanaActThread::loop(), FliteSynthThread::loop(), FestivalSynthThread::loop(), FawkesBeepDaemon::loop(), VisualDisplay2D::process_messages(), and PlayerMotorPositionMapper::sync_fawkes_to_player().
MessageQueue::MessageIterator fawkes::Interface::msgq_end | ( | ) |
Get end iterator for message queue.
Not that you must have locked the queue before this operation! This can only be called on a writing interface instance.
NotLockedException | thrown if message queue is not locked during this operation. |
Definition at line 998 of file interface.cpp.
References fawkes::MessageQueue::end().
unsigned int fawkes::Interface::msgq_enqueue | ( | Message * | message | ) |
Enqueue message at end of queue.
This appends the given message to the queue and transmits the message via the message mediator. The message is afterwards owned by the other side and will be unrefed and freed as soon as it has been processed. If you want to keep this message to read a feedback status you have to reference it _before_ enqueuing it! This can only be called on a reading interface instance.
message | Message to enqueue. |
MessageAlreadyQueuedException | thrown if the message has already been enqueued to an interface. |
Definition at line 763 of file interface.cpp.
References fawkes::Message::id(), message_valid(), fawkes::Message::set_id(), fawkes::Message::set_interface(), fawkes::MessageMediator::transmit(), and fawkes::RefCount::unref().
Referenced by LuaAgentExecutionThread::finalize(), LuaAgentExecutionThread::init(), XabslEngineThread::loop(), SkillShellThread::loop(), RefBoxCommThread::loop(), LaserHtSensorProcThread::loop(), LaserDrawingArea::on_expose_event(), XabslEngineThread::once(), and SkillShellThread::~SkillShellThread().
unsigned int fawkes::Interface::msgq_enqueue_copy | ( | Message * | message | ) |
Enqueue copy of message at end of queue.
This method creates a copy of the message and enqueues it. Note that this way you cannot receive status message in the message, because the other side will not use your message instance but a copy instead.
This is particularly useful if you call from an environment with automatic garbage collection that does not honor the referencing feature of message but rather just deletes it. This can only be called on a reading interface instance.
message | Message to enqueue. |
MessageAlreadyQueuedException | thrown if the message has already been enqueued to an interface. |
Definition at line 798 of file interface.cpp.
References fawkes::Message::clone(), fawkes::Message::id(), message_valid(), fawkes::Message::set_id(), fawkes::Message::set_interface(), fawkes::MessageMediator::transmit(), and fawkes::RefCount::unref().
MessageType * fawkes::Interface::msgq_first | ( | MessageType *& | msg | ) |
Get first message casted to the desired type.
msg | reference to pointer to message of desired type, upon successful return points to the message. |
TypeMismatchException | thrown if message is not of desired type |
Definition at line 262 of file interface.h.
MessageType* fawkes::Interface::msgq_first | ( | ) |
Get first message casted to the desired type.
TypeMismatchException | thrown if message is not of desired type |
MessageType * fawkes::Interface::msgq_first | ( | ) |
Get the first message from the message queue.
This can only be called on a writing interface instance.
Definition at line 1014 of file interface.cpp.
References fawkes::MessageQueue::first().
Referenced by RefBoxCommThread::loop(), AgentControlThread::loop(), PanTiltSonyEviD100PThread::loop(), PanTiltRX28Thread::loop(), PanTiltDirectedPerceptionThread::loop(), KatanaActThread::loop(), FliteSynthThread::loop(), FestivalSynthThread::loop(), FawkesBeepDaemon::loop(), VisualDisplay2D::process_messages(), and PlayerMotorPositionMapper::sync_fawkes_to_player().
bool fawkes::Interface::msgq_first_is | ( | ) |
Check if first message has desired type.
Definition at line 274 of file interface.h.
References fawkes::MessageQueue::first().
Referenced by RefBoxCommThread::loop(), AgentControlThread::loop(), PanTiltSonyEviD100PThread::loop(), PanTiltRX28Thread::loop(), PanTiltDirectedPerceptionThread::loop(), KatanaActThread::loop(), FliteSynthThread::loop(), FestivalSynthThread::loop(), FawkesBeepDaemon::loop(), VisualDisplay2D::process_messages(), and PlayerMotorPositionMapper::sync_fawkes_to_player().
void fawkes::Interface::msgq_flush | ( | ) |
Flush all messages.
Deletes all messages from the queue. This can only be called on a writing interface instance.
Definition at line 913 of file interface.cpp.
References fawkes::MessageQueue::flush().
void fawkes::Interface::msgq_lock | ( | ) |
Lock message queue.
Lock the message queue. You have to do this before using the iterator safely. This can only be called on a writing interface instance.
Definition at line 929 of file interface.cpp.
References fawkes::MessageQueue::lock().
void fawkes::Interface::msgq_pop | ( | ) |
Erase first message from queue.
This can only be called on a writing interface instance.
Definition at line 1028 of file interface.cpp.
References fawkes::MessageQueue::pop().
Referenced by RefBoxCommThread::loop(), AgentControlThread::loop(), PanTiltSonyEviD100PThread::loop(), PanTiltRX28Thread::loop(), PanTiltDirectedPerceptionThread::loop(), KatanaActThread::loop(), FliteSynthThread::loop(), FestivalSynthThread::loop(), FawkesBeepDaemon::loop(), VisualDisplay2D::process_messages(), and PlayerMotorPositionMapper::sync_fawkes_to_player().
void fawkes::Interface::msgq_remove | ( | unsigned int | message_id | ) |
Remove message from queue.
Removes message with the given ID from the queue.
message_id | Message ID to remove. This can only be called on a writing interface instance. |
Definition at line 865 of file interface.cpp.
References fawkes::MessageQueue::remove().
void fawkes::Interface::msgq_remove | ( | Message * | message | ) |
Remove message from queue.
Removes the given message from the queue. Note that if you unref()ed the message after insertion this will most likely delete the object. It is not safe to use the message after removing it from the queue in general. Know what you are doing if you want to use it. This can only be called on a writing interface instance.
message | Message to remove. |
Definition at line 848 of file interface.cpp.
References fawkes::MessageQueue::remove().
unsigned int fawkes::Interface::msgq_size | ( | ) |
Get size of message queue.
This can only be called on a writing interface instance.
Definition at line 881 of file interface.cpp.
References fawkes::MessageQueue::size().
bool fawkes::Interface::msgq_try_lock | ( | ) |
Try to lock message queue.
Try to lock the message queue. Returns immediately and does not wait for lock.
Definition at line 947 of file interface.cpp.
References fawkes::MessageQueue::try_lock().
void fawkes::Interface::msgq_unlock | ( | ) |
Unlock message queue.
Give free the lock on the message queue. This can only be called on a writing interface instance.
Definition at line 963 of file interface.cpp.
References fawkes::MessageQueue::unlock().
unsigned int fawkes::Interface::num_fields | ( | ) |
Get the number of fields in the interface.
Definition at line 1063 of file interface.cpp.
unsigned int fawkes::Interface::num_readers | ( | ) | const |
Get the number of readers.
Use this method to determine how many reading instances of the interface currently exist. If the current instance is a reading instance it will be included in the count number. To determine if you are the last man having this interface you can use the following code:
// for a writing instance: if ( interface->num_readers == 0 ) { // we are the last one to have this interface open } // for a reading instance: if ( ! interface->has_writer() && (interface->num_readers() == 0) ) { // we are the last one to have this interface open }
Definition at line 744 of file interface.cpp.
References fawkes::InterfaceMediator::num_readers().
bool fawkes::Interface::oftype | ( | const char * | interface_type | ) | const |
Check if interface is of given type.
interface_type | type to query |
Definition at line 566 of file interface.cpp.
bool fawkes::Interface::operator== | ( | Interface & | comp | ) | const |
Check equality of two interfaces.
Two interfaces are the same if their types and identifiers are equal. This does not mean that both interfaces are the very same instance for accessing the BlackBoard. Instead this just means that both instances will access the same chunk of memory in the BlackBoard and the instances MAY be the same. If you want to know if two instances are exactly the same compare the instance serials using the serial() method.
comp | interface to compare current instance with |
Definition at line 554 of file interface.cpp.
void fawkes::Interface::parse_uid | ( | const char * | uid, | |
char ** | type, | |||
char ** | id | |||
) | [static] |
Parse UID to type and ID strings.
Note that the returned values (type and id) must be freed once they are no longer used. Also verifies lengths of the type and id strings.
uid | UID to parse | |
type | upon return contains the type part of the UID, must be freed | |
id | upon return contains the ID part, must be freed |
Definition at line 1077 of file interface.cpp.
void fawkes::Interface::read | ( | ) |
Read from BlackBoard into local copy.
InterfaceInvalidException | thrown if the interface has been marked invalid |
Definition at line 425 of file interface.cpp.
References data_ptr, data_size, data_ts, fawkes::ReadWriteLock::lock_for_read(), fawkes::Time::set_time(), fawkes::Interface::interface_data_ts_t::timestamp_sec, fawkes::Interface::interface_data_ts_t::timestamp_usec, and fawkes::ReadWriteLock::unlock().
Referenced by JoystickBlackBoardLogger::bb_interface_data_changed(), LaserDrawingArea::draw_persons_legs(), LaserDrawingArea::draw_segments(), WorldModelSingleCopyFuser::fuse(), WorldModelObjPosMajorityFuser::fuse(), LuaAgentExecutionThread::init(), JoystickBlackBoardLogger::JoystickBlackBoardLogger(), XabslEngineThread::loop(), WorldModelThread::loop(), AgentControlThread::loop(), LuaAgentExecutionThread::loop(), LaserHtSensorProcThread::loop(), BallPosLogThread::loop(), LaserDrawingArea::on_expose_event(), RemoteBlackBoardRefBoxProcessor::refbox_process(), and WorldModelSingleCopyFuser::WorldModelSingleCopyFuser().
unsigned short fawkes::Interface::serial | ( | ) | const |
Get instance serial of interface.
Definition at line 610 of file interface.cpp.
Referenced by fawkes::RemoteBlackBoard::close(), fawkes::BlackBoardInterfaceManager::close(), fawkes::BlackBoardNetworkHandler::loop(), fawkes::BlackBoardInterfaceProxy::notify_of_data_change(), fawkes::BlackBoardNotifier::notify_of_reader_removed(), fawkes::BlackBoardNotifier::notify_of_writer_removed(), fawkes::BlackBoardInterfaceManager::open_for_reading(), fawkes::BlackBoardInterfaceManager::open_for_writing(), and fawkes::BlackBoardInterfaceProxy::transmit().
void fawkes::Interface::set_auto_timestamping | ( | bool | enabled | ) |
Enable or disable automated timestamping.
enabled | true to enable automated timestamping, false to disable |
Definition at line 673 of file interface.cpp.
void fawkes::Interface::set_clock | ( | Clock * | clock | ) |
Set clock to use for timestamping.
clock | clock to use from now on |
Definition at line 662 of file interface.cpp.
References fawkes::Time::set_clock().
void fawkes::Interface::set_from_chunk | ( | void * | chunk | ) |
Set from a raw data chunk.
This allows for setting the interface data from a raw chunk. This is not useful in general but only in rare situations like network transmission. Do not use it unless you really know what you are doing. The method expects the chunk to be exactly of the size returned by datasize(). No check is done, a segfault will most likely occur if you provide invalid data.
chunk | data chunk, must be exactly of the size that is returned by datasize() |
Definition at line 702 of file interface.cpp.
References data_ptr, and data_size.
Referenced by BBLogFile::read_next().
void fawkes::Interface::set_hash | ( | unsigned char * | ihash | ) | [protected] |
Set hash.
Never use directly.
ihash | interface hash |
Definition at line 269 of file interface.cpp.
void fawkes::Interface::set_timestamp | ( | const Time * | t = NULL |
) |
Set timestamp.
t | time stamp to copy time from, if NULL current time is queried from clock. |
Definition at line 642 of file interface.cpp.
References data_changed, and fawkes::Time::stamp().
void fawkes::Interface::set_validity | ( | bool | valid | ) |
Mark this interface invalid.
An interface can become invalid, for example if the connection of a RemoteBlackBoard dies. In this case the interface becomes invalid and successive read()/write() calls will throw an InterfaceInvalidException.
valid | true to mark the interface valid or false to mark it invalid |
Definition at line 403 of file interface.cpp.
References fawkes::ReadWriteLock::lock_for_write(), and fawkes::ReadWriteLock::unlock().
const Time * fawkes::Interface::timestamp | ( | ) | const |
Get timestamp of last write.
Note that you need to call read() before this provides useful information.
Definition at line 631 of file interface.cpp.
const char * fawkes::Interface::type | ( | ) | const |
Get type of interface.
Definition at line 576 of file interface.cpp.
Referenced by BBLogFile::BBLogFile(), fawkes::BlackBoardInterfaceProxy::BlackBoardInterfaceProxy(), fawkes::SkillerDebugInterface::copy_values(), fawkes::PanTiltInterface::copy_values(), fawkes::KatanaInterface::copy_values(), fawkes::VisualDisplay2DInterface::copy_values(), fawkes::TestInterface::copy_values(), fawkes::SwitchInterface::copy_values(), fawkes::SpeechSynthInterface::copy_values(), fawkes::SpeechRecognitionInterface::copy_values(), fawkes::SoccerPenaltyInterface::copy_values(), fawkes::SkillerInterface::copy_values(), fawkes::Position2DTrackInterface::copy_values(), fawkes::ObjectPositionInterface::copy_values(), fawkes::NavigatorInterface::copy_values(), fawkes::MotorInterface::copy_values(), fawkes::LocalizerControlInterface::copy_values(), fawkes::LedInterface::copy_values(), fawkes::Laser720Interface::copy_values(), fawkes::Laser360Interface::copy_values(), fawkes::KickerInterface::copy_values(), fawkes::JoystickInterface::copy_values(), fawkes::HumanoidMotionInterface::copy_values(), fawkes::GameStateInterface::copy_values(), fawkes::FacialExpressionInterface::copy_values(), fawkes::FacerInterface::copy_values(), fawkes::BatteryInterface::copy_values(), PlayerMapperFactory::create_mapper(), BBLogFile::set_interface(), and fawkes::BlackBoardMessageManager::transmit().
const char * fawkes::Interface::uid | ( | ) | const |
Get unique identifier of interface.
As the name suggests this ID denotes a unique memory instance of this interface in the blackboard. It is provided by the system and currently returns a string of the form "type::id", where type is replaced by the type returned by type() and id is the ID returned by id().
Definition at line 600 of file interface.cpp.
Referenced by fawkes::BlackBoardInterfaceListener::bbil_add_data_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_message_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_reader_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_writer_interface(), fawkes::BlackBoardInterfaceListener::bbil_remove_data_interface(), fawkes::BlackBoardInterfaceListener::bbil_remove_message_interface(), fawkes::BlackBoardInterfaceListener::bbil_remove_reader_interface(), fawkes::BlackBoardInterfaceListener::bbil_remove_writer_interface(), BBLogFile::BBLogFile(), BBLoggerThread::init(), fawkes::BlackBoardNotifier::notify_of_data_change(), fawkes::BlackBoardNotifier::notify_of_message_received(), and fawkes::BlackBoardInterfaceProxy::process_interface_message().
void fawkes::Interface::write | ( | ) |
Write from local copy into BlackBoard memory.
InterfaceInvalidException | thrown if the interface has been marked invalid |
Definition at line 444 of file interface.cpp.
References data_changed, data_ptr, data_size, data_ts, fawkes::Time::get_timestamp(), fawkes::ReadWriteLock::lock_for_write(), fawkes::InterfaceMediator::notify_of_data_change(), fawkes::Time::stamp(), fawkes::Interface::interface_data_ts_t::timestamp_sec, fawkes::Interface::interface_data_ts_t::timestamp_usec, and fawkes::ReadWriteLock::unlock().
Referenced by WorldModelNetworkThread::ball_pos_rcvd(), LaserHtSensorProcThread::finalize(), WorldModelSingleCopyFuser::fuse(), WorldModelObjPosAverageFuser::fuse(), WorldModelNetworkThread::gamestate_rcvd(), WorldModelNetworkThread::global_ball_pos_rcvd(), RefBoxCommThread::handle_refbox_state(), PanTiltSonyEviD100PThread::init(), PanTiltRX28Thread::init(), PanTiltDirectedPerceptionThread::init(), SkillerExecutionThread::init(), LaserSensorThread::init(), BBLoggerThread::init(), JoystickBlackBoardPoster::joystick_changed(), JoystickBlackBoardPoster::joystick_plugged(), JoystickBlackBoardPoster::joystick_unplugged(), RefBoxCommThread::loop(), AgentControlThread::loop(), PanTiltSonyEviD100PThread::loop(), PanTiltRX28Thread::loop(), PanTiltDirectedPerceptionThread::loop(), LaserHtSensorProcThread::loop(), KatanaActThread::loop(), LaserSensorThread::loop(), JoystickSensorThread::loop(), BBLogReplayThread::loop(), BBLogReplayThread::once(), WorldModelNetworkThread::opponent_pose_rcvd(), WorldModelNetworkThread::pose_rcvd(), FliteSynthThread::say(), FestivalSynthThread::say(), RefBoxStateBBWriter::send(), PlayerPositionMapper::sync_player_to_fawkes(), PlayerMotorPositionMapper::sync_player_to_fawkes(), PlayerLaserMapper::sync_player_to_fawkes(), PanTiltSonyEviD100PThread::update_sensor_values(), PanTiltRX28Thread::update_sensor_values(), PanTiltDirectedPerceptionThread::update_sensor_values(), and WorldModelSingleCopyFuser::WorldModelSingleCopyFuser().
fawkes::Interface::data_changed [protected] |
Indicator if data has changed.
This must be set by all methods that manipulate internal data or the timestamp. Only if set to true a call to write() will update data_ts.
Definition at line 190 of file interface.h.
Referenced by Interface(), fawkes::BatteryInterface::set_absolute_soc(), fawkes::SwitchInterface::set_activation_count(), fawkes::HumanoidMotionInterface::set_arms_enabled(), fawkes::JoystickInterface::set_axis_x(), fawkes::JoystickInterface::set_axis_y(), fawkes::ObjectPositionInterface::set_bearing(), fawkes::FacerInterface::set_bearing(), fawkes::FacialExpressionInterface::set_brows_action(), fawkes::PanTiltInterface::set_calibrated(), fawkes::KatanaInterface::set_calibrated(), fawkes::Laser720Interface::set_clockwise_angle(), fawkes::Laser360Interface::set_clockwise_angle(), fawkes::SkillerInterface::set_continuous(), fawkes::MotorInterface::set_controller(), fawkes::MotorInterface::set_controller_thread_name(), fawkes::VisualDisplay2DInterface::set_counter(), fawkes::SpeechRecognitionInterface::set_counter(), fawkes::BatteryInterface::set_current(), fawkes::KickerInterface::set_current_intensity(), fawkes::ObjectPositionInterface::set_dbs_covariance(), fawkes::NavigatorInterface::set_dest_dist(), fawkes::NavigatorInterface::set_dest_ori(), fawkes::NavigatorInterface::set_dest_x(), fawkes::NavigatorInterface::set_dest_y(), fawkes::ObjectPositionInterface::set_distance(), fawkes::Laser720Interface::set_distances(), fawkes::Laser360Interface::set_distances(), fawkes::MotorInterface::set_drive_mode(), fawkes::SpeechSynthInterface::set_duration(), fawkes::HumanoidMotionInterface::set_elbow_roll_amplitude(), fawkes::HumanoidMotionInterface::set_elbow_roll_median(), fawkes::PanTiltInterface::set_enabled(), fawkes::KatanaInterface::set_enabled(), fawkes::SwitchInterface::set_enabled(), fawkes::SpeechRecognitionInterface::set_enabled(), fawkes::SkillerInterface::set_error(), fawkes::PanTiltInterface::set_error_code(), fawkes::KatanaInterface::set_error_code(), fawkes::NavigatorInterface::set_error_code(), fawkes::NavigatorInterface::set_escaping_enabled(), fawkes::SkillerInterface::set_exclusive_controller(), fawkes::ObjectPositionInterface::set_extent_x(), fawkes::ObjectPositionInterface::set_extent_y(), fawkes::ObjectPositionInterface::set_extent_z(), fawkes::FacialExpressionInterface::set_eyes_action(), fawkes::PanTiltInterface::set_final(), fawkes::KatanaInterface::set_final(), fawkes::SpeechSynthInterface::set_final(), fawkes::NavigatorInterface::set_final(), fawkes::PanTiltInterface::set_flags(), fawkes::TestInterface::set_flags(), fawkes::ObjectPositionInterface::set_flags(), fawkes::NavigatorInterface::set_flags(), fawkes::GameStateInterface::set_game_state(), fawkes::SkillerDebugInterface::set_graph(), fawkes::SkillerDebugInterface::set_graph_colored(), fawkes::SkillerDebugInterface::set_graph_dir(), fawkes::SkillerDebugInterface::set_graph_fsm(), fawkes::KickerInterface::set_guide_ball_side(), fawkes::GameStateInterface::set_half(), fawkes::HumanoidMotionInterface::set_hip_height(), fawkes::SwitchInterface::set_history(), fawkes::FacerInterface::set_history_ratio(), fawkes::LedInterface::set_intensity(), fawkes::FacialExpressionInterface::set_jowl_action(), fawkes::GameStateInterface::set_kickoff(), fawkes::HumanoidMotionInterface::set_l_hip_roll_compensation(), fawkes::FacerInterface::set_learning_in_progress(), fawkes::MotorInterface::set_left_rpm(), fawkes::Position2DTrackInterface::set_length(), fawkes::SwitchInterface::set_long_activations(), fawkes::LocalizerControlInterface::set_map_name(), fawkes::PanTiltInterface::set_max_pan(), fawkes::PanTiltInterface::set_max_pan_velocity(), fawkes::HumanoidMotionInterface::set_max_step_height(), fawkes::HumanoidMotionInterface::set_max_step_length(), fawkes::HumanoidMotionInterface::set_max_step_side(), fawkes::HumanoidMotionInterface::set_max_step_turn(), fawkes::PanTiltInterface::set_max_tilt(), fawkes::PanTiltInterface::set_max_tilt_velocity(), fawkes::KatanaInterface::set_max_velocity(), fawkes::NavigatorInterface::set_max_velocity(), fawkes::PanTiltInterface::set_min_pan(), fawkes::PanTiltInterface::set_min_tilt(), fawkes::FacerInterface::set_most_likely_identity(), fawkes::MotorInterface::set_motor_state(), fawkes::FacialExpressionInterface::set_mouth_action(), fawkes::PanTiltInterface::set_msgid(), fawkes::KatanaInterface::set_msgid(), fawkes::SpeechSynthInterface::set_msgid(), fawkes::NavigatorInterface::set_msgid(), fawkes::HumanoidMotionInterface::set_msgid(), fawkes::JoystickInterface::set_num_axes(), fawkes::JoystickInterface::set_num_buttons(), fawkes::FacerInterface::set_num_detections(), fawkes::FacerInterface::set_num_identities(), fawkes::KickerInterface::set_num_kicks_center(), fawkes::KickerInterface::set_num_kicks_left(), fawkes::KickerInterface::set_num_kicks_right(), fawkes::KatanaInterface::set_num_motors(), fawkes::FacerInterface::set_num_recognitions(), fawkes::ObjectPositionInterface::set_object_type(), fawkes::MotorInterface::set_odometry_orientation(), fawkes::MotorInterface::set_odometry_path_length(), fawkes::MotorInterface::set_odometry_position_x(), fawkes::MotorInterface::set_odometry_position_y(), fawkes::MotorInterface::set_omega(), fawkes::FacerInterface::set_opmode(), fawkes::GameStateInterface::set_our_goal_color(), fawkes::GameStateInterface::set_our_team(), fawkes::PanTiltInterface::set_pan(), fawkes::PanTiltInterface::set_pan_margin(), fawkes::PanTiltInterface::set_pan_velocity(), fawkes::SoccerPenaltyInterface::set_penalty(), fawkes::KatanaInterface::set_phi(), fawkes::ObjectPositionInterface::set_pitch(), fawkes::JoystickInterface::set_pressed_buttons(), fawkes::SpeechRecognitionInterface::set_processing(), fawkes::KatanaInterface::set_psi(), fawkes::HumanoidMotionInterface::set_r_hip_roll_compensation(), fawkes::MotorInterface::set_rear_rpm(), fawkes::FacerInterface::set_recognized_identity(), fawkes::FacerInterface::set_recognized_name(), fawkes::FacerInterface::set_recording_progress(), fawkes::BatteryInterface::set_relative_soc(), fawkes::ObjectPositionInterface::set_relative_x(), fawkes::ObjectPositionInterface::set_relative_x_velocity(), fawkes::ObjectPositionInterface::set_relative_xyz_covariance(), fawkes::ObjectPositionInterface::set_relative_xyz_velocity_covariance(), fawkes::ObjectPositionInterface::set_relative_y(), fawkes::ObjectPositionInterface::set_relative_y_velocity(), fawkes::ObjectPositionInterface::set_relative_z(), fawkes::ObjectPositionInterface::set_relative_z_velocity(), fawkes::SoccerPenaltyInterface::set_remaining(), fawkes::FacerInterface::set_requested_index(), fawkes::FacerInterface::set_requested_name(), fawkes::TestInterface::set_result(), fawkes::MotorInterface::set_right_rpm(), fawkes::GameStateInterface::set_role(), fawkes::ObjectPositionInterface::set_roll(), fawkes::GameStateInterface::set_score_cyan(), fawkes::GameStateInterface::set_score_magenta(), fawkes::FacerInterface::set_sec_since_detection(), fawkes::NavigatorInterface::set_security_distance(), fawkes::KatanaInterface::set_sensor_value(), fawkes::SwitchInterface::set_short_activations(), fawkes::HumanoidMotionInterface::set_shoulder_pitch_amplitude(), fawkes::HumanoidMotionInterface::set_shoulder_pitch_median(), fawkes::SkillerInterface::set_skill_string(), fawkes::ObjectPositionInterface::set_slope(), fawkes::FacerInterface::set_slope(), fawkes::GameStateInterface::set_state_team(), fawkes::SkillerInterface::set_status(), fawkes::HumanoidMotionInterface::set_supporting_leg(), fawkes::BatteryInterface::set_temperature(), fawkes::TestInterface::set_test_bool(), fawkes::TestInterface::set_test_int(), fawkes::TestInterface::set_test_lint(), fawkes::TestInterface::set_test_string(), fawkes::TestInterface::set_test_uint(), fawkes::TestInterface::set_test_ulint(), fawkes::SpeechSynthInterface::set_text(), fawkes::SpeechRecognitionInterface::set_text(), fawkes::KatanaInterface::set_theta(), fawkes::PanTiltInterface::set_tilt(), fawkes::PanTiltInterface::set_tilt_margin(), fawkes::PanTiltInterface::set_tilt_velocity(), set_timestamp(), fawkes::HumanoidMotionInterface::set_torso_sideward_orientation(), fawkes::Position2DTrackInterface::set_track_id(), fawkes::Position2DTrackInterface::set_track_timestamps(), fawkes::Position2DTrackInterface::set_track_x_positions(), fawkes::Position2DTrackInterface::set_track_y_positions(), fawkes::Position2DTrackInterface::set_valid(), fawkes::ObjectPositionInterface::set_valid(), fawkes::SwitchInterface::set_value(), fawkes::ObjectPositionInterface::set_visibility_history(), fawkes::FacerInterface::set_visibility_history(), fawkes::ObjectPositionInterface::set_visible(), fawkes::BatteryInterface::set_voltage(), fawkes::MotorInterface::set_vx(), fawkes::MotorInterface::set_vy(), fawkes::HumanoidMotionInterface::set_walking(), fawkes::ObjectPositionInterface::set_world_x(), fawkes::ObjectPositionInterface::set_world_x_velocity(), fawkes::ObjectPositionInterface::set_world_xyz_covariance(), fawkes::ObjectPositionInterface::set_world_xyz_velocity_covariance(), fawkes::ObjectPositionInterface::set_world_y(), fawkes::ObjectPositionInterface::set_world_y_velocity(), fawkes::ObjectPositionInterface::set_world_z(), fawkes::ObjectPositionInterface::set_world_z_velocity(), fawkes::KatanaInterface::set_x(), fawkes::NavigatorInterface::set_x(), fawkes::KatanaInterface::set_y(), fawkes::NavigatorInterface::set_y(), fawkes::ObjectPositionInterface::set_yaw(), fawkes::KatanaInterface::set_z(), fawkes::HumanoidMotionInterface::set_zmp_offset_forward(), fawkes::HumanoidMotionInterface::set_zmp_offset_sideward(), and write().
fawkes::Interface::data_ptr [protected] |
Pointer to local memory storage.
Definition at line 188 of file interface.h.
Referenced by datachunk(), Interface(), read(), set_from_chunk(), and write().
fawkes::Interface::data_size [protected] |
Minimal data size to hold data storage.
Definition at line 189 of file interface.h.
Referenced by datasize(), Interface(), read(), set_from_chunk(), and write().
fawkes::Interface::data_ts [protected] |
Pointer to data casted to timestamp struct.
This assumes that the very first two entries are 64 bit wide signed integers containing seconds and microseconds since the Unix epoch.
Definition at line 198 of file interface.h.