| | |
| | | timeConditionsInfo.Add("DelayTime", "0"); |
| | | timeConditionsInfo.Add("StartHour", h); |
| | | timeConditionsInfo.Add("StartMin", m); |
| | | timeConditionsInfo.Add("DoorLockOpenDelayTime", timeVlaue.ToString()); |
| | | timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue*60*60).ToString()); |
| | | //timeConditionsInfo.Add("DoorLockOpenDelayTime", (timeVlaue * 3600).ToString()); |
| | | Dictionary<string, object> actionsInfo = new Dictionary<string, object>(); |
| | | actionsInfo.Add("LinkType", 8); |
| | | actionsInfo.Add("DeviceAddr", common.DeviceAddr); |
| | | actionsInfo.Add("Epoint", common.DeviceEpoint); |
| | | actionsInfo.Add("Epoint", "200"); |
| | | actionsInfo.Add("PassData", "055704010113");//默认门锁常关 |
| | | |
| | | Dictionary<string, string> accounts = new Dictionary<string, string>(); |
| | | accounts.Add("Type", "8"); |
| | | accounts.Add("Option4", common.DeviceAddr.ToString());//用于判断识别是哪个门锁; |
| | | accounts.Add("Option2", common.DeviceEpoint.ToString()); |
| | | |
| | | Common.Logic currentLogic = new Common.Logic(); |
| | | currentLogic.IsEnable = 1;//默认为开 |
| | |
| | | currentLogic.LogicName = Language.StringByID(R.MyInternationalizationString.openmode); |
| | | currentLogic.Conditions.Add(timeConditionsInfo); |
| | | currentLogic.Actions.Add(actionsInfo); |
| | | currentLogic.Accounts.Add(accounts); |
| | | var logicIfon = await Send.AddModifyLogic(currentLogic); |
| | | if (logicIfon != null && logicIfon.LogicId != 0) |
| | | { |
| | |
| | | /// 注意(参数:2-常开自动化;3-失效时间自动化); |
| | | /// 返回值:0不存在;其它值都存在; |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<int> Exist(int valueInt) |
| | | public static async System.Threading.Tasks.Task<int> Exist(int valueInt, ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | int exist = 0; |
| | | var Idlist = await Send.GetLogicId(valueInt); |
| | | if (Idlist.Count != 0) |
| | | { |
| | | //默认取第一个逻辑ID |
| | | exist = Idlist[0]; |
| | | |
| | | var id = Idlist[0]; |
| | | if (valueInt != 3) |
| | | { |
| | | exist = id; |
| | | } |
| | | else |
| | | { |
| | | var logic = await Send.GetLogic(id, 3); |
| | | if (logic != null) |
| | | { |
| | | if (ExistLogic(logic, doorLock)) |
| | | { |
| | | exist = id; |
| | | } |
| | | else |
| | | { |
| | | exist = 0; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return exist; |
| | | } |
| | | |
| | | ///<summary> |
| | | ///获取逻辑信息 |
| | | ///获取门锁逻辑信息 |
| | | /// 返回值:null不存在;其它值都存在; |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<Common.Logic> GetLogicIfon() |
| | | public static async System.Threading.Tasks.Task<Common.Logic> GetLogicIfon(ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | Common.Logic logic = null; |
| | | var Idlist = await Send.GetLogicId(3); |
| | |
| | | //默认取第一个逻辑ID(时效性只有一条逻辑) |
| | | int exist = Idlist[0]; |
| | | logic = await Send.GetLogic(exist, 3); |
| | | if (!ExistLogic(logic, doorLock)) |
| | | { |
| | | logic = null; |
| | | } |
| | | } |
| | | return logic; |
| | | } |
| | | |
| | | ///<summary> |
| | | ///删除所有时效性自动化 |
| | | ///删除该门锁所有时效性自动化 |
| | | /// 返回值:true成功;false失败; |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<bool> GetLogicAll() |
| | | public static async System.Threading.Tasks.Task<bool> GetLogicAll(ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | bool _if = false; |
| | | var Idlist = await Send.GetLogicId(3); |
| | |
| | | for (int i = 0; i < Idlist.Count; i++) |
| | | { |
| | | int id = Idlist[i]; |
| | | var logic = await Send.GetLogic(id, 3); |
| | | if (logic != null) |
| | | { |
| | | if (ExistLogic(logic, doorLock)) |
| | | { |
| | | //本来只有一条时效性自动化, |
| | | //防止特殊情况,找到就删除掉; |
| | | Send.DelLogic(id); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return _if; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查找这一条自动化是否属于该门锁 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static bool ExistLogic(Common.Logic logic, ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | for (int j = 0; j < logic.Accounts.Count; j++) |
| | | { |
| | | //Option4是设备mac;Option2是设备端口; |
| | | if (logic.Accounts[j]["Option4"].ToString() == doorLock.DeviceAddr) |
| | | { |
| | | //查找是否是那个门锁; |
| | | //如果不是该门锁联动事件不显示出来; |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | } |