| | |
| | | /// 0.正常自动化;1.门锁自动化;2.门锁常开.关; |
| | | switch (intvalue) |
| | | { |
| | | case 0: { |
| | | case 0: |
| | | { |
| | | //new一个新逻辑对象; |
| | | //新增正常自动化入口 |
| | | Common.Logic.CurrentLogic = new Common.Logic(); |
| | |
| | | UserView.HomePage.Instance.AddChidren(addLogicPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | addLogicPage.Show(); |
| | | } break; |
| | | case 1: { |
| | | } |
| | | break; |
| | | case 1: |
| | | { |
| | | //进入门锁联动事件入口 |
| | | Send.UserMemberInfoRes = accountObj;
|
| | | Send.CurrentDoorLock = doorLock;
|
| | |
| | | UserView.HomePage.Instance.AddChidren(doorLockLogicList);
|
| | | UserView.HomePage.Instance.PageIndex += 1;
|
| | | doorLockLogicList.Show(); |
| | | } break; |
| | | case 2: { |
| | | } |
| | | break; |
| | | case 2: |
| | | { |
| | | Common.Logic.LogicDviceList.Clear(); |
| | | if (Common.Logic.LogicDviceList.Count == 0) |
| | | { |
| | |
| | | actionsInfo.Add("LinkType", 8); |
| | | actionsInfo.Add("DeviceAddr", doorLock.DeviceAddr); |
| | | actionsInfo.Add("Epoint", doorLock.DeviceEpoint); |
| | | actionsInfo.Add("PassData", "055704010112");//默认门锁常开 |
| | | actionsInfo.Add("PassData", "055704010113");//默认门锁常关 |
| | | |
| | | //new一个新逻辑对象; |
| | | //新增门锁常开模式自动化入口; |
| | |
| | | UserView.HomePage.Instance.AddChidren(oneLogic); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | oneLogic.Show(false); |
| | | } break; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | } |
| | |
| | | /// 加载自动化列表界面 |
| | | /// </summary> |
| | | /// <param name="refresview">Refresview.</param> |
| | | |
| | | static RowLayout selectedRow = new RowLayout() { Tag="0"};//记录左滑状态 |
| | | |
| | | private static async void Automationview(VerticalRefreshLayout refresview, bool no) |
| | | { |
| | | refresview.RemoveAll(); |
| | |
| | | var noIconBtn = new Button |
| | | { |
| | | Y = Application.GetRealHeight(294-55), |
| | | Width = Application.GetMinRealAverage(756), |
| | | Height = Application.GetMinRealAverage(434), |
| | | Width = Application.GetMinRealAverage(757), |
| | | Height = Application.GetMinRealAverage(435), |
| | | UnSelectedImagePath = "Item/NoFunction.png", |
| | | X = Application.GetRealWidth(104), |
| | | }; |
| | |
| | | LineColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, |
| | | SubViewWidth = Application.GetRealWidth(184),//改变编辑控件宽度多少; |
| | | Tag = i.ToString(), |
| | | |
| | | }; |
| | | fLayout.AddChidren(logicRowlayout); |
| | | //左滑菜单事件 |
| | | logicRowlayout.OpenMenuAction += () => |
| | | { |
| | | if (selectedRow.Tag.ToString() != logicRowlayout.Tag.ToString()) |
| | | { //保留左滑只有一个; |
| | | selectedRow.HideMenu();// |
| | | } |
| | | selectedRow = logicRowlayout; |
| | | }; |
| | | if (i == 1) |
| | | { |
| | | //实现android显示逻辑列表的圆角; |
| | | fLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); |
| | | logicRowlayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft); |
| | | i = 2; |
| | | } |
| | | |
| | | } |
| | | i++; |
| | | var logicnameBtn = new Button |
| | | { |
| | | Height = Application.GetRealHeight(58), |
| | |
| | | /// <param name="timeVlaue">时间值</param> |
| | | /// <param name="common">设备</param> |
| | | /// <returns></returns> |
| | | public static void LockAddModifyLogic(int timeVlaue, CommonDevice common) |
| | | public static async System.Threading.Tasks.Task<bool> LockAddModifyLogic(int timeVlaue, CommonDevice common) |
| | | { |
| | | //读取系统当前时间:时-分 |
| | | var h = DateTime.Now.ToString("HH"); |
| | |
| | | currentLogic.Conditions.Add(timeConditionsInfo); |
| | | currentLogic.Actions.Add(actionsInfo); |
| | | Exist(3);//查找是否存在设置过失效时间(有的话删除,再添加) |
| | | Send.AddModifyLogic(currentLogic); |
| | | |
| | | var logicIfon = await Send.AddModifyLogic(currentLogic); |
| | | if (logicIfon != null && logicIfon.LogicId != 0) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | ///<summary> |
| | | /// s-one门锁是否存在自动化的方法(true为存在) |
| | | /// s-one门锁是否存在自动化的方法; |
| | | /// 注意(参数2;3):valueInt=3是删除设置失效时间自动化;valueInt=2判断是否存在自动化; |
| | | /// 返回值:0不存在;1存在;2删除成功;3删除失败; |
| | | /// </summary> |
| | | public static async System.Threading.Tasks.Task<bool> Exist(int valueInt=2) |
| | | public static async System.Threading.Tasks.Task<int> Exist(int valueInt = 2) |
| | | { |
| | | bool exist = false; |
| | | int exist = 0; |
| | | var Idlist = await Send.GetLogicId(valueInt); |
| | | if (Idlist.Count != 0) |
| | | { |
| | | if (valueInt==3) { |
| | | if (valueInt == 3) |
| | | { |
| | | for (int i = 0; i < Idlist.Count; i++) |
| | | { |
| | | //valueInt=3一条特殊的自动化(用来设置失效时间) |
| | | Send.DelLogic(Idlist[i]); |
| | | var d=await Send.DelLogic(Idlist[i]); |
| | | if (d != 0) |
| | | { |
| | | //删除成功 |
| | | exist = 2; |
| | | } |
| | | else |
| | | { |
| | | //删除失败 |
| | | exist = 3; |
| | | } |
| | | return exist; |
| | | |
| | | } |
| | | } |
| | | exist = true; |
| | | exist = 1; |
| | | } |
| | | return exist; |
| | | } |
| | | |
| | | ///<summary> |
| | | /// s-one门锁确认取消(使满足条件所有逻辑失能一次)发送的方法 |
| | | /// </summary> |
| | | public static async void LockCloseLogic(CommonDevice common) |
| | | { |
| | | //读取系统当前时间:时-分 |
| | | int h =int.Parse(DateTime.Now.ToString("HH")); |
| | | int m= int.Parse(DateTime.Now.ToString("mm")); |
| | | //转化为多少分钟; |
| | | int s = h * 60 + m; |
| | | var logicList = new List<Common.Logic>(); |
| | | logicList.Clear(); |
| | | var Idlist = await Send.GetLogicId(2); |
| | | if (Idlist.Count != 0) |
| | | { //先去读取网关看是否存在数据; |
| | | var list = await Send.ReadList(Idlist.Count, 2); |
| | | for (int j = 0; j < list.Count; j++) |
| | | { |
| | | var logic = list[j]; |
| | | foreach (var conditions in logic.Conditions) |
| | | { |
| | | var linkType = conditions["Type"]; |
| | | if (linkType == "5") |
| | | { |
| | | int startMin = int.Parse(conditions["StartMin"]); |
| | | int startHour = int.Parse(conditions["StartHour"]); |
| | | int stopMin = int.Parse(conditions["StopMin"]); |
| | | int stopHour = int.Parse(conditions["StopHour"]); |
| | | int s1 = startMin + startHour * 60;//开始时间值 |
| | | int s2 = stopMin + stopHour * 60;//结束时间值 |
| | | if (s >= s1&&s<=s2) |
| | | { |
| | | //查找系统时间值是否属于这个范围; |
| | | logicList.Add(logic); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | foreach (var logic in logicList) |
| | | { |
| | | logic.IsEnable = 3;//改变逻辑使能状态; |
| | | //用foreach发送命令; |
| | | Send.AddModifyLogic(logic); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |