| | |
| | | } |
| | | break; |
| | | case DeviceType.TemperatureSensor: |
| | | // conditionIcon.UnSelectedImagePath = "ZigeeLogic/temperature.png"; |
| | | // conditionIcon.UnSelectedImagePath = "ZigeeLogic/temperature.png"; |
| | | var dev = deviceinof as TemperatureSensor; |
| | | if (conditions["Cluster_ID"]=="1026") { |
| | | if (conditions["Cluster_ID"] == "1026") |
| | | { |
| | | dev.SensorDiv = 1; |
| | | } else { |
| | | } |
| | | else |
| | | { |
| | | dev.SensorDiv = 2; |
| | | } |
| | | string s = ""; |
| | | switch (conditions["Range"]) |
| | | { |
| | | case "0": |
| | | { |
| | | s = ">"; |
| | | } |
| | | break; |
| | | case "1": |
| | | { |
| | | s = "="; |
| | | } |
| | | break; |
| | | case "2": |
| | | { |
| | | s = "<"; |
| | | } |
| | | break; |
| | | case "6": |
| | | { |
| | | s = "≥"; |
| | | } |
| | | break; |
| | | case "7": |
| | | { |
| | | s = "≤"; |
| | | } |
| | | break; |
| | | } |
| | | if (conditions["Cluster_ID"] == "1026") |
| | | { |
| | | conditionIcon.UnSelectedImagePath = "ZigeeLogic/temperature.png"; |
| | | devicestatus.Text = ">" + conditions["AttriButeData1"] + "℃"; |
| | | devicestatus.Text = s + conditions["AttriButeData1"] + "℃"; |
| | | } |
| | | else |
| | | { |
| | | conditionIcon.UnSelectedImagePath = "ZigeeLogic/humidity.png"; |
| | | devicestatus.Text = "<" + conditions["AttriButeData1"] + "%"; |
| | | devicestatus.Text = s + conditions["AttriButeData1"] + "%"; |
| | | } |
| | | break; |
| | | |
| | |
| | | } |
| | | |
| | | Common.Logic.CurrentLogic.LogicName = name; |
| | | |
| | | bool succeed = false; |
| | | //判断是新添加逻辑(默认0)还是修改逻辑 |
| | | CommonPage.Loading.Start(); |
| | | if (Common.Logic.CurrentLogic.LogicId == 0) |
| | |
| | | var logicifon = await Send.AddModifyLogic(Common.Logic.CurrentLogic); |
| | | if (logicifon != null && logicifon.LogicId != 0) |
| | | { |
| | | succeed = true; |
| | | Common.Logic.CurrentLogic.LogicId = logicifon.LogicId; |
| | | Common.Logic.LogicList.Add(Common.Logic.CurrentLogic); |
| | | } |
| | |
| | | else |
| | | { |
| | | //发送修改逻辑命令 |
| | | Send.AddModifyLogic(Common.Logic.CurrentLogic); |
| | | var modlogic=Send.AddModifyLogic(Common.Logic.CurrentLogic); |
| | | //编辑默认成功(不考虑网络情况); |
| | | succeed = true; |
| | | } |
| | | |
| | | CommonPage.Loading.Hide(); |
| | | |
| | | if (!succeed)//succeed标记是添加成功还是失败 |
| | | { |
| | | //网关回复失败,不关闭界面,让它停留当前界面; |
| | | //(原因:考虑到失败重新编辑原来数据给用户带来了麻烦) |
| | | ///提示:添加自动化失败; |
| | | //TipView("添加自动化失败"); |
| | | //return; |
| | | } |
| | | UserView.HomePage.Instance.RemoveViewByTag("Logic"); |
| | | Category.Category.instance?.RefreshBodyView(); |
| | | |
| | |
| | | }; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 闪现提示框的方法 |
| | | /// </summary> |
| | | /// <param name="tipText">提示内容</param> |
| | | /// <param name="second">停留时间单位为s</param> |
| | | public void TipView(string tipText, int second = 1) |
| | | { |
| | | |
| | | var frameLayout = new FrameLayout { BackgroundColor = 0x50000000 }; |
| | | this.AddChidren(frameLayout); |
| | | |
| | | var btn = new Button |
| | | { |
| | | Gravity = Gravity.Center, |
| | | Text = tipText, |
| | | BackgroundColor = 0xff1f1f1f, |
| | | Width = Application.GetRealWidth(500), |
| | | Height = Application.GetRealHeight(100), |
| | | Radius = (uint)Application.GetRealHeight(50), |
| | | }; |
| | | frameLayout.AddChidren(btn); |
| | | |
| | | var dateTime1 = DateTime.Now; |
| | | new System.Threading.Thread(() => |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | while (true) |
| | | { |
| | | if ((DateTime.Now - dateTime1).TotalMilliseconds > second * 1000) |
| | | { |
| | | //默认一秒关闭 |
| | | frameLayout.RemoveFromParent(); |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | } |
| | | } |
| | | } |