test-LeakDetector.C
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
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include "Devices/BeoChip.H"
00042 #include "BeoSub/BeoSub.H"
00043
00044
00045
00046 class BeoSubLeakDetector : public BeoSub {
00047 public:
00048 BeoSubLeakDetector(OptionManager& mgr,const std::string& descrName,const std::string& tagName);
00049 virtual void turnOpen(Angle, bool);
00050 virtual void advanceRel(float f, bool);
00051 virtual Image<PixRGB<byte> > grabImage(BeoSubCamera) const ;
00052 virtual void dropMarker(bool md);
00053 };
00054
00055
00056 class LeakDetector : public ModelComponent {
00057
00058 public:
00059 LeakDetector(OptionManager& mgr,
00060 const std::string& descrName="LeakDetector",
00061 const std::string& tagName="LeakDetector");
00062 void setBeoChip(nub::soft_ref<BeoChip>& bc);
00063 void setBeoSub(nub::soft_ref<BeoSubLeakDetector>& sub);
00064 bool getState() {return leakState;}
00065
00066 ~LeakDetector();
00067
00068 protected:
00069 void start1();
00070 void stop1();
00071
00072
00073
00074 private:
00075 nub::soft_ref<BeoChip> itsBeoChip;
00076 nub::soft_ref<BeoSubLeakDetector> itsBeoSub;
00077 void dispatchBeoChipEvent(BeoChipEventType t, int valint, float valfloat);
00078 bool leakState;
00079
00080 friend class LeakDetectorListener;
00081
00082 };
00083
00084
00085
00086 class LeakDetectorListener :public BeoChipListener{
00087 public:
00088 LeakDetectorListener(nub::soft_ref<LeakDetector>& ld) : itsLeakDetector(ld) {}
00089
00090 void event(const BeoChipEventType t, const int valint, const float valfloat) {
00091 LDEBUG("Event type %d , vint : %d , vfloat : %f", int(t),valint,valfloat);
00092 itsLeakDetector->dispatchBeoChipEvent(t,valint,valfloat);
00093
00094 }
00095
00096 private:
00097 nub::soft_ref<LeakDetector> itsLeakDetector;
00098
00099 };
00100
00101
00102
00103 LeakDetector::LeakDetector(OptionManager& mgr,const std::string& descrName,const std::string& tagName):
00104 ModelComponent(mgr,descrName,tagName)
00105 {
00106 }
00107
00108 LeakDetector::~LeakDetector() {
00109
00110 }
00111
00112 void LeakDetector::start1() {
00113
00114
00115
00116 return;
00117 }
00118
00119 void LeakDetector::stop1() {
00120
00121 usleep(300000);
00122 return;
00123
00124 }
00125
00126 void LeakDetector::setBeoChip(nub::soft_ref<BeoChip>& bc) {
00127 itsBeoChip = bc;
00128
00129 }
00130
00131 void LeakDetector::setBeoSub(nub::soft_ref<BeoSubLeakDetector>& sub) {
00132
00133 itsBeoSub = sub ;
00134 }
00135
00136 void LeakDetector::dispatchBeoChipEvent(BeoChipEventType t, int valint, float valfloat) {
00137
00138 LDEBUG("Event : %d, valint : %d valfloat : %f",int(t),valint, valfloat);
00139
00140
00141 return;
00142
00143 }
00144
00145 BeoSubLeakDetector::BeoSubLeakDetector(OptionManager& mgr, const std::string& descrName,const std::string& tagName):
00146 BeoSub(mgr,descrName,tagName){}
00147
00148 void BeoSubLeakDetector::turnOpen(Angle, bool) {
00149 LERROR("Not Implemented!");
00150 return;
00151 }
00152
00153 void BeoSubLeakDetector::advanceRel(float relPos, bool) {
00154 LERROR("Not Implemented!");
00155 return;
00156 }
00157
00158 void BeoSubLeakDetector::dropMarker(bool md) {
00159 LERROR("Not Implemented!");
00160 return;
00161 }
00162
00163 Image<PixRGB<byte> > BeoSubLeakDetector::grabImage(BeoSubCamera) const {
00164 LERROR("Not Implemented!");
00165 return Image< PixRGB<byte> >();
00166
00167 }
00168
00169 int main() {
00170
00171 ModelManager manager("Testing Leak Detector");
00172
00173 nub::soft_ref<BeoChip> beochip(new BeoChip(manager)) ;
00174 manager.addSubComponent(beochip);
00175
00176
00177 nub::soft_ref<BeoSubLeakDetector> sub(new BeoSubLeakDetector(manager,"BeoSubLeakDetector","BeoSubLeakDetector"));
00178 manager.addSubComponent(sub);
00179
00180
00181 nub::soft_ref<LeakDetector> leakDetector(new LeakDetector(manager));
00182 manager.addSubComponent(leakDetector);
00183
00184
00185 leakDetector->setBeoChip(beochip);
00186 leakDetector->setBeoSub(sub);
00187
00188
00189 rutz::shared_ptr<LeakDetectorListener> ldLis(new LeakDetectorListener(leakDetector));
00190 rutz::shared_ptr<BeoChipListener> bcLis;
00191 bcLis.dynCastFrom(ldLis);
00192 beochip->setListener(bcLis);
00193
00194 manager.start();
00195
00196 }
00197
00198