Ejemplo n.º 1
0
        protected byte[] CreateIntervalOffMinuteCommand(DayTr day)
        {
            var result = new List<byte>
                             {
                                 2, // command start
                                 (byte)((int)VariableId.IntervalOffMinuteMonday + (int)day), // variable id 141 is monday, 147 is sunday
                                 6, // the # of bytes between the length bit (this bit) and the checksum
                                 (byte)this.DailyProgramList[(int)day].PeriodList[0].StopMinute.Value, // period 1 interval off minute
                                 (byte)this.DailyProgramList[(int)day].PeriodList[1].StopMinute.Value, // period 2 interval off minute
                                 (byte)this.DailyProgramList[(int)day].PeriodList[2].StopMinute.Value, // period 3 interval off minute 
                                 (byte)this.DailyProgramList[(int)day].PeriodList[3].StopMinute.Value, // period 4 interval off minute 
                                 (byte)this.DailyProgramList[(int)day].PeriodList[4].StopMinute.Value, // period 5 interval off minute 
                                 (byte)this.DailyProgramList[(int)day].PeriodList[5].StopMinute.Value  // period 6 interval off minute 
                             };

            var checksum = result.Skip(1).Sum(x => x) % 256;

            result.Add((byte)checksum);
            result.Add(3); // Command stop

            return result.ToArray();
        }
Ejemplo n.º 2
0
        protected ValidationResult ParseDateTime(byte[] value)
        {
            var result = new ValidationResult { Result = true, ValidationError = null };

            var day = value[0];
            var month = value[1];
            var year = value[2];
            var dayOfWeek = value[3];
            var hour = value[4];
            var minute = value[5];

            if (day < 1 || day > 31)
            {
                result.Result = false;
                result.ValidationError = "Gün 1 - 31 aralığında değil";
            }
            else if (month < 1 || month > 12)
            {
                result.Result = false;
                result.ValidationError = "Ay 1 - 12 aralığında değil";
            }
            else if (year < 15 || year > 99)
            {
                result.Result = false;
                result.ValidationError = "Yıl 15 - 99 aralığında değil";
            }
            else if (dayOfWeek < 0 || dayOfWeek > 6)
            {
                result.Result = false;
                result.ValidationError = "Haftanın günü 0 - 6 aralığında değil";
            }
            else if (hour < 0 || hour > 23)
            {
                result.Result = false;
                result.ValidationError = "Saat 0 - 23 aralığında değil";
            }
            else if (minute < 0 || minute > 59)
            {
                result.Result = false;
                result.ValidationError = "Dakika 0 - 59 aralığında değil";
            }
            else
            {
                this.DeviceTime = new DateTime(2000 + year, month, day, hour, minute, 0);
                this.DeviceDay = (DayTr)dayOfWeek;
            }

            return result;
        }