Changeset 18408
- Timestamp:
- 01/06/16 12:38:37 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r18374 r18408 8 8 9 9 #include <sys/stat.h> //for file stats 10 #include <sys/statvfs.h> //for file statvfs 10 11 11 12 #include "Dim.h" … … 33 34 #include "HeadersDrive.h" 34 35 #include "HeadersPower.h" 36 #include "HeadersPFmini.h" 35 37 #include "HeadersAgilent.h" 36 38 #include "HeadersFeedback.h" … … 552 554 553 555 float fFscControlHumidityAvg; 556 557 deque<float> fPfMiniHumidityHist; 558 deque<float> fPfMiniTemperatureHist; 554 559 555 560 deque<float> fTemperatureControlHist; … … 631 636 DimDescribedState fDimFadControl; 632 637 DimDescribedState fDimFscControl; 638 DimDescribedState fDimPfMiniControl; 633 639 DimDescribedState fDimGpsControl; 634 640 DimDescribedState fDimSqmControl; … … 1903 1909 1904 1910 fFscControlHumidityAvg = num>0 ? avg/num : 0; 1911 1912 return GetCurrentState(); 1913 } 1914 1915 int HandlePfMiniData(const EventImp &d) 1916 { 1917 if (!CheckDataSize(d, "PfMini:Data", sizeof(PFmini::Data))) 1918 return GetCurrentState(); 1919 1920 const PFmini::Data &data = d.Ref<PFmini::Data>(); 1921 1922 ostringstream out; 1923 1924 out << fixed << setprecision(1); 1925 out << d.GetJavaDate() << '\n'; 1926 1927 out << HTML::kGreen << '\t' << data.temp << '\n'; 1928 out << HTML::kGreen << '\t' << data.hum << '\n'; 1929 1930 ofstream(fPath+"/pfmini.data") << out.str(); 1931 1932 fPfMiniTemperatureHist.push_back(data.temp); 1933 if (fPfMiniTemperatureHist.size()>60*4) // 1h 1934 fPfMiniTemperatureHist.pop_front(); 1935 1936 fPfMiniHumidityHist.push_back(data.hum); 1937 if (fPfMiniHumidityHist.size()>60*4) // 1h 1938 fPfMiniHumidityHist.pop_front(); 1939 1940 WriteHist(d, "hist-pfmini-temp", 1941 fPfMiniTemperatureHist, 45, 0); 1942 1943 WriteHist(d, "hist-pfmini-hum", 1944 fPfMiniHumidityHist, 100, 0); 1905 1945 1906 1946 return GetCurrentState(); … … 2569 2609 // ============================================================== 2570 2610 2611 bool reqscript = false; 2612 2613 #ifdef HAVE_SQL 2614 try 2615 { 2616 const string query = Tools::Form("SELECT COUNT(*) FROM calendar.Data WHERE NOT u LIKE 'moon' AND y=%d AND m=%d AND d=%d", 2617 now.NightAsInt()/10000, (now.NightAsInt()/100)%100-1, now.NightAsInt()%100); 2618 2619 const mysqlpp::StoreQueryResult res = Database(fDatabase).query(query).store(); 2620 2621 const uint32_t cnt = res[0][0]; 2622 2623 reqscript = cnt>0 && fSun.state>=2 && fSun.state<=6; 2624 } 2625 catch (const exception &e) 2626 { 2627 Out() << e.what() << endl; 2628 } 2629 #endif 2630 // ============================================================== 2631 2632 struct statvfs vfs; 2633 statvfs("/daq", &vfs); 2634 2635 const uint64_t freedaq = vfs.f_bsize*vfs.f_bavail; 2636 2637 // ============================================================== 2638 2571 2639 const bool data_taking = 2572 2640 fDimMcp.state()==MCP::State::kTriggerOn || … … 2596 2664 "<b>datalogger not ready</b>"); 2597 2665 2666 newerr |= SetError(fDimControl.state()!=3 && reqscript, 2667 "<b>No script running during datataking time.</b>"); 2668 2598 2669 //newerr |= SetError(fDimDriveControl.state()==Drive::State::kLocked, 2599 2670 // "<b><#darkred>Drive in LOCKED state, drive was automatically parked</#></b>"); … … 2622 2693 "Average camera humidity exceed 60%"); 2623 2694 2695 newerr |= SetError(!fPfMiniHumidityHist.empty() && fPfMiniHumidityHist.back()>40, 2696 "Camera humidity inside camera exceeds 40% (PFmini)"); 2697 newerr |= SetError(!fTemperatureControlHist.empty() && (fTemperatureControlHist.back()<26.5 || fTemperatureControlHist.back()>29), 2698 "Container temperature outside [26.5;29]°C"); 2699 2624 2700 newerr |= SetError(!fMagicWeatherHist[kHum].empty() && fMagicWeatherHist[kHum].back()>98 && fDimLidControl.state()==Lid::State::kOpen, 2625 2701 "Outside humidity exceeds 98% while lid is open"); … … 2650 2726 2651 2727 newerr |= SetError(fFreeSpace<50000000000, 2652 "Less than 50GB disk space left."); 2728 "Less than 50GB disk space left on newdaq."); 2729 2730 newerr |= SetError(freedaq<80000000000, 2731 "Less than 80GB disk space left on daq."); 2653 2732 2654 2733 newerr |= SetError(fDimPwrControl.state()==Power::State::kCoolingFailure, … … 3055 3134 out << GetStateHtml(fDimRateControl, RateControl::State::kConnected); 3056 3135 out << GetStateHtml(fDimFscControl, FSC::State::kConnected); 3136 out << GetStateHtml(fDimPfMiniControl, PFmini::State::kConnected); 3057 3137 out << GetStateHtml(fDimGpsControl, GPS::State::kConnected); 3058 3138 out << GetStateHtml(fDimSqmControl, SQM::State::kConnected); … … 3079 3159 3080 3160 out << col << '\t' << Tools::Scientific(fFreeSpace) << "B\n"; 3161 3162 col = HTML::kRed; 3163 if (freedaq>uint64_t(199999999999)) 3164 col = HTML::kYellow; 3165 if (freedaq>uint64_t(999999999999)) 3166 col = HTML::kGreen; 3167 if (freedaq==UINT64_MAX) 3168 col = HTML::kWhite; 3169 3170 out << col << '\t' << Tools::Scientific(freedaq) << "B\n"; 3081 3171 3082 3172 out << HTML::kGreen << '\t' << dt.str().substr(0, dt.str().length()-7) << '\n'; … … 3130 3220 fDimFadControl ("FAD_CONTROL"), 3131 3221 fDimFscControl ("FSC_CONTROL"), 3222 fDimPfMiniControl ("PFMINI_CONTROL"), 3132 3223 fDimGpsControl ("GPS_CONTROL"), 3133 3224 fDimSqmControl ("SQM_CONTROL"), … … 3157 3248 fDimFadControl.Subscribe(*this); 3158 3249 fDimFscControl.Subscribe(*this); 3250 fDimPfMiniControl.Subscribe(*this); 3159 3251 fDimGpsControl.Subscribe(*this); 3160 3252 fDimSqmControl.Subscribe(*this); … … 3194 3286 Subscribe("FSC_CONTROL/BIAS_TEMP") 3195 3287 (bind(&StateMachineSmartFACT::HandleFscBiasTemp, this, placeholders::_1)); 3288 3289 Subscribe("PFMINI_CONTROL/DATA") 3290 (bind(&StateMachineSmartFACT::HandlePfMiniData, this, placeholders::_1)); 3196 3291 3197 3292 Subscribe("GPS_CONTROL/NEMA")
Note:
See TracChangeset
for help on using the changeset viewer.