/// <summary>
        /// Parse array from string and return range of darkness time of day of 6 months
        /// </summary>
        /// <param name="mass">array of days from string</param>
        /// <param name="day">what a day from string we parse</param>
        /// <param name="firstHalf">if true - first 6 months, if false - second 6 months</param>
        /// <returns></returns>
        public static List <DateTimeWD> GetMonthDaysFromString(string[] mass, int day, bool firstHalf)
        {
            List <DateTimeWD> temp = new List <DateTimeWD>();

            for (int i = 1; i < mass.Length; i++)
            {
                try
                {
                    var darknessTimes = mass[i].Split(';');
                    var endTime       = new TimeShort(darknessTimes[0].Split(':')[0], darknessTimes[0].Split(':')[1]);
                    var beginTime     = new TimeShort(darknessTimes[1].Split(':')[0], darknessTimes[1].Split(':')[1]);

                    var newDay = new DateTimeWD
                    {
                        DateTime        = new System.DateTime(2017, firstHalf ? i : i + 6, day),
                        BeginOfDarkness = beginTime,
                        EndOfDarkness   = endTime
                    };

                    temp.Add(newDay);
                }
                catch { }
            }
            return(temp);
        }
        public List <SensorRecord> GenerateDayData(DateTimeWD day)
        {
            List <SensorRecord> records = new List <SensorRecord>();

            for (int i = 0; i < 24 * 60; i += 5)
            {
                var  currentTime = new TimeSpan(0, i, 0);
                var  ourTime     = new TimeSpan(8, 5, 0);
                bool isLight     = currentTime <new TimeSpan(day.Sunset.Hour, day.Sunset.Minute, 0) && currentTime> new TimeSpan(day.Sunrise.Hour, day.Sunrise.Minute, 0);

                HumanNeedLightGenerator gen = new HumanNeedLightGenerator();
                if (gen.HumanNeedLight(currentTime) && !isLight)
                {
                    records.Add(new SensorRecord
                    {
                        sensor         = lampSwitchSensor,
                        recordDateTime = new DateTime(day.DateTime.Year, day.DateTime.Month, day.DateTime.Day, currentTime.Hours, currentTime.Minutes, currentTime.Seconds),
                        SensorData     = "1"
                    });
                }
                else
                {
                    records.Add(new SensorRecord
                    {
                        sensor         = lampSwitchSensor,
                        recordDateTime = new DateTime(day.DateTime.Year, day.DateTime.Month, day.DateTime.Day, currentTime.Hours, currentTime.Minutes, currentTime.Seconds),
                        SensorData     = "0"
                    });
                }
            }
            return(records);
        }
Пример #3
0
 public int GetLuxValue(DateTimeWD dateTimeWD)
 {
 }