Ejemplo n.º 1
0
        public void ReadXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("Sunrise", false, out subEle))
            {
                Sunrise.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("Day", false, out subEle))
            {
                Day.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("Sunset", false, out subEle))
            {
                Sunset.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("Night", false, out subEle))
            {
                Night.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("HighNoon", false, out subEle))
            {
                HighNoon.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("Midnight", false, out subEle))
            {
                Midnight.ReadXML(subEle, master);
            }
        }
Ejemplo n.º 2
0
 public void WriteBinary(ESPWriter writer)
 {
     Sunrise.WriteBinary(writer);
     Day.WriteBinary(writer);
     Sunset.WriteBinary(writer);
     Night.WriteBinary(writer);
     HighNoon.WriteBinary(writer);
     Midnight.WriteBinary(writer);
 }
Ejemplo n.º 3
0
        public string GetSunriseSunset()
        {
            if (NextSunAction() == "sunset")
            {
                return(Sunset.UnixTimeStampToDateTime().ToString("h:mm tt"));
            }

            return(Sunrise.UnixTimeStampToDateTime().ToString("h:mm tt"));
        }
Ejemplo n.º 4
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendLine($"City: {City}");
            sb.AppendLine($"Country: {Country}");
            sb.AppendLine($"Temperature: {Temperature}");
            sb.AppendLine($"Sunrise: {Sunrise.ToLongDateString()} {Sunrise.ToLongTimeString()}");
            sb.AppendLine($"Sunset: {Sunset.ToLongDateString()} {Sunset.ToLongTimeString()}");
            return(sb.ToString());
        }
Ejemplo n.º 5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Temperature != null ? Temperature.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Wind != null ? Wind.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Humidity != null ? Humidity.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Visibility != null ? Visibility.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Sunrise != null ? Sunrise.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Sunset != null ? Sunset.GetHashCode() : 0);
         return(hashCode);
     }
 }
Ejemplo n.º 6
0
        public override string ToString()
        {
            //string match = (doTimeZonesMatch) ?
            //	String.Format("Time zone from ZipCode & Actigraph DO NOT MATCH";
            string info = String.Format("<b>{1} {2}</b> {3}{0}<b>Sunset: {4}{0}Sunrise: {5}</b>{0}TimeZone used (from Actigraph):{6}{0}TimeZone of ZipCode:{7}{0}"
                                        , "<br/>"
                                        , Sunrise.ToShortDateString()
                                        , Place
                                        , String.Format("{0} [derived from {1}]", Zip, ZipDerivedFrom)
                                        , Sunset.ToShortTimeString(), Sunrise.ToShortTimeString()
                                        , TimeZoneActigraph.DisplayName
                                        , String.Format("{0} {1}", TimeZoneApiResultZip.zoneName, TimeZoneApiResultZip.abbreviation));

            return(info);
        }
Ejemplo n.º 7
0
 public void ReadBinary(ESPReader reader)
 {
     try
     {
         Sunrise.ReadBinary(reader);
         Day.ReadBinary(reader);
         Sunset.ReadBinary(reader);
         Night.ReadBinary(reader);
         HighNoon.ReadBinary(reader);
         Midnight.ReadBinary(reader);
     }
     catch
     {
         return;
     }
 }
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendLine($"City: {City}");
            sb.AppendLine($"Coordinates: {Coordinates}");
            sb.AppendLine($"Country: {Country}");
            sb.AppendLine($"Temperature: {Temperature}");
            sb.AppendLine($"Humidity: {Humidity}");
            sb.AppendLine($"Pressure: {Pressure}");
            sb.AppendLine($"Wind: {Wind}");
            sb.AppendLine($"Cloud: {Cloud}");
            sb.AppendLine($"Visibility: {Visibility}");
            sb.AppendLine($"Sunrise: {Sunrise.ToLongDateString()} {Sunrise.ToLongTimeString()}");
            sb.AppendLine($"Sunset: {Sunset.ToLongDateString()} {Sunset.ToLongTimeString()}");
            return(sb.ToString());
        }
Ejemplo n.º 9
0
        public void WriteXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Sunrise", true, out subEle);
            Sunrise.WriteXML(subEle, master);

            ele.TryPathTo("Day", true, out subEle);
            Day.WriteXML(subEle, master);

            ele.TryPathTo("Sunset", true, out subEle);
            Sunset.WriteXML(subEle, master);

            ele.TryPathTo("Night", true, out subEle);
            Night.WriteXML(subEle, master);

            ele.TryPathTo("HighNoon", true, out subEle);
            HighNoon.WriteXML(subEle, master);

            ele.TryPathTo("Midnight", true, out subEle);
            Midnight.WriteXML(subEle, master);
        }
