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

Go to the documentation of this file.

    00001 /*******************************************************************
    00002  * Broadcast Status Handler                                        *
    00003  * @Author: Matthias Meyer (robocup@ja-me.de)                      *
    00004  ******************************************************************/
    00005
    00006 #include "BroadCastStatusHandler.h"
    00007 #include <stdio.h>
    00008 #include <iostream.h>
    00009
    00010 BroadCastStatusHandler::BroadCastStatusHandler() :
    00011 UDPEndpoint(2048,2048)
    00012 {
    00013   // Add new DebugDataPackages here
    00014   thePackage[0] = new DebugDataControlerWorldStateMessage();
    00015   thePackage[1] = new DebugDataControlerBallStateMessage();
    00016   thePackage[2] = new DebugDataControlerStatusStateMessage();
    00017   thePackage[3] = new DebugDataControlerDebugStateMessage();
    00018   thePackage[4] = new DebugDataControlerRunTimeMessage();
    00019 }
    00020
    00021 BroadCastStatusHandler::~BroadCastStatusHandler() {
    00022   // Delete new DebugDataPackages here
    00023   delete thePackage[0];
    00024   delete thePackage[1];
    00025   delete thePackage[2];
    00026   delete thePackage[3];
    00027   delete thePackage[4];
    00028 }
    00029
    00030 void BroadCastStatusHandler::sendStatusPackage()
    00031 {
    00032   int sizeOfMessage = 0;
    00033
    00034 #ifdef NDEBUG
    00035   // send only worldstate
    00036   sizeOfMessage += thePackage[0]->getHeaderSize() + thePackage[0]->getSize();
    00037 #else
    00038   // send all Messages
    00039   for (int i = 0; i < DebugDataControlerBase::nrOfDebugTypes; i++) {
    00040     sizeOfMessage += thePackage[i]->getHeaderSize() + thePackage[i]->getSize();
    00041   }
    00042 #endif
    00043
    00044   char* tmpPackage = new char[sizeOfMessage];
    00045   int tmpBeginMessage = 0;
    00046
    00047 #ifdef NDEBUG
    00048   tmpBeginMessage += thePackage[0]->write(tmpPackage,tmpBeginMessage);
    00049 #else
    00050   for (int i = 0; i < DebugDataControlerBase::nrOfDebugTypes; i++) {
    00051     tmpBeginMessage += thePackage[i]->write(tmpPackage,tmpBeginMessage);
    00052   }
    00053 #endif
    00054
    00055   send(tmpPackage,sizeOfMessage,IP_ADDR_BROADCAST,STATUSBROADCASTPORT);
    00056
    00057   delete tmpPackage;
    00058 }
    00059
    00060 void BroadCastStatusHandler::initBroadCastStatusHandler()
    00061 {
    00062 //  bind(0xC1B0);
    00063   bind(STATUSBROADCASTPORT);
    00064   cout << "BroadCastStatusHandler bind(STATUSBROADCASTPORT" << endl << flush;
    00065 }