Changeset 14213
- Timestamp:
- 06/22/12 10:08:19 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r14161 r14213 449 449 set<string> fErrorList; 450 450 deque<string> fErrorHist; 451 deque<string> fChatHist; 452 Time fChatLastTime; 451 453 452 454 Sun fSun; … … 707 709 } 708 710 709 void HandleFscControlStateChange( )711 void HandleFscControlStateChange(const EventImp &d) 710 712 { 711 713 const int32_t &last = fDimFscControl.last.second; … … 716 718 717 719 if (last<FSC::State::kConnected && state==FSC::State::kConnected) 720 { 721 AddMcpConfigurationHist(d, "<B>Camera swiched on</B>"); 718 722 SetAudio("startup"); 723 } 719 724 720 725 if (last==FSC::State::kConnected && state<FSC::State::kConnected) 726 { 727 AddMcpConfigurationHist(d, "<B>Camera swiched off</B>"); 721 728 SetAudio("shutdown"); 729 } 730 } 731 732 void AddMcpConfigurationHist(const EventImp &d, const string &msg) 733 { 734 if (d.GetTime()>fMcpConfigurationLastTime+boost::posix_time::hours(12)) 735 fMcpConfigurationHist.clear(); 736 737 fMcpConfigurationLastTime = d.GetTime(); 738 fMcpConfigurationHist.push_back(d.GetTimeAsStr("%H:%M:%S ")+msg+"<br/>"); 739 740 ostringstream out; 741 out << d.GetJavaDate() << '\n'; 742 out << HTML::kWhite << '\t'; 743 for (auto it=fMcpConfigurationHist.rbegin(); it!=fMcpConfigurationHist.rend(); it++) 744 out << *it; 745 out << '\n'; 746 747 ofstream(fPath+"/observations.data") << out.str(); 722 748 } 723 749 … … 734 760 } 735 761 736 if (d.GetTime()>fMcpConfigurationLastTime+boost::posix_time::hours(12))737 fMcpConfigurationHist.clear();738 739 762 // If a run ends... 740 763 if (fMcpConfigurationState==MCP::State::kTakingData && d.GetQoS()==MCP::State::kIdle) … … 747 770 SetAudio("losticks"); 748 771 772 fLastRunFinishedWithZeroEvents = fFadControlNumEvents==0; 773 749 774 ostringstream out; 750 out << d.GetTimeAsStr("%H:%M:%S") << "<#darkred>" << d.Ptr<char>(16);775 out << "<#darkred>" << d.Ptr<char>(16); 751 776 if (!fDriveControlSourceName.empty()) 752 777 out << " [" << fDriveControlSourceName << ']'; 753 778 out << " (N=" << fFadControlNumEvents << ')'; 754 out << "</#><br/>"; 755 fMcpConfigurationHist.push_back(out.str()); 756 757 fLastRunFinishedWithZeroEvents = fFadControlNumEvents==0; 779 out << "</#>"; 780 781 AddMcpConfigurationHist(d, out.str()); 758 782 } 759 783 … … 764 788 765 789 ostringstream out; 766 out << d.GetTimeAsStr("%H:%M:%S") << "<#darkgreen>" << fMcpConfigurationName;790 out << "<#darkgreen>" << fMcpConfigurationName; 767 791 if (!fDriveControlSourceName.empty()) 768 792 out << " [" << fDriveControlSourceName << ']'; 769 793 if (fFadControlStartRun>0) 770 794 out << " (Run " << fFadControlStartRun << ')'; 771 out << "</#><br/>"; 772 fMcpConfigurationHist.push_back(out.str()); 795 out << "</#>"; 796 797 AddMcpConfigurationHist(d, out.str()); 773 798 } 774 799 … … 777 802 fMcpConfigurationMaxEvents = d.Get<uint64_t>(8); 778 803 fMcpConfigurationName = d.Ptr<char>(16); 779 fMcpConfigurationLastTime = d.GetTime();780 781 ostringstream out;782 out << d.GetJavaDate() << '\n';783 out << HTML::kWhite << '\t';784 for (auto it=fMcpConfigurationHist.rbegin(); it!=fMcpConfigurationHist.rend(); it++)785 out << *it;786 out << '\n';787 788 ofstream(fPath+"/observations.data") << out.str();789 804 790 805 return GetCurrentState(); … … 1659 1674 } 1660 1675 1676 int HandleChatMsg(const EventImp &d) 1677 { 1678 if (d.GetSize()==0 || d.GetQoS()!=MessageImp::kMessage) 1679 return GetCurrentState(); 1680 1681 if (d.GetTime()>fChatLastTime+boost::posix_time::hours(12)) 1682 fChatHist.clear(); 1683 1684 if (Time()<d.GetTime()+boost::posix_time::minutes(1)) 1685 SetAudio("message"); 1686 1687 fChatLastTime = d.GetTime(); 1688 1689 string msg; 1690 msg += d.GetTimeAsStr("%H:%M:%S "); 1691 msg += d.Ptr<char>(); 1692 1693 fChatHist.push_front(msg); 1694 if (fChatHist.size()>80) 1695 fChatHist.pop_back(); 1696 1697 ostringstream out; 1698 out << setprecision(3); 1699 out << Header(d) << '\n'; 1700 out << HTML::kWhite << '\t'; 1701 1702 out << "<->"; 1703 for (auto it=fChatHist.begin(); it!=fChatHist.end(); it++) 1704 out << *it << "<br/>"; 1705 out << "</->"; 1706 1707 out << '\n'; 1708 1709 ofstream(fPath+"/chat.data") << out.str(); 1710 1711 return GetCurrentState(); 1712 } 1713 1661 1714 // ------------------------------------------------------------------- 1662 1715 … … 1785 1838 1786 1839 double max = 0; 1787 double maxjd = jd0; 1788 1840 double maxjd = 0; 1841 1842 int cnt = 0; 1789 1843 1790 1844 vector<float> alt; … … 1797 1851 ln_get_hrz_from_equ(pos, observer, jd+h, &hrz); 1798 1852 1799 if (h>jd0 && h<jd1 && hrz.alt>15)1853 if (h>jd0 && h<jd1) 1800 1854 alt.push_back(hrz.alt); 1801 1855 … … 1805 1859 maxjd = jd+h; 1806 1860 } 1807 } 1808 1809 if (max<15) 1861 1862 if (h>jd0 && h<jd1 && hrz.alt>15) 1863 cnt++; 1864 } 1865 1866 if (max<=15 || cnt==0) 1810 1867 return make_pair(vector<float>(), make_pair(Time(), 0)); 1811 1868 1812 return make_pair(alt, make_pair(maxjd, maxjd>jd 0+jd&&maxjd<jd1+jd?max:0));1869 return make_pair(alt, make_pair(maxjd, maxjd>jd+jd0&&maxjd<jd+jd1?max:0)); 1813 1870 } 1814 1871 #endif … … 2268 2325 if (dev>60) // ~1.5mm 2269 2326 col = HTML::kYellow; 2270 if (dev>1 00) // ~1/4 of a pixel ~ 2.5mm2327 if (dev>120) // ~1/4 of a pixel ~ 2.5mm 2271 2328 col = HTML::kRed; 2272 2329 } … … 2315 2372 if (fDimDNS.online() && fDimFscControl.state()>FSC::State::kDisconnected && fFscControlTemperatureHist.size()>0) 2316 2373 { 2317 out << HTML::kGreen << '\t' << fFscControlTemperatureHist.back() << '\n'; 2374 string col = HTML::kGreen; 2375 if (fFscControlTemperatureHist.back()>5) 2376 col = HTML::kYellow; 2377 if (fFscControlTemperatureHist.back()>8) 2378 col = HTML::kRed; 2379 2380 out << col << '\t' << fFscControlTemperatureHist.back() << '\n'; 2318 2381 } 2319 2382 else … … 2462 2525 out << GetStateHtml(fDimRateControl, 4); 2463 2526 out << GetStateHtml(fDimFscControl, 2); 2527 out << GetStateHtml(fDimRateScan, 4); 2464 2528 out << GetStateHtml(fDimMagicWeather, 2); 2465 2529 out << GetStateHtml(fDimTngWeather, 2); 2466 out << GetStateHtml(fDimRateScan, 4);2467 2530 out << GetStateHtml(fDimChat, 0); 2468 2531 out << GetStateHtml(fDimSkypeClient, 1); … … 2537 2600 fDimSkypeClient.Subscribe(*this); 2538 2601 2539 fDimFscControl.SetCallback(bind(&StateMachineSmartFACT::HandleFscControlStateChange, this ));2602 fDimFscControl.SetCallback(bind(&StateMachineSmartFACT::HandleFscControlStateChange, this, placeholders::_1)); 2540 2603 fDimControl.SetCallback(bind(&StateMachineSmartFACT::HandleControlStateChange, this, placeholders::_1)); 2541 2604 fDimControl.AddCallback("dotest.dim", bind(&StateMachineSmartFACT::HandleDoTest, this, placeholders::_1)); … … 2582 2645 Subscribe("FAD_CONTROL/DRS_RUNS") 2583 2646 (bind(&StateMachineSmartFACT::HandleFadDrsRuns, this, placeholders::_1)); 2647 Subscribe("FAD_CONTROL/EVENT_DATA") 2648 (bind(&StateMachineSmartFACT::HandleFadEventData, this, placeholders::_1)); 2584 2649 2585 2650 Subscribe("FTM_CONTROL/TRIGGER_RATES") … … 2596 2661 (bind(&StateMachineSmartFACT::HandleRateScanData, this, placeholders::_1)); 2597 2662 2598 Subscribe("FAD_CONTROL/EVENT_DATA") 2599 (bind(&StateMachineSmartFACT::HandleFadEventData, this, placeholders::_1)); 2663 Subscribe("CHAT/MESSAGE") 2664 (bind(&StateMachineSmartFACT::HandleChatMsg, this, placeholders::_1)); 2665 2600 2666 2601 2667 // ================================================================= … … 2653 2719 out << Time().JavaDate() << '\n'; 2654 2720 2655 ofstream(fPath+"/errorhist.data") << out.str(); 2656 ofstream(fPath+"/error.data") << out.str(); 2721 ofstream(fPath+"/error.data") << out.str(); 2657 2722 2658 2723 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.