- Timestamp:
- 06/02/12 20:30:15 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r14040 r14042 79 79 Time time; 80 80 81 Time f SunRiseDayTime;82 Time f SunRiseCivil;83 Time f SunRiseAstronomical;84 Time f SunRiseDarkTime;85 86 Time fS unSetDayTime;87 Time fS unSetCivil;88 Time fS unSetAstronomical;89 Time fS unSetDarkTime;81 Time fRiseDayTime; 82 Time fRiseCivil; 83 Time fRiseAstronomical; 84 Time fRiseDarkTime; 85 86 Time fSetDayTime; 87 Time fSetCivil; 88 Time fSetAstronomical; 89 Time fSetDarkTime; 90 90 91 91 int state; … … 100 100 { 101 101 } 102 103 // Could be done more efficient: Only recalcuate if 104 // the current time exceeds at least on of the stored times 102 105 Sun(double lon, double lat, const Time &t=Time()) : time(t) 103 106 { … … 121 124 ln_get_solar_rst_horizon(JD-0.5, &observer, -18, &sun_dark); 122 125 123 fS unSetDayTime = Time(sun_day.set);124 fS unSetCivil = Time(sun_civil.set);125 fS unSetAstronomical = Time(sun_astronomical.set);126 fS unSetDarkTime = Time(sun_dark.set);127 128 f SunRiseDayTime = Time(sun_day.rise);129 f SunRiseCivil = Time(sun_civil.rise);130 f SunRiseAstronomical = Time(sun_astronomical.rise);131 f SunRiseDarkTime = Time(sun_dark.rise);126 fSetDayTime = Time(sun_day.set); 127 fSetCivil = Time(sun_civil.set); 128 fSetAstronomical = Time(sun_astronomical.set); 129 fSetDarkTime = Time(sun_dark.set); 130 131 fRiseDayTime = Time(sun_day.rise); 132 fRiseCivil = Time(sun_civil.rise); 133 fRiseAstronomical = Time(sun_astronomical.rise); 134 fRiseDarkTime = Time(sun_dark.rise); 132 135 133 136 const bool is_day = JD>sun_day.rise; … … 141 144 if (is_day) 142 145 { 143 f SunRiseDayTime = Time(sun_day.rise);144 f SunRiseCivil = Time(sun_civil.rise);145 f SunRiseAstronomical = Time(sun_astronomical.rise);146 f SunRiseDarkTime = Time(sun_dark.rise);146 fRiseDayTime = Time(sun_day.rise); 147 fRiseCivil = Time(sun_civil.rise); 148 fRiseAstronomical = Time(sun_astronomical.rise); 149 fRiseDarkTime = Time(sun_dark.rise); 147 150 } 148 151 149 152 if (is_night) 150 153 { 151 fS unSetDayTime = Time(sun_day.set);152 fS unSetCivil = Time(sun_civil.set);153 fS unSetAstronomical = Time(sun_astronomical.set);154 fS unSetDarkTime = Time(sun_dark.set);154 fSetDayTime = Time(sun_day.set); 155 fSetCivil = Time(sun_civil.set); 156 fSetAstronomical = Time(sun_astronomical.set); 157 fSetDarkTime = Time(sun_dark.set); 155 158 } 156 159 … … 162 165 163 166 state = isday ? 4 : 0; 164 if (time>fS unSetDayTime) state++;165 if (time>fS unSetCivil) state++;166 if (time>fS unSetAstronomical) state++;167 if (time>fS unSetDarkTime) state++;168 169 if (time>f SunRiseDarkTime) state++;170 if (time>f SunRiseAstronomical) state++;171 if (time>f SunRiseCivil) state++;172 if (time>f SunRiseDayTime) state++;167 if (time>fSetDayTime) state++; 168 if (time>fSetCivil) state++; 169 if (time>fSetAstronomical) state++; 170 if (time>fSetDarkTime) state++; 171 172 if (time>fRiseDarkTime) state++; 173 if (time>fRiseAstronomical) state++; 174 if (time>fRiseCivil) state++; 175 if (time>fRiseDayTime) state++; 173 176 174 177 string name[] = … … 188 191 189 192 const string arr = isday ? 190 fS unSetDarkTime.MinutesTo(time)+"↓" :191 f SunRiseDarkTime.MinutesTo(time)+"↑";193 fSetDarkTime.MinutesTo(time)+"↓" : 194 fRiseDarkTime.MinutesTo(time)+"↑"; 192 195 193 196 description += " ["+arr+"]"; … … 222 225 bool visible; 223 226 224 Time f MoonRise;225 Time f MoonTransit;226 Time f MoonSet;227 Time fRise; 228 Time fTransit; 229 Time fSet; 227 230 228 231 string description; 229 232 string color; 230 233 234 int state; 235 231 236 Moon() : time(Time::none) 232 237 { 233 238 } 234 239 240 // Could be done more efficient: Only recalcuate if 241 // the current time exceeds at least on of the stored times 235 242 Moon(double lon, double lat, const Time &t=Time()) : time(t) 236 243 { … … 252 259 ln_get_lunar_rst(JD-0.5, &observer, &moon); 253 260 254 f MoonRise = Time(moon.rise);255 f MoonTransit = Time(moon.transit);256 f MoonSet = Time(moon.set);257 258 visible =259 (JD>moon.rise && JD<moon.set&& moon.rise<moon.set) ||260 ((JD<moon.set || JD>moon.rise) && moon.rise>moon.set);261 fRise = Time(moon.rise); 262 fTransit = Time(moon.transit); 263 fSet = Time(moon.set); 264 265 //visible = 266 // ((JD>moon.rise && JD<moon.set ) && moon.rise<moon.set) || 267 // ((JD<moon.set || JD>moon.rise) && moon.rise>moon.set); 261 268 262 269 const bool is_up = JD>moon.rise; … … 266 273 ln_get_lunar_rst(JD+0.5, &observer, &moon); 267 274 if (is_up) 268 f MoonRise = Time(moon.rise);275 fRise = Time(moon.rise); 269 276 if (is_sinking) 270 f MoonTransit = Time(moon.transit);277 fTransit = Time(moon.transit); 271 278 if (is_dn) 272 f MoonSet = Time(moon.set);279 fSet = Time(moon.set); 273 280 274 281 ln_equ_posn pos; … … 284 291 285 292 disk = ln_get_lunar_disk(JD)*100; 293 state = 0; 294 if (fRise <fTransit && fRise <fSet) state = 0; // not visible 295 if (fTransit<fSet && fTransit<fRise) state = 1; // before culm 296 if (fSet <fRise && fSet <fTransit) state = 2; // after culm 297 298 visible = state!=0; 299 300 // 0: not visible 301 // 1: visible before cul 302 // 2: visible after cul 286 303 287 304 if (!visible || disk<25) … … 290 307 color = disk>75 ? HTML::kRed : HTML::kYellow; 291 308 292 const string arr = f MoonSet<fMoonRise ?293 f MoonSet.MinutesTo(time)+"↓" :294 f MoonRise.MinutesTo(time)+"↑";309 const string arr = fSet<fRise ? 310 fSet.MinutesTo(time) +"↓" : 311 fRise.MinutesTo(time)+"↑"; 295 312 296 313 ostringstream out; … … 632 649 // Not that this will also "ding" just after program startup 633 650 // if the dimctrl is still in state -3 634 if (d.GetQoS()==-3 && fDimControl.scriptdepth==0) 651 if (fDimControl.last.second!=DimState::kOffline && 652 d.GetQoS()==-3 && fDimControl.scriptdepth==0) 635 653 SetAudio("ding"); 636 654 … … 850 868 fDriveControlMoonDist = -1; 851 869 852 Moon moon(-(17.+53./60+26.525/3600), 28.+45./60+42.462/3600); 853 if (moon.visible) 854 { 855 const double angle = moon.Angle(Ra, Dec); 870 if (fMoon.visible) 871 { 872 const double angle = fMoon.Angle(Ra, Dec); 856 873 out << Moon::Color(angle) << '\t' << setprecision(3) << angle << '\n'; 857 874 … … 1667 1684 fMoon = Moon(lon, lat, now); 1668 1685 1686 vector<string> color(8, HTML::kWhite); 1687 color[fSun.state%8] = HTML::kBlue; 1688 1669 1689 ostringstream out; 1670 1690 out << setprecision(3); 1671 1691 out << now.JavaDate() << '\n'; 1672 out << HTML::kWhite << '\t' << fSun.fSunRiseDarkTime.GetAsStr("%H:%M") << '\n';1673 out << HTML::kWhite << '\t' << fSun.fSunRiseAstronomical.GetAsStr("%H:%M") << '\n';1674 out << HTML::kWhite << '\t' << fSun.fSunRiseCivil.GetAsStr("%H:%M") << '\n';1675 out << HTML::kWhite << '\t' << fSun.fSunRiseDayTime.GetAsStr("%H:%M") << '\n';1676 1677 out << HTML::kWhite << '\t' << fSun.fSunSetDayTime.GetAsStr("%H:%M") << '\n';1678 out << HTML::kWhite << '\t' << fSun.fSunSetCivil.GetAsStr("%H:%M") << '\n';1679 out << HTML::kWhite << '\t' << fSun.fSunSetAstronomical.GetAsStr("%H:%M") << '\n';1680 out << HTML::kWhite << '\t' << fSun.fSunSetDarkTime.GetAsStr("%H:%M") << '\n';1692 out << color[0] << '\t' << fSun.fRiseDarkTime.GetAsStr("%H:%M") << '\n'; 1693 out << color[1] << '\t' << fSun.fRiseAstronomical.GetAsStr("%H:%M") << '\n'; 1694 out << color[2] << '\t' << fSun.fRiseCivil.GetAsStr("%H:%M") << '\n'; 1695 out << color[3] << '\t' << fSun.fRiseDayTime.GetAsStr("%H:%M") << '\n'; 1696 1697 out << color[4] << '\t' << fSun.fSetDayTime.GetAsStr("%H:%M") << '\n'; 1698 out << color[5] << '\t' << fSun.fSetCivil.GetAsStr("%H:%M") << '\n'; 1699 out << color[6] << '\t' << fSun.fSetAstronomical.GetAsStr("%H:%M") << '\n'; 1700 out << color[7] << '\t' << fSun.fSetDarkTime.GetAsStr("%H:%M") << '\n'; 1681 1701 1682 1702 ofstream(fPath+"/sun.data") << out.str(); 1703 1704 color.assign(3, HTML::kWhite); 1705 color[fMoon.state%3] = HTML::kBlue; 1683 1706 1684 1707 out.str(""); 1685 1708 out << now.JavaDate() << '\n'; 1686 1709 1687 out << HTML::kWhite << '\t' << fMoon.fMoonRise.GetAsStr("%H:%M") << '\n';1688 out << HTML::kWhite << '\t' << fMoon.fMoonTransit.GetAsStr("%H:%M") << '\n';1689 out << HTML::kWhite << '\t' << fMoon.fMoonSet.GetAsStr("%H:%M") << '\n';1690 1691 out << (fSun. visible?HTML::kWhite:fMoon.color) << '\t' << fMoon.description << '\n';1710 out << color[0] << '\t' << fMoon.fRise.GetAsStr("%H:%M") << '\n'; 1711 out << color[1] << '\t' << fMoon.fTransit.GetAsStr("%H:%M") << '\n'; 1712 out << color[2] << '\t' << fMoon.fSet.GetAsStr("%H:%M") << '\n'; 1713 1714 out << (fSun.isday?HTML::kWhite:fMoon.color) << '\t' << fMoon.description << '\n'; 1692 1715 1693 1716 if (!fMoon.visible) … … 1695 1718 else 1696 1719 { 1697 string col = HTML::kGreen; 1698 if (fMoon.zd>25) 1699 col = HTML::kYellow; 1700 if (fMoon.zd>45 && fMoon.zd<85) 1701 col = HTML::kRed; 1702 out << col << '\t' << fMoon.zd << '\n'; 1720 string col = HTML::kWhite; 1721 if (!fSun.isday) 1722 { 1723 col = HTML::kGreen; 1724 if (fMoon.zd>25) 1725 col = HTML::kYellow; 1726 if (fMoon.zd>45 && fMoon.zd<80) 1727 col = HTML::kRed; 1728 if (fMoon.zd>=80) 1729 col = HTML::kRed; 1730 } 1731 out << col << '\t' << fMoon.zd << '\t' << GetDir(fMoon.az) << '\n'; 1703 1732 } 1704 1733 … … 2092 2121 out << " ☼"; 2093 2122 if (fDimDriveControl.state()<Drive::State::kArmed) 2094 out << " [" << fSun.fS unSetCivil.MinutesTo() << "↓]";2123 out << " [" << fSun.fSetCivil.MinutesTo() << "↓]"; 2095 2124 } 2096 2125 else
Note:
See TracChangeset
for help on using the changeset viewer.