Changeset 18366 for trunk/FACT++/src
- Timestamp:
- 11/07/15 18:46:37 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r18364 r18366 86 86 Time time; 87 87 88 Time fRiseDayTime; 89 Time fRiseCivil; 90 Time fRiseAstronomical; 91 Time fRiseDarkTime; 92 93 Time fSetDayTime; 94 Time fSetCivil; 95 Time fSetAstronomical; 96 Time fSetDarkTime; 88 // This is always the time of the next... 89 Time fSunRise00; 90 Time fSunRise06; 91 Time fSunRise12; 92 Time fSunRise18; 93 94 Time fSunSet00; 95 Time fSunSet06; 96 Time fSunSet12; 97 Time fSunSet18; 97 98 98 99 int state; … … 103 104 bool visible; 104 105 106 Nova::RstTime Rst(double jd, double hrz=LN_SOLAR_STANDART_HORIZON) 107 { 108 Nova::RstTime rs = Nova::GetSolarRst(jd-0.5, hrz); 109 if (jd>rs.rise || jd>rs.set) 110 { 111 const Nova::RstTime rs2 = Nova::GetSolarRst(jd+0.5, hrz); 112 if (jd>rs.rise) 113 rs.rise = rs2.rise; 114 if (jd>rs.set) 115 rs.set = rs2.set; 116 } 117 return rs; 118 } 119 105 120 public: 106 121 Sun() : time(Time::none) … … 116 131 const double JD = time.JD(); 117 132 118 // Warning: return code of 1 means circumpolar and is not checked! 133 // >0deg : day 134 // -6deg - 0deg : civil twilight 135 // -12deg - -6deg : nautical twilight 136 // -18deg - -12deg : astronomical twilight 137 // <-18deg : night 138 139 const Nova::RstTime sun00 = Rst(JD); 140 const Nova::RstTime sun06 = Rst(JD, -6); 141 const Nova::RstTime sun12 = Rst(JD, -12); 142 const Nova::RstTime sun18 = Rst(JD, -18); 143 144 fSunRise00 = sun00.rise; 145 fSunRise06 = sun06.rise; 146 fSunRise12 = sun12.rise; 147 fSunRise18 = sun18.rise; 148 149 fSunSet00 = sun00.set; 150 fSunSet06 = sun06.set; 151 fSunSet12 = sun12.set; 152 fSunSet18 = sun18.set; 153 154 array<double,8> arr = 155 {{ 156 sun00.set, 157 sun06.set, 158 sun12.set, 159 sun18.set, 160 sun18.rise, 161 sun12.rise, 162 sun06.rise, 163 sun00.rise, 164 }}; 165 166 167 state = std::min_element(arr.begin(), arr.end())-arr.begin(); 168 169 string name[] = 170 { 171 "day time", 172 "civil twilight", 173 "nautical twilight", 174 "astron. twilight", 175 "dark time", 176 "astron. twilight", 177 "nautical twilight", 178 "civil twilight" 179 }; 180 181 description = name[state]; 182 183 const string txt = fSunRise18<fSunSet18 ? 184 time.MinutesTo(fSunRise18)+"↑" : 185 time.MinutesTo(fSunSet18)+"↓"; 186 187 description += " ["+txt+"]"; 188 189 isday = state==0; 190 191 switch (state) 192 { 193 case 0: color = HTML::kRed; break; 194 case 1: case 2: color = HTML::kYellow; break; 195 case 3: case 4: case 5: color = HTML::kGreen; break; 196 case 6: case 7: color = HTML::kYellow; break; 197 } 198 199 visible = state==0; 200 201 /* 202 // Warning: return code of 1 means circumpolar and is not checked! 119 203 Nova::RstTime sun_day = Nova::GetSolarRst(JD-0.5); 120 204 Nova::RstTime sun_civil = Nova::GetSolarRst(JD-0.5, -6); … … 156 240 } 157 241 158 // case 0: midnight to sun-rise | !is_day && !is_night | rise/set 159 // case 1: sun-rise to sun-set | is_day && !is_night | set /rise 160 // case 2: sun-set to midnight | is_day && is_night | rise/set 242 // case 0: midnight to sun-rise | !is_day && !is_night | rise/set | -> isday=0 243 // case 1: sun-rise to sun-set | is_day && !is_night | set /rise | -> isday=1 244 // case 2: sun-set to midnight | is_day && is_night | rise/set | -> isday=0 161 245 162 246 isday = is_day^is_night; 163 247 164 state = isday ? 4 : 0; 165 if (time>fSetDayTime) state++; 166 if (time>fSetCivil) state++; 167 if (time>fSetAstronomical) state++; 168 if (time>fSetDarkTime) state++; 169 170 if (time>fRiseDarkTime) state++; 171 if (time>fRiseAstronomical) state++; 172 if (time>fRiseCivil) state++; 173 if (time>fRiseDayTime) state++; 248 Time fRiseDayTime; // 0: Start of day time (=end of civil twilight) 249 Time fRiseCivil; // -6: End of nautical twilight 250 Time fRiseAstronomical; // -12: End of astron. twilight 251 Time fRiseDarkTime; // -18: End of dark time 252 253 Time fSetDayTime; // 0: End of day time (=start of civil twilight) 254 Time fSetCivil; // -6: Start of nautical twilight 255 Time fSetAstronomical; // -12: Start of astron. twilight 256 Time fSetDarkTime; // -18: Start of dark time 257 258 state = isday ? 4 : 0; // 0 [-> Day time ] 259 if (time>fSetDayTime) state++; // 1 [-> Civil twilight] 260 if (time>fSetCivil) state++; // 2 [-> Naut. twilight] 261 if (time>fSetAstronomical) state++; // 3 [-> Astro. twilight] 262 if (time>fSetDarkTime) state++; // 4 [-> Dark time ] 263 264 if (time>fRiseDarkTime) state++; // 5 [-> Astro. twilight] 265 if (time>fRiseAstronomical) state++; // 6 [-> Naut. twilight] 266 if (time>fRiseCivil) state++; // 7 [-> Civil twilight] 267 if (time>fRiseDayTime) state++; // 8 [-> Day time ] 174 268 175 269 string name[] = 176 270 { 177 "dark time", 178 "astron. twilight", 179 "civil twilight", 180 "sunrise", 181 "day time", 182 "sunset", 183 "civil twilight", 184 "astron. twilight", 185 "dark time" 271 "dark time", // 0 272 "astron. twilight", // 1 273 "civil twilight", // 2 274 "sunrise", // 3 275 "day time", // 4 276 "sunset", // 5 277 "civil twilight", // 6 278 "astron. twilight", // 7 279 "dark time" // 8 186 280 }; 187 281 … … 204 298 205 299 visible = state>=3 && state<=5; 300 */ 206 301 #endif 207 302 } … … 1200 1295 vector<float> Uov(ptr+416+6, ptr+416+6+320); 1201 1296 1202 WriteCam(d, "cam-feedback-overvoltage", Uov, 0.2, 1.0);1297 WriteCam(d, "cam-feedback-overvoltage", Uov, 0.2, -0.1); 1203 1298 1204 1299 const Statistics stat2(Uov); … … 2142 2237 pair<vector<float>, pair<Time, float>> GetVisibility(Nova::EquPosn *src=0) 2143 2238 { 2144 const double sunset = fSun.fS etAstronomical.JD();2145 const double sunrise = fSun.f RiseAstronomical.JD();2239 const double sunset = fSun.fSunSet12.JD()-1; 2240 const double sunrise = fSun.fSunRise12.JD(); 2146 2241 2147 2242 Nova::EquPosn moon; … … 2182 2277 pair<vector<float>, pair<Time, float>> GetLightCondition(const Nova::EquPosn &src_pos) 2183 2278 { 2184 const double sunset = fSun.fS etAstronomical.JD();2185 const double sunrise = fSun.f RiseAstronomical.JD();2279 const double sunset = fSun.fSunSet12.JD()-1; 2280 const double sunrise = fSun.fSunRise12.JD(); 2186 2281 2187 2282 double max = -1; … … 2228 2323 2229 2324 vector<string> color(8, HTML::kWhite); 2230 color[fSun.state %8] = HTML::kBlue;2325 color[fSun.state] = HTML::kBlue; 2231 2326 2232 2327 ostringstream out; 2233 2328 out << setprecision(3); 2234 2329 out << now.JavaDate() << '\n'; 2235 out << color[ 0] << '\t' << fSun.fRiseDarkTime.GetAsStr("%H:%M") << '\n';2236 out << color[ 1] << '\t' << fSun.fRiseAstronomical.GetAsStr("%H:%M") << '\n';2237 out << color[ 2] << '\t' << fSun.fRiseCivil.GetAsStr("%H:%M") << '\n';2238 out << color[ 3] << '\t' << fSun.fRiseDayTime.GetAsStr("%H:%M") << '\n';2239 2240 out << color[ 4] << '\t' << fSun.fSetDayTime.GetAsStr("%H:%M") << '\n';2241 out << color[ 5] << '\t' << fSun.fSetCivil.GetAsStr("%H:%M") << '\n';2242 out << color[ 6] << '\t' << fSun.fSetAstronomical.GetAsStr("%H:%M") << '\n';2243 out << color[ 7] << '\t' << fSun.fSetDarkTime.GetAsStr("%H:%M") << '\n';2330 out << color[4] << '\t' << fSun.fSunRise18.GetAsStr("%H:%M") << '\n'; 2331 out << color[5] << '\t' << fSun.fSunRise12.GetAsStr("%H:%M") << '\n'; 2332 out << color[6] << '\t' << fSun.fSunRise06.GetAsStr("%H:%M") << '\n'; 2333 out << color[7] << '\t' << fSun.fSunRise00.GetAsStr("%H:%M") << '\n'; 2334 2335 out << color[0] << '\t' << fSun.fSunSet00.GetAsStr("%H:%M") << '\n'; 2336 out << color[1] << '\t' << fSun.fSunSet06.GetAsStr("%H:%M") << '\n'; 2337 out << color[2] << '\t' << fSun.fSunSet12.GetAsStr("%H:%M") << '\n'; 2338 out << color[3] << '\t' << fSun.fSunSet18.GetAsStr("%H:%M") << '\n'; 2244 2339 2245 2340 ofstream(fPath+"/sun.data") << out.str(); … … 2424 2519 } 2425 2520 2426 if (fSun.fSetAstronomical>fSun.fRiseAstronomical)2427 fSun.fSetAstronomical += boost::posix_time::hours(24);2521 const Time st = fSun.fSunSet12;; 2522 const Time rs = fSun.fSunRise12; 2428 2523 2429 2524 ostringstream title; 2430 title << fSun.fSetAstronomical.GetAsStr("%H:%M");2525 title << st.GetAsStr("%H:%M"); 2431 2526 title << " / "; 2432 title << (( fSun.fRiseAstronomical-fSun.fSetAstronomical)/20).minutes();2527 title << ((rs>st?rs-st:st-rs)/20).minutes(); 2433 2528 title << "' / "; 2434 title << fSun.fRiseAstronomical.GetAsStr("%H:%M");2529 title << rs.GetAsStr("%H:%M"); 2435 2530 2436 2531 out << '\n'; … … 2787 2882 out << " ☼"; 2788 2883 if (fDimDriveControl.state()<Drive::State::kInitialized) 2789 out << " [" << fSun.fS etCivil.MinutesTo() << "↓]";2884 out << " [" << fSun.fSunSet12.MinutesTo() << "↓]"; 2790 2885 } 2791 2886 else
Note:
See TracChangeset
for help on using the changeset viewer.