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(); } }