Homepage Demos Overview Downloads Tutorials Reference
Credits

MMCombo Class Reference

#include <MMCombo.h>

Inheritance diagram for MMCombo:

Inheritance graph
[legend]
List of all members.

Detailed Description

Contains code for both MainObj and MotoObj processes.

Why go to all this trouble? Virtual functions and polymorphism! Instead of writing my own object typing and serialization system, I would rather just use C++'s. But function lookups of the run time type information (RTTI) will break unless the object that created the object and the object that's actually calling the function agree on what object A's information is.

The easiest way to guarantee this is to compile them as one object, and then replace the strings in the source binary with strings for each of the final objects so they'll each have their own identity, but share the same code.

This is as close as I can get to a "fork", which is what i really want.

Definition at line 30 of file MMCombo.h.

Public Member Functions

 MMCombo ()
 constructor

virtual ~MMCombo ()
 destructor

virtual OStatus DoInit (const OSystemEvent &)
 first call (after constructor), set up memory

virtual OStatus DoStart (const OSystemEvent &)
 second call, ask for messages

virtual OStatus DoStop (const OSystemEvent &)
 next to last call, stop sending and receiving messages

virtual OStatus DoDestroy (const OSystemEvent &)
 last call (before destructor), clean up memory here

void ReadyRegisterWorldState (const OReadyEvent &)
 main only, send out the state global

void GotWorldState (const ONotifyEvent &event)
 motion only, called when state global is received

void ReadyRegisterMotionManager (const OReadyEvent &)
 motion only, send out motman global

void GotMotionManager (const ONotifyEvent &event)
 main only, called when motman global is received

void ReadyRegisterEventTranslatorQueue (const OReadyEvent &)
 main only, send out the EventTranslatorQueue

void GotEventTranslatorQueue (const ONotifyEvent &event)
 motion only, called when EventTranslatorQueue is received

void ReadySendJoints (const OReadyEvent &event)
 motion only (until main does ears again, then both) calls SendJoints, if DoStart has already been called

void GotSensorFrame (const ONotifyEvent &event)
 main only, called when new sensor information is available

void GotImage (const ONotifyEvent &event)
 main only, called when a new image is available

void GotPowerEvent (void *msg)
 main only, called when a power event occurs (can be just status events)

void GotMotionMsg (const ONotifyEvent &event)
 both, called when a new MotionManagerMsg has been received

void GotSoundManager (const ONotifyEvent &event)
 both, called when the sndman global is received

void ListenCont (void *msg)
 main only, called when //ALTODO

void BindCont (void *msg)
 main only, called when //ALTODO

void ConnectCont (void *msg)
 main only, called when //ALTODO

void SendCont (void *msg)
 main only, called when //ALTODO

void ReceiveCont (void *msg)
 main only, called when //ALTODO

void CloseCont (void *msg)
 main only, called when //ALTODO

bool RPOPENR_isReady ()
 main only, called when //ALTODO

int RPOPENR_send (char *buf, int bufsize)
 main only, called when //ALTODO

void RPOPENR_ready (const OReadyEvent &)
 main only, called when //ALTODO

void RPOPENR_notify (const ONotifyEvent &event)
 main only, called when //ALTODO


Public Attributes

OSubject * subject [numOfSubject]
 holds information for each of our subjects (data we provide)

OObserver * observer [numOfObserver]
 holds information for each of the sources we're observing


Protected Member Functions

void OpenPrimitives ()
 both, called from SetupOutputs() (mostly for motion, but main does ears), uses open to tell which to open

void SetupOutputs (const bool to_open[NumOutputs])
 both, called from DoInit() (mostly for motion, but main does ears)

RCRegion * InitRegion (unsigned int size)
 both, called to set up a shared memory region of a given size

void addRunLevel ()
 Main, checks runLevel and creates StartBehavior when ready.

OLEDValue calcLEDValue (unsigned int i, float x)
 Motion only, maintains the activation level of the LEDs, returns whether it should be 'fired'.


Static Protected Member Functions

float clipRange01 (float f)
 returns f clipped to be between 0 and 1


Protected Attributes

RCRegion * motmanMemRgn
 Motion creates, Main receives.

RCRegion * worldStateMemRgn
 Main creates, Motion receives.

RCRegion * soundManagerMemRgn
 SoundPlay creates, Main & Motion receives.

