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'.


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 27 of file MMCombo.cc.

References Profiler::initBuckets(), ERS210Info::NumOutputs, open, and primIDs.

Here is the call graph for this function:

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 601 of file MMCombo.cc.

References BehaviorBase::DoStart(), readyLevel, runLevel, and startupBehavior.

Here is the call graph for this function:

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

main only, called when //ALTODO

Definition at line 61 of file MMCombo.h.

References Wireless::BindCont(), and wireless.

Here is the call graph for this function:

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.

References ledActivation.

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

main only, called when //ALTODO

Definition at line 65 of file MMCombo.h.

References Wireless::CloseCont(), and wireless.

Here is the call graph for this function:

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

main only, called when //ALTODO

Definition at line 62 of file MMCombo.h.

References Wireless::ConnectCont(), and wireless.

Here is the call graph for this function:

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

last call (before destructor), clean up memory here

Definition at line 165 of file MMCombo.cc.

References erouter, eventTranslatorQueueMemRgn, motmanMemRgn, ReferenceCounter::RemoveReference(), soundManagerMemRgn, startupBehavior, and worldStateMemRgn.

Here is the call graph for this function:

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

first call (after constructor), set up memory

Definition at line 41 of file MMCombo.cc.

References ReferenceCounter::AddReference(), config, Vision::enableEvents(), erouter, etrans, eventTranslatorQueueMemRgn, MotionManager::InitAccess(), InitRegion(), ERS210Info::IsFastOutput, isStopped, ProcessID::MainProcess, MotionManager::MAX_MOTIONS, ProcessID::MotionProcess, motman, motmanMemRgn, ERS210Info::NumOutputs, observer, EventTranslator::Queue_t, serr, Wireless::setDaemon(), Socket::setFlushType(), Socket::setForward(), ProcessID::setID(), MotionCommand::setQueue(), EventTranslator::setQueue(), Socket::setTextForward(), SetupOutputs(), Wireless::socket(), sout, startupBehavior, state, subject, vision, wireless, Wireless::WIRELESS_DEF_RECV_SIZE, Wireless::WIRELESS_DEF_SEND_SIZE, and worldStateMemRgn.

Here is the call graph for this function:

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

second call, ask for messages

Definition at line 124 of file MMCombo.cc.

References addRunLevel(), config, Config::main_config::console_port, erouter, isStopped, Wireless::listen(), Config::main, WorldState::read(), serr, sout, state, Config::main_config::stderr_port, and wireless.

Here is the call graph for this function:

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

next to last call, stop sending and receiving messages

Definition at line 149 of file MMCombo.cc.

References Wireless::close(), BehaviorBase::DoStop(), isStopped, serr, sout, startupBehavior, and wireless.

Here is the call graph for this function:

void MMCombo::GotEventTranslatorQueue const ONotifyEvent &  event  ) 
 

motion only, called when EventTranslatorQueue is received

Definition at line 265 of file MMCombo.cc.

References EventRouter::addTrapper(), ASSERT, erouter, etrans, eventTranslatorQueueMemRgn, observer, EventTranslator::Queue_t, MotionCommand::setQueue(), and EventTranslator::setQueue().

Here is the call graph for this function:

void MMCombo::GotImage const ONotifyEvent &  event  ) 
 

main only, called when a new image is available

Definition at line 417 of file MMCombo.cc.

References erouter, etrans, Vision::imageLayer, isStopped, WorldState::mainProfile, observer, Vision::processFrame(), EventRouter::processTimers(), PROFSECTION, state, EventTranslator::translateEvents(), vision, and WMvari.

Here is the call graph for this function:

void MMCombo::GotMotionManager const ONotifyEvent &  event  ) 
 

main only, called when motman global is received

Definition at line 231 of file MMCombo.cc.

References addRunLevel(), ASSERT, MotionManager::InitAccess(), motman, motmanMemRgn, observer, and subject.

Here is the call graph for this function:

void MMCombo::GotMotionMsg const ONotifyEvent &  event  ) 
 

both, called when a new MotionManagerMsg has been received

Definition at line 482 of file MMCombo.cc.

References isStopped, motman, observer, and MotionManager::receivedMsg().

Here is the call graph for this function:

void MMCombo::GotPowerEvent void *  msg  ) 
 

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

Definition at line 451 of file MMCombo.cc.

References addRunLevel(), erouter, etrans, isStopped, WorldState::mainProfile, WorldState::powerFlags, EventRouter::processTimers(), PROFSECTION, WorldState::read(), state, and EventTranslator::translateEvents().

Here is the call graph for this function:

void MMCombo::GotSensorFrame const ONotifyEvent &  event  ) 
 

main only, called when new sensor information is available

Definition at line 389 of file MMCombo.cc.

References addRunLevel(), erouter, etrans, isStopped, WorldState::mainProfile, observer, EventRouter::processTimers(), PROFSECTION, WorldState::read(), WorldStateSerializer::serialize(), state, EventTranslator::translateEvents(), and WorldState::wsser.

Here is the call graph for this function:

void MMCombo::GotSoundManager const ONotifyEvent &  event  ) 
 

both, called when the sndman global is received

Definition at line 498 of file MMCombo.cc.

