cdataratechannel.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __CDATARATECHANNEL_H
00017 #define __CDATARATECHANNEL_H
00018
00019 #include "cchannel.h"
00020 #include "csimulation.h"
00021
00022 NAMESPACE_BEGIN
00023
00024
00030 class SIM_API cDatarateChannel : public cChannel
00031 {
00032 protected:
00033 static simsignal_t channelBusySignal;
00034 static simsignal_t messageSentSignal;
00035 static simsignal_t messageDiscardedSignal;
00036
00037 private:
00038 enum {
00039 FL_ISDISABLED = 128,
00040 FL_DELAY_NONZERO = 256,
00041 FL_DATARATE_NONZERO = 512,
00042 FL_BER_NONZERO = 1024,
00043 FL_PER_NONZERO = 2048,
00044 };
00045
00046
00047 simtime_t delay;
00048 double datarate;
00049 double ber;
00050 double per;
00051
00052
00053 simtime_t txfinishtime;
00054
00055 private:
00056
00057 void checkState() const {if (!parametersFinalized()) throw cRuntimeError(this, ePARAMSNOTREADY);}
00058
00059 protected:
00060
00061 void rereadPars();
00062
00066 virtual void handleParameterChange(const char *parname);
00067
00068 public:
00071
00077 explicit cDatarateChannel(const char *name=NULL);
00078
00082 virtual ~cDatarateChannel();
00083
00088 static cDatarateChannel *create(const char *name);
00090
00097 virtual std::string info() const;
00099
00105 virtual bool isTransmissionChannel() const {return true;}
00106
00110 virtual void setDelay(double d);
00111
00117 virtual void setDatarate(double d);
00118
00124 virtual void setBitErrorRate(double d);
00125
00131 virtual void setPacketErrorRate(double d);
00132
00136 virtual void setDisabled(bool d);
00137
00142 virtual simtime_t getDelay() const {checkState(); return delay;}
00143
00150 virtual double getDatarate() const {checkState(); return datarate;}
00151
00158 virtual double getBitErrorRate() const {checkState(); return ber;}
00159
00166 virtual double getPacketErrorRate() const {checkState(); return per;}
00167
00173 virtual bool isDisabled() const {checkState(); return flags & FL_ISDISABLED;}
00175
00181 virtual double getNominalDatarate() const {return getDatarate();}
00182
00190 virtual simtime_t calculateDuration(cMessage *msg) const;
00191
00200 virtual simtime_t getTransmissionFinishTime() const {return txfinishtime;}
00201
00206 virtual bool isBusy() const {return simTime() < txfinishtime;}
00207
00214 virtual void forceTransmissionFinishTime(simtime_t t);
00216
00222 virtual void initialize();
00223
00227 virtual void processMessage(cMessage *msg, simtime_t t, result_t& result);
00229 };
00230
00231 NAMESPACE_END
00232
00233 #endif
00234
00235