Changeset 13932 for trunk/FACT++/src/smartfact.cc
- Timestamp:
- 05/26/12 21:39:28 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r13907 r13932 22 22 #include "HeadersBIAS.h" 23 23 #include "HeadersFTM.h" 24 #include "HeadersFSC.h" 25 #include "HeadersMCP.h" 26 #include "HeadersDrive.h" 27 #include "HeadersRateScan.h" 28 #include "HeadersRateControl.h" 29 #include "HeadersMagicWeather.h" 24 30 25 31 #include <boost/filesystem.hpp> … … 364 370 deque<float> fDriveControlTrackingDevHist; 365 371 366 int64_t fFadControlNumEvents; 372 int64_t fFadControlNumEvents; 373 int32_t fFadControlDrsStep; 374 uint32_t fFadControlDrsRuns[3]; 367 375 368 376 float fFtmControlTriggerRateCam; … … 402 410 bool CheckDataSize(const EventImp &d, const char *name, size_t size, bool min=false) 403 411 { 412 if (d.GetSize()==0) 413 return false; 414 404 415 if ((!min && d.GetSize()==size) || (min && d.GetSize()>size)) 405 416 return true; … … 878 889 } 879 890 880 if (fDimBiasControl.state()==BIAS:: kVoltageOn)891 if (fDimBiasControl.state()==BIAS::State::kVoltageOn) 881 892 WriteBinary(d, "biascontrol-voltage", val, 10, 65); 882 893 else … … 1019 1030 1020 1031 fFadControlNumEvents = d.Get<uint32_t>(); 1032 1033 return GetCurrentState(); 1034 } 1035 1036 int HandleFadDrsRuns(const EventImp &d) 1037 { 1038 if (!CheckDataSize(d, "FadControl:DrsRuns", 4*4)) 1039 { 1040 fFadControlDrsStep = -1; 1041 return GetCurrentState(); 1042 } 1043 1044 const uint32_t *ptr = d.Ptr<uint32_t>(); 1045 fFadControlDrsStep = ptr[0]; 1046 fFadControlDrsRuns[0] = ptr[1]; 1047 fFadControlDrsRuns[1] = ptr[2]; 1048 fFadControlDrsRuns[2] = ptr[3]; 1021 1049 1022 1050 return GetCurrentState(); … … 1467 1495 1468 1496 if (&state==&fDimControl) 1469 return kHtmlGreen +'\t'+(state.state() ==-3?"Idle":fDimControl.shortmsg)+'\n';1497 return kHtmlGreen +'\t'+(state.state()<-2?"Idle":fDimControl.shortmsg)+'\n'; 1470 1498 1471 1499 const State rc = state.description(); … … 1515 1543 if (fDimDriveControl.state()>0xff) 1516 1544 msg << "Drive in ERROR state<br/>"; 1517 if (fDimBiasControl.state()<BIAS:: kRamping && (fDimMcp.state()==11 || fDimMcp.state()==12))1545 if (fDimBiasControl.state()<BIAS::State::kRamping && (fDimMcp.state()==MCP::State::kTriggerOn || fDimMcp.state()==MCP::State::kTakingData)) 1518 1546 msg << "BIAS not operating during data-taking<br/>"; 1519 if (fDimBiasControl.state()==BIAS:: kOverCurrent)1547 if (fDimBiasControl.state()==BIAS::State::kOverCurrent) 1520 1548 msg << "BIAS channels in OverCurrent<br/>"; 1521 if (fDimBiasControl.state()==BIAS:: kNotReferenced)1549 if (fDimBiasControl.state()==BIAS::State::kNotReferenced) 1522 1550 msg << "BIAS voltage not at reference<br/>"; 1523 if (fBiasControlCurrentMed>75) 1524 msg << "Median current exceeds 75µA/pix<br/>"; 1525 if (fBiasControlCurrentMax>90) 1526 msg << "Maximum current exceeds 90µA/pix<br/>"; 1527 if (fMagicWeatherHist[kHum].size()>0 && fMagicWeatherHist[kHum].back()>98 && (fDimMcp.state()==11 || fDimMcp.state()==12)) 1551 if (fFeedbackCalibration.size()>0) 1552 { 1553 if (fBiasControlCurrentMed>75) 1554 msg << "Median current exceeds 75µA/pix<br/>"; 1555 if (fBiasControlCurrentMax>90) 1556 msg << "Maximum current exceeds 90µA/pix<br/>"; 1557 } 1558 if (fMagicWeatherHist[kHum].size()>0 && fMagicWeatherHist[kHum].back()>98 && (fDimMcp.state()==MCP::State::kTriggerOn || fDimMcp.state()==MCP::State::kTakingData)) 1528 1559 msg << "Outside humidity exceeds 98% during data-taking<br/>"; 1529 if (fMagicWeatherHist[kGusts].size()>0 && fMagicWeatherHist[kGusts].back()>98 && fDimDriveControl.state()== 7)1560 if (fMagicWeatherHist[kGusts].size()>0 && fMagicWeatherHist[kGusts].back()>98 && fDimDriveControl.state()==Drive::State::kTracking) 1530 1561 msg << "Wind gusts exceed 50km/h during tracking<br/>"; 1531 1562 if (fFscControlTemperatureHist.size()>0 && fFscControlTemperatureHist.back()>7) 1532 1563 msg << "Sensor temperature exceeds outside temperature by more than 7°C<br/>"; 1533 if (fFtmControlTriggerRateCam<0.01 && (fDimMcp.state()== 11 || fDimMcp.state()==12))1564 if (fFtmControlTriggerRateCam<0.01 && (fDimMcp.state()==MCP::State::kTriggerOn || fDimMcp.state()==MCP::State::kTakingData)) 1534 1565 msg << "Trigger rate below 10mHz during data taking<br/>"; 1535 1566 if (fFscControlHumidityAvg>60) … … 1537 1568 if (!fDimControl.online()) 1538 1569 msg << "dimctrl offline<br/>"; 1570 1571 if (!fDimFeedback.state()==Feedback::State::kCalibrating && 1572 fDimBias.state()==BIAS::State::kVoltageOn && 1573 fBiasControlVoltageMed>3 && 1574 fFeedbackCalibration.size()==0) 1575 msg << "bias voltage switched on, but bias crate not calibrated."; 1539 1576 1540 1577 // FTM in Connected instead of Idle --> power cyclen … … 1583 1620 1584 1621 // -------------- System status -------------- 1585 if (fDimMcp.state()>= 5) // Idle1622 if (fDimMcp.state()>=MCP::State::kIdle) // Idle 1586 1623 { 1587 1624 string col = kHtmlBlue; 1588 if (fMcpConfigurationState!= 5 &&// Idle1589 fMcpConfigurationState!= 11&& // Trigger On1590 fMcpConfigurationState!= 12)// Taking Data1625 if (fMcpConfigurationState!=MCP::State::kIdle && // Idle 1626 fMcpConfigurationState!=MCP::State::kTriggerOn && // Trigger On 1627 fMcpConfigurationState!=MCP::State::kTakingData) // Taking Data 1591 1628 col = kHtmlYellow; 1592 1629 else 1593 if (fDimFadControl.state()==FAD:: kWritingData)1630 if (fDimFadControl.state()==FAD::State::kWritingData) 1594 1631 col = kHtmlGreen; 1595 1632 1596 1633 out << col << '\t'; 1597 1634 1598 if (fDimRateControl.state()!=5 && fDimRateScan.state()!=6) 1635 if (fDimRateControl.state()!=RateControl::State::kSettingGlobalThreshold && 1636 fDimRateScan.state()!=RateScan::State::kInProgress) 1599 1637 { 1600 1638 switch (fMcpConfigurationState) … … 1614 1652 } 1615 1653 else 1616 if (fDimRateControl.state()== 5/*kStateSettingGlobalThreshold*/)1654 if (fDimRateControl.state()==RateControl::State::kSettingGlobalThreshold) 1617 1655 out << "Calibrating threshold"; 1618 1656 else 1619 if (fDimRateScan.state()== 6/*kStateSettingGlobalThreshold*/)1657 if (fDimRateScan.state()==RateScan::State::kInProgress) 1620 1658 out << "Rate scan in progress"; 1621 1659 1622 if (fMcpConfigurationState>10 && fDimRateControl.state()!=5) 1660 if (fMcpConfigurationState>MCP::State::kConfigured && 1661 fDimRateControl.state()!=RateControl::State::kSettingGlobalThreshold) 1623 1662 { 1624 if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12) 1625 out << " ["; 1663 ostringstream evt; 1626 1664 if (fMcpConfigurationMaxEvents>0) 1627 1665 { 1628 if (fFadControlNumEvents>0 && fMcpConfigurationState==12) 1629 out << fMcpConfigurationMaxEvents-fFadControlNumEvents; 1666 const int64_t de = int64_t(fMcpConfigurationMaxEvents) - int64_t(fFadControlNumEvents); 1667 if (de>=0 && fMcpConfigurationState==MCP::State::kTakingData) 1668 evt << de; 1630 1669 else 1631 out << fMcpConfigurationMaxEvents; 1632 } 1633 if (fMcpConfigurationMaxEvents>0 && (fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12)) 1634 out << '/'; 1635 if (fMcpConfigurationMaxTime>0) 1636 { 1637 if (fMcpConfigurationState==12) 1638 { 1639 1640 const uint32_t dt = (Time()-fMcpConfigurationRunStart).total_seconds(); 1641 if (dt>fMcpConfigurationMaxTime) 1642 out << "---"; 1643 else 1644 out << fMcpConfigurationMaxTime-dt << 's'; 1645 } 1646 else 1647 out << fMcpConfigurationMaxTime << 's'; 1670 evt << fMcpConfigurationMaxEvents; 1648 1671 } 1649 1672 else 1650 1673 { 1651 if (fMcpConfigurationState==12) 1674 if (fMcpConfigurationState==MCP::State::kTakingData) 1675 evt << fFadControlNumEvents; 1676 } 1677 1678 ostringstream tim; 1679 if (fMcpConfigurationMaxTime>0) 1680 { 1681 const uint32_t dt = (Time()-fMcpConfigurationRunStart).total_seconds(); 1682 if (dt<=fMcpConfigurationMaxTime && fMcpConfigurationState==MCP::State::kTakingData) 1683 tim << fMcpConfigurationMaxTime-dt << 's'; 1684 else 1685 tim << fMcpConfigurationMaxTime << 's'; 1686 } 1687 else 1688 { 1689 if (fMcpConfigurationState==MCP::State::kTakingData) 1652 1690 { 1653 1691 ostringstream d; 1654 1692 d << Time()-fMcpConfigurationRunStart; 1655 out<< d.str().substr(3, 5);1693 tim << d.str().substr(3, 5); 1656 1694 } 1657 1695 } 1658 1696 1659 if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12) 1697 const bool has_evt = !evt.str().empty(); 1698 const bool has_tim = !tim.str().empty(); 1699 1700 if (has_evt || has_tim) 1701 out << " ["; 1702 out << evt.str(); 1703 if (has_evt && has_tim) 1704 out << '/'; 1705 out << tim.str(); 1706 if (has_evt || has_tim) 1660 1707 out << ']'; 1661 1708 } 1709 1710 if (fFadControlDrsRuns[2]>0) 1711 out << " (" << fFadControlDrsRuns[2] << ")"; 1662 1712 } 1663 1713 else … … 1666 1716 1667 1717 // ------------------ Drive ----------------- 1668 if (fDimDriveControl.state()>= 5) // Armed, Moving, Tracking1718 if (fDimDriveControl.state()>=Drive::State::kArmed) // Armed, Moving, Tracking 1669 1719 { 1670 1720 const double dev = fDriveControlTrackingDevHist.size()>0 ? fDriveControlTrackingDevHist.back() : 0; … … 1701 1751 1702 1752 // ------------------- FSC ------------------ 1703 if (fDimFscControl.state()> 1&& fFscControlTemperatureHist.size()>0)1753 if (fDimFscControl.state()>FSC::State::kDisconnected && fFscControlTemperatureHist.size()>0) 1704 1754 { 1705 1755 out << kHtmlGreen << '\t' << fFscControlTemperatureHist.back() << '\n'; … … 1709 1759 1710 1760 // --------------- MagicWeather ------------- 1711 if (fDimMagicWeather.state()== 3&& fMagicWeatherHist[kWeatherBegin].size()>0)1761 if (fDimMagicWeather.state()==MagicWeather::State::kReceiving && fMagicWeatherHist[kWeatherBegin].size()>0) 1712 1762 { 1713 1763 /* … … 1738 1788 1739 1789 // --------------- FtmControl ------------- 1740 if (fDimFtmControl.state()==FTM:: kTriggerOn)1790 if (fDimFtmControl.state()==FTM::State::kTriggerOn) 1741 1791 { 1742 1792 string col = kHtmlGreen; … … 1752 1802 1753 1803 // --------------- BiasControl ------------- 1754 if (fDimBiasControl.state()==BIAS:: kRamping ||1755 fDimBiasControl.state()==BIAS:: kOverCurrent ||1756 fDimBiasControl.state()==BIAS:: kVoltageOn ||1757 fDimBiasControl.state()==BIAS:: kVoltageOff)1758 { 1759 const bool off = fDimBiasControl.state()==BIAS:: kVoltageOff;1760 const bool oc = fDimBiasControl.state()==BIAS:: kOverCurrent;1804 if (fDimBiasControl.state()==BIAS::State::kRamping || 1805 fDimBiasControl.state()==BIAS::State::kOverCurrent || 1806 fDimBiasControl.state()==BIAS::State::kVoltageOn || 1807 fDimBiasControl.state()==BIAS::State::kVoltageOff) 1808 { 1809 const bool off = fDimBiasControl.state()==BIAS::State::kVoltageOff; 1810 const bool oc = fDimBiasControl.state()==BIAS::State::kOverCurrent; 1761 1811 1762 1812 string col = fBiasControlVoltageMed>3?kHtmlGreen:kHtmlWhite; … … 1767 1817 1768 1818 // Bias in overcurrent => Red 1769 if (fDimBiasControl.state()==BIAS:: kOverCurrent)1819 if (fDimBiasControl.state()==BIAS::State::kOverCurrent) 1770 1820 col = kHtmlRed; 1771 1821 1772 1822 // MCP in ReadyForDatataking/Configuring/Configured/TriggerOn/TakingData 1773 1823 // and Bias not in "data-taking state' => Red 1774 if (fMcpConfigurationState> 5&&1775 fDimBiasControl.state()!=BIAS:: kVoltageOn &&1776 fDimBiasControl.state()!=BIAS:: kVoltageOff)1824 if (fMcpConfigurationState>MCP::State::kIdle && 1825 fDimBiasControl.state()!=BIAS::State::kVoltageOn && 1826 fDimBiasControl.state()!=BIAS::State::kVoltageOff) 1777 1827 col = kHtmlRed; 1778 1828 … … 1828 1878 out << GetStateHtml(fDimDataLogger, 1); 1829 1879 out << GetStateHtml(fDimDriveControl, 2); 1830 out << GetStateHtml(fDimFadControl, FAD:: kConnected);1831 out << GetStateHtml(fDimFtmControl, FTM:: kConnected);1832 out << GetStateHtml(fDimBiasControl, BIAS:: kConnected);1880 out << GetStateHtml(fDimFadControl, FAD::State::kConnected); 1881 out << GetStateHtml(fDimFtmControl, FTM::State::kConnected); 1882 out << GetStateHtml(fDimBiasControl, BIAS::State::kConnected); 1833 1883 out << GetStateHtml(fDimFeedback, 4); 1834 1884 out << GetStateHtml(fDimRateControl, 4); … … 1934 1984 Subscribe("FAD_CONTROL/EVENTS") 1935 1985 (bind(&StateMachineSmartFACT::HandleFadEvents, this, placeholders::_1)); 1986 Subscribe("FAD_CONTROL/DRS_RUNS") 1987 (bind(&StateMachineSmartFACT::HandleFadDrsRuns, this, placeholders::_1)); 1936 1988 1937 1989 Subscribe("FTM_CONTROL/TRIGGER_RATES")
Note:
See TracChangeset
for help on using the changeset viewer.