Changeset 11034 for trunk/FACT++/src/fscctrl.cc
- Timestamp:
- 06/16/11 17:46:06 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fscctrl.cc
r11033 r11034 39 39 40 40 protected: 41 /* 41 42 virtual void UpdateTemp(float, const vector<float> &) 43 { 44 } 45 46 virtual void UpdateHum(float, const vector<float>&) 47 { 48 } 49 50 virtual void UpdateVolt(float, const vector<float>&) 51 { 52 } 53 54 virtual void UpdateCur(float, const vector<float>&) 55 { 56 } 57 58 /* 42 59 virtual void UpdateError() 43 60 { … … 75 92 } 76 93 94 if (fIsVerbose) 95 Out() << kBold << "Received:" << endl; 96 77 97 istream is(&fBuffer); 78 98 99 int state = 0; 100 bool values = false; 101 int offset = 0; 102 /* 79 103 string buffer; 80 104 while (getline(is, buffer, '\n')) 81 105 { 82 cout << "Line: " << buffer << endl; 106 if (fIsVerbose) 107 Out() << buffer << endl; 108 109 buffer = Tools::Trim(buffer); 110 111 if (buffer.empty()) 112 continue; 113 114 if (buffer.substr(0, 4)=="end.") 115 break; 116 117 if (buffer.substr(0, 8)=="status: ") 118 { 119 } 120 121 if (buffer.substr(0, 8)=="time_s: ") 122 { 123 } 124 125 if (buffer.substr(0, 8)=="VOLTAGES") 126 state = 1; 127 128 if (buffer.substr(0, 11)=="RESISTANCES") 129 state = 2; 130 131 if (state==1 && buffer.substr(0, 7)=="values:") 132 { 133 } 134 135 if (state==2 && buffer.substr(0, 7)=="values:") 136 { 137 values = true; 138 continue; 139 } 140 141 istringtream str(buffer); 142 for (int i=0; i<8; i++) 143 { 144 float f; 145 str >> f; 146 offset += 8; 147 } 83 148 } 84 cout << endl; 149 */ 85 150 /* 86 151 "status: 00000538 \n" … … 108 173 */ 109 174 StartRead(); 110 111 112 175 } 113 176 … … 117 180 boost::bind(&ConnectionFSC::HandleReceivedData, this, 118 181 dummy::error, dummy::bytes_transferred, 0)); 182 183 // FIXME: Add timeout here 119 184 } 120 185 … … 124 189 PostMessage("m", 1); 125 190 126 fBuffer.prepare(10000 0);191 fBuffer.prepare(10000); 127 192 StartRead(); 128 193 } … … 178 243 }; 179 244 180 //const uint16_t ConnectionFSC::kMaxAddr = 0xfff;181 182 245 // ------------------------------------------------------------------------ 183 246 … … 188 251 private: 189 252 190 DimDescribedService fDimPassport; 191 192 template<class T> 193 void Update(DimDescribedService &svc, const T &data) const 194 { 195 //cout << "Update: " << svc.getName() << " (" << sizeof(T) << ")" << endl; 196 svc.setData(const_cast<T*>(&data), sizeof(T)); 253 DimDescribedService fDimTemp; 254 DimDescribedService fDimHum; 255 DimDescribedService fDimVolt; 256 DimDescribedService fDimCurrent; 257 258 void Update(DimDescribedService &svc, vector<float> data, float time) const 259 { 260 data.insert(data.begin(), time); 261 svc.setData(data.data(), data.size()*sizeof(float)); 197 262 svc.updateService(); 198 263 } 199 264 200 /* 201 void UpdateFirstHeader() 202 { 203 ConnectionFSC::UpdateFirstHeader(); 204 205 const FTM::DimPassport data(fHeader); 206 Update(fDimPassport, data); 207 }*/ 265 void UpdateTemp(float time, const vector<float> &temp) 266 { 267 Update(fDimTemp, temp, time); 268 } 269 270 void UpdateHum(float time, const vector<float> &hum) 271 { 272 Update(fDimHum, hum, time); 273 } 274 275 void UpdateVolt(float time, const vector<float> &volt) 276 { 277 Update(fDimVolt, volt, time); 278 } 279 280 void UpdateCur(float time, const vector<float> &curr) 281 { 282 Update(fDimCurrent, curr, time); 283 } 208 284 209 285 public: 210 286 ConnectionDimFSC(ba::io_service& ioservice, MessageImp &imp) : 211 287 ConnectionFSC(ioservice, imp), 212 fDimPassport ("FSC_CONTROL/PASSPORT", "I:1", "") 213 214 // DimService Update (SERVER_NAME"/Time", "F", Val+TIME_OFF, sizeof(float)); 215 // DimService Temperature(SERVER_NAME"/Temperature", "F", Val+TEMP_OFF, sizeof(float)*TEMP_NUM); 216 // DimService Humidity (SERVER_NAME"/Humindity", "F", Val+HUMI_OFF, sizeof(float)*HUMI_NUM); 217 // DimService Voltage (SERVER_NAME"/Voltage", "F", Val+VOLT_OFF, sizeof(float)*VOLT_NUM); 218 // DimService Current (SERVER_NAME"/Current", "F", Val+CURR_OFF, sizeof(float)*CURR_NUM); 288 fDimTemp ("FSC_CONTROL/TEMPERATURE", "F:1;F:64", ""), 289 fDimHum ("FSC_CONTROL/HUMIDITY", "F:1;F:40", ""), 290 fDimVolt ("FSC_CONTROL/VOLTAGE", "F:1;F:40", ""), 291 fDimCurrent("FSC_CONTROL/CURRENT", "F:1;F:4", "") 219 292 { 220 293 } … … 246 319 kStateDisconnected = 1, 247 320 kStateConnected = 2, 248 249 kCmdTest250 321 }; 251 322
Note:
See TracChangeset
for help on using the changeset viewer.