예제 #1
0
        public static DeviceInfo ToModel(byte[] deviceData)
        {
            var deviceService = new DeviceInfo();

            deviceService.AntiPassbackEnabled = (deviceData[3] == 1);

            deviceService.Services.Add(DoorOpenBehaviorServiceMapper.BuildUnlockOpenService(deviceData[27]));
            deviceService.Services.Add(DuressServiceMapper.BuildService(deviceData));
            deviceService.Services.Add(MultiPersionLockServiceMapper.BuildService(deviceData));
            deviceService.Services.Add(DoorLinkageServiceMapper.BuildService(deviceData));

            var doors = DoorInfoMapper.BuildService(deviceData);

            doors.ForEach(d => deviceService.Services.Add(d));

            return(deviceService);
        }
예제 #2
0
        public static List <DoorInfo> BuildService(byte[] deviceData)
        {
            var doors = new List <DoorInfo>();

            var masterDoor = new DoorInfo();

            masterDoor.Name      = "门一";
            masterDoor.DoorIndex = 1;
            masterDoor.DoorType  = DoorType.Master;
            //masterDoor.ElectricalAppliances = 0;
            //masterDoor.CheckOutAction = CheckOutOptions.Button;
            //masterDoor.AlertType = 0;
            //masterDoor.Remark = "";

            masterDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildDelayOpenService(deviceData[16]));
            masterDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildOverTimeOpenService(deviceData[18]));
            masterDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildIllegalOpenService(deviceData[19]));
            masterDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildUnlockOpenService(deviceData[27]));
            masterDoor.Services.Add(DuressServiceMapper.BuildService(deviceData));

            doors.Add(masterDoor);

            var slaveDoor = new DoorInfo();

            slaveDoor.Name      = "门二";
            slaveDoor.DoorIndex = 2;
            slaveDoor.DoorType  = DoorType.Slave;
            //slaveDoor.ElectricalAppliances = 0;
            //slaveDoor.CheckOutAction = CheckOutOptions.Button;
            //slaveDoor.AlertType = 0;
            //slaveDoor.Remark = "";

            slaveDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildDelayOpenService(deviceData[20]));
            slaveDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildOverTimeOpenService(deviceData[22]));
            slaveDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildIllegalOpenService(deviceData[23]));
            slaveDoor.Services.Add(DoorOpenBehaviorServiceMapper.BuildUnlockOpenService(deviceData[28]));
            slaveDoor.Services.Add(DuressServiceMapper.BuildService(deviceData));
            doors.Add(slaveDoor);

            return(doors);
        }
예제 #3
0
        public static void UpdateDeviceData(ref byte[] deviceData, DeviceInfo deviceService)
        {
            if (deviceService.AntiPassbackEnabled.HasValue)
            {
                deviceData[3] = (byte)(deviceService.AntiPassbackEnabled.Value ? 1 : 0);
            }

            if (deviceService.Services != null)
            {
                foreach (var s in deviceService.Services)
                {
                    if (s is DuressService)
                    {
                        DuressServiceMapper.UpdateDeviceData(ref deviceData, s as DuressService);
                    }
                    else if (s is MultiPersionLockService)
                    {
                        MultiPersionLockServiceMapper.UpdateDeviceData(ref deviceData, s as MultiPersionLockService);
                    }
                    else if (s is DoorLinkageService)
                    {
                        DoorLinkageServiceMapper.UpdateDeviceData(ref deviceData, s as DoorLinkageService);
                    }
                    else if (s is DoorUnlockOpenBehaviorService)
                    {
                        var timeZoneService = s as DoorUnlockOpenBehaviorService;
                        if (timeZoneService != null)
                        {
                            deviceData[27] = (byte)timeZoneService.TimezoneId;
                        }
                    }
                    else if (s is DoorInfo)
                    {
                        DoorInfoMapper.UpdateDeviceData(ref deviceData, s as DoorInfo);
                    }
                }
            }
        }