Changeset 13497 for trunk/FACT++/src/smartfact.cc
- Timestamp:
- 05/01/12 14:27:04 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r13483 r13497 62 62 DimStampedInfo fDimMagicWeatherData; 63 63 64 DimStampedInfo fDimFeedback; 64 65 DimStampedInfo fDimFeedbackCalibration; 65 66 … … 75 76 enum weather_t { kTemp = 0, kDew, kHum, kPress, kWind, kGusts, kDir }; 76 77 float fMagicWeatherData[7]; 78 79 vector<float> fFeedbackCalibration; 80 vector<float> fBiasControlVoltageVec; 77 81 78 82 float fBiasControlVoltageMed; … … 231 235 void HandleFeedbackCalibration(const DimData &d) 232 236 { 237 if (!CheckDataSize(d, "Feedback:Calibration", 3*4*416)) 238 { 239 fFeedbackCalibration.clear(); 240 return; 241 } 242 243 const float *ptr = d.ptr<float>(); 244 fFeedbackCalibration.assign(ptr+2*416, ptr+3*416); 245 } 246 247 void HandleBiasControlVoltage(const DimData &d) 248 { 233 249 if (!CheckDataSize(d, "BiasControl:Voltage", 1664)) 234 return; 235 236 vector<float> v(d.ptr<float>(), d.ptr<float>()+320); 250 { 251 fBiasControlVoltageVec.clear(); 252 return; 253 } 254 255 fBiasControlVoltageVec.assign(d.ptr<float>(), d.ptr<float>()+320); 256 257 vector<float> v(fBiasControlVoltageVec); 237 258 sort(v.begin(), v.end()); 238 259 … … 245 266 } 246 267 247 void HandleBiasControlVoltage(const DimData &d)248 {249 if (!CheckDataSize(d, "BiasControl:Voltage", 1664))250 return;251 252 vector<float> v(d.ptr<float>(), d.ptr<float>()+320);253 sort(v.begin(), v.end());254 255 fBiasControlVoltageMed = (v[159]+v[160])/2;256 257 const char *ptr = d.ptr<char>();258 259 ofstream fout("www/biascontrol-voltage.bin");260 fout.write(ptr, 320*sizeof(float));261 }262 263 268 void HandleBiasControlCurrent(const DimData &d) 264 269 { … … 266 271 return; 267 272 268 vector<uint16_t> v(d.ptr<uint16_t>(), d.ptr<uint16_t>()+320); 273 vector<float> v(320); 274 for (int i=0; i<320; i++) 275 v[i] = d.ptr<uint16_t>()[i]; 276 277 if (fFeedbackCalibration.size()>0 && fBiasControlVoltageVec.size()>0) 278 for (int i=0; i<320; i++) 279 v[i] -= fBiasControlVoltageVec[i]/fFeedbackCalibration[i]*1e6; 280 281 vector<uint8_t> val(160, 0); 282 for (int i=0; i<160; i++) 283 { 284 const float I = max(v[i*2], v[i*2+1]); 285 286 float range = nearbyint(128*I/1000); // [0, 1000uA] 287 if (range>127) 288 range=127; 289 if (range<0) 290 range=0; 291 val[i] = (uint8_t)range; 292 } 293 269 294 sort(v.begin(), v.end()); 270 295 … … 273 298 fBiasControlCurrentMax = v[316] * 5000./4096; 274 299 275 const char *ptr = d.ptr<char>();300 const char *ptr = reinterpret_cast<char*>(val.data()); 276 301 277 302 ofstream fout("www/biascontrol-current.bin"); 278 fout.write(ptr, 320*sizeof(uint16_t));303 fout.write(ptr, 160*sizeof(uint8_t)); 279 304 } 280 305 … … 425 450 out << "n/a\n"; 426 451 452 const static string kWhite = "#ffffff"; 453 const static string kYellow = "#fffff0"; 454 const static string kRed = "#fff8f0"; 455 const static string kGreen = "#f0fff0"; 456 const static string kBlue = "#f0f0ff"; 457 427 458 // ------------------ Drive ----------------- 428 459 if (fStatusDriveControl.second>=5) // Armed, Moving, Tracking 429 460 { 430 461 const State rc = fNetwork.GetState("DRIVE_CONTROL", fStatusDriveControl.second); 431 out << "#ffffff\t";462 out << kWhite << "\t"; 432 463 out << rc.name << '\t'; 433 464 out << fDriveControlPointingZd << '\t'; … … 437 468 } 438 469 else 439 out << "#ffffff\t\t\t\t\t\n";470 out << kWhite << "\t\t\t\t\t\n"; 440 471 441 472 // --------------- MagicWeather ------------- … … 443 474 { 444 475 const float diff = fMagicWeatherData[kTemp]-fMagicWeatherData[kDew]; 445 string col1 = "#fff8f0";476 string col1 = kRed; 446 477 if (diff>0.3) 447 col1 ="#fffff0";478 col1 = kYellow; 448 479 if (diff>0.7) 449 col1 ="#f0fff0";480 col1 = kGreen; 450 481 451 482 const float wind = fMagicWeatherData[kGusts]; 452 string col2 = "#f0fff0";483 string col2 = kGreen; 453 484 if (wind>35) 454 col2 ="#fffff0";485 col2 = kYellow; 455 486 if (wind>50) 456 col2 ="#fff8f0";487 col2 = kRed; 457 488 458 489 out << col1 << "\t"; … … 463 494 } 464 495 else 465 out << "#ffffff\t\t\n\n";496 out << kWhite << "\t\t\n\n"; 466 497 467 498 // --------------- BiasControl ------------- … … 470 501 fStatusBiasControl.second==9) // Off 471 502 { 472 string col = fBiasControlVoltageMed>3? "#fff8f0":"#ffffff";503 string col = fBiasControlVoltageMed>3?kGreen:kWhite; 473 504 if (fBiasControlCurrentMax>280) 474 col = "#fffff0";505 col = kYellow; 475 506 if (fBiasControlCurrentMax>350) 476 col = "#fff8f0"; 507 col = kRed; 508 509 if (fFeedbackCalibration.size()==0) 510 col = kBlue; 477 511 478 512 out << col << "\t"; … … 482 516 } 483 517 else 484 out << "#ffffff\t\t\t\n";518 out << kWhite << "\t\t\t\n"; 485 519 486 520
Note:
See TracChangeset
for help on using the changeset viewer.