public bool AddOrModifyAuthority(Controller controller, string hexCardNum, DateTime startTime, DateTime endTime, Dictionary <int, int> doorNumAuthorities, int password = 0) { WGPacket packet = new WGPacket(0x50); packet.SetDevSn(controller.sn); // hexCardNum = DataHelper.ToWGAccessCardNo(hexCardNum); packet.SetCardNum(hexCardNum); packet.SetAuthoriTimeTime(startTime, endTime); if (controller.doorType == ControllerDoorType.Elevator) { packet.SetAuthoriElevator(doorNumAuthorities); } else { packet.SetAuthoriDoors(doorNumAuthorities); } packet.SetAuthoriPassword(password); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }
public bool AddTimeTask(Controller controller, TimeTask task) { try { WGPacket packet = new WGPacket(0xA8); packet.SetDevSn(controller.sn); packet.SetTimeTask(task); bool ret = true; foreach (var item in task.doorIndexs) { if (item < 1 || item > 4) { continue; } packet.SetTimeTaskDoorIndex(item); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacket(1); if (packets.Count == 1) { ret = ret && (packets[0].data[0] == 1); } } return(ret); } finally { this.Close(); } }
public bool SetSuperPwds(Controller controller, int doorIndex, List <string> pwds) { WGPacket packet = new WGPacket(0x8C); packet.SetDevSn(controller.sn); packet.SetDoorNum(doorIndex); try { packet.SetSuperPwds(pwds); } catch (Exception ex) { log.Error("密码转换发生异常:", ex); return(false); } DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }
public long GetControllerReadedIndex(Controller controller) { WGPacket packet = new WGPacket(0xB4); packet.SetDevSn(controller.sn); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].GetRecordIndex()); } return(-1); }
public DateTime GetControllerTime(Controller controller) { WGPacket packet = new WGPacket(0x32); packet.SetDevSn(controller.sn); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].ToDateTime()); } return(DateTime.Now); }
public ControllerState GetControllerState(Controller controller) { WGPacket packet = new WGPacket(0x20); packet.SetDevSn(controller.sn); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].ToControllerState()); } return(null); }
public bool OpenRemoteControllerDoor(Controller controller, int doorNum) { WGPacket packet = new WGPacket(0x40); packet.SetDevSn(controller.sn); packet.SetDoorNum(doorNum); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }
public ControllerState GetControllerRecord(Controller controller, long recordIndex) { WGPacket packet = new WGPacket(0xB0); packet.SetDevSn(controller.sn); packet.SetRecordIndex(recordIndex); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].ToControllerState(true)); } return(null); }
public bool SetRecordButtonRecords(Controller controller, bool record) { WGPacket packet = new WGPacket(0x8E); packet.SetDevSn(controller.sn); packet.data[0] = record ? (byte)1 : (byte)0; DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }
public bool ClearTimeTask(Controller controller) { WGPacket packet = new WGPacket(0xA6); packet.SetDevSn(controller.sn); packet.SetClearTag(); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }
public bool SetAlarmConnectPortSetting(Controller controller, AlarmConnectPortSetting setting) { WGPacket packet = new WGPacket(0xC6); packet.SetDevSn(controller.sn); packet.SetAlarmConnectPortSetting(setting); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }
public bool SetHoliday(Controller controller, HolidayPrm holiday) { WGPacket packet = new WGPacket(0xCC); packet.SetDevSn(controller.sn); packet.SetHoliday(holiday); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }
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); }
public bool GetReceiveServer(Controller controller, ref string ip, ref int port) { WGPacket packet = new WGPacket(0x92); packet.SetDevSn(controller.sn); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].GetReceiveServer(ref ip, ref port)); } return(false); }
public bool SetDoorControlStyle(Controller controller, int doorNum, DoorControlStyle ctrlStyle, int delaySecond = 3) { WGPacket packet = new WGPacket(0x80); packet.SetDevSn(controller.sn); packet.SetDoorNum(doorNum); packet.SetCtrlStyle(ctrlStyle, delaySecond); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] > 0); } return(false); }
public bool SetControllerReadedIndex(Controller controller, long recordIndex) { WGPacket packet = new WGPacket(0xB2); packet.SetDevSn(controller.sn); packet.SetRecordIndex(recordIndex); packet.SetReadedIndexTag(); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }
public bool DeleteAuthority(Controller controller, string hexCardNum) { WGPacket packet = new WGPacket(0x52); packet.SetDevSn(controller.sn); //hexCardNum = DataHelper.ToWGAccessCardNo(hexCardNum); packet.SetCardNum(hexCardNum); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }
public bool SetControllerTime(Controller controller, DateTime dateTime) { WGPacket packet = new WGPacket(0x30); packet.SetDevSn(controller.sn); packet.SetDateTime(dateTime); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { DateTime dt = packets[0].ToDateTime(); return(dt.Year == dateTime.Year && dt.Month == dateTime.Month && dt.Day == dateTime.Day && dt.Hour == dateTime.Hour && dt.Minute == dateTime.Minute && dt.Second == dateTime.Second); } return(false); }
public bool SetReceiveServer(Controller controller, string ip, int port) { WGPacket packet = new WGPacket(0x90); packet.SetDevSn(controller.sn); var bts = DataHelper.GetIPBytes(ip); if (bts == null) { return(false); } packet.SetRecieverIPAndPort(bts, port); DoSend(packet, controller.ip, controller.port); List <WGPacket> packets = WGRecievePacketAddClose(1); if (packets.Count == 1) { return(packets[0].data[0] == 1); } return(false); }