Changeset 17359
- Timestamp:
- 11/23/13 14:36:10 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r17347 r17359 27 27 #include "HeadersFTM.h" 28 28 #include "HeadersFSC.h" 29 #include "HeadersGPS.h" 29 30 #include "HeadersMCP.h" 30 31 #include "HeadersLid.h" … … 436 437 Time fMcpConfigurationRunStart; 437 438 EventHist fMcpConfigurationHist; 438 439 439 bool fLastRunFinishedWithZeroEvents; 440 440 … … 456 456 457 457 float fFscControlHumidityAvg; 458 459 deque<float> fTemperatureControlHist; 458 460 459 461 float fDriveControlPointingZd; … … 533 535 DimDescribedState fDimFadControl; 534 536 DimDescribedState fDimFscControl; 537 DimDescribedState fDimGpsControl; 535 538 DimDescribedState fDimAgilentControl; 536 539 DimDescribedState fDimPwrControl; … … 1146 1149 1147 1150 // write the history to a file 1148 WriteHist(d, "hist-biascontrol-current", fBiasControlCurrentHist, 1 00);1151 WriteHist(d, "hist-biascontrol-current", fBiasControlCurrentHist, 125); 1149 1152 1150 1153 // -------------------------------------------------------- … … 1787 1790 1788 1791 fFscControlHumidityAvg = num>0 ? avg/num : 0; 1792 1793 return GetCurrentState(); 1794 } 1795 1796 int HandleGpsNema(const EventImp &d) 1797 { 1798 if (!CheckDataSize(d, "GpsControl:Nema", sizeof(GPS::NEMA))) 1799 return GetCurrentState(); 1800 1801 const GPS::NEMA &nema = d.Ref<GPS::NEMA>(); 1802 1803 ostringstream out; 1804 1805 out << fixed; 1806 out << d.GetJavaDate() << '\n'; 1807 1808 switch (nema.qos) 1809 { 1810 case 1: out << HTML::kGreen << "\tGPS fix [1]\n"; break; 1811 case 2: out << HTML::kGreen << "\tDifferential fix [2]\n"; break; 1812 default: out << HTML::kRed << "\tinvalid [" << nema.qos << "]\n"; break; 1813 } 1814 1815 out << HTML::kWhite << '\t' << nema.count << '\n'; 1816 out << HTML::kWhite << '\t' << Time(nema.time).GetAsStr("%H:%M:%S") << '\n'; 1817 out << HTML::kWhite << '\t' << setprecision(4) << nema.lat << '\n'; 1818 out << HTML::kWhite << '\t' << setprecision(4) << nema.lng << '\n'; 1819 out << HTML::kWhite << '\t' << setprecision(1) << nema.height << "\n"; 1820 out << HTML::kWhite << '\t' << setprecision(1) << nema.hdop << "\n"; 1821 out << HTML::kWhite << '\t' << setprecision(1) << nema.geosep << "\n"; 1822 1823 ofstream(fPath+"/gps.data") << out.str(); 1824 1825 return GetCurrentState(); 1826 } 1827 1828 string GetTempColor(float t) 1829 { 1830 if (t>25 && t<30) 1831 return HTML::kGreen; 1832 1833 if (t<20 || t>35) 1834 return HTML::kRed; 1835 1836 return HTML::kYellow; 1837 } 1838 1839 int HandleTemperatureData(const EventImp &d) 1840 { 1841 if (!CheckDataSize(d, "Temperature:Data", 3*sizeof(float))) 1842 return GetCurrentState(); 1843 1844 const float *temp = d.Ptr<float>(); 1845 1846 ostringstream out; 1847 1848 out << fixed << setprecision(1); 1849 out << d.GetJavaDate() << '\n'; 1850 1851 out << GetTempColor(temp[1]) << '\t' << temp[1] << '\n'; 1852 out << GetTempColor(temp[0]) << '\t' << temp[0] << '\n'; 1853 out << GetTempColor(temp[2]) << '\t' << temp[2] << '\n'; 1854 1855 ofstream(fPath+"/temperature.data") << out.str(); 1856 1857 if (!fTemperatureControlHist.empty()) 1858 { 1859 fTemperatureControlHist.push_back(temp[0]); 1860 if (fTemperatureControlHist.size()>60) // 1h 1861 fTemperatureControlHist.pop_front(); 1862 } 1863 1864 WriteHist(d, "hist-temperaturecontrol", 1865 fTemperatureControlHist, 45, 0); 1866 1867 return GetCurrentState(); 1868 } 1869 1870 int HandleAgilentData(const EventImp &d) 1871 { 1872 if (!CheckDataSize(d, "Agilent:Data", 4*sizeof(float))) 1873 return GetCurrentState(); 1874 1875 const float *data = d.Ptr<float>(); 1876 1877 ostringstream out; 1878 1879 out << fixed << setprecision(1); 1880 out << d.GetJavaDate() << '\n'; 1881 1882 out << HTML::kWhite << '\t' << data[0] << '\n'; 1883 out << HTML::kWhite << '\t' << data[1] << '\n'; 1884 out << HTML::kWhite << '\t' << data[2] << '\n'; 1885 out << HTML::kWhite << '\t' << data[3] << '\n'; 1886 1887 ofstream(fPath+"/agilent.data") << out.str(); 1789 1888 1790 1889 return GetCurrentState(); … … 2220 2319 { 2221 2320 const mysqlpp::StoreQueryResult res = 2222 Database(fDatabase).query("SELECT fSourceName, fRightAscension, fDeclination FROM source WHERE fSourceTypeKEY=1").store();2321 Database(fDatabase).query("SELECT fSourceName, fRightAscension, fDeclination FROM Source WHERE fSourceTypeKEY=1").store(); 2223 2322 2224 2323 out << HTML::kWhite << '\t'; … … 2837 2936 out << GetStateHtml(fDimRateControl, RateControl::State::kConnected); 2838 2937 out << GetStateHtml(fDimFscControl, FSC::State::kConnected); 2938 out << GetStateHtml(fDimGpsControl, GPS::State::kConnected); 2839 2939 out << GetStateHtml(fDimAgilentControl, Agilent::State::kVoltageOff); 2840 2940 out << GetStateHtml(fDimPwrControl, Power::State::kSystemOff); … … 2908 3008 fDimFadControl ("FAD_CONTROL"), 2909 3009 fDimFscControl ("FSC_CONTROL"), 3010 fDimGpsControl ("GPS_CONTROL"), 2910 3011 fDimAgilentControl("AGILENT_CONTROL"), 2911 3012 fDimPwrControl ("PWR_CONTROL"), … … 2931 3032 fDimFadControl.Subscribe(*this); 2932 3033 fDimFscControl.Subscribe(*this); 3034 fDimGpsControl.Subscribe(*this); 2933 3035 fDimAgilentControl.Subscribe(*this); 2934 3036 fDimPwrControl.Subscribe(*this); … … 2964 3066 Subscribe("FSC_CONTROL/BIAS_TEMP") 2965 3067 (bind(&StateMachineSmartFACT::HandleFscBiasTemp, this, placeholders::_1)); 3068 3069 Subscribe("GPS_CONTROL/NEMA") 3070 (bind(&StateMachineSmartFACT::HandleGpsNema, this, placeholders::_1)); 3071 3072 Subscribe("TEMPERATURE/DATA") 3073 (bind(&StateMachineSmartFACT::HandleTemperatureData, this, placeholders::_1)); 3074 3075 Subscribe("AGILENT_CONTROL/DATA") 3076 (bind(&StateMachineSmartFACT::HandleAgilentData, this, placeholders::_1)); 2966 3077 2967 3078 Subscribe("MAGIC_WEATHER/DATA")
Note:
See TracChangeset
for help on using the changeset viewer.