コード例 #1
0
ファイル: WGAccess.cs プロジェクト: radtek/smartaccess
        public void SetTimeScale(TimeScaleNum tsNum)
        {
            data[0] = (byte)tsNum.Num;
            data[1] = DataHelper.ToByteBCD((int)(tsNum.startDate.Year / 100));
            data[2] = DataHelper.ToByteBCD(tsNum.startDate.Year - ((int)(tsNum.startDate.Year / 100)) * 100);
            data[3] = DataHelper.ToByteBCD(tsNum.startDate.Month);
            data[4] = DataHelper.ToByteBCD(tsNum.startDate.Day);

            data[5] = DataHelper.ToByteBCD((int)(tsNum.endDate.Year / 100));
            data[6] = DataHelper.ToByteBCD(tsNum.endDate.Year - ((int)(tsNum.endDate.Year / 100)) * 100);
            data[7] = DataHelper.ToByteBCD(tsNum.endDate.Month);
            data[8] = DataHelper.ToByteBCD(tsNum.endDate.Day);

            for (int i = 0; i < 7; i++)
            {
                data[9 + i] = tsNum.weekDaysEnable[i] ? (byte)1 : (byte)0;
            }
            //data[15]
            for (int i = 0; i < tsNum.timeScales.Count; i++)
            {
                if (i == 3)
                {
                    break;
                }
                data[16 + i * 4]     = DataHelper.ToByteBCD(tsNum.timeScales[i].start.Hours);
                data[16 + i * 4 + 1] = DataHelper.ToByteBCD(tsNum.timeScales[i].start.Minutes);
                data[16 + i * 4 + 2] = DataHelper.ToByteBCD(tsNum.timeScales[i].end.Hours);
                data[16 + i * 4 + 3] = DataHelper.ToByteBCD(tsNum.timeScales[i].end.Minutes);
            }
            //data[27]
            data[28] = (byte)tsNum.NextNum;
        }
コード例 #2
0
        public static TimeScaleNum ToTimeScale(Maticsoft.Model.SMT_TIMESCALE_INFO tsInfo)
        {
            TimeScaleNum tsNum = new TimeScaleNum();

            tsNum.Num               = tsInfo.TIME_NO;
            tsNum.NextNum           = tsInfo.TIME_NEXT_NO;
            tsNum.startDate         = tsInfo.TIME_DATE_START;
            tsNum.endDate           = tsInfo.TIME_DATE_END;
            tsNum.weekDaysEnable[0] = tsInfo.TIME_WEEK_DAY1;
            tsNum.weekDaysEnable[1] = tsInfo.TIME_WEEK_DAY2;
            tsNum.weekDaysEnable[2] = tsInfo.TIME_WEEK_DAY3;
            tsNum.weekDaysEnable[3] = tsInfo.TIME_WEEK_DAY4;
            tsNum.weekDaysEnable[4] = tsInfo.TIME_WEEK_DAY5;
            tsNum.weekDaysEnable[5] = tsInfo.TIME_WEEK_DAY6;
            tsNum.weekDaysEnable[6] = tsInfo.TIME_WEEK_DAY7;
            tsNum.timeScales.Add(new TimeScale()
            {
                start = tsInfo.TIME_RANGE_START1,
                end   = tsInfo.TIME_RANGE_END1
            });
            tsNum.timeScales.Add(new TimeScale()
            {
                start = tsInfo.TIME_RANGE_START2,
                end   = tsInfo.TIME_RANGE_END2
            });
            tsNum.timeScales.Add(new TimeScale()
            {
                start = tsInfo.TIME_RANGE_START3,
                end   = tsInfo.TIME_RANGE_END3
            });
            return(tsNum);
        }
コード例 #3
0
ファイル: WGAccess.cs プロジェクト: radtek/smartaccess
        public bool SetTimeScales(Controller controller, TimeScaleNum tsNum)
        {
            WGPacket packet = new WGPacket(0x88);

            packet.SetDevSn(controller.sn);
            packet.SetTimeScale(tsNum);
            DoSend(packet, controller.ip, controller.port);
            List <WGPacket> packets = WGRecievePacketAddClose(1);

            if (packets.Count == 1)
            {
                return(packets[0].data[0] == 1);
            }
            return(false);
        }