Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Main.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_Main_h_
00003 #define INCLUDED_Main_h_
00004 
00005 #include "Process.h"
00006 #include "sim.h"
00007 #include "IPC/SharedObject.h"
00008 #include "SharedGlobals.h"
00009 #include "Motion/MotionManager.h"
00010 #include "Sound/SoundManager.h"
00011 #include "Shared/WorldStatePool.h"
00012 #include "local/EntryPoint.h"
00013 #include "Vision/BufferedImageGenerator.h"
00014 #include "Shared/Profiler.h"
00015 #include "Events/EventListener.h"
00016 
00017 class Main : public Process, public virtual EventListener {
00018 public:
00019   //! constructor
00020   Main();
00021   //! destructor
00022   ~Main();
00023 
00024   virtual void DoStart();
00025   virtual void run();
00026   virtual void DoStop();
00027   
00028   //! listens for a sensor update event, then calls SharedGlobals::signalHaveSensors()
00029   virtual void processEvent(const EventBase& event);
00030 
00031   static const char* getClassName() { return "Main"; }
00032   static ProcessID::ProcessID_t getID() { return ProcessID::MainProcess; }
00033   
00034   static const char * getEventsID() { return "MainEvents"; }
00035   static const char * getWorldStatePoolID() { return "WorldStatePool"; }
00036   
00037 protected:
00038   SharedObject<sim::SoundPlayQueue_t> sounds;
00039   SharedObject<sim::MotionCommandQueue_t> motions;
00040   SharedObject<sim::EventQueue_t> events;
00041   SharedObject<sim::CameraQueue_t> cameraFrames;
00042   SharedObject<sim::SensorQueue_t> sensorFrames;
00043   SharedObject<sim::TimerWakeup_t> timerWakeup;
00044   SharedObject<sim::StatusRequest_t> statusRequest;
00045   SharedObject<MotionManager> motionmanager;
00046   SharedObject<SoundManager> soundmanager;
00047   SharedObject<WorldStatePool> worldstatepool;
00048   SharedObject<motionProfiler_t> motionProf;
00049   SharedObject<soundProfiler_t> soundProf;
00050   
00051   class MessageReceiver * visrecv;
00052   class MessageReceiver * sensrecv;
00053   class MessageReceiver * evtrecv;
00054   class MessageReceiver * timerrecv;
00055   class MessageReceiver * statusrecv;
00056   class TimerExecThread * timerExec;
00057   bool visionRead;
00058   WirelessThread wireless_thread;
00059   WorldState worldStateCache; //!< used for temporary storage when parsing sensor frames, allocation here avoids rather costly constructor call on every sensor frame
00060   EntryPoint behaviorLock;
00061 
00062   static bool gotCamera(RCRegion* msg);
00063   static bool gotSensors(RCRegion* msg);
00064   static bool gotEvent(RCRegion* msg);
00065   static bool gotTimer(RCRegion* msg);
00066   RCRegion * curimgregion;
00067   BufferedImageGenerator::ImageSource img; //!< root data source for vision stream, references data in #curimgregion
00068   unsigned int lastVisionSN; //!< serial number of last camera frame, just so we can give warning message when we drop (if verbose is set)
00069   unsigned int lastSensorSN; //!< serial number of last sensor frame, just so we can give warning message when we drop (if verbose is set)
00070   unsigned int lastSensorUpdateTime; //!< time that last sensor update was posted
00071   
00072 private:
00073   Main(const Main&); //!< don't call (copy constructor)
00074   Main& operator=(const Main&); //!< don't call (assignment operator)
00075 };
00076 
00077 /*! @file
00078  * @brief Defines Main, which DESCRIPTION
00079  * @author ejt (Creator)
00080  *
00081  * $Author: ejt $
00082  * $Name: tekkotsu-4_0 $
00083  * $Revision: 1.2 $
00084  * $State: Exp $
00085  * $Date: 2007/11/09 19:01:17 $
00086  */
00087 
00088 #endif

Tekkotsu Hardware Abstraction Layer 4.0
Generated Thu Nov 22 01:00:53 2007 by Doxygen 1.5.4