SimpleNodeEntry.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2000 Institut fuer Telematik, Universitaet Karlsruhe
00003 // Copyright (C) 2004 Andras Varga
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 
00026 #ifndef __SIMPLENODEENTRY_H
00027 #define __SIMPLENODEENTRY_H
00028 
00029 
00030 #include <omnetpp.h>
00031 #include <IPvXAddress.h>
00032 
00033 #include "SimpleUDPPacket_m.h"
00034 
00035 
00036 class NodeRecord
00037 {
00038   public:
00039     //NodeRecord(uint32_t dim);
00040     NodeRecord();
00041     ~NodeRecord();
00042     NodeRecord(const NodeRecord& nodeRecord);
00043     NodeRecord& operator=(const NodeRecord& nodeRecord);
00044     void debugOutput(int dim);
00045 
00046     double* coords;
00047     //IPvXAddress ip;
00048     static uint8_t dim;
00049     static void setDim(uint8_t dimension) { dim = dimension; };
00050     uint8_t getDim() const { return dim; };
00051 };
00052 
00058 class SimpleNodeEntry : public cPolymorphic
00059 {
00060 public:
00061 
00062     ~SimpleNodeEntry()
00063     {
00064         if (index == -1) delete nodeRecord;
00065     }
00066 
00076     SimpleNodeEntry(cModule* node, cChannelType* typeRx, cChannelType* typeTx,
00077                     uint32_t sendQueueLength, uint32_t fieldSize);
00078 
00089     SimpleNodeEntry(cModule* node, cChannelType* typeRx, cChannelType* typeTx, uint32_t sendQueueLength,
00090                     NodeRecord* nodeRecord, int index);
00091 
00097     inline cGate* getGate() const
00098     {
00099         return ingate;
00100     };
00101 
00102     typedef std::pair<simtime_t, bool> SimpleDelay; 
00103 
00112     SimpleDelay calcDelay(SimpleUDPPacket* msg,
00113                           const SimpleNodeEntry& dest,
00114                           bool faultyDelay = false);
00115 
00121     std::string info() const;
00122 
00130     friend std::ostream& operator<<(std::ostream& out, const SimpleNodeEntry& entry);
00131 
00132     simtime_t getAccessDelay() const { return tx.accessDelay; };
00133 
00134     // typo fixed, thanks to huebby
00135     float getBandwidth() const { return tx.bandwidth; };
00136 
00137     float getErrorRate() const { return tx.errorRate; };
00138 
00139     inline float getX() const { return nodeRecord->coords[0]; };
00140     inline float getY() const { return nodeRecord->coords[1]; };
00141     inline float getCoords(int dim) const { return nodeRecord->coords[dim]; };
00142     inline uint8_t getDim() const { return nodeRecord->getDim(); };
00143 
00144     int getRecordIndex() const { return index; };
00145     NodeRecord* getNodeRecord() const { return nodeRecord; };
00146 
00152     static simtime_t getFaultyDelay(simtime_t oldDelay);
00153 
00154 
00155 protected:
00156 
00163     float operator-(const SimpleNodeEntry& entry) const;
00164 
00165     cGate* ingate; 
00166 
00167     struct Channel {
00168         simtime_t finished; 
00169         simtime_t maxQueueTime; 
00170         simtime_t accessDelay; 
00171         double bandwidth; 
00172         double errorRate; 
00173     } rx, tx;
00174 
00175     NodeRecord* nodeRecord;
00176     int index;
00177 };
00178 
00179 
00180 #endif // __SIMPLENODEENTRY_H
Generated on Wed May 26 16:21:15 2010 for OverSim by  doxygen 1.6.3