RCRegion * eventTranslatorQueueMemRgn
 Main creates, Motion (& SoundPlay) receive.

OPrimitiveID primIDs [NumOutputs]
 both, Main ears only, Motion the rest

RCRegion * region [NUM_COMMAND_VECTOR]
 both, the actual buffers

float ledActivation [NumLEDs]
 Motion, used for partial LED activation.

unsigned int runLevel
 Main, incremented until all sections are ready.

bool open [NumOutputs]
 both, holds information regarding which outputs are open in ("controlled by") this process

unsigned int num_open
 both, count of how many are open

EventTranslator etrans
 both, allows events to be sent between processes (from other processes besides these two too)

bool RPOPENR_isready
 true if we've received a ready message from a remote process

bool isStopped
 true if we've received a DoStart and no DoStop - we need this because sometimes an extra message seems to slip in after we've been told to stop, in which case we should ignore it


Static Protected Attributes

const unsigned int NUM_COMMAND_VECTOR = 2
 both, for double buffering

const unsigned int readyLevel = 5
 Main, runLevel at which StartBehavior is created. (1st power event, 1st sensor event, motman init, sndman init, MainObj::DoStart()).


Private Member Functions

 MMCombo (const MMCombo &)
 should never be called...

MMCombooperator= (const MMCombo &)
 should never be called...


Constructor & Destructor Documentation

MMCombo::MMCombo  ) 
 

constructor

Definition at line 29 of file MMCombo.cc.

virtual MMCombo::~MMCombo  )  [inline, virtual]
 

destructor

Definition at line 34 of file MMCombo.h.

MMCombo::MMCombo const MMCombo  )  [private]
 

should never be called...


Member Function Documentation

void MMCombo::addRunLevel  )  [protected]
 

Main, checks runLevel and creates StartBehavior when ready.

Definition at line 674 of file MMCombo.cc.

Referenced by DoStart(), GotMotionManager(), GotPowerEvent(), GotSensorFrame(), and GotSoundManager().

void MMCombo::BindCont void *  msg  )  [inline]
 

main only, called when //ALTODO

Definition at line 61 of file MMCombo.h.

Referenced by _BindCont().

OLEDValue MMCombo::calcLEDValue unsigned int  i,
float  x
[inline, protected]
 

Motion only, maintains the activation level of the LEDs, returns whether it should be 'fired'.

Definition at line 103 of file MMCombo.h.

Referenced by ReadySendJoints().

float MMCombo::clipRange01 float  f  )  [inline, static, protected]
 

returns f clipped to be between 0 and 1

Definition at line 122 of file MMCombo.h.

Referenced by ReadySendJoints().

void MMCombo::CloseCont void *  msg  )  [inline]
 

main only, called when //ALTODO

Definition at line 65 of file MMCombo.h.

Referenced by _CloseCont().

void MMCombo::ConnectCont void *  msg  )  [inline]
 

main only, called when //ALTODO

Definition at line 62 of file MMCombo.h.

Referenced by _ConnectCont().

OStatus MMCombo::DoDestroy const OSystemEvent &   )  [virtual]
 

last call (before destructor), clean up memory here

Definition at line 166 of file MMCombo.cc.

OStatus MMCombo::DoInit const OSystemEvent &   )  [virtual]
 

first call (after constructor), set up memory

Definition at line 43 of file MMCombo.cc.

OStatus MMCombo::DoStart const OSystemEvent &   )  [virtual]
 

second call, ask for messages

Definition at line 124 of file MMCombo.cc.

OStatus MMCombo::DoStop const OSystemEvent &   )  [virtual]
 

next to last call, stop sending and receiving messages

Definition at line 150 of file MMCombo.cc.

void MMCombo::GotEventTranslatorQueue const ONotifyEvent &  event  ) 
 

motion only, called when EventTranslatorQueue is received

Definition at line 266 of file MMCombo.cc.

void MMCombo::GotImage const ONotifyEvent &  event  ) 
 

main only, called when a new image is available

Definition at line 469 of file MMCombo.cc.

void MMCombo::GotMotionManager const ONotifyEvent &  event  ) 
 

main only, called when motman global is received

Definition at line 232 of file MMCombo.cc.

void MMCombo::GotMotionMsg const ONotifyEvent &  event  ) 
 