References addRunLevel(), ASSERT, SoundManager::InitAccess(), observer, sndman, soundManagerMemRgn, and subject.

Here is the call graph for this function:

void MMCombo::GotWorldState const ONotifyEvent &  event  ) 
 

motion only, called when state global is received

Definition at line 200 of file MMCombo.cc.

References ASSERT, observer, state, and worldStateMemRgn.

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 592 of file MMCombo.cc.

References ASSERT.

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

main only, called when //ALTODO

Definition at line 60 of file MMCombo.h.

References Wireless::ListenCont(), and wireless.

Here is the call graph for this function:

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 512 of file MMCombo.cc.

References ERS210Info::NumOutputs, open, primIDs, and ERS210Info::PrimitiveName.

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 252 of file MMCombo.cc.

References eventTranslatorQueueMemRgn, and subject.

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 218 of file MMCombo.cc.

References motmanMemRgn, and subject.

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 187 of file MMCombo.cc.

References subject, and worldStateMemRgn.

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 283 of file MMCombo.cc.

References ASSERTRET, ERS210Info::BinJointOffset, calcLEDValue(), ProcessID::getID(), Profiler::getNewID(), MotionManager::getOutputs(), isStopped, ERS210Info::LEDOffset, ProcessID::MainProcess, WorldState::mainProfile, ProcessID::MotionProcess, WorldState::motionProfile, motman, NUM_COMMAND_VECTOR, num_open, ERS210Info::NumBinJoints, ERS210Info::NumFrames, ERS210Info::NumLEDs, ERS210Info::NumOutputs, ERS210Info::NumPIDJoints, ERS210Info::NumSlowFrames, open, WorldState::outputs, ERS210Info::PIDJointOffset, primIDs, region, Profiler::Timer::setID(), state, subject, MotionManager::updatePIDs(), and MotionManager::updateWorldState().

Here is the call graph for this function:

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

main only, called when //ALTODO

Definition at line 64 of file MMCombo.h.

References Wireless::ReceiveCont(), and wireless.

Here is the call graph for this function:

bool MMCombo::RPOPENR_isReady  )  [inline]
 

main only, called when //ALTODO

Definition at line 67 of file MMCombo.h.

References RPOPENR_isready.

void MMCombo::RPOPENR_notify const ONotifyEvent &  event  ) 
 

main only, called when //ALTODO

Definition at line 611 of file MMCombo.cc.

References erouter, observer, and EventRouter::postEvent().

Here is the call graph for this function:

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

main only, called when //ALTODO

Definition at line 70 of file MMCombo.h.

References RPOPENR_isready.

int MMCombo::RPOPENR_send char *  buf,
int  bufsize
 

main only, called when //ALTODO

Definition at line 626 of file MMCombo.cc.

References RPOPENR_isready, and subject.

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

main only, called when //ALTODO

Definition at line 63 of file MMCombo.h.

References Wireless::SendCont(), and wireless.

Here is the call graph for this function:

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

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

Definition at line 523 of file MMCombo.cc.

References ASSERT, ERS210Info::BinJointOffset, ERS210Info::LEDOffset, NUM_COMMAND_VECTOR, num_open, ERS210Info::NumBinJoints, ERS210Info::NumFrames, ERS210Info::NumLEDs, ERS210Info::NumOutputs, ERS210Info::NumPIDJoints, ERS210Info::NumSlowFrames, open, OpenPrimitives(), ERS210Info::PIDJointOffset, primIDs, and region.

Here is the call graph for this function:


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.

RCRegion* MMCombo::eventTranslatorQueueMemRgn [protected]
 

Main creates, Motion (& SoundPlay) receive.

Definition at line 81 of file MMCombo.h.

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.

float MMCombo::ledActivation[NumLEDs] [protected]
 

Motion, used for partial LED activation.

Definition at line 87 of file MMCombo.h.

RCRegion* MMCombo::motmanMemRgn [protected]
 

Motion creates, Main receives.

Definition at line 78 of file MMCombo.h.

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

both, for double buffering

Definition at line 84 of file MMCombo.h.

unsigned int MMCombo::num_open [protected]
 

both, count of how many are open

Definition at line 94 of file MMCombo.h.

OObserver* MMCombo::observer[numOfObserver]
 

holds information for each of the sources we're observing

Definition at line 37 of file MMCombo.h.

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.

OPrimitiveID MMCombo::primIDs[NumOutputs] [protected]
 

both, Main ears only, Motion the rest

Definition at line 83 of file MMCombo.h.

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.

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.

unsigned int MMCombo::runLevel [protected]
 

Main, incremented until all sections are ready.

Definition at line 89 of file MMCombo.h.

RCRegion* MMCombo::soundManagerMemRgn [protected]
 

SoundPlay creates, Main & Motion receives.

Definition at line 80 of file MMCombo.h.

OSubject* MMCombo::subject[numOfSubject]
 

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

Definition at line 36 of file MMCombo.h.

RCRegion* MMCombo::worldStateMemRgn [protected]
 

Main creates, Motion receives.

Definition at line 79 of file MMCombo.h.


The documentation for this class was generated from the following files:
Tekkotsu v1.5
Generated Fri Oct 10 15:56:50 2003 by Doxygen 1.3.4