00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef SensorObserver_h_DEFINED
00013 #define SensorObserver_h_DEFINED
00014
00015 #include <OPENR/OObject.h>
00016 #include <OPENR/OSubject.h>
00017 #include <OPENR/OObserver.h>
00018 #include "def.h"
00019
00020 const int NUM_COMMON_SENSORS = 28;
00021 const int NUM_ERS210_SENSORS = 3;
00022 const int NUM_ERS220_SENSORS = 3;
00023
00024 const int ACC_Y = 0;
00025 const int ACC_X = 1;
00026 const int ACC_Z = 2;
00027 const int TACT_R = 3;
00028 const int TACT_F = 4;
00029 const int TIN_SW = 5;
00030 const int PSD = 6;
00031 const int HEAD_TILT = 7;
00032 const int HEAD_PAN = 8;
00033 const int HEAD_ROLL = 9;
00034 const int RFLEG_J1 = 10;
00035 const int RFLEG_J2 = 11;
00036 const int RFLEG_J3 = 12;
00037 const int RFLEG_SW = 13;
00038 const int LFLEG_J1 = 14;
00039 const int LFLEG_J2 = 15;
00040 const int LFLEG_J3 = 16;
00041 const int LFLEG_SW = 17;
00042 const int RRLEG_J1 = 18;
00043 const int RRLEG_J2 = 19;
00044 const int RRLEG_J3 = 20;
00045 const int RRLEG_SW = 21;
00046 const int LRLEG_J1 = 22;
00047 const int LRLEG_J2 = 23;
00048 const int LRLEG_J3 = 24;
00049 const int LRLEG_SW = 25;
00050 const int BACK_SW = 26;
00051 const int THERMO = 27;
00052
00053 const int MOUTH = 0;
00054 const int TAIL_PAN = 1;
00055 const int TAIL_TILT = 2;
00056
00057 const int TAIL_SW_L = 0;
00058 const int TAIL_SW_M = 1;
00059 const int TAIL_SW_R = 2;
00060
00061 static const char* const COMMON_SENSOR_LOCATOR[] = {
00062
00063 "PRM:/a1-Sensor:a1",
00064 "PRM:/a2-Sensor:a2",
00065 "PRM:/a3-Sensor:a3",
00066
00067
00068 "PRM:/r1/c1/c2/c3/f1-Sensor:f1",
00069 "PRM:/r1/c1/c2/c3/f2-Sensor:f2",
00070 "PRM:/r1/c1/c2/c3/c4/s5-Sensor:s5",
00071 "PRM:/r1/c1/c2/c3/p1-Sensor:p1",
00072 "PRM:/r1/c1-Joint2:j1",
00073 "PRM:/r1/c1/c2-Joint2:j2",
00074 "PRM:/r1/c1/c2/c3-Joint2:j3",
00075
00076
00077 "PRM:/r4/c1-Joint2:j1",
00078 "PRM:/r4/c1/c2-Joint2:j2",
00079 "PRM:/r4/c1/c2/c3-Joint2:j3",
00080 "PRM:/r4/c1/c2/c3/c4-Sensor:s4",
00081
00082
00083 "PRM:/r2/c1-Joint2:j1",
00084 "PRM:/r2/c1/c2-Joint2:j2",
00085 "PRM:/r2/c1/c2/c3-Joint2:j3",
00086 "PRM:/r2/c1/c2/c3/c4-Sensor:s4",
00087
00088
00089 "PRM:/r5/c1-Joint2:j1",
00090 "PRM:/r5/c1/c2-Joint2:j2",
00091 "PRM:/r5/c1/c2/c3-Joint2:j3",
00092 "PRM:/r5/c1/c2/c3/c4-Sensor:s4",
00093
00094
00095 "PRM:/r3/c1-Joint2:j1",
00096 "PRM:/r3/c1/c2-Joint2:j2",
00097 "PRM:/r3/c1/c2/c3-Joint2:j3",
00098 "PRM:/r3/c1/c2/c3/c4-Sensor:s4",
00099
00100
00101 "PRM:/r6/s1-Sensor:s1",
00102 "PRM:/r6/t1-Sensor:t1"
00103 };
00104
00105 static const char* const ERS210_SENSOR_LOCATOR[] = {
00106
00107 "PRM:/r1/c1/c2/c3/c4-Joint2:j4",
00108
00109
00110 "PRM:/r6/c1-Joint2:j1",
00111 "PRM:/r6/c2-Joint2:j2"
00112 };
00113
00114 static const char* const ERS220_SENSOR_LOCATOR[] = {
00115
00116 "PRM:/r6/s2-Sensor:s2",
00117 "PRM:/r6/s3-Sensor:s3",
00118 "PRM:/r6/s4-Sensor:s4"
00119 };
00120
00121 class SensorObserver : public OObject {
00122 public:
00123 SensorObserver();
00124 virtual ~SensorObserver() {}
00125
00126 OSubject* subject[numOfSubject];
00127 OObserver* observer[numOfObserver];
00128
00129 virtual OStatus DoInit (const OSystemEvent& event);
00130 virtual OStatus DoStart (const OSystemEvent& event);
00131 virtual OStatus DoStop (const OSystemEvent& event);
00132 virtual OStatus DoDestroy(const OSystemEvent& event);
00133
00134 void NotifyERS210(const ONotifyEvent& event);
00135 void NotifyERS220(const ONotifyEvent& event);
00136
00137 private:
00138 void InitCommonSensorIndex(OSensorFrameVectorData* sensorVec);
00139 void InitERS210SensorIndex(OSensorFrameVectorData* sensorVec);
00140 void InitERS220SensorIndex(OSensorFrameVectorData* sensorVec);
00141 void PrintCommonSensor(OSensorFrameVectorData* sensorVec);
00142 void PrintERS210Sensor(OSensorFrameVectorData* sensorVec);
00143 void PrintERS220Sensor(OSensorFrameVectorData* sensorVec);
00144 void PrintSensorValue(OSensorFrameVectorData* sensorVec, int index);
00145 void PrintJointValue(OSensorFrameVectorData* sensorVec, int index);
00146 void PrintSeparator();
00147 void WaitReturnKey();
00148
00149 bool initSensorIndex;
00150 int commonidx[NUM_COMMON_SENSORS];
00151 int ers210idx[NUM_ERS210_SENSORS];
00152 int ers220idx[NUM_ERS220_SENSORS];
00153 };
00154
00155 #endif // SensorObserver_h_DEFINED