Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

WorldStateSerializerBehavior Class Reference

Copies WorldState into a buffer for transmission over the network. More...

#include <WorldStateSerializerBehavior.h>

Inheritance diagram for WorldStateSerializerBehavior:

Detailed Description

Copies WorldState into a buffer for transmission over the network.

To determine the communication protocol, just look in the doEvent() function - it's pretty straightforward binary copy of values.

Protocol:

  • <char[]: modelName> (null terminated character array)
  • <unsigned int: timestamp>
  • <unsigned int: framenumber>
  • <unsigned int: NumOutputs>
  • for each i of NumOutputs:
    • <float: position of output i>
  • <unsigned int: NumSensors>
  • for each i of NumSensors:
    • <float: value of sensor i>
  • <unsigned int: NumButtons>
  • for each i of NumButtons:
    • <float: value of button i>
  • <unsigned int: NumPIDJoints>
  • for each i of NumPIDJoints:
    • <float: duty cycle of joint i>

Definition at line 33 of file WorldStateSerializerBehavior.h.

List of all members.

Public Member Functions

 WorldStateSerializerBehavior ()
 constructor
virtual void doStart ()
 starts listening for sensor update events
virtual void doStop ()
 stops listening for events
virtual void doEvent ()
 core functionality - performs serialization, sends to sockets
virtual std::string getDescription () const
 Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).
virtual std::string getGUIType () const
 returns string corresponding to the Java GUI which should be launched
virtual unsigned int getPort () const
 returns port number the Java GUI should connect to

Static Public Member Functions

static std::string getClassDescription ()
 Gives a short description of what this class of behaviors does... you should override this (but don't have to).

Static Protected Member Functions

template<class T >
static void copy (char **dst, const T &value)
 writes value to dst and advances dst by sizeof(T)
template<class T >
static void copy (char **dst, const T *src, size_t num)
 writes num copies of T from src to dst and advances dst by num * sizeof(T)
static void copy (char **dst, const std::string &src, size_t num)
 writes num characters from src to dst and advances dst by num * sizeof(T)

Protected Attributes

SocketwsJoints
 socket for sending current joint data
SocketwsPIDs
 socket for sending current PID info
unsigned int lastProcessedTime
 the time that the last event was processed

Private Member Functions

 WorldStateSerializerBehavior (const WorldStateSerializerBehavior &)
 don't call
WorldStateSerializerBehavioroperator= (const WorldStateSerializerBehavior &)
 don't call

Constructor & Destructor Documentation

WorldStateSerializerBehavior::WorldStateSerializerBehavior (  ) 

constructor

Definition at line 16 of file WorldStateSerializerBehavior.cc.

WorldStateSerializerBehavior::WorldStateSerializerBehavior ( const WorldStateSerializerBehavior  )  [private]

don't call


Member Function Documentation

static void WorldStateSerializerBehavior::copy ( char **  dst,
const std::string &  src,
size_t  num 
) [static, protected]

writes num characters from src to dst and advances dst by num * sizeof(T)

Definition at line 70 of file WorldStateSerializerBehavior.h.

template<class T >
static void WorldStateSerializerBehavior::copy ( char **  dst,
const T *  src,
size_t  num 
) [static, protected]

writes num copies of T from src to dst and advances dst by num * sizeof(T)

doesn't do any byte swapping, so this is only used if LoadSave indicates no byte swapping is needed

Definition at line 64 of file WorldStateSerializerBehavior.h.

template<class T >
static void WorldStateSerializerBehavior::copy ( char **  dst,
const T &  value 
) [static, protected]

writes value to dst and advances dst by sizeof(T)

doesn't do any byte swapping, so this is only used if LoadSave indicates no byte swapping is needed

Definition at line 56 of file WorldStateSerializerBehavior.h.

Referenced by doEvent().

void WorldStateSerializerBehavior::doEvent (  )  [virtual]

core functionality - performs serialization, sends to sockets

Reimplemented from BehaviorBase.

Definition at line 53 of file WorldStateSerializerBehavior.cc.

void WorldStateSerializerBehavior::doStart (  )  [virtual]

starts listening for sensor update events

Reimplemented from BehaviorBase.

Definition at line 21 of file WorldStateSerializerBehavior.cc.

void WorldStateSerializerBehavior::doStop (  )  [virtual]

stops listening for events

Reimplemented from BehaviorBase.

Definition at line 40 of file WorldStateSerializerBehavior.cc.

static std::string WorldStateSerializerBehavior::getClassDescription (  )  [static]

Gives a short description of what this class of behaviors does... you should override this (but don't have to).

If you do override this, also consider overriding getDescription() to return it

Reimplemented from BehaviorBase.

Definition at line 40 of file WorldStateSerializerBehavior.h.

Referenced by getDescription().

virtual std::string WorldStateSerializerBehavior::getDescription (  )  const [virtual]

Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).

By default simply returns getName(), because any calls from a BehaviorBase function to getClassDescription() are going to call BehaviorBase::getClassDescription(), not ~YourSubClass~getClassDescription(), because static functions can't be virtual in C++ (doh!)

This means that getDescription called on a pointer to a BehaviorBase of unknown subtype would always return an empty string, which is pretty useless. So instead we return the name in this situation. If you want getDescription to return getClassDescription, you'll have to override it in your subclass to do so.

Reimplemented from BehaviorBase.

Definition at line 45 of file WorldStateSerializerBehavior.h.

virtual std::string WorldStateSerializerBehavior::getGUIType (  )  const [virtual]

returns string corresponding to the Java GUI which should be launched

Definition at line 48 of file WorldStateSerializerBehavior.h.

Referenced by doStart(), and doStop().

virtual unsigned int WorldStateSerializerBehavior::getPort (  )  const [virtual]

returns port number the Java GUI should connect to

Definition at line 50 of file WorldStateSerializerBehavior.h.

Referenced by doStart().

WorldStateSerializerBehavior& WorldStateSerializerBehavior::operator= ( const WorldStateSerializerBehavior  )  [private]

don't call


Member Data Documentation

the time that the last event was processed

Definition at line 77 of file WorldStateSerializerBehavior.h.

Referenced by doEvent().

socket for sending current joint data

Definition at line 75 of file WorldStateSerializerBehavior.h.

Referenced by doEvent(), doStart(), and doStop().

socket for sending current PID info

Definition at line 76 of file WorldStateSerializerBehavior.h.

Referenced by doEvent(), doStart(), and doStop().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:18 2016 by Doxygen 1.6.3