- Timestamp:
- 06/01/12 12:08:39 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r14009 r14014 69 69 // ======================================================================== 70 70 71 class Astro71 class Sun 72 72 { 73 73 public: … … 89 89 90 90 bool isday; 91 bool visible; 91 92 92 93 public: 93 Astro(double lon, double lat, const Time &t=Time()) : time(t) 94 Sun() : time(Time::none) 95 { 96 } 97 Sun(double lon, double lat, const Time &t=Time()) : time(t) 94 98 { 95 99 #ifdef HAVE_LIBNOVA … … 107 111 108 112 // Warning: return code of 1 means circumpolar and is not checked! 109 //ln_get_lunar_rst (JD-0.5, &observer, &moon);110 113 ln_get_solar_rst (JD-0.5, &observer, &sun_day); 111 114 ln_get_solar_rst_horizon(JD-0.5, &observer, - 6, &sun_civil); … … 126 129 const bool is_night = JD>sun_dark.set; 127 130 128 //ln_get_lunar_rst (JD+0.5, &observer, &moon);129 131 ln_get_solar_rst (JD+0.5, &observer, &sun_day); 130 132 ln_get_solar_rst_horizon(JD+0.5, &observer, - 6, &sun_civil); … … 151 153 // case 1: sun-rise to sun-set | is_day && !is_night | set /rise 152 154 // case 2: sun-set to midnight | is_day && is_night | rise/set 153 /*154 if (is_day^is_night)155 {156 cout << "SunSet: " << fSunSetDayTime << endl;157 cout << "SunRise: " << fSunRiseDayTime << endl;158 }159 else160 {161 cout << "SunRise: " << fSunRiseDayTime << endl;162 cout << "SunSet: " << fSunSetDayTime << endl;163 }*/164 155 165 156 isday = is_day^is_night; … … 205 196 case 7: case 8: color = HTML::kGreen; break; 206 197 } 198 199 visible = state>=3 && state<=5; 207 200 #endif 208 201 } … … 212 205 { 213 206 public: 207 Time time; 208 214 209 double ra; 215 210 double dec; … … 226 221 string color; 227 222 228 Time time; 223 Moon() : time(Time::none) 224 { 225 } 229 226 230 227 Moon(double lon, double lat, const Time &t=Time()) : time(t) … … 391 388 deque<float> fRateScanDataHist[41]; 392 389 393 bool fSunIsVisible; 394 bool fMoonIsVisible; 395 396 Time fTimeOfCivilTwilight; 390 Sun fSun; 391 Moon fMoon; 392 393 //bool fSunIsVisible; 394 //bool fMoonIsVisible; 395 //Time fTimeOfCivilTwilight; 396 //float fMoonPhase; 397 398 // --------------------------- File header ---------------------------- 397 399 398 400 int fHasError; 401 402 Time fAudioTime; 403 string fAudioName; 404 405 string Header(const Time &d) 406 { 407 ostringstream msg; 408 msg << d.JavaDate() << '\t' << fAudioTime.JavaDate() << '\t' << fAudioName; 409 return msg.str(); 410 } 411 412 string Header(const EventImp &d) 413 { 414 return Header(d.GetTime()); 415 } 416 417 void SetAudio(const string &name) 418 { 419 fAudioName = name; 420 fAudioTime = Time(); 421 } 399 422 400 423 // ------------- Initialize variables before the Dim stuff ------------ … … 531 554 ostringstream out; 532 555 out << setprecision(3); 533 out << d.GetJavaDate() << '\n';556 out << Header(d) << '\n'; 534 557 out << HTML::kWhite << '\t'; 535 558 … … 562 585 if (d.GetQoS()==-2 && fDimControl.scriptdepth==0) 563 586 fControlMessageHist.clear(); 587 588 // Not that this will also "ding" just after program startup 589 // if the dimctrl is still in state -3 590 if (d.GetQoS()==-3 && fDimControl.scriptdepth==0) 591 SetAudio("ding"); 564 592 565 593 if (d.GetQoS()>=0) … … 589 617 } 590 618 619 if (fMcpConfigurationState==MCP::State::kTakingData && d.GetQoS()==MCP::State::kIdle) 620 SetAudio("sound_10"); 621 622 if (fMcpConfigurationState==MCP::State::kTriggerOn && d.GetQoS()==MCP::State::kTakingData) 623 SetAudio("losticks"); 624 591 625 fMcpConfigurationState = d.GetQoS(); 592 626 fMcpConfigurationMaxTime = d.Get<uint64_t>(); … … 594 628 fMcpConfigurationName = d.Ptr<char>(16); 595 629 596 if (d.GetQoS()== 12)630 if (d.GetQoS()==MCP::State::kTakingData) 597 631 fMcpConfigurationRunStart = Time(); 598 632 … … 643 677 //const uint16_t idx = uint16_t(floor(fmod(fMagicWeatherHist[kDir].back()/22.5+360+11.25, 360)/22.5))%16; 644 678 645 Astro astro(-(17.+53./60+26.525/3600), 28.+45./60+42.462/3600);646 Moon moon(-(17.+53./60+26.525/3600), 28.+45./60+42.462/3600);679 Sun sun (-(17.+53./60+26.525/3600), 28.+45./60+42.462/3600); 680 Moon moon(-(17.+53./60+26.525/3600), 28.+45./60+42.462/3600); 647 681 648 682 ostringstream out; 649 683 out << d.GetJavaDate() << '\n'; 650 out << astro.color << '\t' << astro.description << '\n';684 out << sun.color << '\t' << sun.description << '\n'; 651 685 out << setprecision(2); 652 out << ( astro.isday?HTML::kWhite:moon.color) << '\t' << moon.description << '\n';686 out << (sun.isday?HTML::kWhite:moon.color) << '\t' << moon.description << '\n'; 653 687 out << setprecision(3); 654 688 for (int i=0; i<6; i++) … … 661 695 out << "\t\n"; 662 696 663 fSunIsVisible = astro.state>=3 && astro.state<=5; 664 fMoonIsVisible = !fSunIsVisible && moon.visible; 665 666 fTimeOfCivilTwilight = astro.fSunSetCivil; 697 fSun = sun; 698 fMoon = moon; 667 699 668 700 ofstream(fPath+"/weather.data") << out.str(); 669 701 670 702 out.str(""); 671 out << astro.time.JavaDate() << '\n';672 out << HTML::kWhite << '\t' << astro.fSunRiseDarkTime.GetAsStr("%H:%M") << '\n';673 out << HTML::kWhite << '\t' << astro.fSunRiseAstronomical.GetAsStr("%H:%M") << '\n';674 out << HTML::kWhite << '\t' << astro.fSunRiseCivil.GetAsStr("%H:%M") << '\n';675 out << HTML::kWhite << '\t' << astro.fSunRiseDayTime.GetAsStr("%H:%M") << '\n';676 677 out << HTML::kWhite << '\t' << astro.fSunSetDayTime.GetAsStr("%H:%M") << '\n';678 out << HTML::kWhite << '\t' << astro.fSunSetCivil.GetAsStr("%H:%M") << '\n';679 out << HTML::kWhite << '\t' << astro.fSunSetAstronomical.GetAsStr("%H:%M") << '\n';680 out << HTML::kWhite << '\t' << astro.fSunSetDarkTime.GetAsStr("%H:%M") << '\n';703 out << sun.time.JavaDate() << '\n'; 704 out << HTML::kWhite << '\t' << sun.fSunRiseDarkTime.GetAsStr("%H:%M") << '\n'; 705 out << HTML::kWhite << '\t' << sun.fSunRiseAstronomical.GetAsStr("%H:%M") << '\n'; 706 out << HTML::kWhite << '\t' << sun.fSunRiseCivil.GetAsStr("%H:%M") << '\n'; 707 out << HTML::kWhite << '\t' << sun.fSunRiseDayTime.GetAsStr("%H:%M") << '\n'; 708 709 out << HTML::kWhite << '\t' << sun.fSunSetDayTime.GetAsStr("%H:%M") << '\n'; 710 out << HTML::kWhite << '\t' << sun.fSunSetCivil.GetAsStr("%H:%M") << '\n'; 711 out << HTML::kWhite << '\t' << sun.fSunSetAstronomical.GetAsStr("%H:%M") << '\n'; 712 out << HTML::kWhite << '\t' << sun.fSunSetDarkTime.GetAsStr("%H:%M") << '\n'; 681 713 682 714 out << HTML::kWhite << '\t' << moon.fMoonRise.GetAsStr("%H:%M") << '\n'; … … 1590 1622 Time now; 1591 1623 if (now-fLastUpdate<boost::posix_time::seconds(1)) 1592 return kStateRunning;1624 return fDimDNS.online() ? kStateRunning : kStateDimNetworkNA; 1593 1625 1594 1626 fLastUpdate=now; … … 1675 1707 1676 1708 ostringstream out; 1677 out << now.JavaDate() << '\t' << haserror << '\t' << (fDimControl.state()>-3) << '\n';1709 out << Header(now) << '\t' << haserror << '\t' << (fDimControl.state()>-3) << '\n'; 1678 1710 out << setprecision(3); 1679 1711 out << HTML::kWhite << '\t' << msg.str() << '\n'; … … 1690 1722 1691 1723 out.str(""); 1692 out << now.JavaDate() << '\t' << fHasError << '\t' << (fDimControl.state()>-3) << '\n';1724 out << Header(now) << '\t' << fHasError << '\t' << (fDimControl.state()>-3) << '\n'; 1693 1725 out << setprecision(3); 1694 1726 … … 1718 1750 const bool other = 1719 1751 fDimRateControl.state()==RateControl::State::kSettingGlobalThreshold || 1720 fDimRateScan.state() !=RateScan::State::kInProgress;1752 fDimRateScan.state()==RateScan::State::kInProgress; 1721 1753 1722 1754 if (other) … … 1845 1877 else 1846 1878 out << HTML::kWhite << '\t'; 1847 if (fSunIsVisible) 1848 { 1849 out << " ☼"; 1850 if (fTimeOfCivilTwilight.IsValid() && fDimDriveControl.state()<Drive::State::kArmed) 1851 out << " [" << fTimeOfCivilTwilight.MinutesTo() << "]"; 1852 } 1853 else 1854 if (fMoonIsVisible) 1855 out << " ☾"; 1856 out << '\n'; 1879 if (fSun.time.IsValid() && fMoon.time.IsValid()) 1880 { 1881 if (fSun.visible) 1882 { 1883 out << " ☼"; 1884 if (fDimDriveControl.state()<Drive::State::kArmed) 1885 out << " [" << fSun.fSunSetCivil.MinutesTo() << "↓]"; 1886 } 1887 else 1888 if (!fSun.visible && fMoon.visible) 1889 { 1890 out << " ☾"; 1891 if (fDimDriveControl.state()<Drive::State::kArmed) 1892 out << " [" << fMoon.disk << "%]"; 1893 } 1894 out << '\n'; 1895 } 1857 1896 1858 1897 // ------------------- FSC ------------------ … … 1976 2015 1977 2016 out.str(""); 1978 out << now.JavaDate() << '\t' << fHasError << '\t' << (fDimControl.state()>-3) << '\n';2017 out << Header(now) << '\t' << fHasError << '\t' << (fDimControl.state()>-3) << '\n'; 1979 2018 1980 2019 if (!fDimDNS.online()) … … 2031 2070 fRateScanDataId(0), 2032 2071 fRateScanBoard(0), 2033 fSunIsVisible(true),2034 fMoonIsVisible(false),2035 fTimeOfCivilTwilight(Time::none),2036 2072 fHasError(2), 2037 2073 // ---
Note:
See TracChangeset
for help on using the changeset viewer.