Changeset 13803 for trunk/FACT++/src
- Timestamp:
- 05/21/12 15:45:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r13800 r13803 39 39 const static string kHtmlBlue = "#f0f0ff"; 40 40 41 #ifdef HAVE_LIBNOVA 41 // ======================================================================== 42 // ======================================================================== 43 // ======================================================================== 42 44 43 45 class Astro … … 299 301 }; 300 302 301 // ------------------------------------------------------------------------ 303 // ======================================================================== 304 // ======================================================================== 305 // ======================================================================== 306 307 class DimState : public DimInfoHandler 308 { 309 public: 310 DimState(const string &n, const string s="STATE") : 311 server(n), info(make_pair(Time(), -4)), 312 dim((n+"/"+s).c_str(), (void*)NULL, 0, this) { } 313 314 string server; 315 pair<Time, int> info; 316 string msg; 317 318 DimStampedInfo dim; 319 320 void infoHandler() 321 { 322 DimInfo *curr = getInfo(); // get current DimInfo address 323 if (!curr || curr != &dim) 324 return; 325 326 const bool disconnected = dim.getSize()==0; 327 328 // Make sure getTimestamp is called _before_ getTimestampMillisecs 329 const int tsec = dim.getTimestamp(); 330 const int tms = dim.getTimestampMillisecs(); 331 332 info = make_pair(Time(tsec, tms*1000), 333 disconnected ? -4 : dim.getQuality()); 334 335 msg = disconnected ? "" : dim.getString(); 336 } 337 338 const Time &time() const { return info.first; } 339 const int &state() const { return info.second; } 340 341 bool online() const { return info.second>-4; } 342 343 const string &name() const { return server; } 344 }; 345 346 class DimVersion : public DimState 347 { 348 public: 349 DimVersion() : DimState("DIS_DNS", "VERSION_NUMBER") { } 350 351 void infoHandler() 352 { 353 DimInfo *curr = getInfo(); // get current DimInfo address 354 if (!curr || curr != &dim) 355 return; 356 357 DimState::infoHandler(); 358 359 info.second = dim.getSize()==4 ? dim.getInt() : 0; 360 } 361 362 string version() const 363 { 364 if (info.second==0) 365 return "Offline"; 366 367 ostringstream out; 368 out << "V" << info.second/100 << 'r' << info.second%100; 369 return out.str(); 370 } 371 }; 372 373 class DimControl : public DimState 374 { 375 typedef function<void(const DimData &)> callback; 376 map<string, callback> fCallbacks; 377 public: 378 DimControl() : DimState("DIM_CONTROL") { } 379 380 void AddCallback(const string &script, const callback &cb) 381 { 382 fCallbacks[script] = cb; 383 } 384 385 void infoHandler() 386 { 387 DimInfo *curr = getInfo(); // get current DimInfo address 388 if (!curr || curr != &dim) 389 return; 390 391 DimState::infoHandler(); 392 393 // Evaluate msg 394 const size_t p0 = msg.find_first_of(':'); 395 if (p0==string::npos) 396 return; 397 398 const size_t p1 = msg.find_last_of('['); 399 if (p1==string::npos) 400 return; 401 402 const size_t p2 = msg.find_first_of(':', p0+1); 403 404 const size_t p3 = p2==string::npos || p2>p1 ? p1-1 : p2; 405 406 const string file = msg.substr(p0+2, p3-p0-2); 407 408 const auto func = fCallbacks.find(file); 409 if (func==fCallbacks.end()) 410 return; 411 412 // Call callback 413 func->second(DimData(curr)); 414 } 415 }; 416 417 struct DimSubscriptions 418 { 419 DimServiceInfoList fNetwork; 420 421 DimVersion fDNS; 422 DimControl fControl; 423 DimState fMcp; 424 DimState fDataLogger; 425 DimState fDriveControl; 426 DimState fMagicWeather; 427 DimState fFeedback; 428 DimState fBiasControl; 429 DimState fFtmControl; 430 DimState fFadControl; 431 DimState fFscControl; 432 DimState fRateControl; 433 DimState fRateScan; 434 DimState fChatServer; 435 436 DimStampedInfo fMcpConfiguration; 437 438 DimStampedInfo fDriveControlPointing; 439 DimStampedInfo fDriveControlTracking; 440 DimStampedInfo fDriveControlSource; 441 442 DimStampedInfo fFscControlTemperature; 443 DimStampedInfo fFscControlHumidity; 444 445 DimStampedInfo fMagicWeatherData; 446 447 DimStampedInfo fFeedbackDeviation; 448 DimStampedInfo fFeedbackCalibration; 449 450 DimStampedInfo fBiasControlVoltage; 451 DimStampedInfo fBiasControlCurrent; 452 453 DimStampedInfo fFadConnections; 454 DimStampedInfo fFadEvents; 455 456 DimStampedInfo fFtmControlTriggerRates; 457 DimStampedInfo fFtmControlStaticData; 458 DimStampedInfo fFtmControlFtuList; 459 460 DimStampedInfo fRateScanData; 461 462 DimStampedInfo fFadControlEventData; 463 464 DimSubscriptions(DimInfoHandler *h) : 465 fMcp ("MCP"), 466 fDataLogger ("DATA_LOGGER"), 467 fDriveControl ("DRIVE_CONTROL"), 468 fMagicWeather ("MAGIC_WEATHER"), 469 fFeedback ("FEEDBACK"), 470 fBiasControl ("BIAS_CONTROL"), 471 fFtmControl ("FTM_CONTROL"), 472 fFadControl ("FAD_CONTROL"), 473 fFscControl ("FSC_CONTROL"), 474 fRateControl ("RATE_CONTROL"), 475 fRateScan ("RATE_SCAN"), 476 fChatServer ("CHAT_SERVER"), 477 //--- 478 fMcpConfiguration ("MCP/CONFIGURATION", (void*)NULL, 0, h), 479 //--- 480 fDriveControlPointing ("DRIVE_CONTROL/POINTING_POSITION", (void*)NULL, 0, h), 481 fDriveControlTracking ("DRIVE_CONTROL/TRACKING_POSITION", (void*)NULL, 0, h), 482 fDriveControlSource ("DRIVE_CONTROL/SOURCE_POSITION", (void*)NULL, 0, h), 483 //--- 484 fFscControlTemperature ("FSC_CONTROL/TEMPERATURE", (void*)NULL, 0, h), 485 fFscControlHumidity ("FSC_CONTROL/HUMIDITY", (void*)NULL, 0, h), 486 //--- 487 fMagicWeatherData ("MAGIC_WEATHER/DATA", (void*)NULL, 0, h), 488 //--- 489 fFeedbackDeviation ("FEEDBACK/DEVIATION", (void*)NULL, 0, h), 490 fFeedbackCalibration ("FEEDBACK/CALIBRATION", (void*)NULL, 0, h), 491 //--- 492 fBiasControlVoltage ("BIAS_CONTROL/VOLTAGE", (void*)NULL, 0, h), 493 fBiasControlCurrent ("BIAS_CONTROL/CURRENT", (void*)NULL, 0, h), 494 //--- 495 fFadConnections ("FAD_CONTROL/CONNECTIONS", (void*)NULL, 0, h), 496 fFadEvents ("FAD_CONTROL/EVENTS", (void*)NULL, 0, h), 497 //--- 498 fFtmControlTriggerRates("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, h), 499 fFtmControlStaticData ("FTM_CONTROL/STATIC_DATA", (void*)NULL, 0, h), 500 fFtmControlFtuList ("FTM_CONTROL/FTU_LIST", (void*)NULL, 0, h), 501 //--- 502 fRateScanData ("RATE_SCAN/DATA", (void*)NULL, 0, h), 503 //--- 504 fFadControlEventData ("FAD_CONTROL/EVENT_DATA", (void*)NULL, 0, h) 505 506 { 507 } 508 509 const State GetState(const DimState &s) const 510 { 511 return fNetwork.GetState(s.name(), s.state()); 512 } 513 }; 514 515 // ======================================================================== 516 // ======================================================================== 517 // ======================================================================== 302 518 303 519 … … 359 575 vector<float> fFtmPatchThresholds; 360 576 577 bool fFtmControlFtuOk; 578 361 579 uint64_t fRateScanDataId; 362 580 deque<float> fRateScanDataHist; … … 364 582 // ------------- Initialize variables before the Dim stuff ------------ 365 583 366 DimServiceInfoList fNetwork; 367 368 class DimState : public DimInfoHandler 369 { 370 public: 371 DimState(const string &n, const string s="STATE") : 372 server(n), info(make_pair(Time(), -4)), 373 dim((n+"/"+s).c_str(), (void*)NULL, 0, this) { } 374 375 string server; 376 pair<Time, int> info; 377 string msg; 378 379 DimStampedInfo dim; 380 381 void infoHandler() 382 { 383 DimInfo *curr = getInfo(); // get current DimInfo address 384 if (!curr || curr != &dim) 385 return; 386 387 const bool disconnected = dim.getSize()==0; 388 389 // Make sure getTimestamp is called _before_ getTimestampMillisecs 390 const int tsec = dim.getTimestamp(); 391 const int tms = dim.getTimestampMillisecs(); 392 393 info = make_pair(Time(tsec, tms*1000), 394 disconnected ? -4 : dim.getQuality()); 395 396 msg = disconnected ? "" : dim.getString(); 397 } 398 399 const Time &time() const { return info.first; } 400 const int &state() const { return info.second; } 401 402 bool online() const { return info.second>-4; } 403 404 const string &name() const { return server; } 405 }; 406 407 class DimVersion : public DimState 408 { 409 public: 410 DimVersion() : DimState("DIS_DNS", "VERSION_NUMBER") { } 411 412 void infoHandler() 413 { 414 DimInfo *curr = getInfo(); // get current DimInfo address 415 if (!curr || curr != &dim) 416 return; 417 418 DimState::infoHandler(); 419 420 info.second = dim.getSize()==4 ? dim.getInt() : 0; 421 } 422 423 string version() const 424 { 425 if (info.second==0) 426 return "Offline"; 427 428 ostringstream out; 429 out << "V" << info.second/100 << 'r' << info.second%100; 430 return out.str(); 431 } 432 }; 433 434 class DimControl : public DimState 435 { 436 typedef function<void(const DimData &)> callback; 437 map<string, callback> fCallbacks; 438 public: 439 DimControl() : DimState("DIM_CONTROL") { } 440 441 void AddCallback(const string &script, const callback &cb) 442 { 443 fCallbacks[script] = cb; 444 } 445 446 void infoHandler() 447 { 448 DimInfo *curr = getInfo(); // get current DimInfo address 449 if (!curr || curr != &dim) 450 return; 451 452 DimState::infoHandler(); 453 454 // Evaluate msg 455 const size_t p0 = msg.find_first_of(':'); 456 if (p0==string::npos) 457 return; 458 459 const size_t p1 = msg.find_last_of('['); 460 if (p1==string::npos) 461 return; 462 463 const size_t p2 = msg.find_first_of(':', p0+1); 464 465 const size_t p3 = p2==string::npos || p2>p1 ? p1-1 : p2; 466 467 const string file = msg.substr(p0+2, p3-p0-2); 468 469 const auto func = fCallbacks.find(file); 470 if (func==fCallbacks.end()) 471 return; 472 473 // Call callback 474 func->second(DimData(curr)); 475 } 476 }; 477 478 479 480 DimVersion fDim; 481 DimControl fDimControl; 482 DimState fDimMcp; 483 DimState fDimDataLogger; 484 DimState fDimDriveControl; 485 DimState fDimMagicWeather; 486 DimState fDimFeedback; 487 DimState fDimBiasControl; 488 DimState fDimFtmControl; 489 DimState fDimFadControl; 490 DimState fDimFscControl; 491 DimState fDimRateControl; 492 DimState fDimRateScan; 493 DimState fDimChatServer; 494 495 DimStampedInfo fDimMcpConfiguration; 496 497 DimStampedInfo fDimDriveControlPointing; 498 DimStampedInfo fDimDriveControlTracking; 499 DimStampedInfo fDimDriveControlSource; 500 501 DimStampedInfo fDimFscControlTemperature; 502 DimStampedInfo fDimFscControlHumidity; 503 504 DimStampedInfo fDimMagicWeatherData; 505 506 DimStampedInfo fDimFeedbackDeviation; 507 DimStampedInfo fDimFeedbackCalibration; 508 509 DimStampedInfo fDimBiasControlVoltage; 510 DimStampedInfo fDimBiasControlCurrent; 511 512 DimStampedInfo fDimFadConnections; 513 DimStampedInfo fDimFadEvents; 514 515 DimStampedInfo fDimFtmControlTriggerRates; 516 DimStampedInfo fDimFtmControlStaticData; 517 518 DimStampedInfo fDimRateScanData; 519 520 DimStampedInfo *fDimFadControlEventData; 584 DimSubscriptions *fDim; 521 585 522 586 // ------------------------------------------------------------------- 523 587 524 const State GetState(const DimState &s) const525 {526 return fNetwork.GetState(s.name(), s.state());527 }528 588 529 589 // ------------------------------------------------------------------- … … 891 951 } 892 952 893 if (fDim BiasControl.state()==BIAS::kVoltageOn)953 if (fDim->fBiasControl.state()==BIAS::kVoltageOn) 894 954 WriteBinary(d, "biascontrol-voltage", val, 10, 65); 895 955 else … … 1156 1216 } 1157 1217 1218 void HandleFtmControlFtuList(const DimData &d) 1219 { 1220 if (!CheckDataSize(d, "FtmControl:FtuList", sizeof(FTM::DimFtuList))) 1221 return; 1222 1223 const FTM::DimFtuList &sdata = d.ref<FTM::DimFtuList>(); 1224 1225 ostringstream out; 1226 out << d.time.JavaDate() << '\n'; 1227 1228 int cnt = 0; 1229 for (int i=0; i<4; i++) 1230 { 1231 out << kHtmlWhite << '\t'; 1232 for (int j=0; j<10; j++) 1233 if (sdata.IsActive(i*10+j)) 1234 { 1235 if (sdata.fPing[i*10+j]==1) 1236 { 1237 out << '*'; 1238 cnt++; 1239 } 1240 else 1241 out << sdata.fPing[i*10+j]; 1242 } 1243 else 1244 out << '-'; 1245 out << '\n'; 1246 } 1247 1248 fFtmControlFtuOk = cnt==40; 1249 1250 ofstream(fPath+"/ftu.txt") << out.str(); 1251 } 1252 1158 1253 void HandleFadControlEventData(const DimData &d) 1159 1254 { … … 1219 1314 rms = sqrt(rms/num-avg*avg); 1220 1315 1221 fFscControlTemperatureHist.push_back(avg-fMagicWeatherHist[kTemp].back()); 1222 if (fFscControlTemperatureHist.size()>300) 1223 fFscControlTemperatureHist.pop_front(); 1316 if (fMagicWeatherHist[kTemp].size()>0) 1317 { 1318 fFscControlTemperatureHist.push_back(avg-fMagicWeatherHist[kTemp].back()); 1319 if (fFscControlTemperatureHist.size()>300) 1320 fFscControlTemperatureHist.pop_front(); 1321 } 1224 1322 1225 1323 const Statistics stat(fFscControlTemperatureHist); … … 1285 1383 { 1286 1384 ostringstream out; 1287 out << d.time.JavaDate() << '\t' << fDim Control.online() << '\n';1385 out << d.time.JavaDate() << '\t' << fDim->fControl.online() << '\n'; 1288 1386 switch (d.qos) 1289 1387 { … … 1305 1403 return; 1306 1404 1307 if (HandleService(curr, fDimMcpConfiguration, &StateMachineSmartFACT::HandleMcpConfiguration)) 1308 return; 1309 if (HandleService(curr, fDimMagicWeatherData, &StateMachineSmartFACT::HandleMagicWeatherData)) 1310 return; 1311 if (HandleService(curr, fDimDriveControlPointing, &StateMachineSmartFACT::HandleDriveControlPointing)) 1312 return; 1313 if (HandleService(curr, fDimDriveControlTracking, &StateMachineSmartFACT::HandleDriveControlTracking)) 1314 return; 1315 if (HandleService(curr, fDimDriveControlSource, &StateMachineSmartFACT::HandleDriveControlSource)) 1316 return; 1317 if (HandleService(curr, fDimFeedbackDeviation, &StateMachineSmartFACT::HandleFeedbackDeviation)) 1318 return; 1319 if (HandleService(curr, fDimFeedbackCalibration, &StateMachineSmartFACT::HandleFeedbackCalibration)) 1320 return; 1321 if (HandleService(curr, fDimBiasControlVoltage, &StateMachineSmartFACT::HandleBiasControlVoltage)) 1322 return; 1323 if (HandleService(curr, fDimBiasControlCurrent, &StateMachineSmartFACT::HandleBiasControlCurrent)) 1324 return; 1325 if (HandleService(curr, fDimFadConnections, &StateMachineSmartFACT::HandleFadConnections)) 1326 return; 1327 if (HandleService(curr, fDimFadEvents, &StateMachineSmartFACT::HandleFadEvents)) 1328 return; 1329 if (HandleService(curr, fDimFtmControlTriggerRates, &StateMachineSmartFACT::HandleFtmControlTriggerRates)) 1330 return; 1331 if (HandleService(curr, fDimFtmControlStaticData, &StateMachineSmartFACT::HandleFtmControlStaticData)) 1332 return; 1333 if (HandleService(curr, *fDimFadControlEventData, &StateMachineSmartFACT::HandleFadControlEventData)) 1334 return; 1335 if (HandleService(curr, fDimFscControlTemperature, &StateMachineSmartFACT::HandleFscControlTemperature)) 1336 return; 1337 if (HandleService(curr, fDimFscControlHumidity, &StateMachineSmartFACT::HandleFscControlHumidity)) 1338 return; 1339 if (HandleService(curr, fDimRateScanData, &StateMachineSmartFACT::HandleRateScanData)) 1405 if (HandleService(curr, fDim->fMcpConfiguration, &StateMachineSmartFACT::HandleMcpConfiguration)) 1406 return; 1407 if (HandleService(curr, fDim->fMagicWeatherData, &StateMachineSmartFACT::HandleMagicWeatherData)) 1408 return; 1409 if (HandleService(curr, fDim->fDriveControlPointing, &StateMachineSmartFACT::HandleDriveControlPointing)) 1410 return; 1411 if (HandleService(curr, fDim->fDriveControlTracking, &StateMachineSmartFACT::HandleDriveControlTracking)) 1412 return; 1413 if (HandleService(curr, fDim->fDriveControlSource, &StateMachineSmartFACT::HandleDriveControlSource)) 1414 return; 1415 if (HandleService(curr, fDim->fFeedbackDeviation, &StateMachineSmartFACT::HandleFeedbackDeviation)) 1416 return; 1417 if (HandleService(curr, fDim->fFeedbackCalibration, &StateMachineSmartFACT::HandleFeedbackCalibration)) 1418 return; 1419 if (HandleService(curr, fDim->fBiasControlVoltage, &StateMachineSmartFACT::HandleBiasControlVoltage)) 1420 return; 1421 if (HandleService(curr, fDim->fBiasControlCurrent, &StateMachineSmartFACT::HandleBiasControlCurrent)) 1422 return; 1423 if (HandleService(curr, fDim->fFadConnections, &StateMachineSmartFACT::HandleFadConnections)) 1424 return; 1425 if (HandleService(curr, fDim->fFadEvents, &StateMachineSmartFACT::HandleFadEvents)) 1426 return; 1427 if (HandleService(curr, fDim->fFtmControlTriggerRates, &StateMachineSmartFACT::HandleFtmControlTriggerRates)) 1428 return; 1429 if (HandleService(curr, fDim->fFtmControlStaticData, &StateMachineSmartFACT::HandleFtmControlStaticData)) 1430 return; 1431 if (HandleService(curr, fDim->fFtmControlFtuList, &StateMachineSmartFACT::HandleFtmControlFtuList)) 1432 return; 1433 if (HandleService(curr, fDim->fFadControlEventData, &StateMachineSmartFACT::HandleFadControlEventData)) 1434 return; 1435 if (HandleService(curr, fDim->fFscControlTemperature, &StateMachineSmartFACT::HandleFscControlTemperature)) 1436 return; 1437 if (HandleService(curr, fDim->fFscControlHumidity, &StateMachineSmartFACT::HandleFscControlHumidity)) 1438 return; 1439 if (HandleService(curr, fDim->fRateScanData, &StateMachineSmartFACT::HandleRateScanData)) 1340 1440 return; 1341 1441 } … … 1354 1454 void PrintState(const DimState &state) const 1355 1455 { 1356 const State rc = GetState(state);1456 const State rc = fDim->GetState(state); 1357 1457 1358 1458 Out() << state.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - "; … … 1372 1472 int Print() const 1373 1473 { 1374 Out() << fDim .time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";1375 Out() << kBold << "DIM_DNS: " << fDim .version() << endl;1376 1377 PrintState(fDim Mcp);1378 PrintState(fDim Control);1379 PrintState(fDim DataLogger);1380 PrintState(fDim DriveControl);1381 PrintState(fDim FadControl);1382 PrintState(fDim FtmControl);1383 PrintState(fDim BiasControl);1384 PrintState(fDim Feedback);1385 PrintState(fDim RateControl);1386 PrintState(fDim FscControl);1387 PrintState(fDim MagicWeather);1388 PrintState(fDim RateScan);1389 PrintState(fDim ChatServer);1474 Out() << fDim->fDNS.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - "; 1475 Out() << kBold << "DIM_DNS: " << fDim->fDNS.version() << endl; 1476 1477 PrintState(fDim->fMcp); 1478 PrintState(fDim->fControl); 1479 PrintState(fDim->fDataLogger); 1480 PrintState(fDim->fDriveControl); 1481 PrintState(fDim->fFadControl); 1482 PrintState(fDim->fFtmControl); 1483 PrintState(fDim->fBiasControl); 1484 PrintState(fDim->fFeedback); 1485 PrintState(fDim->fRateControl); 1486 PrintState(fDim->fFscControl); 1487 PrintState(fDim->fMagicWeather); 1488 PrintState(fDim->fRateScan); 1489 PrintState(fDim->fChatServer); 1390 1490 1391 1491 return GetCurrentState(); … … 1397 1497 return kHtmlWhite+"\t—\n"; 1398 1498 1399 if (&state==&fDim Control)1499 if (&state==&fDim->fControl) 1400 1500 { 1401 1501 ostringstream out; … … 1404 1504 } 1405 1505 1406 const State rc = GetState(state);1506 const State rc = fDim->GetState(state); 1407 1507 1408 1508 // Sate not found in list, server online (-3: offline; -2: not found) … … 1434 1534 //poll_one(); 1435 1535 1436 if (fDim .state()==0)1536 if (fDim->fDNS.state()==0) 1437 1537 return kStateDimNetworkNA; 1438 1538 … … 1444 1544 1445 1545 ostringstream out; 1446 out << now.JavaDate() << '\t' << fDim Control.online() << '\n';1546 out << now.JavaDate() << '\t' << fDim->fControl.online() << '\n'; 1447 1547 out << setprecision(3); 1448 1548 1449 1549 // -------------- System status -------------- 1450 if (fDim Mcp.state()>=5) // Idle1550 if (fDim->fMcp.state()>=5) // Idle 1451 1551 { 1452 1552 string col = kHtmlBlue; … … 1455 1555 fMcpConfigurationState!=11 && // Trigger On 1456 1556 fMcpConfigurationState!=12) // Taking Data*/ 1457 if (fDim Mcp.state()!= 5 && // Idle1458 fDim Mcp.state()!=11 && // Trigger On1459 fDim Mcp.state()!=12) // Taking Data1557 if (fDim->fMcp.state()!= 5 && // Idle 1558 fDim->fMcp.state()!=11 && // Trigger On 1559 fDim->fMcp.state()!=12) // Taking Data 1460 1560 col = kHtmlYellow; 1461 1561 else 1462 if (fDim FadControl.state()==FAD::kWritingData)1562 if (fDim->fFadControl.state()==FAD::kWritingData) 1463 1563 col = kHtmlGreen; 1464 1564 1465 1565 out << col << '\t'; 1466 1566 1467 if (fDim RateControl.state()!=5 && fDimRateScan.state()!=5)1567 if (fDim->fRateControl.state()!=5 && fDim->fRateScan.state()!=5) 1468 1568 { 1469 switch (fDim Mcp.state()/*fMcpConfigurationState*/)1569 switch (fDim->fMcp.state()/*fMcpConfigurationState*/) 1470 1570 { 1471 1571 // kStateIdle … … 1483 1583 } 1484 1584 else 1485 if (fDim RateControl.state()==5/*kStateSettingGlobalThreshold*/)1585 if (fDim->fRateControl.state()==5/*kStateSettingGlobalThreshold*/) 1486 1586 out << "Calibrating threshold"; 1487 1587 else 1488 1588 1489 if (fDim RateScan.state()==5/*kStateSettingGlobalThreshold*/)1589 if (fDim->fRateScan.state()==5/*kStateSettingGlobalThreshold*/) 1490 1590 out << "Rate scan in progress"; 1491 1591 1492 if (fDim Mcp.state()>10 && fDimRateControl.state()!=5)1592 if (fDim->fMcp.state()>10 && fDim->fRateControl.state()!=5) 1493 1593 { 1494 1594 if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12) … … 1536 1636 1537 1637 // ------------------ Drive ----------------- 1538 if (fDim DriveControl.state()>=5) // Armed, Moving, Tracking1638 if (fDim->fDriveControl.state()>=5) // Armed, Moving, Tracking 1539 1639 { 1540 1640 const double dev = fDriveControlTrackingDevHist.size()>0 ? fDriveControlTrackingDevHist.back() : 0; 1541 const State rc = GetState(fDimDriveControl);1641 const State rc = fDim->GetState(fDim->fDriveControl); 1542 1642 string col = kHtmlGreen; 1543 1643 if (rc.index==6) // Moving … … 1557 1657 out << fDriveControlPointingZd << '\t'; 1558 1658 out << fDriveControlPointingAz << '\t'; 1559 if (fDim DriveControl.state()==7)1659 if (fDim->fDriveControl.state()==7) 1560 1660 { 1561 1661 out << fDriveControlSourceName << '\t'; … … 1571 1671 1572 1672 // ------------------- FSC ------------------ 1573 if (fDim FscControl.state()>1 && fFscControlTemperatureHist.size()>0)1673 if (fDim->fFscControl.state()>1 && fFscControlTemperatureHist.size()>0) 1574 1674 { 1575 1675 out << kHtmlGreen << '\t' << fFscControlTemperatureHist.back() << '\n'; … … 1579 1679 1580 1680 // --------------- MagicWeather ------------- 1581 if (fDim MagicWeather.state()==3 && fMagicWeatherHist[kWeatherBegin].size()>0)1681 if (fDim->fMagicWeather.state()==3 && fMagicWeatherHist[kWeatherBegin].size()>0) 1582 1682 { 1583 1683 /* … … 1608 1708 1609 1709 // --------------- FtmControl ------------- 1610 if (fDim FtmControl.state()==FTM::kTriggerOn)1710 if (fDim->fFtmControl.state()==FTM::kTriggerOn) 1611 1711 { 1612 1712 string col = kHtmlGreen; … … 1622 1722 1623 1723 // --------------- BiasControl ------------- 1624 if (fDim BiasControl.state()==BIAS::kRamping ||1625 fDim BiasControl.state()==BIAS::kOverCurrent ||1626 fDim BiasControl.state()==BIAS::kVoltageOn ||1627 fDim BiasControl.state()==BIAS::kVoltageOff)1628 { 1629 const bool off = fDim BiasControl.state()==BIAS::kVoltageOff;1630 const bool oc = fDim BiasControl.state()==BIAS::kOverCurrent;1724 if (fDim->fBiasControl.state()==BIAS::kRamping || 1725 fDim->fBiasControl.state()==BIAS::kOverCurrent || 1726 fDim->fBiasControl.state()==BIAS::kVoltageOn || 1727 fDim->fBiasControl.state()==BIAS::kVoltageOff) 1728 { 1729 const bool off = fDim->fBiasControl.state()==BIAS::kVoltageOff; 1730 const bool oc = fDim->fBiasControl.state()==BIAS::kOverCurrent; 1631 1731 1632 1732 string col = fBiasControlVoltageMed>3?kHtmlGreen:kHtmlWhite; … … 1637 1737 1638 1738 // Bias in overcurrent => Red 1639 if (fDim BiasControl.state()==BIAS::kOverCurrent)1739 if (fDim->fBiasControl.state()==BIAS::kOverCurrent) 1640 1740 col = kHtmlRed; 1641 1741 1642 1742 // MCP in ReadyForDatataking/Configuring/Configured/TriggerOn/TakingData 1643 1743 // and Bias not in "data-taking state' => Red 1644 if (fDim Mcp.state()>5 &&1645 fDim BiasControl.state()!=BIAS::kVoltageOn &&1646 fDim BiasControl.state()!=BIAS::kVoltageOff)1744 if (fDim->fMcp.state()>5 && 1745 fDim->fBiasControl.state()!=BIAS::kVoltageOn && 1746 fDim->fBiasControl.state()!=BIAS::kVoltageOff) 1647 1747 col = kHtmlRed; 1648 1748 … … 1650 1750 1651 1751 // Feedback is currently calibrating => Blue 1652 if (fDim Feedback.state()==13)1752 if (fDim->fFeedback.state()==13) 1653 1753 { 1654 1754 out << kHtmlBlue << '\t'; … … 1686 1786 1687 1787 out.str(""); 1688 out << now.JavaDate() << '\t' << fDim Control.online() << '\n';1689 1690 if (fDim .state()==0)1788 out << now.JavaDate() << '\t' << fDim->fControl.online() << '\n'; 1789 1790 if (fDim->fDNS.state()==0) 1691 1791 out << kHtmlWhite << "\tOffline\n\n\n\n\n\n\n\n\n\n\n\n"; 1692 1792 else 1693 1793 { 1694 out << kHtmlGreen << '\t' << fDim .version() << '\n';1695 1696 out << GetStateHtml(fDim Mcp, 4);1697 out << GetStateHtml(fDim Control, 0);1698 out << GetStateHtml(fDim DataLogger, 1);1699 out << GetStateHtml(fDim DriveControl, 2);1700 out << GetStateHtml(fDim FadControl, FAD::kConnected);1701 out << GetStateHtml(fDim FtmControl, FTM::kConnected);1702 out << GetStateHtml(fDim BiasControl, BIAS::kConnected);1703 out << GetStateHtml(fDim Feedback, 4);1704 out << GetStateHtml(fDim RateControl, 4);1705 out << GetStateHtml(fDim FscControl, 2);1706 out << GetStateHtml(fDim MagicWeather, 2);1707 out << GetStateHtml(fDim RateScan, 4);1708 out << GetStateHtml(fDim ChatServer, 1);1794 out << kHtmlGreen << '\t' << fDim->fDNS.version() << '\n'; 1795 1796 out << GetStateHtml(fDim->fMcp, 4); 1797 out << GetStateHtml(fDim->fControl, 0); 1798 out << GetStateHtml(fDim->fDataLogger, 1); 1799 out << GetStateHtml(fDim->fDriveControl, 2); 1800 out << GetStateHtml(fDim->fFadControl, FAD::kConnected); 1801 out << GetStateHtml(fDim->fFtmControl, FTM::kConnected); 1802 out << GetStateHtml(fDim->fBiasControl, BIAS::kConnected); 1803 out << GetStateHtml(fDim->fFeedback, 4); 1804 out << GetStateHtml(fDim->fRateControl, 4); 1805 out << GetStateHtml(fDim->fFscControl, 2); 1806 out << GetStateHtml(fDim->fMagicWeather, 2); 1807 out << GetStateHtml(fDim->fRateScan, 4); 1808 out << GetStateHtml(fDim->fChatServer, 1); 1709 1809 } 1710 1810 … … 1720 1820 fMcpConfigurationMaxEvents(0), 1721 1821 fRateScanDataId(0), 1722 //--- 1723 fDimMcp ("MCP"), 1724 fDimDataLogger ("DATA_LOGGER"), 1725 fDimDriveControl ("DRIVE_CONTROL"), 1726 fDimMagicWeather ("MAGIC_WEATHER"), 1727 fDimFeedback ("FEEDBACK"), 1728 fDimBiasControl ("BIAS_CONTROL"), 1729 fDimFtmControl ("FTM_CONTROL"), 1730 fDimFadControl ("FAD_CONTROL"), 1731 fDimFscControl ("FSC_CONTROL"), 1732 fDimRateControl ("RATE_CONTROL"), 1733 fDimRateScan ("RATE_SCAN"), 1734 fDimChatServer ("CHAT_SERVER"), 1735 //--- 1736 fDimMcpConfiguration ("MCP/CONFIGURATION", (void*)NULL, 0, this), 1737 //--- 1738 fDimDriveControlPointing ("DRIVE_CONTROL/POINTING_POSITION", (void*)NULL, 0, this), 1739 fDimDriveControlTracking ("DRIVE_CONTROL/TRACKING_POSITION", (void*)NULL, 0, this), 1740 fDimDriveControlSource ("DRIVE_CONTROL/SOURCE_POSITION", (void*)NULL, 0, this), 1741 //--- 1742 fDimFscControlTemperature ("FSC_CONTROL/TEMPERATURE", (void*)NULL, 0, this), 1743 fDimFscControlHumidity ("FSC_CONTROL/HUMIDITY", (void*)NULL, 0, this), 1744 //--- 1745 fDimMagicWeatherData ("MAGIC_WEATHER/DATA", (void*)NULL, 0, this), 1746 //--- 1747 fDimFeedbackDeviation ("FEEDBACK/DEVIATION", (void*)NULL, 0, this), 1748 fDimFeedbackCalibration ("FEEDBACK/CALIBRATION", (void*)NULL, 0, this), 1749 //--- 1750 fDimBiasControlVoltage ("BIAS_CONTROL/VOLTAGE", (void*)NULL, 0, this), 1751 fDimBiasControlCurrent ("BIAS_CONTROL/CURRENT", (void*)NULL, 0, this), 1752 //--- 1753 fDimFadConnections ("FAD_CONTROL/CONNECTIONS", (void*)NULL, 0, this), 1754 fDimFadEvents ("FAD_CONTROL/EVENTS", (void*)NULL, 0, this), 1755 //--- 1756 fDimFtmControlTriggerRates("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, this), 1757 fDimFtmControlStaticData ("FTM_CONTROL/STATIC_DATA", (void*)NULL, 0, this), 1758 //- 1759 fDimRateScanData ("RATE_SCAN/DATA", (void*)NULL, 0, this), 1760 //- 1761 fDimFadControlEventData(0) 1822 fDim(0) 1762 1823 { 1763 1824 // State names … … 1771 1832 (""); 1772 1833 1773 fDimControl.AddCallback("dotest.dim", bind(&StateMachineSmartFACT::HandleDoTest, this, placeholders::_1));1774 1834 } 1775 1835 ~StateMachineSmartFACT() 1776 1836 { 1777 delete fDim FadControlEventData;1837 delete fDim; 1778 1838 } 1779 1839 int EvalOptions(Configuration &conf) … … 1785 1845 } 1786 1846 1787 // First move all the dim services to another class so that 1788 // they can be instatiated all at once _after_ path was set 1789 //fPath = conf.Get<string>("path"); 1790 1791 // Pixel map is needed to deal with this service 1792 fDimFadControlEventData=new DimStampedInfo("FAD_CONTROL/EVENT_DATA", (void*)NULL, 0, this); 1847 fPath = conf.Get<string>("path"); 1848 1849 fDim = new DimSubscriptions(this); 1850 fDim->fControl.AddCallback("dotest.dim", bind(&StateMachineSmartFACT::HandleDoTest, this, placeholders::_1)); 1793 1851 1794 1852 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.