SimpleGameClient.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00025 #ifndef __SIMPLEGAMECLIENT_H_
00026 #define __SIMPLEGAMECLIENT_H_
00027 
00028 #include <map>
00029 #include <Vector2D.h>
00030 #include <BaseApp.h>
00031 #include <string>
00032 
00033 #include <GlobalCoordinator.h>
00034 #include <GlobalStatisticsAccess.h>
00035 #include <MovementGenerator.h>
00036 #include <randomRoaming.h>
00037 #include <groupRoaming.h>
00038 #include <hotspotRoaming.h>
00039 #include <traverseRoaming.h>
00040 #include <greatGathering.h>
00041 #include <realWorldRoaming.h>
00042 #include "SCPacket.h"
00043 #include "SimpleGameClient_m.h"
00044 
00045 #include <tunoutscheduler.h>
00046 #include <realtimescheduler.h>
00047 
00049 
00053 class SimpleGameClient : public BaseApp
00054 {
00055     public:
00056         // OMNeT++
00057         virtual ~SimpleGameClient();
00058         virtual void initializeApp(int stage);
00059         virtual void handleTimerEvent(cMessage* msg);
00060         virtual void handleLowerMessage(cMessage* msg);
00061         virtual void handleReadyMessage(CompReadyMessage* msg);
00062         virtual void finishApp();
00063 
00064         Vector2D getPosition() {return position;};
00065         double getAOI() {return AOIWidth;};
00066         bool isOverlayReady() {return overlayReady;};
00067         NodeHandle getThisNode() {return overlay->getThisNode();};
00068 
00069         NeighborMap Neighbors;
00070 
00071     protected:
00072         GlobalCoordinator* coordinator;
00073         CollisionList CollisionRect;
00074 
00075         void updateNeighbors(GameAPIListMessage* sgcMsg);
00076         void updatePosition();
00077 
00078         // parameters
00079         simtime_t movementDelay;
00080         double areaDimension, movementSpeed, movementRate, AOIWidth;
00081         bool useScenery;
00082         bool overlayReady;
00083         Vector2D position;
00084         MovementGenerator *Generator;
00085         bool logAOI;
00086 
00087         NeighborMap::iterator itNeighbors;
00088         std::string GeneratorType;
00089 
00090         // timers
00091         cMessage* move_timer;
00092 
00093         // realworld
00094         void handleRealworldPacket(char *buf, uint32_t len);
00095         cMessage* packetNotification; // used by TunOutScheduler to notify about new packets
00096         RealtimeScheduler::PacketBuffer packetBuffer; // received packets are stored here
00097         RealtimeScheduler* scheduler;
00098         unsigned int mtu;
00099         SOCKET appFd;
00100         bool doRealworld;
00101         bool frozen;
00102 
00103         // AOI measuring / hotspots
00104         double startAOI;
00105         bool useHotspots;
00106         bool lastInHotspot;
00107         bool lastFarFromHotspot;
00108         simtime_t lastAOImeasure;
00109         double avgAOI;
00110         simtime_t nonHotspotTime;
00111         simtime_t farFromHotspotTime;
00112         double avgFarFromHotspotAOI;
00113         simtime_t hotspotTime;
00114         double avgHotspotAOI;
00115 };
00116 
00117 #endif