Ejemplo n.º 10
0
 public override int GetHashCode()
 {
     return(Sunrise.GetHashCode());
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Returns the sunrise/sunset times at the given location on the specified day
        /// </summary>
        /// <param name="dt">The requested date/time, utc.  Day/night will be computed based on the time</param>
        private void ComputeTimesAtLocation(DateTime dt)
        {
            if (Latitude > 90 || Latitude < -90)
            {
                throw new MyFlightbookException(Resources.Airports.errInvalidLatitude);
            }
            if (Longitude > 180 || Longitude < -180)
            {
                throw new MyFlightbookException(Resources.Airports.errInvalidLongitude);
            }

            double JD = Solar.calcJD(dt.Year, dt.Month, dt.Day);

            DateTime dtUTC = dt.ToUniversalTime();

            SolarAngle      = Solar.calcSolarAngle(Latitude, Longitude, JD, dtUTC.Hour * 60 + dtUTC.Minute);
            IsFAACivilNight = SolarAngle <= -6.0;

            Boolean nosunrise   = false;
            double  riseTimeGMT = Solar.calcSunriseUTC(JD, Latitude, -Longitude);

            if (double.IsNaN(riseTimeGMT))
            {
                nosunrise = true;
            }

            // Calculate sunset for this date
            // if no sunset is found, set flag nosunset
            Boolean nosunset   = false;
            double  setTimeGMT = Solar.calcSunsetUTC(JD, Latitude, -Longitude);

            if (double.IsNaN(setTimeGMT))
            {
                nosunset = true;
            }

            // we now know the UTC # of minutes for each. Return the UTC sunrise/sunset times
            if (!nosunrise)
            {
                Sunrise = MinutesToDateTime(dt, riseTimeGMT);
            }

            if (!nosunset)
            {
                Sunset = MinutesToDateTime(dt, setTimeGMT);
            }

            // Update daytime/nighttime
            // 3 possible scenarios:
            // (a) time is between sunrise/sunset as computed - it's daytime or FAA daytime.
            // (b) time is after the sunset - figure out the next sunrise and compare to that
            // (c) time is before sunrise - figure out the previous sunset and compare to that
            IsNight             = IsFAACivilNight;
            IsFAANight          = false;
            IsWithinNightOffset = false;
            if (Sunrise.CompareTo(dt) <= 0 && Sunset.CompareTo(dt) >= 0)
            {
                // between sunrise and sunset - it's daytime no matter how you slice it; use default values (set above)
            }
            else if (Sunset.CompareTo(dt) < 0)
            {
                // get the next sunrise.  It is night if the time is between sunset and the next sunrise
                DateTime dtTomorrow = dt.AddDays(1);
                JD = Solar.calcJD(dtTomorrow.Year, dtTomorrow.Month, dtTomorrow.Day);
                double nextSunrise = Solar.calcSunriseUTC(JD, Latitude, -Longitude);
                if (!double.IsNaN(nextSunrise))
                {
                    DateTime dtNextSunrise = MinutesToDateTime(dtTomorrow, nextSunrise);
                    IsNight             = (dtNextSunrise.CompareTo(dt) > 0); // we've already determined that we're after sunset, we just need to be before sunrise
                    IsFAANight          = (Sunset.AddMinutes(NightLandingOffset).CompareTo(dt) <= 0 && dtNextSunrise.AddMinutes(-NightLandingOffset).CompareTo(dt) >= 0);
                    IsWithinNightOffset = (Sunset.AddMinutes(NightFlightOffset).CompareTo(dt) <= 0 && dtNextSunrise.AddMinutes(-NightFlightOffset).CompareTo(dt) >= 0);
                }
            }
            else if (Sunrise.CompareTo(dt) > 0)
            {
                // get the previous sunset.  It is night if the time is between that sunset and the sunrise
                DateTime dtYesterday = dt.AddDays(-1);
                JD = Solar.calcJD(dtYesterday.Year, dtYesterday.Month, dtYesterday.Day);
                double prevSunset = Solar.calcSunsetUTC(JD, Latitude, -Longitude);
                if (!double.IsNaN(prevSunset))
                {
                    DateTime dtPrevSunset = MinutesToDateTime(dtYesterday, prevSunset);
                    IsNight             = (dtPrevSunset.CompareTo(dt) < 0); // we've already determined that we're before sunrise, we just need to be after sunset.
                    IsFAANight          = (dtPrevSunset.AddMinutes(NightLandingOffset).CompareTo(dt) <= 0 && Sunrise.AddMinutes(-NightLandingOffset).CompareTo(dt) >= 0);
                    IsWithinNightOffset = (dtPrevSunset.AddMinutes(NightFlightOffset).CompareTo(dt) <= 0 && Sunrise.AddMinutes(-NightFlightOffset).CompareTo(dt) >= 0);
                }
            }
        }
Ejemplo n.º 12
0
        public string NextSunAction()
        {
            var now = DateTime.Now;

            return(now >= Sunrise.UnixTimeStampToDateTime() && now < Sunset.UnixTimeStampToDateTime() ? "sunset" : "sunrise");
        }
Ejemplo n.º 13
0
 public override void InitializeModel()
 {
     Sunrise     = Sunrise.ConvertUnixTime();
     Sunset      = Sunset.ConvertUnixTime();
     Temperature = ConvertTemperature(TemperatureUom.Celsius);
 }
Ejemplo n.º 14
0
 public override void ConvertValues()
 {
     Sunrise     = Sunrise.ConvertUnixTime();
     Sunset      = Sunset.ConvertUnixTime();
     Temperature = ConvertTemperature(TemperatureUom.Celsius);
 }