Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

RegionCam.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_RegionCam_h_
00003 #define INCLUDED_RegionCam_h_
00004 
00005 #include "Behaviors/BehaviorBase.h"
00006 #include "Shared/Config.h"
00007 
00008 class Socket;
00009 class FilterBankGenerator;
00010 class FilterBankEvent;
00011 
00012 //! Forwards segmented images from camera over wireless
00013 
00014 class RegionCam : public BehaviorBase {
00015 public:
00016   //! constructor
00017   RegionCam();
00018 
00019   static const unsigned int TCP_WIRELESS_BUFFER_SIZE=85000; //!< 85000 bytes for use up to 416x320 pixels / 8 min expected runs * 5 bytes per run + some padding
00020   static const unsigned int UDP_WIRELESS_BUFFER_SIZE=64*1024; //!< 64KB is the max udp packet size
00021 
00022   virtual void doStart();
00023 
00024   virtual void doStop();
00025 
00026   virtual void doEvent();
00027 
00028   static std::string getClassDescription() {
00029     char tmp[20];
00030     sprintf(tmp,"%d",*config->vision.segcam.port);
00031     return std::string("Forwards regions calculated out of images from camera over port ")+tmp;
00032   }
00033   virtual std::string getDescription() const { return getClassDescription(); }
00034   
00035 protected:
00036   void closeServer(); //!<tear down the server socket (#visRegion)
00037   void setupServer(); //!<setup the server socket (#visRegion)
00038   
00039   //! opens a new packet, writes header info; returns true if open, false if otherwise open (check cur==NULL for error)
00040   /*! see the class documentation for RegionCam for the protocol documentation */
00041   bool openPacket(FilterBankGenerator& fbkgen, unsigned int time, unsigned int layer); 
00042   bool writeRegions(const FilterBankEvent& fbke); //!< writes the region information
00043   void closePacket(); //!< closes and sends a packet, does nothing if no packet open
00044 
00045   Socket * visRegion; //!< socket to send image stream over
00046   char * packet; //!< buffer being filled out to be sent
00047   char * cur; //!< current location in #packet
00048   unsigned int avail; //!< number of bytes remaining in #packet
00049   unsigned int max_buf; //!< the buffer size requested from Wireless when the socket was allocated
00050 
00051 private:
00052   RegionCam(const RegionCam&); //!< don't call
00053   RegionCam& operator=(const RegionCam&); //!< don't call
00054 };
00055 
00056 /*! @file
00057  * @brief Implements RegionCam, which forwards the regions from RegionGenerator over wireless
00058  * @author harm & niels (Creators)
00059  */
00060 
00061 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:50 2016 by Doxygen 1.6.3