both, called when a new MotionManagerMsg has been received

Definition at line 520 of file MMCombo.cc.

void MMCombo::GotPowerEvent void *  msg  ) 
 

main only, called when a power event occurs (can be just status events)

Definition at line 489 of file MMCombo.cc.

Referenced by _GotPowerEvent().

void MMCombo::GotSensorFrame const ONotifyEvent &  event  ) 
 

main only, called when new sensor information is available

Definition at line 443 of file MMCombo.cc.

void MMCombo::GotSoundManager const ONotifyEvent &  event  ) 
 

both, called when the sndman global is received

Definition at line 536 of file MMCombo.cc.

void MMCombo::GotWorldState const ONotifyEvent &  event  ) 
 

motion only, called when state global is received

Definition at line 201 of file MMCombo.cc.

RCRegion * MMCombo::InitRegion unsigned int  size  )  [protected]
 

both, called to set up a shared memory region of a given size

Will round up size to the nearest page

Definition at line 665 of file MMCombo.cc.

Referenced by DoInit().

void MMCombo::ListenCont void *  msg  )  [inline]
 

main only, called when //ALTODO

Definition at line 60 of file MMCombo.h.

Referenced by _ListenCont().

void MMCombo::OpenPrimitives  )  [protected]
 

both, called from SetupOutputs() (mostly for motion, but main does ears), uses open to tell which to open

Definition at line 550 of file MMCombo.cc.

Referenced by SetupOutputs().

MMCombo& MMCombo::operator= const MMCombo  )  [private]
 

should never be called...

void MMCombo::ReadyRegisterEventTranslatorQueue const OReadyEvent &   ) 
 

main only, send out the EventTranslatorQueue

Called when MotoObj is initially ready as well as when it has finished processing the previous message - we only want to do this the first time otherwise we infinite loop.

Definition at line 253 of file MMCombo.cc.

void MMCombo::ReadyRegisterMotionManager const OReadyEvent &   ) 
 

motion only, send out motman global

Called when MainObj is initially ready as well as when it has finished processing the previous message - we only want to do this the first time otherwise we infinite loop.

Definition at line 219 of file MMCombo.cc.

void MMCombo::ReadyRegisterWorldState const OReadyEvent &   ) 
 

main only, send out the state global

Called when MotoObj is initially ready as well as when it has finished processing the previous message - we only want to do this the first time otherwise we infinite loop.

Definition at line 188 of file MMCombo.cc.

void MMCombo::ReadySendJoints const OReadyEvent &  event  ) 
 

motion only (until main does ears again, then both) calls SendJoints, if DoStart has already been called

Definition at line 284 of file MMCombo.cc.

void MMCombo::ReceiveCont void *  msg  )  [inline]
 

main only, called when //ALTODO

Definition at line 64 of file MMCombo.h.

Referenced by _ReceiveCont().

bool MMCombo::RPOPENR_isReady  )  [inline]
 

main only, called when //ALTODO

Definition at line 67 of file MMCombo.h.

void MMCombo::RPOPENR_notify const ONotifyEvent &  event  ) 
 

main only, called when //ALTODO

Definition at line 684 of file MMCombo.cc.

void MMCombo::RPOPENR_ready const OReadyEvent &   )  [inline]
 

main only, called when //ALTODO

Definition at line 70 of file MMCombo.h.

int MMCombo::RPOPENR_send char *  buf,
int  bufsize
 

main only, called when //ALTODO

Definition at line 699 of file MMCombo.cc.

void MMCombo::SendCont void *  msg  )  [inline]
 

main only, called when //ALTODO

Definition at line 63 of file MMCombo.h.

Referenced by _SendCont().

void MMCombo::SetupOutputs const bool  to_open[NumOutputs]  )  [protected]
 

both, called from DoInit() (mostly for motion, but main does ears)

Definition at line 561 of file MMCombo.cc.

Referenced by DoInit().


Member Data Documentation

EventTranslator MMCombo::etrans [protected]
 

both, allows events to be sent between processes (from other processes besides these two too)

Definition at line 96 of file MMCombo.h.

Referenced by DoInit(), GotEventTranslatorQueue(), GotImage(), GotPowerEvent(), and GotSensorFrame().

RCRegion* MMCombo::eventTranslatorQueueMemRgn [protected]
 

