Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

ChannelControl.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        ChannelControl.h
00003  *
00004  * author:      Steffen Sroka, Daniel Willkomm
00005  *
00006  * copyright:   (C) 2004 Telecommunication Networks Group (TKN) at
00007  *              Technische Universitaet Berlin, Germany.
00008  *
00009  *              This program is free software; you can redistribute it 
00010  *              and/or modify it under the terms of the GNU General Public 
00011  *              License as published by the Free Software Foundation; either
00012  *              version 2 of the License, or (at your option) any later 
00013  *              version.
00014  *              For further information see file COPYING 
00015  *              in the top level directory
00016  ***************************************************************************
00017  * part of:     framework implementation developed by tkn
00018  * description: Module to control the channel and handle all connection
00019  *              related stuff
00020  **************************************************************************/
00021 
00022 #ifndef CHANNELCONTROL_H
00023 #define CHANNELCONTROL_H
00024 
00025 #include <omnetpp.h>
00026 #include <list>
00027 #include <vector>
00028 
00029 #include "Coord.h"
00030 #include "NicEntry.h"
00031 
00044 class ChannelControl : public cSimpleModule
00045 {
00046 protected:
00048     bool coreDebug;
00049 
00050     typedef std::map<int, NicEntry*> NicEntries;
00051     typedef std::vector<NicEntries> RowVector;
00052     typedef std::vector<RowVector> NicMatrix;
00053 
00059     NicMatrix nics;
00060 
00062     bool sendDirect;
00063 
00065     Coord playgroundSize;
00066     
00068     double maxInterferenceDistance;
00069 
00073     double maxDistSquared;
00074 
00080     double findDistance;
00081 
00085     unsigned maxX, maxY;
00086 
00091     bool useTorus;
00092     
00093 protected:
00102     bool increment(unsigned max, unsigned src, unsigned* target) {
00103         bool res = true;
00104         unsigned v = src + 1;
00105         if(src == max) {
00106             v = 0;
00107             if(!useTorus) res = false;
00108         }
00109         *target = v;
00110         return res;
00111     }
00112     
00117     bool decrement(unsigned max, unsigned src, unsigned* target) {
00118         bool res = true;
00119         unsigned v = src - 1;
00120         if(src == 0) {
00121             v = max;
00122             if(!useTorus) res = false;
00123         }
00124         *target = v;
00125         return res;
00126     }
00127 
00131     bool inRangeEuclid(const Coord& a, const Coord& b) {
00132         return a.sqrdist(b) < maxDistSquared;
00133     }
00134 
00139     bool inRangeTorus(const Coord& a, const Coord& b);
00144 public:
00148     Module_Class_Members(ChannelControl, cSimpleModule, 0);
00149     
00154     virtual void initialize();
00155     
00157     // const Coord* getNicPos( int );
00158     
00160     bool registerNic( cModule*, const Coord* );
00161     
00163     void updateNicPos(int, const Coord* oldPos, const Coord* newPos);
00164     
00166     const Coord* getPgs(){
00167         return &playgroundSize;
00168     };
00169     
00170     const NicEntry::GateList& getGateList( int, const Coord* );
00171 
00172     const cGate* getOutGateTo(int, int, const Coord*);
00173   
00175     static const double speedOfLight;
00176 
00177 protected:
00179     void updateConnections(NicEntries& nmap, NicEntry* nic);
00180     
00182     virtual double calcInterfDist();
00183 
00187     void checkGrid(unsigned oldX, unsigned oldY,
00188                    unsigned newX, unsigned newY,
00189                    int id);
00190 };
00191 
00192 #endif

Generated on Fri Jan 12 08:29:32 2007 for Mobility Framework by  doxygen 1.4.4