SimpleNodeEntry.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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
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
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