Main creates, Motion (& SoundPlay) receive.

Definition at line 81 of file MMCombo.h.

Referenced by DoDestroy(), DoInit(), GotEventTranslatorQueue(), and ReadyRegisterEventTranslatorQueue().

bool MMCombo::isStopped [protected]
 

true if we've received a DoStart and no DoStop - we need this because sometimes an extra message seems to slip in after we've been told to stop, in which case we should ignore it

Definition at line 100 of file MMCombo.h.

Referenced by DoInit(), DoStart(), DoStop(), GotImage(), GotMotionMsg(), GotPowerEvent(), GotSensorFrame(), and ReadySendJoints().

float MMCombo::ledActivation[NumLEDs] [protected]
 

Motion, used for partial LED activation.

Definition at line 87 of file MMCombo.h.

Referenced by calcLEDValue().

RCRegion* MMCombo::motmanMemRgn [protected]
 

Motion creates, Main receives.

Definition at line 78 of file MMCombo.h.

Referenced by DoDestroy(), DoInit(), GotMotionManager(), and ReadyRegisterMotionManager().

const unsigned int MMCombo::NUM_COMMAND_VECTOR = 2 [static, protected]
 

both, for double buffering

Definition at line 84 of file MMCombo.h.

Referenced by ReadySendJoints(), and SetupOutputs().

unsigned int MMCombo::num_open [protected]
 

both, count of how many are open

Definition at line 94 of file MMCombo.h.

Referenced by ReadySendJoints(), and SetupOutputs().

OObserver* MMCombo::observer[numOfObserver]
 

holds information for each of the sources we're observing

Definition at line 37 of file MMCombo.h.

Referenced by DoInit(), GotEventTranslatorQueue(), GotImage(), GotMotionManager(), GotMotionMsg(), GotSensorFrame(), GotSoundManager(), GotWorldState(), and RPOPENR_notify().

bool MMCombo::open[NumOutputs] [protected]
 

both, holds information regarding which outputs are open in ("controlled by") this process

Definition at line 93 of file MMCombo.h.

Referenced by MMCombo(), OpenPrimitives(), ReadySendJoints(), and SetupOutputs().

OPrimitiveID MMCombo::primIDs[NumOutputs] [protected]
 

both, Main ears only, Motion the rest

Definition at line 83 of file MMCombo.h.

Referenced by MMCombo(), OpenPrimitives(), ReadySendJoints(), and SetupOutputs().

const unsigned int MMCombo::readyLevel = 5 [static, protected]
 

Main, runLevel at which StartBehavior is created. (1st power event, 1st sensor event, motman init, sndman init, MainObj::DoStart()).

Definition at line 90 of file MMCombo.h.

Referenced by addRunLevel().

RCRegion* MMCombo::region[NUM_COMMAND_VECTOR] [protected]
 

both, the actual buffers

Definition at line 85 of file MMCombo.h.

bool MMCombo::RPOPENR_isready [protected]
 

true if we've received a ready message from a remote process

Definition at line 98 of file MMCombo.h.

Referenced by RPOPENR_isReady(), RPOPENR_ready(), and RPOPENR_send().

unsigned int MMCombo::runLevel [protected]
 

Main, incremented until all sections are ready.

Definition at line 89 of file MMCombo.h.

Referenced by addRunLevel().

RCRegion* MMCombo::soundManagerMemRgn [protected]
 

SoundPlay creates, Main & Motion receives.

Definition at line 80 of file MMCombo.h.

Referenced by DoDestroy(), and GotSoundManager().

OSubject* MMCombo::subject[numOfSubject]
 

holds information for each of our subjects (data we provide)

Definition at line 36 of file MMCombo.h.

Referenced by DoInit(), GotMotionManager(), GotSoundManager(), ReadyRegisterEventTranslatorQueue(), ReadyRegisterMotionManager(), ReadyRegisterWorldState(), ReadySendJoints(), and RPOPENR_send().

RCRegion* MMCombo::worldStateMemRgn [protected]
 

Main creates, Motion receives.

Definition at line 79 of file MMCombo.h.

Referenced by DoDestroy(), DoInit(), GotWorldState(), and ReadyRegisterWorldState().


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

Tekkotsu v2.1
Generated Tue Mar 16 23:22:16 2004 by Doxygen 1.3.5