Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Platform/Aperios1.3.2/BroadCastStatusHandler.h

Go to the documentation of this file.

    00001 /*******************************************************************
    00002 * Broadcast Status Handler                                        *
    00003 * @Author: Matthias Meyer (robocup@ja-me.de)                      *
    00004 ******************************************************************/
    00005 #ifndef _BroadCastStatusHandler_H_
    00006 #define _BroadCastStatusHandler_H_
    00007
    00008 #include <stdio.h>
    00009 #include <iostream.h>
    00010 #include "NetConfig.h"
    00011 #include "Tools/Debugging/Debugging.h"
    00012 #include "UDPEndpoint.h"
    00013 #include "Tools/Player.h"
    00014
    00015 // Redifinition to use .cs in .h
    00016 #define ignoreThisCSPartInCPP defined doNotDefineThisDefineAsItWillMakeBAAAADThings
    00017
    00018 class DebugDataWorldStateMessage
    00019 {
    00020 public:
    00021   int robotPoseX;
    00022   int robotPoseY;
    00023   double robotPoseRotation;
    00024   bool robotPoseColor;
    00025 };
    00026
    00027 class DebugDataBallStateMessage
    00028 {
    00029 public:
    00030   int seenBallStateX;
    00031   int seenBallStateY;
    00032   int propagatedBallStateX;
    00033   int propagatedBallStateY;
    00034   int communicatedBallStateX;
    00035   int communicatedBallStateY;
    00036 };
    00037
    00038 class DebugDataStatusStateMessage
    00039 {
    00040 public:
    00041   int batteryStatus;
    00042   unsigned long Systemtime;
    00043   unsigned long freeMem;
    00044   unsigned long MAC;
    00045   unsigned int WLANSignalStrengh;
    00046 };
    00047
    00048 class DebugDataRunTimeMessage
    00049 {
    00050 public:
    00051   double CognitionAverage;
    00052   double GTCamAverage;
    00053   double SpecialVisionAverage;
    00054   double SensorBehaviorControlAverage;
    00055   double BehaviorControlAverage;
    00056   double SelfLocatorAverage;
    00057   double ObstaclesLocatorAverage;
    00058   double PlayersLocatorAverage;
    00059   double TeamBallLocatorAverage;
    00060   double BallLocatorAverage;
    00061   double RobotStateDetectorAverage;
    00062   double CollisionDetectorAverage;
    00063   double SensorDataProcessorAverage;
    00064   double ImageProcessorAverage;
    00065   double ColorTableModAverage;
    00066 };
    00067
    00068 class DebugDataDebugStateMessage
    00069 {
    00070 public:
    00071   int DebugPort;
    00072 };
    00073
    00074
    00075
    00076 /**
    00077 * DebugDataControler
    00078 */
    00079
    00080 class DebugDataControlerBase {
    00081 private:
    00082   unsigned int size;
    00083
    00084 public:
    00085
    00086   int getHeaderSize() {
    00087     // HeaderSize = id + sizeOf(int)
    00088     return sizeof(id) + 4;
    00089   }
    00090
    00091 #include <RobotControl2/RobotControl/Tools/BroadCastStatus/BroadCastStatusEnum.cs>
    00092
    00093   TYPEOFDEBUGDATA id;
    00094
    00095   DebugDataControlerBase(TYPEOFDEBUGDATA _id)  {
    00096     id = _id;
    00097   };
    00098
    00099   virtual unsigned int getSize() =0;
    00100
    00101   virtual int write(char* dst, int pos) {
    00102     int writePos = 0;
    00103     memcpy(&dst[pos], &id, sizeof(id));
    00104     writePos += sizeof(id);
    00105
    00106     unsigned int tmpSizeOfData = getSize();
    00107     memcpy(&dst[pos+writePos], &tmpSizeOfData, sizeof(unsigned int));
    00108     writePos += sizeof(unsigned int);
    00109     return writePos;
    00110   };
    00111 };
    00112
    00113
    00114
    00115 class DebugDataControlerWorldStateMessage : public DebugDataControlerBase {
    00116 public:
    00117   DebugDataWorldStateMessage _data;
    00118
    00119   DebugDataControlerWorldStateMessage() : DebugDataControlerBase(worldStateMessage) {
    00120   };
    00121
    00122   virtual unsigned int getSize() {
    00123     return sizeof(_data);
    00124   };
    00125
    00126   virtual int write(char* dst, int pos) {
    00127     int writePos = DebugDataControlerBase::write(dst,pos);
    00128     memcpy(&dst[pos + writePos],&_data,sizeof(_data));
    00129     writePos += sizeof(_data);
    00130     return writePos;
    00131   };
    00132 };
    00133
    00134 class DebugDataControlerBallStateMessage : public DebugDataControlerBase {
    00135 public:
    00136   DebugDataBallStateMessage _data;
    00137
    00138   DebugDataControlerBallStateMessage() : DebugDataControlerBase(ballStateMessage) {
    00139   };
    00140
    00141   virtual unsigned int getSize() {
    00142     return sizeof(_data);
    00143   };
    00144
    00145   virtual int write(char* dst, int pos) {
    00146     int writePos = DebugDataControlerBase::write(dst,pos);
    00147     memcpy(&dst[pos + writePos],&_data,sizeof(_data));
    00148     writePos += sizeof(_data);
    00149     return writePos;
    00150   };
    00151 };
    00152
    00153 class DebugDataControlerStatusStateMessage : public DebugDataControlerBase {
    00154 public:
    00155   DebugDataStatusStateMessage _data;
    00156
    00157   DebugDataControlerStatusStateMessage() : DebugDataControlerBase(statusStateMessage) {
    00158   };
    00159
    00160   virtual unsigned int getSize() {
    00161     return sizeof(_data);
    00162   };
    00163
    00164   virtual int write(char* dst, int pos) {
    00165     int writePos = DebugDataControlerBase::write(dst,pos);
    00166     memcpy(&dst[pos + writePos],&_data,sizeof(_data));
    00167     writePos += sizeof(_data);
    00168     return writePos;
    00169   };
    00170 };
    00171
    00172 class DebugDataControlerDebugStateMessage : public DebugDataControlerBase {
    00173 public:
    00174   DebugDataDebugStateMessage _data;
    00175
    00176   DebugDataControlerDebugStateMessage() : DebugDataControlerBase(debugStateMessage) {
    00177   };
    00178
    00179   virtual unsigned int getSize() {
    00180     return sizeof(_data);
    00181   };
    00182
    00183   virtual int write(char* dst, int pos) {
    00184     int writePos = DebugDataControlerBase::write(dst,pos);
    00185     memcpy(&dst[pos + writePos],&_data,sizeof(_data));
    00186     writePos += sizeof(_data);
    00187     return writePos;
    00188   };
    00189 };
    00190
    00191 class DebugDataControlerRunTimeMessage : public DebugDataControlerBase {
    00192 public:
    00193   DebugDataRunTimeMessage _data;
    00194
    00195   DebugDataControlerRunTimeMessage() : DebugDataControlerBase(runTime) {
    00196   };
    00197
    00198   virtual unsigned int getSize() {
    00199     return sizeof(_data);
    00200   };
    00201
    00202   virtual int write(char* dst, int pos) {
    00203     int writePos = DebugDataControlerBase::write(dst,pos);
    00204     memcpy(&dst[pos + writePos],&_data,sizeof(_data));
    00205     writePos += sizeof(_data);
    00206     return writePos;
    00207   };
    00208 };
    00209
    00210
    00211
    00212 /**
    00213 * Main class
    00214 */
    00215 class BroadCastStatusHandler : public UDPEndpoint
    00216 {
    00217 public:
    00218   BroadCastStatusHandler();
    00219   ~BroadCastStatusHandler();
    00220   void initBroadCastStatusHandler();
    00221   void sendStatusPackage();
    00222   DebugDataControlerBase* thePackage[DebugDataControlerBase::nrOfDebugTypes];
    00223 };
    00224
    00225 #undef ignoreThisCSPartInCPP
    00226 #endif