00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef RADIOSTATE_H
00021 #define RADIOSTATE_H
00022
00023 #include <omnetpp.h>
00024 #include <Blackboard.h>
00025 #include <sstream>
00026
00042 class RadioState : public BBItem
00043 {
00044 BBITEM_METAINFO(BBItem);
00045
00046 public:
00048 enum States
00049 {
00050 SLEEP,
00051 RECV,
00052 SEND,
00053 SWITCH_TO_SLEEP,
00054 SWITCH_TO_RECV,
00055 SWITCH_TO_SEND
00056 };
00057
00058 protected:
00060 States state;
00061
00062 public:
00063
00065 States getState() const {
00066 return state;
00067 }
00068
00070 void setState(States s) {
00071 state=s;
00072 }
00073
00075 RadioState(States s=RECV) : BBItem(), state(s) {
00076 };
00077
00079 std::string info() const {
00080 std::ostringstream ost;
00081 ost << " RadioState is ";
00082 switch(state) {
00083 case SLEEP:
00084 ost<<"SLEEP";
00085 break;
00086 case RECV:
00087 ost<<"RECV";
00088 break;
00089 case SEND:
00090 ost<<"SEND";
00091 break;
00092 case SWITCH_TO_SLEEP:
00093 ost<<"SWITCH_TO_SLEEP";
00094 break;
00095 case SWITCH_TO_RECV:
00096 ost<<"SWITCH_TO_RECV";
00097 break;
00098 case SWITCH_TO_SEND:
00099 ost<<"SWITCH_TO_SEND";
00100 break;
00101 default: ost << "???"; break;
00102 }
00103 return ost.str();
00104 }
00105 };
00106
00107 #endif