Changeset 13872
- Timestamp:
- 05/24/12 15:20:34 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r13850 r13872 334 334 deque<float> fMagicWeatherHist[kWeatherEnd]; 335 335 336 deque<float> fTngWeatherDustHist; 337 Time fTngWeatherDustTime; 338 336 339 vector<float> fFeedbackCalibration; 337 340 … … 361 364 deque<float> fFtmControlTriggerRateHist; 362 365 363 vector<float> fFtmPatchThresholds;366 float fFtmPatchThresholdMed; 364 367 365 368 bool fFtmControlFtuOk; … … 368 371 uint8_t fRateScanBoard; 369 372 deque<float> fRateScanDataHist[41]; 373 374 bool fHasError; 370 375 371 376 // ------------- Initialize variables before the Dim stuff ------------ … … 377 382 DimDescribedState fDimDriveControl; 378 383 DimDescribedState fDimMagicWeather; 384 DimDescribedState fDimTngWeather; 379 385 DimDescribedState fDimFeedback; 380 386 DimDescribedState fDimBiasControl; … … 475 481 return; 476 482 477 const string str = fControlMessageHist.size()>0 ? fControlMessageHist.back() : " ";478 483 const string time = d.GetTimeAsStr("%H:%M:%S "); 484 485 string str = " "; 486 for (auto it=fControlMessageHist.rbegin(); it!=fControlMessageHist.rend(); it++) 487 { 488 str = it->substr(0, time.length()); 489 if (str!="--:--:-- ") 490 break; 491 } 479 492 480 493 ostringstream tst; … … 482 495 483 496 string msg; 484 msg += str .substr(0, time.length())==time ? "--:--:-- " : time;497 msg += str==time ? "--:--:-- " : time; 485 498 msg += "<->"+string(d.Ptr<char>())+"</->"; 486 499 … … 497 510 out << '\n'; 498 511 499 ofstream(fPath+"/ test.txt") << out.str();512 ofstream(fPath+"/scriptlog.txt") << out.str(); 500 513 } 501 514 … … 514 527 515 528 if (d.GetQoS()<0) 516 HandleControlMessageImp(d); 529 { 530 DimControl ctrl; 531 ctrl.Handler(d); 532 533 const string msg = ctrl.shortmsg+"<br>"+ctrl.file; 534 HandleControlMessageImp(Event(d, msg.data(), msg.length()+1)); 535 } 517 536 } 518 537 … … 595 614 out << "#ffffff\t" << fMagicWeatherHist[i].back() << '\n'; 596 615 out << "#ffffff\t" << dir[idx] << '\n'; 597 598 ofstream(fPath+"/magicweather.txt") << out.str(); 616 out << "#ffffff\t"; 617 if (fTngWeatherDustHist.size()>0) 618 out << fTngWeatherDustHist.back() << '\t' << fTngWeatherDustTime.GetAsStr("%H:%M") << '\n'; 619 else 620 out << "\t\n"; 621 622 ofstream(fPath+"/weather.txt") << out.str(); 599 623 600 624 out.str(""); … … 613 637 out << kHtmlWhite << '\t' << moon.fMoonTransit.GetAsStr("%H:%M") << '\n'; 614 638 out << kHtmlWhite << '\t' << moon.fMoonSet.GetAsStr("%H:%M") << '\n'; 639 out << kHtmlWhite << '\t'; 615 640 616 641 ofstream(fPath+"/astro.txt") << out.str(); … … 622 647 WriteWeather(d, "gusts", kGusts, 0, 100); 623 648 WriteWeather(d, "press", kPress, 700, 1000); 649 650 return GetCurrentState(); 651 } 652 653 int HandleTngWeatherDust(const EventImp &d) 654 { 655 if (!CheckDataSize(d, "TngWeather:Dust", 4)) 656 return GetCurrentState(); 657 658 fTngWeatherDustTime = d.GetTime(); 659 660 fTngWeatherDustHist.push_back(d.GetFloat()); 661 if (fTngWeatherDustHist.size()>300) 662 fTngWeatherDustHist.pop_front(); 663 664 const Statistics stat(fTngWeatherDustHist); 665 666 const double scale = stat.max>0 ? pow(10, ceil(log10(stat.max))) : 0; 667 668 WriteBinary(d, "tng-dust-hist", fTngWeatherDustHist, scale); 669 670 ostringstream out; 671 out << d.GetJavaDate() << '\n'; 672 673 ofstream(fPath+"/tngdust.txt") << out.str(); 624 674 625 675 return GetCurrentState(); … … 763 813 int HandleFeedbackDeviation(const EventImp &d) 764 814 { 765 if (!CheckDataSize(d, "Feedback:Deviation", 2*4*416+8))815 if (!CheckDataSize(d, "Feedback:Deviation", (2*416+2)*4)) 766 816 return GetCurrentState(); 767 817 … … 1079 1129 1080 1130 const Statistics stat(vec); 1131 1132 fFtmPatchThresholdMed = stat.med; 1081 1133 1082 1134 ostringstream out; … … 1267 1319 } 1268 1320 1321 // Cycle by time! 1269 1322 fRateScanBoard ++; 1270 1323 fRateScanBoard %= 40; 1271 1324 1272 1325 WriteBinary(d, "ratescan-hist", fRateScanDataHist[0], 10, -2); 1273 WriteBinary(d, "ratescan-board", fRateScanDataHist[fRateScanBoard+1], 10, - 2);1326 WriteBinary(d, "ratescan-board", fRateScanDataHist[fRateScanBoard+1], 10, -4); 1274 1327 1275 1328 ostringstream out; 1276 1329 out << setprecision(3); 1277 1330 out << d.GetJavaDate() << '\n'; 1331 out << "#ffffff\t" << fFtmPatchThresholdMed << '\n'; 1278 1332 out << "#ffffff\t" << pow(10, fRateScanDataHist[0].back()) << '\n'; 1279 1333 out << "#ffffff\t" << max << '\n'; 1280 1334 1281 ofstream(fPath+"/rate can.txt") << out.str();1335 ofstream(fPath+"/ratescan.txt") << out.str(); 1282 1336 1283 1337 out.str(""); … … 1286 1340 out << "#ffffff\t" << pow(10, fRateScanDataHist[fRateScanBoard+1].back()) << '\n'; 1287 1341 1288 ofstream(fPath+"/rate can_board.txt") << out.str();1342 ofstream(fPath+"/ratescan_board.txt") << out.str(); 1289 1343 1290 1344 return GetCurrentState(); … … 1296 1350 { 1297 1351 ostringstream out; 1298 out << d.GetJavaDate() << '\t' << f DimControl.online()<< '\n';1352 out << d.GetJavaDate() << '\t' << fHasError << '\n'; 1299 1353 switch (d.GetQoS()) 1300 1354 { … … 1335 1389 Out() << fDimFscControl << endl; 1336 1390 Out() << fDimMagicWeather << endl; 1391 Out() << fDimTngWeather << endl; 1337 1392 Out() << fDimRateScan << endl; 1338 1393 Out() << fDimChatServer << endl; … … 1347 1402 1348 1403 if (&state==&fDimControl) 1349 { 1350 ostringstream out; 1351 out << kHtmlGreen << '\t'; 1352 return kHtmlGreen+'\t'+(state.state()==-3?"Idle":state.msg)+'\n'; 1353 } 1404 return kHtmlGreen +'\t'+(state.state()==-3?"Idle":fDimControl.shortmsg)+'\n'; 1354 1405 1355 1406 const State rc = state.description(); … … 1392 1443 fLastUpdate=now; 1393 1444 1445 // ============================================================== 1446 1447 ostringstream msg; 1448 1449 if (fDimDriveControl.state()>0xff) 1450 msg << "Drive in ERROR state<br/>"; 1451 if (fDimBiasControl.state()<BIAS::kRamping && (fDimMcp.state()==11 || fDimMcp.state()==12)) 1452 msg << "BIAS not operating during data-taking<br/>"; 1453 if (fDimBiasControl.state()==BIAS::kOverCurrent) 1454 msg << "BIAS channels in OverCurrent<br/>"; 1455 if (fDimBiasControl.state()==BIAS::kNotReferenced) 1456 msg << "BIAS voltage not at reference<br/>"; 1457 if (fBiasControlCurrentMed>75) 1458 msg << "Median current exceeds 75µA/pix<br/>"; 1459 if (fBiasControlCurrentMax>90) 1460 msg << "Maximum current exceeds 90µA/pix<br/>"; 1461 if (fMagicWeatherHist[kHum].size()>0 && fMagicWeatherHist[kHum].back()>98 && (fDimMcp.state()==11 || fDimMcp.state()==12)) 1462 msg << "Outside humidity exceeds 98% during data-taking<br/>"; 1463 if (fMagicWeatherHist[kGusts].size()>0 && fMagicWeatherHist[kGusts].back()>98 && fDimDriveControl.state()==7) 1464 msg << "Wind gusts exceed 50km/h during tracking<br/>"; 1465 if (fFscControlTemperatureHist.size()>0 && fFscControlTemperatureHist.back()>7) 1466 msg << "Sensor temperature exceeds outside temperature by more than 7°C<br/>"; 1467 if (fFtmControlTriggerRateCam<0.01 && (fDimMcp.state()==11 || fDimMcp.state()==12)) 1468 msg << "Trigger rate below 10mHz during data taking<br/>"; 1469 if (fFscControlHumidityAvg>60) 1470 msg << "Average camera humidity exceed 60%<br/>"; 1471 if (!fDimControl.online()) 1472 msg << "dimctrl offline<br/>"; 1473 1474 /* // Check offline and disconnected status? 1475 Out() << fDimMcp << endl; 1476 Out() << fDimControl << endl; 1477 Out() << fDimDataLogger << endl; 1478 Out() << fDimDriveControl << endl; 1479 Out() << fDimFadControl << endl; 1480 Out() << fDimFtmControl << endl; 1481 Out() << fDimBiasControl << endl; 1482 Out() << fDimFeedback << endl; 1483 Out() << fDimRateControl << endl; 1484 Out() << fDimFscControl << endl; 1485 Out() << fDimMagicWeather << endl; 1486 Out() << fDimRateScan << endl; 1487 Out() << fDimChatServer << endl; 1488 */ 1489 1490 // FTU in error 1491 // FAD lost 1492 1493 // -------------------------------------------------------------- 1494 1495 const bool haserror = msg.str().size()>0; 1496 1394 1497 ostringstream out; 1395 out << now.JavaDate() << '\t' << fDimControl.online() << '\n'; 1498 out << now.JavaDate() << '\t' << haserror << '\n'; 1499 out << setprecision(3); 1500 out << kHtmlWhite << '\t' << msg.str() << '\n'; 1501 1502 if (haserror || fHasError) 1503 ofstream(fPath+"/error.txt") << out.str(); 1504 1505 fHasError = haserror; 1506 1507 // ============================================================== 1508 1509 out.str(""); 1510 out << now.JavaDate() << '\t' << fHasError << '\n'; 1396 1511 out << setprecision(3); 1397 1512 … … 1623 1738 out << kHtmlWhite << '\n'; 1624 1739 1625 1626 // ------------------------------------------1627 1628 1740 ofstream(fPath+"/fact.txt") << out.str(); 1629 1741 1630 // ========================================== 1742 // ============================================================== 1631 1743 1632 1744 out.str(""); 1633 out << now.JavaDate() << '\t' << f DimControl.online()<< '\n';1745 out << now.JavaDate() << '\t' << fHasError << '\n'; 1634 1746 1635 1747 if (!fDimDNS.online()) … … 1639 1751 out << kHtmlGreen << '\t' << fDimDNS.version() << '\n'; 1640 1752 1753 out << GetStateHtml(fDimControl, 0); 1641 1754 out << GetStateHtml(fDimMcp, 4); 1642 out << GetStateHtml(fDimControl, 0);1643 1755 out << GetStateHtml(fDimDataLogger, 1); 1644 1756 out << GetStateHtml(fDimDriveControl, 2); … … 1650 1762 out << GetStateHtml(fDimFscControl, 2); 1651 1763 out << GetStateHtml(fDimMagicWeather, 2); 1764 out << GetStateHtml(fDimTngWeather, 2); 1652 1765 out << GetStateHtml(fDimRateScan, 4); 1653 1766 out << GetStateHtml(fDimChatServer, 1); … … 1665 1778 fMcpConfigurationMaxTime(0), 1666 1779 fMcpConfigurationMaxEvents(0), 1780 fTngWeatherDustTime(Time::none), 1667 1781 fBiasControlVoltageMed(0), 1782 fBiasControlCurrentMed(0), 1668 1783 fBiasControlCurrentMax(0), 1669 1784 fFscControlHumidityAvg(0), 1785 fFtmControlTriggerRateCam(0), 1670 1786 fRateScanDataId(0), 1671 1787 fRateScanBoard(0), 1788 fHasError(false), 1672 1789 // --- 1673 1790 fDimMcp ("MCP"), … … 1675 1792 fDimDriveControl("DRIVE_CONTROL"), 1676 1793 fDimMagicWeather("MAGIC_WEATHER"), 1794 fDimTngWeather ("TNG_WEATHER"), 1677 1795 fDimFeedback ("FEEDBACK"), 1678 1796 fDimBiasControl ("BIAS_CONTROL"), … … 1690 1808 fDimDriveControl.Subscribe(*this); 1691 1809 fDimMagicWeather.Subscribe(*this); 1810 fDimTngWeather.Subscribe(*this); 1692 1811 fDimFeedback.Subscribe(*this); 1693 1812 fDimBiasControl.Subscribe(*this); … … 1700 1819 1701 1820 Subscribe("DIM_CONTROL/MESSAGE") 1702 (bind(&StateMachineSmartFACT::HandleDimControlMessage, this, placeholders::_1));1821 (bind(&StateMachineSmartFACT::HandleDimControlMessage, this, placeholders::_1)); 1703 1822 1704 1823 Subscribe("MCP/CONFIGURATION") 1705 (bind(&StateMachineSmartFACT::HandleMcpConfiguration, this, placeholders::_1));1824 (bind(&StateMachineSmartFACT::HandleMcpConfiguration, this, placeholders::_1)); 1706 1825 1707 1826 Subscribe("DRIVE_CONTROL/POINTING_POSITION") 1708 (bind(&StateMachineSmartFACT::HandleDrivePointing, this, placeholders::_1));1827 (bind(&StateMachineSmartFACT::HandleDrivePointing, this, placeholders::_1)); 1709 1828 Subscribe("DRIVE_CONTROL/TRACKING_POSITION") 1710 (bind(&StateMachineSmartFACT::HandleDriveTracking, this, placeholders::_1));1829 (bind(&StateMachineSmartFACT::HandleDriveTracking, this, placeholders::_1)); 1711 1830 Subscribe("DRIVE_CONTROL/SOURCE_POSITION") 1712 (bind(&StateMachineSmartFACT::HandleDriveSource, this, placeholders::_1));1831 (bind(&StateMachineSmartFACT::HandleDriveSource, this, placeholders::_1)); 1713 1832 1714 1833 Subscribe("FSC_CONTROL/TEMPERATURE") 1715 (bind(&StateMachineSmartFACT::HandleFscTemperature, this, placeholders::_1));1834 (bind(&StateMachineSmartFACT::HandleFscTemperature, this, placeholders::_1)); 1716 1835 Subscribe("FSC_CONTROL/HUMIDITY") 1717 (bind(&StateMachineSmartFACT::HandleFscHumidity, this, placeholders::_1));1836 (bind(&StateMachineSmartFACT::HandleFscHumidity, this, placeholders::_1)); 1718 1837 1719 1838 Subscribe("MAGIC_WEATHER/DATA") 1720 (bind(&StateMachineSmartFACT::HandleMagicWeatherData, this, placeholders::_1)); 1839 (bind(&StateMachineSmartFACT::HandleMagicWeatherData, this, placeholders::_1)); 1840 Subscribe("TNG_WEATHER/DUST") 1841 (bind(&StateMachineSmartFACT::HandleTngWeatherDust, this, placeholders::_1)); 1721 1842 1722 1843 Subscribe("FEEDBACK/DEVIATION")
Note:
See TracChangeset
for help on using the changeset viewer.