ZigbeeApp/GateWay.Droid/Assets/Language.ini
@@ -237,13 +237,11 @@ 231=接近感应 232=接近感应功能设置置失败 233=获取接近感应功能失败 235=按住面板模式(Mode)和风速(Fan)按键{0}绿色指示灯亮起。则配网成功 ;三按键面板入网操作指示 235=按住面板模式按键5秒,绿色指示灯闪烁{0}进入配网状态;闪烁停止{0}指示灯变白色表示配网成功 236=绿色指示灯闪烁 237=指示灯 238=长按5秒(按键) 239=长按图示按键5秒以上,指示灯变绿、闪烁{0}进入配网状态。绿灯熄灭则配网成功 ;三按键面板入网操作指示 241=设置常开模式后,您的门锁将始终{0}处于打开状态,确认开启? 242=电量 243=常开模式已开启 @@ -316,6 +314,7 @@ 311=手动 312= 背光灯颜色 313=长按图示按键5秒以上,信号图标{0}快闪, 进入配网状态。信号图标常亮则配网成功 314=自动模式不支持操作 5097=取消 5098=确定 @@ -590,6 +589,12 @@ 5397=时间为空 5398=只支持数字输入 5399=关闭失败 5400=开启失败 5401=添加失败 5402=时效性常开设置 5403=时关闭 10000=HDL Home 10001=常用 @@ -671,7 +676,7 @@ 11001=场景 11002=自动化 11010=没有功能 {\r\n} 请在个人中心--设备管理处添加 11010=没有功能{0}请在个人中心--设备管理处添加 11011=编辑 11012=功能设置 11013=信息编辑 @@ -685,7 +690,7 @@ 11021=保存 11022=提醒 11023=取消 11024=没有场景 {\r\n} 请点击右上角添加 11024=没有场景{0}请点击右上角添加 11025=设置 11026=延时 11027=确定删除吗? @@ -1914,11 +1919,11 @@ ;温湿度传感器入网操作指示 21017=长按图示按键5秒以上,信号图标{0}快闪, 进入配网状态。图标常亮则配网成功 ;方悦2按键轻触式面板入网操作指示 21018=按住面板左上角按键,所有按键指示灯{0}亮起,则配网成功 21018=长按BUTTON1按键5秒,所有指示灯{0}变为绿色并闪烁,进入配网状态 ;方悦4按键轻触式面板入网操作指示 21019=按住面板左上角按键,所有按键指示灯{0}亮起,则配网成功 21019=长按BUTTON1按键5秒,所有指示灯{0}变为绿色并闪烁,进入配网状态 ;方悦8按键轻触式面板入网操作指示 21020=按住面板左上角按键,所有按键指示灯{0}亮起,则配网成功 21020=长按BUTTON1按键5秒,所有指示灯{0}变为绿色并闪烁,进入配网状态 ;方悦环境面板入网操作指示 21021=按住面板功能(function)按键,所有按键{0}指示灯亮起,则配网成功 ;窗帘面板的入网操作指示 @@ -1967,6 +1972,7 @@ 30037=S-one 30038=方悦新风小模块 30039=Zigbee吸顶燃气传感器 30040=PM2.5空气质量传感器 ;★★★★下面这些是设备所属种类的翻译名字,从40000开始★★★★ 40000=遮阳 @@ -2030,6 +2036,7 @@ 50037=Zigbee智能门锁 50038=新风控制小模块 50039=Zigbee吸顶燃气传感器 50040=PM2.5空气质量传感器 ;★★★★下面这些是模块ID的设备类型名字,从60000开始.注:它并不需要再R.cs文件中定义★★★★ 60000=传感器 ZigbeeApp/Home.Ios/Resources/Language.ini
@@ -237,13 +237,11 @@ 231=接近感应 232=接近感应功能设置置失败 233=获取接近感应功能失败 235=按住面板模式(Mode)和风速(Fan)按键{0}绿色指示灯亮起。则配网成功 ;三按键面板入网操作指示 235=按住面板模式按键5秒,绿色指示灯闪烁{0}进入配网状态;闪烁停止{0}指示灯变白色表示配网成功 236=绿色指示灯闪烁 237=指示灯 238=长按5秒(按键) 239=长按图示按键5秒以上,指示灯变绿、闪烁{0}进入配网状态。绿灯熄灭则配网成功 ;三按键面板入网操作指示 241=设置常开模式后,您的门锁将始终{0}处于打开状态,确认开启? 242=电量 243=常开模式已开启 @@ -316,6 +314,7 @@ 311=手动 312= 背光灯颜色 313=长按图示按键5秒以上,信号图标{0}快闪, 进入配网状态。信号图标常亮则配网成功 314=自动模式不支持操作 5097=取消 5098=确定 @@ -590,6 +589,12 @@ 5397=时间为空 5398=只支持数字输入 5399=关闭失败 5400=开启失败 5401=添加失败 5402=时效性常开设置 5403=时关闭 10000=HDL Home 10001=常用 @@ -671,7 +676,7 @@ 11001=场景 11002=自动化 11010=没有功能 {\r\n} 请在个人中心--设备管理处添加 11010=没有功能{0}请在个人中心--设备管理处添加 11011=编辑 11012=功能设置 11013=信息编辑 @@ -685,7 +690,7 @@ 11021=保存 11022=提醒 11023=取消 11024=没有场景 {\r\n} 请点击右上角添加 11024=没有场景{0}请点击右上角添加 11025=设置 11026=延时 11027=确定删除吗? @@ -1914,11 +1919,11 @@ ;温湿度传感器入网操作指示 21017=长按图示按键5秒以上,信号图标{0}快闪, 进入配网状态。图标常亮则配网成功 ;方悦2按键轻触式面板入网操作指示 21018=按住面板左上角按键,所有按键指示灯{0}亮起,则配网成功 21018=长按BUTTON1按键5秒,所有指示灯{0}变为绿色并闪烁,进入配网状态 ;方悦4按键轻触式面板入网操作指示 21019=按住面板左上角按键,所有按键指示灯{0}亮起,则配网成功 21019=长按BUTTON1按键5秒,所有指示灯{0}变为绿色并闪烁,进入配网状态 ;方悦8按键轻触式面板入网操作指示 21020=按住面板左上角按键,所有按键指示灯{0}亮起,则配网成功 21020=长按BUTTON1按键5秒,所有指示灯{0}变为绿色并闪烁,进入配网状态 ;方悦环境面板入网操作指示 21021=按住面板功能(function)按键,所有按键{0}指示灯亮起,则配网成功 ;窗帘面板的入网操作指示 @@ -1967,6 +1972,7 @@ 30037=S-one 30038=方悦新风小模块 30039=Zigbee吸顶燃气传感器 30040=PM2.5空气质量传感器 ;★★★★下面这些是设备所属种类的翻译名字,从40000开始★★★★ 40000=遮阳 @@ -2030,6 +2036,7 @@ 50037=Zigbee智能门锁 50038=新风控制小模块 50039=Zigbee吸顶燃气传感器 50040=PM2.5空气质量传感器 ;★★★★下面这些是模块ID的设备类型名字,从60000开始.注:它并不需要再R.cs文件中定义★★★★ 60000=传感器 ZigbeeApp/Shared/Common/Device.cs
@@ -628,6 +628,9 @@ /// <param name="deleteRoom">是否从房间删除</param> public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true) { //删除缓存设备的话,主页需要重新刷新 Phone.UserView.UserPage.Instance.RefreshForm = true; if (deleteRoom == true) { //从房间中删除 @@ -2086,6 +2089,50 @@ #endregion #region ■ 获取设备在线状态列表_______________ /// <summary> /// 获取设备在线状态列表(注意,一个设备只返回一个回路) /// </summary> /// <param name="gwId">网关id</param> /// <returns></returns> public List<CommonDevice> GetDeviceOnlineList(string gwId) { var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId); int statu = 0; var listDevice = this.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO); if (statu == -1) { //当出现异常时,使用后备操作,直接获取本地的设备列表 listDevice = this.GetDeviceByGatewayID(gwId); } var dicDevice = new Dictionary<string, CommonDevice>(); foreach (var device in listDevice) { if (dicDevice.ContainsKey(device.DeviceAddr) == false) { dicDevice[device.DeviceAddr] = device; continue; } //设备是否处于在线状态 bool online = this.CheckDeviceIsOnline(device); if (online == true) { //如果设备回路在线,则优先使用在线的回路,后来的直接覆盖 dicDevice[device.DeviceAddr] = device; } } var listReturn = new List<CommonDevice>(); foreach (var device in dicDevice.Values) { listReturn.Add(device); } return listReturn; } #endregion #region ■ 一般方法___________________________ /// <summary> @@ -2673,6 +2720,9 @@ this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1200-60000";//紧急按键 this.dicDeviceModelIdEnum["MGCD01/ZB.10"] = "1306-1200-60000";//吸顶燃气传感器 //PM2.5空气质量传感器 【该设备属于第三方设备,没有镜像ID】 this.dicDeviceModelIdEnum["SZ_PM100"] = "1307-1200-60000";//PM2.5空气质量传感器 //=========★★继电器类(2300-2499)★★========= this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3路继电器小模块 this.dicDeviceModelIdEnum["MFA01-ZB.10"] = "2310-2300-60011";//方悦新风小模块 @@ -2864,6 +2914,11 @@ /// </summary> Sensor_CeilingGas = 1306, /// <summary> /// PM2.5空气质量传感器 /// </summary> Sensor_PMTwoPointFive = 1307, /// <summary> /// 运动传感器 /// </summary> Sensor_Motion = -1306, ZigbeeApp/Shared/Common/House.cs
@@ -250,13 +250,6 @@ //当住宅为空时先提示用户新建住宅 var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.CurrentlyTheUserIshHouseIsEmptyPleaseBuildANewHouseFirst), Language.StringByID(R.MyInternationalizationString.Close), Language.StringByID(R.MyInternationalizationString.Confrim)); alert.Show(); alert.ResultEventHandler += (sender, e) => { if (e) { // } }; } else { @@ -295,7 +288,7 @@ listHouse.Add(house); } //如果切换了账号,或者原来的id不存在,则重置住宅ID if (UserCenterResourse.ResidenceOption.TheSameLoginAccount == false || if (Config.Instance.TheSameLoginAccount == false || Config.Instance.HomeFilePathList.Find((obj) => obj == $"House_{Config.Instance.HomeId}.json") == null) { Config.Instance.HomeId = listHouse[0].Id; ZigbeeApp/Shared/Phone/Device/Logic/AddLogicPage.cs
@@ -18,6 +18,8 @@ } public void Show() { #region 界面的布局代码 TopView view = new TopView(); this.AddChidren(view.TopRowView()); @@ -72,6 +74,7 @@ UserView.HomePage.Instance.PageIndex += 1; roomAndDeviceView.IfType = LogicView.IfString.Condition_Logic; roomAndDeviceView.Show(Language.StringByID(MyInternationalizationString.devicestate)); }; securityView.clickviewBtn.MouseUpEventHandler += (sender, e) => { ZigbeeApp/Shared/Phone/Device/Logic/CurrentDeviceState.cs
@@ -387,6 +387,7 @@ break; case 40: { openView.titleBtn.TextID = MyInternationalizationString.smokescreen; openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; completeView.Show(1).AddChidren(openView.Show()); @@ -403,7 +404,7 @@ } break; case 43: { {//召元说的 openView.titleBtn.TextID = MyInternationalizationString.gas; openView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor; completeView.Show(1).AddChidren(openView.Show()); ZigbeeApp/Shared/Phone/Device/Logic/LogicView/TipView.cs
@@ -281,8 +281,8 @@ } dialog.Close(); action(editTime.Text); dialog.Close(); }; @@ -412,7 +412,6 @@ dialog.Close(); }; } /// <summary> /// 闪错提示框 /// </summary> ZigbeeApp/Shared/Phone/Device/Logic/Method.cs
@@ -882,11 +882,13 @@ else if (LogicView.IfString._SoneLogic == if_logic) { //跳到Sone门锁联动事件列表界面 UserView.HomePage.Instance.RemoveViewByTag("SoneLogic");//移除所有标记LockListView界面 var soneLogicList = new SoneLogicList(); UserView.HomePage.Instance.AddChidren(soneLogicList); UserView.HomePage.Instance.PageIndex += 1; soneLogicList.Show(); //UserView.HomePage.Instance.RemoveViewByTag("SoneLogic");//移除所有标记LockListView界面 //var soneLogicList = new SoneLogicList(); //UserView.HomePage.Instance.AddChidren(soneLogicList); //UserView.HomePage.Instance.PageIndex += 1; //soneLogicList.Show(); SoneLogicList.soneLogicList?.RefreshView(); } } ZigbeeApp/Shared/Phone/Device/Logic/RoomAndDeviceView.cs
@@ -245,7 +245,7 @@ }; fra.AddChidren(roomnameBtn); if (i == 0)// if (i == 0)//默认选中第一个房间 { roombjButton.IsSelected = false; roombjButton = roombjBtn; @@ -344,6 +344,16 @@ }; deviceRowLayout.AddChidren(devicetypename); //if (i == 0)//默认选中第一个设备类型 //{ // devicetypeButton.IsSelected = false; // devicetypeButton = backgroundColor; // backgroundColor.IsSelected = true; // var list = Method.GetDeviceType(devicetypename.Text); // ConditionDeviceView(list, devicelist); //} EventHandler<MouseEventArgs> devicetypeclick = (sender13, e13) => { devicetypeButton.IsSelected = false; @@ -361,6 +371,7 @@ ///显示房间所有设备 ConditionDeviceView(new List<DeviceType>(), devicelist); } /// <summary> /// 加载该类型设备视图方法 ZigbeeApp/Shared/Phone/Device/Logic/SkipView.cs
@@ -242,8 +242,7 @@ logicScrolView.BeginHeaderRefreshingAction += () => { if (!Config.Instance.Home.IsVirtually) { //虚拟的不获取网关逻辑列表 {//虚拟的不获取网关逻辑列表 //重新刷新logic列表 Common.Logic.LogicList.Clear(); Read(logicScrolView, no); @@ -262,6 +261,14 @@ /// <param name="logicScrolView"></param> private static async void Read(VerticalRefreshLayout logicScrolView, bool no) { //if (Config.Instance.HomeId != UserCenter.UserCenterResourse.AccountOption.OldHomeStringId) //{ // //切换住宅清除之前缓存数据; // Common.Logic.LogicList.Clear(); // Common.Logic.LockLogicList.Clear(); // Common.Logic.SoneLogicList.Clear(); //} CommonPage.Loading.Start(); try { ZigbeeApp/Shared/Phone/Device/Logic/SoneLogicList.cs
@@ -8,20 +8,28 @@ { public class SoneLogicList : FrameLayout { /// <summary> /// 给Sone门锁徐梅更新界面用的 /// </summary> /// public static SoneLogicList soneLogicList; public SoneLogicList() { Tag = "SoneLogic"; soneLogicList = this; } /// <summary> /// /// </summary> /// <param name="action">给徐梅刷新界面用的</param> /// <param name="bool_If"></param> /// 给徐梅刷新界面用的 public Action<bool> action; ///第二块第一级父控件 FrameLayout fLayout = new FrameLayout(); ///常开模式图标 Button modeIconBtn = new Button(); ///第二块第二级父控件 FrameLayout modeFl = new FrameLayout(); Button button1 = new Button(); Button button2= new Button(); ///第三块第一级父控件 FrameLayout listLogicFl = new FrameLayout(); ///常开自动化列表上下滑动的控件 VerticalRefreshLayout verticalRefresh = new VerticalRefreshLayout(); public async void Show() { @@ -29,13 +37,21 @@ UserView.HomePage.Instance.ScrollEnabled = false;//锁住左滑 TopView view = new TopView(); this.AddChidren(view.TopRowView()); view.toptitleNameBtn.TextID = MyInternationalizationString.selection; view.toptitleNameBtn.TextID = MyInternationalizationString.openmode; view.clickBtn.MouseDownEventHandler += (sender, e) => { UserView.HomePage.Instance.ScrollEnabled = true; if (updateThread != null && updateThread.IsAlive) { updateThread.Abort(); } //把静态变量的这个东西置空 soneLogicList = null; this.RemoveFromParent(); if (action != null) { action(Send.CurrentDoorLock.IsDoorLockNormallyMode); RemoveFromParent(); } }; var middle = new FrameLayout @@ -49,7 +65,7 @@ #region 常开模式图标 时效性常开设置 ///第二块第一级父控件 var fLayout = new FrameLayout fLayout = new FrameLayout { Width = Application.GetRealWidth(1080), Height = Application.GetRealHeight(829 - 184), @@ -57,203 +73,35 @@ }; middle.AddChidren(fLayout); ///常开模式图标 var modeIconBtn = new Button modeIconBtn = new Button { X = Application.GetRealWidth(395), Y = Application.GetRealHeight(92), Width = Application.GetMinRealAverage(294), Height = Application.GetMinRealAverage(294), UnSelectedImagePath = "ZigeeLogic/noMode.png", SelectedImagePath = "ZigeeLogic/openMode.png", }; fLayout.AddChidren(modeIconBtn); if (Send.CurrentDoorLock.IsDoorLockNormallyMode) ///第二块第二级父控件 modeFl = new FrameLayout { /// 查找是否存在时效性自动化;有的话就返回自动化对象; var logic = await SkipView.GetLogicIfon(); fLayout.Height = Application.GetRealHeight(780);//改变高度 modeIconBtn.IsSelected = true;//改变图标状态 ///第二级父控件 var openModeFl = new FrameLayout { Y = Application.GetRealHeight(455), Height = Application.GetRealHeight(127 + 199), Width = Application.GetRealWidth(1080), }; fLayout.AddChidren(openModeFl); ///关闭时效性自动化 Button closeBtn = new Button { X = Application.GetRealWidth(86), Height = Application.GetRealHeight(127), Width = Application.GetRealWidth(907), Radius = (uint)Application.GetRealHeight(58), BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor, TextID = MyInternationalizationString.closeUp, TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor, TextSize = 16, }; openModeFl.AddChidren(closeBtn); closeBtn.MouseUpEventHandler += async (sender, e) => { var result = await UserCenter.DoorLock.DoorLockCommonInfo.DelNormallyOpenMode(Send.CurrentDoorLock); if (result) { if (logic != null) { ///有可能只有常开模式,没有时效性自动化 ///没有判断的话,逻辑会为空,抛出异常; Send.DelLogic(logic.LogicId); } Send.CurrentDoorLock.IsDoorLockNormallyMode = false; this.RemoveFromParent(); var soneLogicList = new SoneLogicList(); UserView.HomePage.Instance.AddChidren(soneLogicList); UserView.HomePage.Instance.PageIndex += 1; soneLogicList.Show(); action = soneLogicList.action; //添加历史记录 UserCenter.HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(Send.CurrentDoorLock, 9004, ""); } else { LogicView.TipView.ShowFlashTip("关闭失败"); } }; ///显示失效设置时间文本控件 var timeTextBtn = new Button { Y = Application.GetRealHeight(127 + 69), X = Application.GetRealWidth(225), Width = Application.GetRealWidth(634), Height = Application.GetRealHeight(60), TextSize = 15, TextColor = ZigbeeColor.Current.LogicTextBlackColor, Text = "时效性常开设置12:20", }; if (logic != null) { ///有时效性常开才显示时间条件文本 openModeFl.AddChidren(timeTextBtn); } ///时效性常开只有一个条件; try { var y = DateTime.Now.ToString("yy");//那一年 var m = DateTime.Now.ToString("mm");//那一月 var d = DateTime.Now.ToString("dd");//那一天 var h = int.Parse(DateTime.Now.ToString("HH"));//当前系统时间 var me = DateTime.Now.ToLongDateString(); var timeInt = int.Parse(logic.Conditions[0]["DoorLockOpenDelayTime"]); int dayInt = (h + timeInt) / 24;//算出几天后执行 int hour = (h + timeInt) % 24;//算出几天后那个时间执行 timeTextBtn.Text = "时效性常开设置" + y + "年" + m + "月" + d + dayInt + "号" + timeInt + "时" + "执行"; } catch { } } else { fLayout.Height = Application.GetRealHeight(645);//改变高度 modeIconBtn.IsSelected = false;//改变图标状态 ///第二级父控件 var modeFl = new FrameLayout { Y = Application.GetRealHeight(478), X = Application.GetRealWidth(58), Height = Application.GetRealHeight(138), Width = Application.GetRealWidth(1022), BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor, }; fLayout.AddChidren(modeFl); modeFl.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft); modeFl.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerBottomLeft); ///时效性常开设置显示文本控件 var modeTextBtn = new Button { Y = Application.GetRealHeight(40), X = Application.GetRealWidth(58), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(60), TextSize = 15, TextColor = ZigbeeColor.Current.LogicTextBlackColor, TextAlignment = TextAlignment.CenterLeft, // Text = "时效性常开设置", TextID = MyInternationalizationString.timeSetSone, button1 = new Button { }; modeFl.AddChidren(modeTextBtn); ///下一级菜单图标控件 var nextIconBtn = new Button modeFl.AddChidren(button1); button2 = new Button { Width = Application.GetMinRealAverage(104), Height = Application.GetMinRealAverage(104), X = Application.GetRealWidth(861), Y = Application.GetRealHeight(17), UnSelectedImagePath = "ZigeeLogic/nextIconSone.png", }; modeFl.AddChidren(nextIconBtn); nextIconBtn.MouseUpEventHandler += (sender, e) => { LogicView.TipView.ShowConfrimTip(() => {///再次确认 LogicView.TipView.ShowInputTip(true, async (str) => {///确认发送命令 try { ///xm var result = await UserCenter.DoorLock.DoorLockCommonInfo.SetNormallyOpenModeFuncAsync(Send.CurrentDoorLock); if (!result) { LogicView.TipView.ShowFlashTip("开启失败"); return; } else { ///因为有常开模式下才可以创建失效逻辑; SkipView.GetLogicAll();//删除之前所有失效逻辑 var addResult = await SkipView.LockAddModifyLogic(int.Parse(str), Send.CurrentDoorLock);//添加一条失效逻辑 if (!addResult) { ///提示失败 LogicView.TipView.ShowFlashTip("添加失败"); return; } Send.CurrentDoorLock.IsDoorLockNormallyMode = true; this.RemoveFromParent(); var soneLogicList = new SoneLogicList(); UserView.HomePage.Instance.AddChidren(soneLogicList); UserView.HomePage.Instance.PageIndex += 1; soneLogicList.Show(); action = soneLogicList.action; } } catch { } }); }); }; } modeFl.AddChidren(button2); ModeView(); #endregion #region 常开自动化 ///第三块第一级父控件 var listLogicFl = new FrameLayout listLogicFl = new FrameLayout { Y = fLayout.Bottom, X = Application.GetRealWidth(58), @@ -295,7 +143,16 @@ UnSelectedImagePath = "ZigeeLogic/add.png", }; addLogicfL.AddChidren(addIconBtn); addIconBtn.MouseUpEventHandler += (sender, e) => var addIconclickBtn = new Button { Width = Application.GetRealWidth(90+69+63), Height = Application.GetRealHeight(69), X = Application.GetRealWidth(800), Y = Application.GetRealHeight(60), }; addLogicfL.AddChidren(addIconclickBtn); addIconclickBtn.MouseUpEventHandler += (sender, e) => { //读取系统当前时间:时-分 @@ -333,7 +190,7 @@ }; ///常开自动化列表上下滑动的控件 var verticalRefresh = new VerticalRefreshLayout verticalRefresh = new VerticalRefreshLayout { Y = addLogicfL.Bottom, @@ -345,17 +202,194 @@ verticalRefresh.BeginHeaderRefreshingAction += () => { Common.Logic.SoneLogicList.Clear(); Read(verticalRefresh, false); Read(false); verticalRefresh.EndHeaderRefreshing(); }; Read(verticalRefresh, true); Read(true); #endregion } /// <summary> /// 常开模式开关切换图标界面 /// </summary> public async void ModeView() { if (Send.CurrentDoorLock.IsDoorLockNormallyMode) { /// 查找是否存在时效性自动化;有的话就返回自动化对象; var logic = await SkipView.GetLogicIfon(); fLayout.Height = Application.GetRealHeight(780);//改变高度 modeIconBtn.UnSelectedImagePath = "ZigeeLogic/openMode.png";//改变图标状态 modeFl.Y = modeIconBtn.Bottom + Application.GetRealHeight(64); modeFl.X = Application.GetRealWidth(0); modeFl.Height = Application.GetRealHeight(127 + 199); modeFl.Width = Application.GetRealHeight(1080); modeFl.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor; modeFl.SetCornerWithSameRadius(Application.GetRealHeight(0), HDLUtils.RectCornerBottomLeft); ///关闭时效性自动化 button1.Y = Application.GetRealHeight(0); button1.X = Application.GetRealWidth(86); button1.Width = Application.GetRealWidth(907); button1.Height = Application.GetRealHeight(127); button1.Radius = (uint)Application.GetRealHeight(58); button1.BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor; button1.TextAlignment = TextAlignment.Center; button1.TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor; button1.TextID = MyInternationalizationString.closeUp; button1.TextSize = 16; button1.MouseUpEventHandler = async (sender, e) => { var result = await UserCenter.DoorLock.DoorLockCommonInfo.DelNormallyOpenMode(Send.CurrentDoorLock); if (result) { if (logic != null) { ///有可能只有常开模式,没有时效性自动化 ///没有判断的话,逻辑会为空,抛出异常; Send.DelLogic(logic.LogicId); } Send.CurrentDoorLock.IsDoorLockNormallyMode = false; ModeView(); } else { LogicView.TipView.ShowFlashTip(Language.StringByID(MyInternationalizationString.closeFailed)); } }; if (logic != null) { ///显示失效设置时间文本控件 button2.Y = Application.GetRealHeight(127 + 69); button2.X = Application.GetRealWidth(125); button2.Width = Application.GetRealWidth(634 + 200); button2.Height = Application.GetRealHeight(60); button2.UnSelectedImagePath = "ZigeeLogic/1234.png"; button2.TextSize = 15; button2.TextColor = ZigbeeColor.Current.LogicTextBlackColor; ///有时效性常开才显示时间条件文本 } else { button2.Width = Application.GetRealWidth(0); button2.Height = Application.GetRealHeight(0); } ///时效性常开只有一个条件; try { var y = DateTime.Now.Year.ToString();//那一年 var m = DateTime.Now.Month.ToString();//那一月 var d = DateTime.Now.ToString("dd");//那一天 var h = int.Parse(DateTime.Now.ToString("HH"));//当前系统时间 var timeInt = int.Parse(logic.Conditions[0]["DoorLockOpenDelayTime"]); int dayInt = (h + timeInt) / 24;//算出几天后执行 int hour = (h + timeInt) % 24;//算出几天后那个时间执行 int days = int.Parse(d) + dayInt; string text1 = Language.StringByID(MyInternationalizationString.timeSensitive); string text2 = Language.StringByID(MyInternationalizationString.yearSone); string text3 = Language.StringByID(MyInternationalizationString.monthSone); string text4 = Language.StringByID(MyInternationalizationString.numberSone); string text5 = Language.StringByID(MyInternationalizationString.executeSone); button2.Text = text1 + y + text2 + m + text3 + days.ToString() + text4 + hour.ToString() + text5; } catch { } } else { fLayout.Height = Application.GetRealHeight(645);//改变高度 modeIconBtn.UnSelectedImagePath = "ZigeeLogic/noMode.png";//改变图标状态 modeFl.Y = modeIconBtn.Bottom + Application.GetRealHeight(92); modeFl.X = Application.GetRealWidth(58); modeFl.Height = Application.GetRealHeight(138); modeFl.Width = Application.GetRealHeight(1022); modeFl.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; modeFl.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerBottomLeft); ///时效性常开设置显示文本控件 button1.Y = Application.GetRealHeight(40); button1.X = Application.GetRealWidth(58); button1.Width = Application.GetRealWidth(600); button1.Height = Application.GetRealHeight(60); button1.Radius = (uint)Application.GetRealHeight(0); button1.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; button1.TextAlignment = TextAlignment.CenterLeft; button1.TextColor = ZigbeeColor.Current.LogicTextBlackColor; // Text = "时效性常开设置", button1.TextID = MyInternationalizationString.timeSetSone; button1.TextSize = 15; ///下一级菜单图标控件 button2.Width = Application.GetMinRealAverage(104); button2.Height = Application.GetMinRealAverage(104); button2.X = Application.GetRealWidth(861); button2.Y = Application.GetRealHeight(17); button2.UnSelectedImagePath = "ZigeeLogic/nextIconSone.png"; button2.TextSize = 15; button2.TextColor = ZigbeeColor.Current.LogicTextBlackColor; button2.MouseUpEventHandler = (sender, e) => { LogicView.TipView.ShowConfrimTip(() => {///再次确认 LogicView.TipView.ShowInputTip(true, async (str) => {///确认发送命令 try { ///xm var result = await UserCenter.DoorLock.DoorLockCommonInfo.SetNormallyOpenModeFuncAsync(Send.CurrentDoorLock); if (!result) { LogicView.TipView.ShowFlashTip(Language.StringByID(MyInternationalizationString.openFailed)); return; } else { ///因为有常开模式下才可以创建失效逻辑; SkipView.GetLogicAll();//删除之前所有失效逻辑 var addResult = await SkipView.LockAddModifyLogic(int.Parse(str), Send.CurrentDoorLock);//添加一条失效逻辑 if (!addResult) { ///可欣说如果常开模式开,创建自动化失败,那么将要发一条常开模式关闭命令; UserCenter.DoorLock.DoorLockCommonInfo.DelNormallyOpenMode(Send.CurrentDoorLock); ///提示失败 LogicView.TipView.ShowFlashTip(Language.StringByID(MyInternationalizationString.addFailed)); return; } Send.CurrentDoorLock.IsDoorLockNormallyMode = true; ModeView(); //添加App开启常开模式的历史记录 UserCenter.HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(Send.CurrentDoorLock, 9001, string.Empty); } } catch { } }); }); }; } listLogicFl.Y = fLayout.Bottom; listLogicFl.X = Application.GetRealWidth(58); listLogicFl.Height = Application.GetRealHeight(Method.H - 184) - fLayout.Height; listLogicFl.Width = Application.GetRealWidth(1022); listLogicFl.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; } /// <summary> /// 读取自动化列表数据; /// </summary> /// <param name="verticalRefresh"></param> private async void Read(VerticalRefreshLayout verticalRefresh, bool yes) /// <param name="yes"></param> private async void Read( bool yes) { if (yes) { @@ -386,41 +420,40 @@ var dd = e.Message; } //自动化 RefreshView(verticalRefresh); RefreshView(); if (yes) { CommonPage.Loading.Hide(); } } RowLayout selectedRow = new RowLayout() { Tag = "0" };//记录左滑状态 int a = 1; /// <summary> /// 加载自动化列表 /// </summary> /// <param name="verticalRefresh"></param> RowLayout selectedRow = new RowLayout() { Tag = "0" };//记录左滑状态 int i = 1; private void RefreshView(VerticalRefreshLayout verticalRefresh) public void RefreshView() { verticalRefresh.RemoveAll(); foreach (var logic in Common.Logic.SoneLogicList) { #region 自动化布局View ///自动化父控件 var fLayout = new FrameLayout var fLayoutLogic = new FrameLayout { Height = Application.GetRealHeight(184), }; verticalRefresh.AddChidren(fLayout); verticalRefresh.AddChidren(fLayoutLogic); ///左右可滑动控件 var logicRow = new RowLayout { LineColor = ZigbeeColor.Current.LogicBackgroundColor, BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor, SubViewWidth = Application.GetRealWidth(184),//改变编辑控件宽度多少; Tag = i.ToString(), Tag = a.ToString(), }; fLayout.AddChidren(logicRow); fLayoutLogic.AddChidren(logicRow); //左滑菜单事件 logicRow.OpenMenuAction += () => { @@ -430,7 +463,7 @@ } selectedRow = logicRow; }; i++; a++; ///显示逻辑名称的控件 var nameBtn = new Button { @@ -510,12 +543,12 @@ ///线的控件 var line = new Button { Y = fLayout.Height - 1, Y = fLayoutLogic.Height - 1, Height = 1, Width = Application.GetRealWidth(976), BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor, }; fLayout.AddChidren(line); fLayoutLogic.AddChidren(line); #endregion ///开关点击事件 switchBtn.MouseUpEventHandler += (sender1, e1) => @@ -557,14 +590,39 @@ { Common.Logic.SoneLogicList.Remove(logic); //logicRow.Parent.RemoveFromParent(); fLayout.RemoveFromParent(); fLayoutLogic.RemoveFromParent(); Send.DelLogic(logic.LogicId); }; }; } } /// <summary> /// 定时更新常开模式(防止通过门锁关闭没及时刷新状态) /// </summary> System.Threading.Thread updateThread; public void UpdateModeIcon() { updateThread = new System.Threading.Thread(() => { while (this.Parent != null) { System.Threading.Thread.Sleep(1000); Application.RunOnMainThread(() => { try { ModeView(); } catch { } }); } }); updateThread.Start(); } } } ZigbeeApp/Shared/Phone/Login/AccountLoginForm.cs
@@ -907,7 +907,7 @@ var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString()); var revertData = responseDataObj; //标记上一次是不是同一个账号登陆 UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.Account = revertData.Account; Config.Instance.MD5PWD = revertData.MD5PWD; Config.Instance.Guid = revertData.Guid; @@ -1094,7 +1094,7 @@ var revertData = responseDataObj; Config.ReFresh(); //标记上一次是不是同一个账号登陆 UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.Account = revertData.Account; Config.Instance.Password = i_psw; Config.Instance.MD5PWD = revertData.MD5PWD; ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceFreshAirDetailCardForm.cs
@@ -36,7 +36,6 @@ #endregion #region ■ 初始化_____________________________ public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack) { @@ -129,6 +128,13 @@ this.listControl.Add(btnHighSpeed); btnHighSpeed.ButtonClickEvent += (sender, e) => { if (FreshAirDev.currentFanMode == 5) { var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AutoModeForbiddenOperate)); msgContr.Show(); return; } if (!btnHighSpeed.IsSelected) { this.SetFanComand(3); @@ -166,6 +172,12 @@ this.listControl.Add(btnLowSpeed); btnLowSpeed.ButtonClickEvent += (sender, e) => { if (FreshAirDev.currentFanMode == 5) { var msgContr = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AutoModeForbiddenOperate)); msgContr.Show(); return; } if (!btnLowSpeed.IsSelected) { this.SetFanComand(1); ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Common/ResidenceOption.cs
@@ -45,11 +45,6 @@ /// </summary> [Newtonsoft.Json.JsonIgnore] public int CategoryPageSwitchIndex = 0; /// <summary> /// 当前登录的账号是不是之前的账号 /// </summary> [Newtonsoft.Json.JsonIgnore] public bool TheSameLoginAccount = false; #endregion ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceObjectControl.cs
@@ -20,24 +20,27 @@ /// </summary> private bool hadRefresh = false; /// <summary> /// 在线状态 /// </summary> private bool m_isOnline = false; /// <summary> /// 传感器推送中 /// </summary> private bool sensorPushing = false; /// <summary> /// 在线状态 /// </summary> public bool isOnline private bool m_isOnline = true; /// <summary> /// 在线状态 /// </summary> public bool IsOnline { get { return m_isOnline; } set { if (m_isOnline != value) { m_isOnline = value; //设置在线状态的特效 this.SetOnlineStatu(m_isOnline); } } } @@ -96,7 +99,7 @@ frameTable.AddBottomLine(); //设置在线状态的特效 this.isOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(listDevice[0]); this.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(listDevice[0]); } #endregion @@ -106,10 +109,10 @@ /// <summary> /// 设置在线状态的特效 /// </summary> /// <param name="isOnline"></param> private void SetOnlineStatu(bool isOnline) /// <param name="i_isOnline"></param> private void SetOnlineStatu(bool i_isOnline) { if (isOnline == false) if (i_isOnline == false) { btnDeviceName.TextColor = UserCenterColor.Current.TextGrayColor1; } @@ -143,8 +146,6 @@ btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceMacName(listDevice[0]); //设备房间 btnDeviceRoom.Text = Common.LocalDevice.Current.GeteRealDeviceRoomName(listDevice[0]); //设置在线状态的特效 this.isOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(listDevice[0]); } ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/DeviceRoomControl.cs
@@ -26,18 +26,21 @@ /// <summary> /// 在线状态 /// </summary> private bool m_isOnline = false; private bool m_isOnline = true; /// <summary> /// 在线状态 /// </summary> public bool isOnline public bool IsOnline { get { return m_isOnline; } set { if (m_isOnline != value) { m_isOnline = value; //设置在线状态的特效 this.SetOnlineStatu(m_isOnline); } } } /// <summary> @@ -155,10 +158,10 @@ /// <summary> /// 设置在线状态的特效 /// </summary> /// <param name="isOnline"></param> private void SetOnlineStatu(bool isOnline) /// <param name="i_isOnline"></param> private void SetOnlineStatu(bool i_isOnline) { if (isOnline == false) if (i_isOnline == false) { btnDevie.TextColor = UserCenterColor.Current.TextGrayColor1; } ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/DeviceControls/GatewayRowControl.cs
@@ -57,11 +57,14 @@ get { return m_IsOnline; } set { if (m_IsOnline != value) { m_IsOnline = value; //变更状态 this.SetOnlineStatu(m_IsOnline); } } } #endregion ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
@@ -611,6 +611,9 @@ } //切换网关,保存缓存 this.SaveGatewayIdToLocation(gatewayId); //切换网关的话,主页需要重新刷新 UserView.UserPage.Instance.RefreshForm = true; return true; } @@ -794,9 +797,8 @@ /// 刷新网关的在线状态(注意,刷新的是缓存,请调用CheckGatewayOnlineByFlag来判断是否在线) /// </summary> /// <param name="listGateway"></param> /// <param name="waitTime">局域网的时候,时候等待3秒延迟</param> /// <returns></returns> public void RefreshGatewayOnlineStatu(List<ZbGateway> listGateway, bool waitTime = true) public void RefreshGatewayOnlineStatu(List<ZbGateway> listGateway) { var listRealWay = new List<ZbGateway>(); for (int i = 0; i < listGateway.Count; i++) @@ -811,21 +813,11 @@ { //虚拟物理网关 listRealWay.Add(listGateway[i]); if (waitTime == false) { //不等待的话,标识指定网关为不在线 this.SetGatewayNotOnLineFlag(listRealWay[i]); } } if (waitTime == true) { //只有等待的时候,才标识指定网关为不在线 this.SetGatewayNotOnLineFlag(listRealWay[i]); } //标识指定网关为不在线 listRealWay[i].GatewayOnlineFlage = false; } if (waitTime == true) { //这是第一道坎,强制检查WIFI:等待2秒(因为wifi的时候,它会自动去刷新flage) System.Threading.Thread.Sleep(2000); //检查是否拥有网关存在于WIFi下 @@ -833,7 +825,6 @@ { //第二道坎:在远程的情况下刷新网关的在线状态 this.RefreshGatewayOnlineOnRemode(listRealWay); } } //刷新缓存的在线标识 @@ -845,7 +836,6 @@ continue; } this.dicGateway[gwID].GatewayOnlineFlage = zbway.GatewayOnlineFlage; this.dicGateway[gwID].ReSave(); } } @@ -887,26 +877,11 @@ continue; } string strId = this.GetGatewayId(way); if (dicDbGateway.ContainsKey(strId) == true //如果云端上面有这个网关 && dicDbGateway[strId].MqttOnlineStatus == true //如果云端上面这个网关是在线的 ) if (dicDbGateway.ContainsKey(strId) == true) //如果云端上面有这个网关 { way.GatewayOnlineFlage = true; way.GatewayOnlineFlage = dicDbGateway[strId].MqttOnlineStatus; } } } /// <summary> /// 标识指定网关为不在线 /// </summary> /// <param name="zbGateway"></param> public void SetGatewayNotOnLineFlag(ZbGateway zbGateway) { if (zbGateway == null) { return; } zbGateway.GatewayOnlineFlage = false; } /// <summary> @@ -1926,272 +1901,6 @@ #endregion #region ■ 网关监视___________________________ #region ■ 变量声明___________________________ /// <summary> /// 当前的网络连接模式 /// </summary> private GatewayConnectMode nowGwConnectMode = GatewayConnectMode.None; /// <summary> /// 是否存在网关正在升级 /// </summary> private bool hadGatewayUpdate = false; #endregion #region ■ 网关连接方式变更___________________ /// <summary> /// 当网关的连接方式改变时,检测网关,然后显示特效 /// </summary> /// <param name="connectMode">网关变更后的连接方式</param> public void CheckGatewayByConnectChanged(GatewayConnectMode connectMode) { if (this.nowGwConnectMode == connectMode || this.hadGatewayUpdate == true) { //相同的连接模式,或者有网关正在升级,则不需要操作 return; } //没有网络 if (connectMode == GatewayConnectMode.NoLine) { nowGwConnectMode = GatewayConnectMode.NoLine; //在远程的条件下,检查网关的在线状态(网络变更时触发) } //可以叫4G else if (connectMode == GatewayConnectMode.Remote) { nowGwConnectMode = GatewayConnectMode.Remote; //在远程的条件下,检查网关的在线状态(网络变更时触发) this.CheckGatewayStatuByRemote(); } //WIFI else if (connectMode == GatewayConnectMode.WIFI) { nowGwConnectMode = GatewayConnectMode.WIFI; //在WIFI的条件下,检查网关的在线状态(网络变更时触发) this.CheckGatewayStatuByWIFI(); } } #endregion #region ■ 检查网关(WIFI)_____________________ /// <summary> /// 在WIFI的条件下,检查网关的在线状态(网络变更时触发) /// </summary> private void CheckGatewayStatuByWIFI() { if (this.dicGateway.Count == 0) { //如果本地都没有网关的话,不需要处理 return; } HdlThreadLogic.Current.RunThread(() => { var dicStatu = this.GetNowOnlineStatuBeforeCheck(); //等个3秒,准备一下 System.Threading.Thread.Sleep(3000); if (nowGwConnectMode != GatewayConnectMode.WIFI) { //网络临时变更?? return; } //从网关获取全部的网关 List<ZbGateway> list = this.GetAllGatewayFromGateway(); foreach (var way in list) { string gwId = this.GetGatewayId(way); if (this.dicGateway.ContainsKey(gwId) == true) { //刷新一下缓存 this.dicGateway[gwId].GatewayOnlineFlage = way.GatewayOnlineFlage; } if (this.CheckGatewayOnlineByFlag(way) == true) { //网关在线 dicStatu[gwId] = true; } } //将变化的网关推送到界面上 this.PushGatewayOnlineStatuToForm(dicStatu); }); } #endregion #region ■ 检查网关(4G)_______________________ /// <summary> /// 在远程的条件下,检查网关的在线状态(网络变更时触发) /// </summary> private void CheckGatewayStatuByRemote() { if (this.dicGateway.Count == 0) { //如果本地都没有网关的话,不需要处理 return; } HdlThreadLogic.Current.RunThread(() => { //先获取现在全部的网关,初期値设置为不在线 var dicStatu = this.GetNowOnlineStatuBeforeCheck(); //获取云端上面的网关 Dictionary<string, GatewayResult> dicDbGateway = HdlGatewayLogic.Current.GetGateWayListFromDataBase(); if (nowGwConnectMode != GatewayConnectMode.Remote || dicDbGateway == null) { //网络临时变更?? return; } bool hadOnline = false; lock (dicGateway) { foreach (var way in this.dicGateway.Values) { //循环处理本地全部的网关列表 string gwId = this.GetGatewayId(way); if (dicDbGateway.ContainsKey(gwId) == true//如果云端上面有这个网关 && dicDbGateway[gwId].MqttOnlineStatus == true//如果云端上面这个网关是在线的 ) { dicGateway[gwId].GatewayOnlineFlage = true; //它是在线的 dicStatu[gwId] = true; hadOnline = true; } } } //将变化的网关推送到界面上 this.PushGatewayOnlineStatuToForm(dicStatu); //如果没有网关在线 if (hadOnline == false) { //远程连接超时,没有网关在线 string msg = Language.StringByID(R.MyInternationalizationString.uRemoteTimeOutAndNotGatewaiOnline); //this.ShowTipMsg(msg); } }); } #endregion #region ■ 检查网关(无网络)___________________ /// <summary> /// 在远程的条件下,检查网关的在线状态(网络变更时触发) /// </summary> private void CheckGatewayStatuByNotNet() { //当前无网络连接,请确认网络 string msg = Language.StringByID(R.MyInternationalizationString.uNowIsDonotNetworkAndCheckNetwork); this.ShowTipMsg(msg); } #endregion #region ■ 网关推送___________________________ /// <summary> /// 将变化的网关推送到界面上 /// </summary> /// <param name="dicStatu"></param> private void PushGatewayOnlineStatuToForm(Dictionary<string, bool> dicStatu) { List<ZbGateway> listChange = new List<ZbGateway>(); List<bool> listChangeStatu = new List<bool>(); foreach (string gwid in dicStatu.Keys) { //网关不多,直接推送,不判断是否改变了 ZbGateway zbGateway = this.GetLocalGateway(gwid); if (zbGateway != null) { listChange.Add(zbGateway); listChangeStatu.Add(dicStatu[gwid]); zbGateway.GatewayOnlineFlage = dicStatu[gwid]; } } if (listChange.Count == 0) { return; } //保存当前激活的界面ID var listId = new List<string>(); listId.AddRange(UserCenterResourse.listActionFormId); for (int i = 0; i < listId.Count; i++) { if (UserCenterResourse.DicActionForm.ContainsKey(listId[i]) == false) { continue; } //网关在线推送 for (int j = 0; j < listChange.Count; j++) { UserCenterResourse.DicActionForm[listId[i]]?.GatewayOnlinePush(listChange[j], listChangeStatu[j]); } } } #endregion #region ■ 一般方法___________________________ /// <summary> /// 设置存在网关正在升级的标识 /// </summary> /// <param name="update">是否有网关在升级</param> public void SetHadGatewayUpdateFlage(bool update) { this.hadGatewayUpdate = update; } /// <summary> /// 在网络连接变更之后,网关连接检测之前,设置全部网关为离线状态(以本地网关为标准) /// </summary> /// <returns></returns> private Dictionary<string, bool> GetNowOnlineStatuBeforeCheck() { //先获取现在全部的网关 List<ZbGateway> listOldGateway = this.GetAllGatewayFromGateway(); var dicOldZb = new Dictionary<string, ZbGateway>(); foreach (var zb in listOldGateway) { string gwID = this.GetGatewayId(zb); dicOldZb[gwID] = zb; } var dicStatu = new Dictionary<string, bool>(); lock (dicGateway) { foreach (string gwId in this.dicGateway.Keys) { if (dicOldZb.ContainsKey(gwId) == true) { //标记为不在线 this.SetGatewayNotOnLineFlag(dicOldZb[gwId]); } dicStatu[gwId] = false; } } return dicStatu; } #endregion #endregion #region ■ 从云端获取全部网关列表ID___________ /// <summary> @@ -2477,253 +2186,208 @@ #endregion #region ■ 恢复网关___________________________ #region ■ 网关监视___________________________ /// <summary> /// 恢复网关配置 /// 当前的网络连接模式 /// </summary> /// <param name="zbGateway">网关对象</param> /// <param name="listGatewayFile">网关里面拥有的文件</param> /// <param name="backDirectory">云端下载的备份数据的文件夹名字</param> /// <returns></returns> public async Task<bool> RecoverGatewaySettion(ZbGateway zbGateway, List<string> listGatewayFile, string backDirectory) { //获取从云端那里得来的全部文件 var listBackFile = HdlAutoBackupLogic.GetFileFromDirectory(UserCenterLogic.CombinePath(backDirectory)); listBackFile.Sort(); //添加附加情报:还原设备配置 ProgressBar.SetAppendText(Language.StringByID(R.MyInternationalizationString.uRecoverDeviceSettion)); ProgressBar.SetMaxValue(listBackFile.Count); ProgressBar.Show(); private GatewayConnectMode nowGwConnectMode = GatewayConnectMode.None; /// <summary> /// 是否存在网关正在升级 /// </summary> private bool hadGatewayUpdate = false; var listSaveFile = new HashSet<string>(); foreach (string fileName in listBackFile) /// <summary> /// 当网关的连接方式改变时,记录当前的连接方式 /// </summary> /// <param name="connectMode">网关变更后的连接方式</param> public void CheckGatewayByConnectChanged(GatewayConnectMode connectMode) { if (fileName.Length < 10 || fileName.StartsWith("Device_") == false) { //不是设备备份文件 continue; } //恢复设备配置 var result = await this.RecoverDeviceSettion(backDirectory, fileName); if (result == -1) { ProgressBar.Close(); return false; } if (result == 1 || result == 2) { listSaveFile.Add(fileName); } ProgressBar.SetValue(1); listGatewayFile.Remove(fileName); } //添加附加情报:覆盖网关备份中 ProgressBar.SetAppendText(Language.StringByID(R.MyInternationalizationString.uGatewayBackupDataIsCovering)); foreach (var file in listSaveFile) { //创建文件对象 var result = await zbGateway.CreateFileAsync(file); if (result == null || result.Result != 0) { Application.RunOnMainThread(() => { //覆盖网关备份失败 string msg = Language.StringByID(R.MyInternationalizationString.uCoverGatewayBackupDataFail); var control = new ShowMsgControl(ShowMsgType.Tip, msg); control.Show(); }); ProgressBar.Close(); return false; } //发送数据流 var byteData = Shared.Common.Global.ReadFileByDirectory(backDirectory, file); var result2 = await zbGateway.SendFileAsync(byteData); if (result2 == null || result2.Result != 0) { Application.RunOnMainThread(() => { //覆盖网关备份失败 string msg = Language.StringByID(R.MyInternationalizationString.uCoverGatewayBackupDataFail); var control = new ShowMsgControl(ShowMsgType.Tip, msg); control.Show(); }); ProgressBar.Close(); return false; } } //删除多余的文件 foreach (var deleteFile in listGatewayFile) { if (deleteFile.Length > 12) { string deviceFileName = deleteFile.Substring(5); if (deviceFileName.StartsWith("Device_") == false) { //不是设备文件 continue; } string[] strArry = deviceFileName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); if (strArry.Length < 4 || listSaveFile.Contains(deleteFile) == true) { //我也不知道它是什么文件,或者这个文件是覆盖的 continue; } //这个或许可以不理他 var result = await zbGateway.DelFileOrDirAsync("/etc/hdlDat/" + deleteFile); } } ProgressBar.Close(); return true; this.nowGwConnectMode = connectMode; } /// <summary> /// 恢复设备配置 /// 开启检测网关在线状态的线程(此方法是给设备列表界面用的) /// </summary> /// <param name="backDirectory">云端下载的备份数据的文件夹名字</param> /// <param name="backFileName">网关的设备备份名字</param> /// <param name="frameLayout">界面对象</param> public void StartCheckGatewayOnlineThread(EditorCommonForm frameLayout) { HdlThreadLogic.Current.RunThread(() => { int waitCount = 0; //如果住宅ID变更了,则不再处理 while (frameLayout.Parent != null) { System.Threading.Thread.Sleep(1000); if (this.hadGatewayUpdate == true) { //网关正在升级,不需要操作 continue; } waitCount++; if (this.nowGwConnectMode == GatewayConnectMode.Remote) { //远程每10秒检测一次 if (waitCount < 10) { continue; } } else if (this.nowGwConnectMode == GatewayConnectMode.WIFI) { //局域网每3秒检测一次 if (waitCount < 3) { continue; } } waitCount = 0; //获取前回网关的在线状态 Dictionary<string, bool> dicOldOnline = this.GetOldGatewayOnlineStatu(); if (dicOldOnline == null) { //则不处理 continue; } //可以叫4G if (this.nowGwConnectMode == GatewayConnectMode.Remote) { //在远程的条件下,检查网关的在线状态 this.CheckGatewayStatuByRemote(dicOldOnline); } //WIFI else if (this.nowGwConnectMode == GatewayConnectMode.WIFI) { //在WIFI的条件下,检查网关的在线状态 this.CheckGatewayStatuByWIFI(dicOldOnline); } } }, ShowErrorMode.NO); } /// <summary> /// 在WIFI的条件下,检查网关的在线状态 /// </summary> private void CheckGatewayStatuByWIFI(Dictionary<string, bool> dicOldOnline) { //从网关获取全部的网关 List<ZbGateway> list = this.GetAllGatewayFromGateway(); foreach (var way in list) { //将标识置为false way.GatewayOnlineFlage = false; } //等个2秒 System.Threading.Thread.Sleep(2000); foreach (var way in list) { string gwId = this.GetGatewayId(way); if (dicOldOnline.ContainsKey(gwId) == true) { //网关也不多,直接推送吧 this.PushGatewayOnlineStatuToForm(gwId, way.GatewayOnlineFlage); } else { //没有包含,默认为false this.PushGatewayOnlineStatuToForm(gwId, false); } } } /// <summary> /// 在远程的条件下,检查网关的在线状态 /// </summary> private void CheckGatewayStatuByRemote(Dictionary<string, bool> dicOldOnline) { //获取云端上面的网关 Dictionary<string, GatewayResult> dicDbGateway = HdlGatewayLogic.Current.GetGateWayListFromDataBase(); if (dicDbGateway == null) { //如果网络不通,则也往下走 dicDbGateway = new Dictionary<string, GatewayResult>(); } foreach (var gwId in dicOldOnline.Keys) { //如果云端上面有这个网关 if (dicDbGateway.ContainsKey(gwId) == true) { //网关也不多,直接推送 this.PushGatewayOnlineStatuToForm(gwId, dicDbGateway[gwId].MqttOnlineStatus); } else { //云端不包含的,当不在线处理 this.PushGatewayOnlineStatuToForm(gwId, false); } } } /// <summary> /// 获取前回网关的在线状态 /// </summary> /// <returns></returns> private async Task<int> RecoverDeviceSettion(string backDirectory, string backFileName) private Dictionary<string, bool> GetOldGatewayOnlineStatu() { string deviceFileName = backFileName.Substring(0, backFileName.Length - 5); string[] strArry = deviceFileName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); if (strArry.Length < 4) if (this.dicGateway.Count == 0) { //我也不知道它是什么文件 return 0; } var device = Common.LocalDevice.Current.GetDevice(strArry[2], Convert.ToInt32(strArry[3])); if (device == null) { //这个设备不见了 return 2; //没有网关,则不处理 return null; } var byteData = Shared.Common.Global.ReadFileByDirectory(backDirectory, backFileName); var backType = (GatewayBackupEnum)Convert.ToInt32(backFileName.Substring(backFileName.Length - 5, 5)); try { var dicOldOnline = new Dictionary<string, bool>(); //如果在循环的过程中,动了里面的东西,报错则不理它,下一回合 foreach (var zbway in this.dicGateway.Values) { //获取前回的在线状态 string gwId = this.GetGatewayId(zbway); dicOldOnline[gwId] = zbway.GatewayOnlineFlage; } return dicOldOnline; } catch { return null; } } bool result = true; if (backType == GatewayBackupEnum.AMac名称) /// <summary> /// 将变化的网关推送到界面上 /// </summary> /// <param name="gwId"></param> /// <param name="online"></param> private void PushGatewayOnlineStatuToForm(string gwId, bool online) { var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(System.Text.Encoding.UTF8.GetString(byteData)); result = await Common.LocalDevice.Current.ReMacName(new List<CommonDevice>() { device }, recoverData); try { for (int i = 0; i < UserCenterResourse.listActionFormId.Count; i++) { string formId = UserCenterResourse.listActionFormId[i]; if (UserCenterResourse.DicActionForm.ContainsKey(formId) == false) { continue; } else if (backType == GatewayBackupEnum.A端点名称) { var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(System.Text.Encoding.UTF8.GetString(byteData)); result = await Common.LocalDevice.Current.ReName(device, recoverData); } else if (backType == GatewayBackupEnum.APir灯光配置) { var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.ConfigureParamates>(System.Text.Encoding.UTF8.GetString(byteData)); result = await HdlDevicePirSensorLogic.Current.SetPirSensorSettion((IASZone)device, recoverData); } else if (backType == GatewayBackupEnum.A干接点颜色调节) { var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.KeyColorData>(System.Text.Encoding.UTF8.GetString(byteData)); result = await HdlDevicePanelLogic.Current.SetPanelEpointColorInfo((Panel)device, recoverData); } else if (backType == GatewayBackupEnum.A干接点亮度调节) { var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(System.Text.Encoding.UTF8.GetString(byteData)); int directionsLevel = Convert.ToInt32(recoverData["directionsLevel"]); int backlightLevel = Convert.ToInt32(recoverData["backlightLevel"]); result = await HdlDevicePanelLogic.Current.SetDeviceLightSettion((Panel)device, directionsLevel, backlightLevel); } else if (backType == GatewayBackupEnum.A干接点节能模式) { var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(System.Text.Encoding.UTF8.GetString(byteData)); bool modeEnable = Convert.ToBoolean(recoverData["modeEnable"]); int modeTime = Convert.ToInt32(recoverData["modeTime"]); int level = Convert.ToInt32(recoverData["level"]); result = await HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode((Panel)device, modeEnable, modeTime, level); } else if (backType == GatewayBackupEnum.A干接点第三级别私有属性) { var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(System.Text.Encoding.UTF8.GetString(byteData)); result = await HdlDevicePanelLogic.Current.EditorDryContactThirdFunction((Panel)device, recoverData); } else if (backType == GatewayBackupEnum.A窗帘方向) { var statu = Newtonsoft.Json.JsonConvert.DeserializeObject<bool>(System.Text.Encoding.UTF8.GetString(byteData)); result = await HdlDeviceCurtainLogic.Current.SetCurtainDirection((Rollershade)device, statu); } else if (backType == GatewayBackupEnum.A窗帘手拉控制) { var statu = Newtonsoft.Json.JsonConvert.DeserializeObject<bool>(System.Text.Encoding.UTF8.GetString(byteData)); result = await HdlDeviceCurtainLogic.Current.SetHandPullControl((Rollershade)device, statu); } else if (backType == GatewayBackupEnum.A窗帘上下限位) { var curtainDevice = (Rollershade)device; var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(System.Text.Encoding.UTF8.GetString(byteData)); int upLimit = Convert.ToInt32(recoverData["upLimit"]); int downLimit = Convert.ToInt32(recoverData["downLimit"]); //先重置窗帘 result = await HdlDeviceCurtainLogic.Current.RestoreCurtain(curtainDevice); if (result == false) { return -1; } await Task.Delay(5000); //重置上限位 result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.UpLimit); if (result == false) { return -1; } //将窗帘调整到指定百分比 curtainDevice.WcdGoToTiltValue(upLimit); await Task.Delay(3000); //执行确认及覆盖窗帘限位点 result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit, -1, -1); if (result == false) { return -1; } //网关在线推送 var zbway = this.GetLocalGateway(gwId); zbway.GatewayOnlineFlage = online; await Task.Delay(2000); //重置下限位 result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.DownLimit); if (result == false) { return -1; } //将窗帘调整到指定百分比 curtainDevice.WcdGoToTiltValue(downLimit); await Task.Delay(3000); //执行确认及覆盖窗帘限位点 result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit, -1, -1); UserCenterResourse.DicActionForm[formId]?.GatewayOnlinePush(zbway, online); } else if (backType == GatewayBackupEnum.A空调自定义模式) } catch { } } /// <summary> /// 设置存在网关正在升级的标识 /// </summary> /// <param name="update">是否有网关在升级</param> public void SetHadGatewayUpdateFlage(bool update) { var data = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(System.Text.Encoding.UTF8.GetString(byteData)); result = await HdlDeviceAirConditionerLogic.Current.SetAcModeSupport((AC)device, data); if (result == true) { //转换为二进制 var value = Convert.ToString(data, 2).PadLeft(16, '0'); //这五个设置是放在后面的 var fixValue = value.Substring(0, value.Length - 5); var reportValue = value.Substring(fixValue.Length); //更改缓存 for (int i = 0; i < reportValue.Length; i++) { ((AC)device).listSupportMode[i] = Convert.ToInt32(reportValue[i]); } device.ReSave(); } } return result == true ? 1 : -1; this.hadGatewayUpdate = update; } #endregion #region ■ 一般方法___________________________ /// <summary> /// 弹出网关不在线的 /// </summary> private void ShowGatewayNotOnlineMsg() { Application.RunOnMainThread(() => { //网关连接失败,请确认网络 string msg = Language.StringByID(R.MyInternationalizationString.uGatewayIsNotLinkAndCheckNetwork); var control = new ShowMsgControl(ShowMsgType.Tip, msg); control.Show(); }); } /// <summary> /// 显示错误信息窗口 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
@@ -582,13 +582,18 @@ tempDevice.IsOnline = Convert.ToInt32(receiveData["Data"]["IsOnline"].ToString()); //处理网关上报的数据,然后变更本地缓存 var locadevice = Common.LocalDevice.Current.GetDevice(tempDevice.DeviceAddr, tempDevice.DeviceEpoint); if (locadevice != null) var locadevice = Common.LocalDevice.Current.GetDevicesByMac(tempDevice.DeviceAddr); for (int i = 0; i < locadevice.Count; i++) { locadevice.IsOnline = tempDevice.IsOnline; bool onlineChanged = locadevice[i].IsOnline != tempDevice.IsOnline; locadevice[i].IsOnline = tempDevice.IsOnline; //记录回复时间 locadevice.LastDateTime = DateTime.Now; locadevice.ReSave(); locadevice[i].LastDateTime = DateTime.Now; if (onlineChanged == true) { //在线状态变更了,才保存 locadevice[i].ReSave(); } } this.DeviceReportPush(tempDevice, ReceiveComandDiv.A设备在线上报); ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/UserCenterLogic.cs
@@ -869,7 +869,7 @@ UserCenterResourse.ResidenceOption = UserCenterResourse.ResidenceOption.Load(); //初始化登陆账号的信息 var hadNet = await InitUserAccoutInfo(); var hadNet = await InitUserAccoutInfo(true); //如果有网络的话 if (hadNet == true) { @@ -990,14 +990,18 @@ /// <summary> /// 初始化登陆账号的信息 /// </summary> /// <param name="reLoad">是否从新从本地加载(重新初始化登陆账号的信息,不需要重新加载)</param> /// <returns></returns> private async static Task<bool> InitUserAccoutInfo() private async static Task<bool> InitUserAccoutInfo(bool reLoad) { //初始化个人信息的标识 UserCenterResourse.UserInfo.InitUserInfoSuccess = false; if (reLoad == true) { //获取本地记录的用户信息 UserCenterResourse.UserInfo = GetUserInformationFromLocation(); UserCenterResourse.UserInfo.UserIconFile = System.IO.Path.Combine(UserCenterResourse.AccountOption.UserPictruePath, "Admin.png"); } //获取登录账号的信息 var pra = new AccountInfoPra(); @@ -1120,7 +1124,7 @@ private async static Task<bool> ReInitUserAccoutInfo() { //重新初始化账号信息 var result = await InitUserAccoutInfo(); var result = await InitUserAccoutInfo(false); if (result == false) { return result; ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs
@@ -45,6 +45,9 @@ listNewDevice.Add(Common.LocalDevice.Current.GetOTADevice(deviceMac)); } //添加新设备的话,主页需要重新刷新 UserView.UserPage.Instance.RefreshForm = true; //设置标题信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice)); ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
@@ -30,10 +30,6 @@ /// </summary> private Dictionary<string, DeviceObjRowInfo> dicRowInfo = new Dictionary<string, DeviceObjRowInfo>(); /// <summary> /// 重新获取设备的在线状态 /// </summary> private bool reGetDeviceOnlineStatu = false; /// <summary> /// 当前正在操作的设备对象Mac地址(设备信息编辑界面用) /// </summary> private string nowActionDeviceMac = null; @@ -65,15 +61,28 @@ //初始化中部控件 this.InitMiddleFrame(); //开启传感器报警监视 this.StartCheckDeviceAlarm(); //添加接收设备在线上报的监听 HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A设备在线上报, (report) => { HdlThreadLogic.Current.RunMain(() => { //接受设备状态 this.ReceiveDeviceStatu(report); }, ShowErrorMode.NO); }); //开启检测网关在线状态的线程 HdlGatewayLogic.Current.StartCheckGatewayOnlineThread(this); } /// <summary> /// 初始化中部控件(外部可以调用) /// </summary> /// <param name="i_reGetDeviceOnlineStatu">重新获取设备的在线状态</param> public void InitMiddleFrame(bool i_reGetDeviceOnlineStatu = true) public void InitMiddleFrame() { this.reGetDeviceOnlineStatu = i_reGetDeviceOnlineStatu; //清空bodyFrame this.ClearBodyFrame(); @@ -125,6 +134,9 @@ frame.AddChidren(listView); listView.BeginHeaderRefreshingAction += () => { //刷新设备的话,主页需要重新刷新 UserView.UserPage.Instance.RefreshForm = true; HdlThreadLogic.Current.RunThread(() => { //下拉刷新 @@ -348,8 +360,7 @@ //右箭头 rowDevice.frameTable.AddRightArrow(); //在线状态 rowDevice.isOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device); rowDevice.IsOnline = rowInfo.MenuRow.IsOnline; //保存控件 string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device); rowInfo.dicDetailRow[maikey] = rowDevice; @@ -646,7 +657,7 @@ if (result != -1) { //重新刷新界面 this.InitMiddleFrame(false); this.InitMiddleFrame(); } }); } @@ -676,9 +687,10 @@ if (this.gatewayViewRow != null && this.gatewayViewRow.zbGatewayId == selectGwId) { bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbGateway); this.gatewayViewRow.RefreshControl(); //开启设备在线线程 this.StartDeviceListControlThread(online); //刷新控件在线状态 this.gatewayViewRow?.RefreshOnlineStatu(); //根据网关在线状态刷新设备在线状态 this.RefreshDeviceOnlineStatuByGatewayOnline(online); } }); }); @@ -699,7 +711,14 @@ { Application.RunOnMainThread(() => { this.gatewayViewRow?.RefreshControl(); //相同的状态,不需要再次刷新 if (this.gatewayViewRow.isOnline != online) { //根据网关在线状态刷新设备在线状态 this.RefreshDeviceOnlineStatuByGatewayOnline(online); } //刷新控件在线状态 this.gatewayViewRow?.RefreshOnlineStatu(); }); } } @@ -709,52 +728,43 @@ #region ■ 设备在线检测_______________________ /// <summary> /// 开启设备在线线程 /// 根据网关在线状态刷新设备在线状态 /// </summary> /// <param name="gatewayOnline">网关的在线状态</param> private void StartDeviceListControlThread(bool gatewayOnline) private void RefreshDeviceOnlineStatuByGatewayOnline(bool gatewayOnline) { if (gatewayOnline == false) { //设置全部设备离线 this.SetAllDeviceOffLine(); return; } //开启传感器报警监视 this.StartCheckDeviceAlarm(); //开启设备在线监测 this.StartCheckDeviceOnline(); else { //刷新设备在线状态 this.RefreshDeviceOnlineStatu(); } } /// <summary> /// 开启设备在线监测 /// 刷新设备在线状态 /// </summary> private void StartCheckDeviceOnline() private void RefreshDeviceOnlineStatu() { //外部调用的话,不再重新获取设备状态 if (this.reGetDeviceOnlineStatu == false) { return; } //添加接收设备在线上报的监听 HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A设备在线上报, this.ReceiveDeviceStatu); string gwId = GatewayResourse.NowSelectGatewayId; HdlThreadLogic.Current.RunThread(() => { System.Threading.Thread.Sleep(2000); //这里主要只是获取在线状态 var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId); int statu = 0; var list = LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO); if (statu != -1) var list = LocalDevice.Current.GetDeviceOnlineList(gwId); HdlThreadLogic.Current.RunMain(() => { for (int i = 0; i < list.Count; i++) { //设置设备在线状态 this.ReceiveDeviceStatu(list[i]); } } }, ShowErrorMode.NO); }); } @@ -788,20 +798,14 @@ localDevice.ReSave(); } HdlThreadLogic.Current.RunMain(() => { if (rowInfo != null) { rowInfo.MenuRow.isOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device); rowInfo.MenuRow.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device); if (rowInfo.dicDetailRow != null) { foreach (var detailRow in rowInfo.dicDetailRow.Values) { detailRow.isOnline = rowInfo.MenuRow.isOnline; detailRow.IsOnline = rowInfo.MenuRow.IsOnline; } } } }); } /// <summary> @@ -809,17 +813,20 @@ /// </summary> private void SetAllDeviceOffLine() { lock (dicRowInfo) { foreach (var rowInfo in this.dicRowInfo.Values) { Application.RunOnMainThread(() => { //菜单 if (rowInfo.MenuRow != null) { rowInfo.MenuRow.isOnline = false; rowInfo.MenuRow.IsOnline = false; } }); //明细 if (rowInfo.dicDetailRow != null) { foreach (var detailRow in rowInfo.dicDetailRow.Values) { detailRow.IsOnline = false; } } } } @@ -1082,6 +1089,10 @@ /// 网关名字控件 /// </summary> private NormalViewControl btnName = null; /// <summary> /// 在线状态 /// </summary> public bool isOnline = false; /// <summary> /// 自定义网关控件 @@ -1124,7 +1135,9 @@ if (zbway != null) { btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false) //在线状态 this.isOnline = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway); if (this.isOnline == false) { btnName.TextColor = UserCenterColor.Current.TextGrayColor1; } @@ -1176,7 +1189,27 @@ return; } btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway); if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false) //刷新控件在线状态 this.RefreshOnlineStatu(); } /// <summary> /// 刷新控件在线状态 /// </summary> public void RefreshOnlineStatu() { //获取本地网关对象 ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId); if (zbway == null) { return; } //在线状态 bool statu = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway); if (this.isOnline != statu) { this.isOnline = statu; if (this.isOnline == false) { btnName.TextColor = UserCenterColor.Current.TextGrayColor1; } @@ -1186,6 +1219,7 @@ } } } } #endregion } ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/PanelFangyueFreshAirDirectionForm.cs
@@ -51,8 +51,9 @@ btnSecond.TextID = R.MyInternationalizationString.uPressAndHoldThisKey; framePic.AddChidren(btnSecond); //长按图示按键5秒以上,指示灯变绿、闪烁 //进入配网状态。绿灯快闪3秒则配网成功 //按住面板模式按键5秒,绿色指示灯闪烁 //进入配网状态;闪烁停止 //指示灯变白色表示配网成功 string[] msgArry = Language.StringByID(R.MyInternationalizationString.AddFreshAirPanelMsg).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries); var msg1 = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); @@ -61,6 +62,7 @@ msg1.TextColor = UserCenterColor.Current.TextGrayColor3; msg1.TextAlignment = TextAlignment.Center; bodyFrameLayout.AddChidren(msg1); var msg2 = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); msg2.Y = msg1.Bottom; if (msgArry.Length > 1) @@ -70,6 +72,17 @@ msg2.TextColor = UserCenterColor.Current.TextGrayColor3; msg2.TextAlignment = TextAlignment.Center; bodyFrameLayout.AddChidren(msg2); var msg3 = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(60), false); msg3.Y = msg2.Bottom; if (msgArry.Length > 2) { msg3.Text = msgArry[2]; } msg3.TextColor = UserCenterColor.Current.TextGrayColor3; msg3.TextAlignment = TextAlignment.Center; bodyFrameLayout.AddChidren(msg3); } #endregion } ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs
@@ -49,10 +49,6 @@ /// 其他消息的主键,它存在另外的一张数据库表中 /// </summary> private List<string> listOtherMsgId = new List<string>(); /// <summary> /// 无法识别的开锁记录的用户ID(因为那个密码有可能没有分配给成员) /// </summary> private List<string> listOtherUserId = new List<string>(); #endregion @@ -69,6 +65,9 @@ //设置头部信息 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uHistoryLog)); //成员不允许清空记录 if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) { //删除 var btnDelete = new MostRightIconControl(69, 69); btnDelete.UnSelectedImagePath = "Item/DeleteIcon2Selected.png"; @@ -96,6 +95,7 @@ }); }); }; } //初始化中部信息 this.InitMiddleFrame(); @@ -493,7 +493,6 @@ //历史记录太麻烦了,存在不同的数据库表里,并且数据还不一样,只能这样一个个判断了 var listScreeningData = new List<HistoryInfo>(); //清除掉之前的记录 this.listOtherUserId = new List<string>(); this.listOtherMsgId = new List<string>(); //是否选择全选用户 @@ -573,12 +572,6 @@ //其他消息的主键,它存在另外的一张数据库表中 this.listOtherMsgId.Add(info.MsgKeyId); } } if (info.CloudAccountId != string.Empty && dicMemberName.ContainsKey(info.CloudAccountId) == false && this.listOtherUserId.Contains(info.CloudAccountId) == false) { //无法识别的开锁记录的用户ID(因为那个密码有可能没有分配给成员) this.listOtherUserId.Add(info.CloudAccountId); } return true; @@ -877,7 +870,7 @@ /// </summary> private async void ClearAllHistoryLog() { //获取访问云端接口的启动参数 //获取访问云端接口的启动参数(2020.05.08:全部清空) var pra = this.GetDeleteDataPra(); //打开进度条 @@ -912,7 +905,6 @@ //清空 this.listOtherMsgId = new List<string>(); this.listOtherUserId = new List<string>(); this.listHistoryInfo = null; HdlThreadLogic.Current.RunMain(() => @@ -954,34 +946,11 @@ DateTime dateFrom = new DateTime(dateFromControl.Year, dateFromControl.Month, dateFromControl.Day, 0, 0, 0); DateTime dateTo = new DateTime(dateToControl.Year, dateToControl.Month, dateToControl.Day, 23, 59, 59); List<string> listUser = null; //指定用户 if (listSearchUserId.Contains("-1") == false) { listUser = new List<string>(); listUser.AddRange(listSearchUserId); //如果指定有其他 if (listSearchUserId.Contains("-9999") == true) { listUser.AddRange(this.listOtherUserId); } } //全选则为null List<int> listLock = null; if (listSearchLockId.Contains(-1) == false) { listLock = new List<int>(); listLock.AddRange(listSearchLockId); } var pra = new DeleteHistoryDataPra(); pra.UnlockTimeBegin = dateFrom.ToUniversalTime().ToString(); pra.UnlockTimeEnd = dateTo.ToUniversalTime().ToString(); pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); pra.DoorLockId = this.DeviceDoor.DeviceAddr + "_" + this.DeviceDoor.DeviceEpoint; pra.CloudAccountIds = listUser; pra.OpenLockModes = listLock; return pra; } ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs
@@ -37,6 +37,22 @@ /// PM目标名字 /// </summary> private string bindPmName = string.Empty; /// <summary> /// 被绑目标是新风 /// </summary> private CommonDevice bindFreshAirDev; /// <summary> /// 被绑目标是温度 /// </summary> private CommonDevice bindTemperatureDev; /// <summary> /// 被绑目标是湿度 /// </summary> private CommonDevice bindHumidityDev; /// <summary> /// 被绑目标是PM2.5 /// </summary> private CommonDevice bindPMDev; #endregion @@ -188,7 +204,7 @@ rowNewWind.ButtonClickEvent += (sender, e) => { var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 1); var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, bindFreshAirDev, 1); Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addDevicePage.Show(); @@ -208,8 +224,6 @@ }); }; //var form = new PanelFangyueFreshAirTargetForm(); //form.AddForm(this.deviceObj, string.Empty, 3); }; } #endregion @@ -242,19 +256,32 @@ continue; } bindFreshAirName = device.DeviceEpointName; bindFreshAirDev = device; } if (device.Type == DeviceType.TemperatureSensor) { var bD = device as TemperatureSensor; if (bD.SensorDiv == 1) { bindTemperatureName = device.DeviceEpointName; bindTemperatureDev = device; } if (bD.SensorDiv == 2) { bindHumidityName = device.DeviceEpointName; bindHumidityDev = device; } } if (device.Type == DeviceType.FreshAirHumiditySensor) { bindHumidityName = device.DeviceEpointName; bindHumidityDev = device; } //if (device.Type == DeviceType.FreshAir) //{ // bindPmName = device.DeviceEpointName; //} if (device.Type == DeviceType.PMSensor) { bindPmName = device.DeviceEpointName; bindPMDev = device; } } result = true; } @@ -283,7 +310,7 @@ var btnPMStatu = rowPM.AddMostRightView(msg, 700); rowPM.ButtonClickEvent += (sender, e) => { var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 4); var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, bindPMDev, 4); Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addDevicePage.Show(); @@ -328,7 +355,7 @@ var btnTemperatureStatu = rowTemPerature.AddMostRightView(msg, 700); rowTemPerature.ButtonClickEvent += (sender, e) => { var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 2); var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, bindTemperatureDev, 2); Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addDevicePage.Show(); @@ -373,7 +400,7 @@ var btnHumidityStatu = rowHumidity.AddMostRightView(msg, 700); rowHumidity.ButtonClickEvent += (sender, e) => { var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 3); var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, bindHumidityDev, 3); Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; addDevicePage.Show(); ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
@@ -16,23 +16,25 @@ /// 构造函数 /// </summary> /// <param name="device"></param> /// <param name="deviceBindType">1:新风;2:温度传感器;3:湿度传感器</param> public PanelFangyueFreshAirTargetsForm(CommonDevice device, int deviceBindType) /// <param name="deviceBindType">1:新风;2:温度传感器;3:湿度传感器;4:PM2.5传感器</param> /// <param name="bindDev">绑定目标 </param> public PanelFangyueFreshAirTargetsForm(CommonDevice device, CommonDevice bindDev, int deviceBindType) { this.curControlDev = device as FreshAir; this.curBindDevice = bindDev; this.curDeviceBindType = deviceBindType; } #endregion #region 变量申明 /// <summary> /// 当前控制设备 /// </summary> //CommonDevice currentControlDevice; /// <summary> /// 当前新风面板【控制设备】 /// </summary> FreshAir curControlDev; /// <summary> /// 当前被绑设备 /// </summary> CommonDevice curBindDevice; /// <summary> /// 显示被绑定设备或场景的view /// </summary> @@ -318,6 +320,19 @@ curentOldRoom = btnRoom; curentOldRoomFrameLayout = btnRoomFrameLayout; } //被绑定的目标还未分配区域,默认是第一个 if (string.IsNullOrEmpty(curControlDev.currentSelectRoomId)) { if (index == 0) { btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png"; btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite; curentOldRoom = btnRoom; curentOldRoomFrameLayout = btnRoomFrameLayout; } } EventHandler<MouseEventArgs> eHandlerRoom = (sender, e) => { if (!btnRoom.IsSelected) @@ -450,6 +465,21 @@ line2.Visible = false; } switch (curDeviceBindType) { case 1: devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png"; break; case 2: devicePic.UnSelectedImagePath = "Device/SensorTemperature.png"; break; case 3: devicePic.UnSelectedImagePath = "Device/SensorHumidity.png"; break; case 4: devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png"; break; } #endregion string mianKey = device.DeviceAddr + device.DeviceEpoint; @@ -608,7 +638,7 @@ btnFloorText.Text = dicFloorList[floorId]; //获取楼层中房间列表 supportRoomList = GetFloorRoomList(curFloorId); supportRoomList = GetFloorRoomList(); if (!btnMethodText.IsSelected) { if (oldbutton != null) @@ -665,11 +695,13 @@ { CommonPage.Loading.Start(""); }); //获取被绑目标等信息 BindDevInfo(curBindDevice); //获取楼层 dicFloorList = HdlRoomLogic.Current.GetFloorSortList(); //获取楼层中房间列表 supportRoomList = GetFloorRoomList(curControlDev.currentSelectFloorId); supportRoomList = GetFloorRoomList(); //获取所有房间中匹配的能绑的目标 currentPanelSupportBindDeviceList = GetAllRoomSupportDeviceList(); @@ -725,11 +757,24 @@ case 2: if (device.Type == DeviceType.TemperatureSensor) { var bDev = device as TemperatureSensor; if (bDev.SensorDiv == 1) { targetList.Add(device); oldTargetList.Add(device); } } break; case 3: if (device.Type == DeviceType.TemperatureSensor) { var bDev = device as TemperatureSensor; if (bDev.SensorDiv == 2) { targetList.Add(device); oldTargetList.Add(device); } } if (device.Type == DeviceType.FreshAirHumiditySensor) { targetList.Add(device); @@ -759,6 +804,7 @@ if (targetList.Count == 0) { curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId(); curControlDev.currentSelectRoomId = null; if (BindInfo.GetCurrentSelectFloorIdName() != null) { Application.RunOnMainThread(() => @@ -966,31 +1012,32 @@ { foreach (var bd in oldTargetList) { var delDevice = new DelDeviceBindData(); delDevice.DeviceAddr = curControlDev.DeviceAddr; delDevice.Epoint = curControlDev.DeviceEpoint; var removeDevice = new RemoveBindListObj(); removeDevice.BindType = 0; switch (curDeviceBindType) var delDevice = DelBindDevice(bd); var delResult = new DelDeviceBindResponseAllData(); delResult = await curControlDev.DelDeviceBindAsync(delDevice); if (delResult != null && delResult.removeBindResultResponseData != null) { case 1: removeDevice.BindCluster = 514; break; case 2: removeDevice.BindCluster = 1026; break; case 3: removeDevice.BindCluster = 1029; break; case 4: //PM2.5 break; if (delResult.removeBindResultResponseData.Result != 0) { Application.RunOnMainThread(() => { new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(CommonPage.Instance); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; CommonPage.Loading.Hide(); }); return; } removeDevice.BindMacAddr = bd.DeviceAddr; removeDevice.BindEpoint = bd.DeviceEpoint; delDevice.RemoveBindList.Add(removeDevice); } } } else { //检测已经绑定的目标是否不在本地或者没有分配到任何房间中 //此时需要删除已经被绑定到目标,才能继续绑定新目标 if (curBindDevice != null) { var delDevice = DelBindDevice(curBindDevice); var delResult = new DelDeviceBindResponseAllData(); delResult = await curControlDev.DelDeviceBindAsync(delDevice); if (delResult != null && delResult.removeBindResultResponseData != null) @@ -1141,6 +1188,31 @@ } /// <summary> /// 当前被绑定设备所属楼层和房间 /// </summary> /// <param name="bindDev"></param> void BindDevInfo(CommonDevice bindDev) { if (bindDev == null) { return; } //获取本地设备列表 var localDeviceList = Shared.Common.LocalDevice.Current.listAllDevice; var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == bindDev.DeviceAddr && obj.DeviceEpoint == bindDev.DeviceEpoint); if (tempDev != null) { //获取设备所属房间 var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev); if (tempDevRoom != null) { curControlDev.currentSelectRoomId = tempDevRoom.Id; curControlDev.currentSelectFloorId = tempDevRoom.FloorId; } } } /// <summary> /// 检测目标是否被绑定过 /// </summary> /// <returns></returns> @@ -1161,6 +1233,39 @@ } } return exist; } /// <summary> /// 检测已经绑定的目标是否不在本地或者没有分配到任何房间中 /// </summary> /// <returns></returns> private DelDeviceBindData DelBindDevice(CommonDevice bd) { var delDevice = new DelDeviceBindData(); delDevice.DeviceAddr = curControlDev.DeviceAddr; delDevice.Epoint = curControlDev.DeviceEpoint; var removeDevice = new RemoveBindListObj(); removeDevice.BindType = 0; switch (curDeviceBindType) { case 1: removeDevice.BindCluster = 514; break; case 2: removeDevice.BindCluster = 1026; break; case 3: removeDevice.BindCluster = 1029; break; case 4: //PM2.5 break; } removeDevice.BindMacAddr = bd.DeviceAddr; removeDevice.BindEpoint = bd.DeviceEpoint; delDevice.RemoveBindList.Add(removeDevice); return delDevice; } /// <summary> @@ -1211,19 +1316,10 @@ } break; case 2: foreach (var de in room.ListDevice) { var device = LocalDevice.Current.GetDevice(de); if (device != null) { if (device.Type == DeviceType.TemperatureSensor) { roomIncludeMatchDevice.Add(device); } } } roomIncludeMatchDevice = GetMatchTemperatureSensorDevice(room); break; case 3: roomIncludeMatchDevice = GetMatchHumiditySensorDevice(room); foreach (var de in room.ListDevice) { var device = LocalDevice.Current.GetDevice(de); @@ -1244,7 +1340,6 @@ { continue; } } if (!string.IsNullOrEmpty(room.FloorId)) { @@ -1260,14 +1355,65 @@ roomTempList.Add(room); } } } return roomTempList; } /// <summary> /// 匹配温度传感器 /// </summary> /// <param name="room"></param> List<CommonDevice> GetMatchTemperatureSensorDevice(Room room) { List<CommonDevice> roomIncludeMatchTempDevice = new List<CommonDevice>(); foreach (var de in room.ListDevice) { var device = LocalDevice.Current.GetDevice(de); if (device != null) { if (device.Type == DeviceType.TemperatureSensor) { var dev = device as TemperatureSensor; if (dev.SensorDiv == 1) { roomIncludeMatchTempDevice.Add(device); } } } } return roomIncludeMatchTempDevice; } /// <summary> /// 匹配湿度传感器 /// </summary> /// <param name="room"></param> List<CommonDevice> GetMatchHumiditySensorDevice(Room room) { List<CommonDevice> roomIncludeMatchHumpDevice = new List<CommonDevice>(); foreach (var de in room.ListDevice) { var device = LocalDevice.Current.GetDevice(de); if (device != null) { if (device.Type == DeviceType.TemperatureSensor) { var dev = device as TemperatureSensor; if (dev.SensorDiv == 2) { roomIncludeMatchHumpDevice.Add(device); } } } } return roomIncludeMatchHumpDevice; } /// <summary> /// 获取楼层对应的房间列表 /// </summary> /// <returns></returns> private List<Room> GetFloorRoomList(string floorId) private List<Room> GetFloorRoomList() { supportRoomList.Clear(); var supportRoomListTemp = new List<Room>(); @@ -1279,10 +1425,6 @@ { if (string.IsNullOrEmpty(room.FloorId)) { if (room.FloorId != floorId) { continue; } if (room.IsLove) { continue; @@ -1350,16 +1492,10 @@ { continue; } foreach (var deviceKeys in r.ListDevice) var deviceListTemp = GetMatchTemperatureSensorDevice(r); foreach (var dev in deviceListTemp) { var device = LocalDevice.Current.GetDevice(deviceKeys); if (device != null) { if (device.Type == DeviceType.TemperatureSensor) { currentPanelBindSupportDeviceListTemp.Add(device); } } currentPanelBindSupportDeviceListTemp.Add(dev); } } break; @@ -1369,6 +1505,11 @@ if (r.ListDevice.Count == 0) { continue; } var deviceListTemp = GetMatchHumiditySensorDevice(r); foreach (var dev in deviceListTemp) { currentPanelBindSupportDeviceListTemp.Add(dev); } foreach (var deviceKeys in r.ListDevice) { @@ -1420,19 +1561,10 @@ } break; case 2: foreach (var deviceKeys in curRoom.ListDevice) { var device = LocalDevice.Current.GetDevice(deviceKeys); if (device != null) { if (device.Type == DeviceType.TemperatureSensor) { curRoomDeviceListTemp.Add(device); } } } curRoomDeviceListTemp = GetMatchTemperatureSensorDevice(curRoom); break; case 3: curRoomDeviceListTemp = GetMatchHumiditySensorDevice(curRoom); foreach (var deviceKeys in curRoom.ListDevice) { var device = LocalDevice.Current.GetDevice(deviceKeys); ZigbeeApp/Shared/Phone/UserCenter/DoorLock/DoorLockCommonInfo.cs
@@ -165,7 +165,7 @@ /// <param name="doorLockMessType">导致门锁失效的操作类型</param> /// <param name="haveLogic">网关中是否存在逻辑常开模式</param> /// <param name="action">回调处理更新内容</param> public static async void NomallyOpenModeInvalidDialog(ZigBee.Device.DoorLock doorLock, DoorLockMessType doorLockMessType, bool haveLogic, Action action = null) public static async void NomallyOpenModeInvalidDialog(ZigBee.Device.DoorLock doorLock, DoorLockMessType doorLockMessType, bool haveLogic, Action<bool> action = null) { //常开模式只能主人操作 if (UserCenterResourse.UserInfo.AuthorityNo != 1) @@ -202,7 +202,8 @@ //保持常开 NormallyOpenModeValue(doorLock, true); } action?.Invoke(); action?.Invoke(doorLock.IsDoorLockNormallyMode); action = null; }; alert.CancelClickEvent += async () => @@ -226,7 +227,8 @@ NormallyOpenModeValue(doorLock, false); CommonPage.Loading.Hide(); }); action?.Invoke(); action?.Invoke(doorLock.IsDoorLockNormallyMode); action = null; return; } if (result.defaultControlResponseData.status != 0) @@ -238,7 +240,8 @@ NormallyOpenModeValue(doorLock, false); CommonPage.Loading.Hide(); }); action?.Invoke(); action?.Invoke(doorLock.IsDoorLockNormallyMode); action = null; return; } else @@ -259,7 +262,8 @@ //app操作不取消“常开模式” DoorLockCommonInfo.NormallyOpenModeValue(doorLock, true); } action?.Invoke(); action?.Invoke(doorLock.IsDoorLockNormallyMode); action = null; }; alert.ConfirmClickEvent += async () => @@ -271,6 +275,7 @@ { //温居城方法??? //此处是否要删除温居城的特殊逻辑 var resTemp1 = await Shared.Phone.Device.Logic.SkipView.GetLogicAll(); } } else @@ -285,7 +290,8 @@ ShowTipMsg(Language.StringByID(R.MyInternationalizationString.GwResponseOvertime)); CommonPage.Loading.Hide(); }); action?.Invoke(); action?.Invoke(doorLock.IsDoorLockNormallyMode); action = null; return; } if (result.defaultControlResponseData.status != 0) @@ -296,7 +302,8 @@ ShowTipMsg(msg1); CommonPage.Loading.Hide(); }); action?.Invoke(); action?.Invoke(doorLock.IsDoorLockNormallyMode); action = null; return; } else @@ -308,7 +315,7 @@ //删除设置常开模式创建的逻辑 if (haveLogic) { var resTemp1 = await Shared.Phone.Device.Logic.SkipView.Exist(3); var resTemp1 = await Shared.Phone.Device.Logic.SkipView.GetLogicAll(); //温居城方法??? //此处是否要删除温居城的特殊逻辑 } @@ -320,7 +327,8 @@ }); } } action?.Invoke(); action?.Invoke(doorLock.IsDoorLockNormallyMode); action = null; }; } @@ -359,7 +367,7 @@ public static async System.Threading.Tasks.Task<bool> SetNormallyOpenModeFuncAsync(ZigBee.Device.DoorLock doorLock) { //app设置“常开模式”失败 var result = await doorLock.SetNormallyOpenModeFuncAsync(false); var result = await doorLock.SetNormallyOpenModeFuncAsync(true); if (result == null || result.defaultControlResponseData == null || result.defaultControlResponseData.status != 0) { return false; ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs
@@ -73,7 +73,7 @@ EventHandler<MouseEventArgs> eHandlerBack = (sender, e) => { RemoveFromParent(); UserDoorLockPage.canShowDialog = true; //暂时不考虑下级界面等推送导致常开模式失效的问题 //var userDoorLockPage = new UserDoorLockPage(currentRoom, deviceUI); //HomePage.Instance.AddChidren(userDoorLockPage); ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UndistributeDoorlockUserPage.cs
@@ -462,8 +462,8 @@ var btnChoose = new Button() { Width = Application.GetRealWidth(60), Height = Application.GetRealHeight(60), Width = Application.GetMinRealAverage(60), Height = Application.GetMinRealAverage(60), X = Application.GetRealWidth(861 + 81), Y = Application.GetRealHeight(35), SelectedImagePath = "DoorLock/SelectedIcon.png", ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
@@ -41,7 +41,13 @@ /// <summary> /// 逻辑中是否有常开模式 /// </summary> private bool HaveLogicNormallyOpenMode = false; private bool haveLogicNormallyOpenMode = false; /// <summary> /// 门锁深度控制上报窗口是否弹出 /// </summary> public static bool canShowDialog = true; /// <summary> /// 当前电量 /// </summary> @@ -609,7 +615,14 @@ { if (canOpenNormallyMode) { Application.RunOnMainThread(() => { NomallyOpenModeInvalidDialog(true); }); Application.RunOnMainThread(() => { Action<bool> action = (obj) => { UpdateNomallyOpenStatus(); }; DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.ServicePush, haveLogicNormallyOpenMode, action); }); } } } @@ -687,11 +700,11 @@ var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(2); if (resTemp == 1) { HaveLogicNormallyOpenMode = true; haveLogicNormallyOpenMode = true; } else if (resTemp == 0) { HaveLogicNormallyOpenMode = false; haveLogicNormallyOpenMode = false; } }); } @@ -784,14 +797,11 @@ //设置 EventHandler<MouseEventArgs> btnFuncSetHander = (sender, e) => { //打开其他界面时前移除【暂时不移除】 //RemoveFromParent(); var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(currentRoom, doorLock); Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; functionSetting.Show(); canShowDialog = false; functionSetting.devicNameAction += (deviceRename) => { if (!string.IsNullOrEmpty(deviceRename)) @@ -822,6 +832,7 @@ //历史记录 ---- stan var form = new DeviceDoorLock.DoorLockHistoryLogForm(); form.AddForm(this.doorLock.DeviceAddr); canShowDialog = false; }; btnRecordFrameLayout.MouseDownEventHandler += handerRecord; btnRecord.MouseDownEventHandler += handerRecord; @@ -849,7 +860,14 @@ { if (canOpenNormallyMode) { NomallyOpenModeInvalidDialog(false); Application.RunOnMainThread(() => { Action<bool> action = (obj) => { UpdateNomallyOpenStatus(); }; DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.AppOperate, haveLogicNormallyOpenMode, action); }); } else { @@ -875,7 +893,14 @@ { if (doorLock.IsDoorLockNormallyMode) { NomallyOpenModeInvalidDialog(); Application.RunOnMainThread(() => { Action<bool> action = (obj) => { UpdateNomallyOpenStatus(); }; DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.AppOperate, haveLogicNormallyOpenMode, action); }); } } else @@ -1066,73 +1091,6 @@ }; HdlCheckLogic.Current.CheckSecondarySecurity(action); #endregion #region 暂时版本 (最终去掉) if (!btnNormallyOpen.IsSelected) { if (UserCenterResourse.UserInfo.AuthorityNo != 1) { this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate)); return; } if (!UserCenterResourse.AccountOption.DoorUnLockByRemote) { SystemSecondAuthentication(); return; } action = () => { string msg = Language.StringByID(R.MyInternationalizationString.SetDoorLockNomallyOpen).Replace("{0}", "\r\n"); var confirm = Language.StringByID(R.MyInternationalizationString.Confrim); var alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.Confirm, msg, confirm); alert.Show(); alert.ConfirmClickEvent += async () => { Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); var result = await doorLock.SetNormallyOpenModeFuncAsync(true); if (result == null || result.defaultControlResponseData == null) { string msg0 = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime); this.ShowTipMsg(msg0); return; } if (result.defaultControlResponseData.status != 0) { string msg1 = Language.StringByID(R.MyInternationalizationString.OpenNormallyOpenModeFailed); this.ShowTipMsg(msg1); return; } else { //添加App开启常开模式的历史记录 HdlDeviceDoorLockLogic.Current.AddDoorHistoryLog(this.doorLock, 9001, string.Empty); //每次重新设置常开,默认时间都是12小时 DoorLockCommonInfo.NormallyOpenModeInvalidTime = 12; DoorLockCommonInfo.NormallyOpenModeValue(doorLock, true); Application.RunOnMainThread(() => { UpdateNomallyOpenStatus(); CommonPage.Loading.Hide(); }); //常开模式开启提示 AlreadyOpenNormallyMode(); } }; }; HdlCheckLogic.Current.CheckSecondarySecurity(action); } else { NomallyOpenModeInvalidDialog(); } #endregion } /// <summary> @@ -1140,6 +1098,11 @@ /// </summary> public void NomallyOpenModeInvalidDialog(bool IsFromReport = false) { if (!canShowDialog) { return; } if (UserCenterResourse.UserInfo.AuthorityNo != 1) { this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate)); @@ -1148,7 +1111,7 @@ string msg = Language.StringByID(R.MyInternationalizationString.NomallyModeIsCanceled).Replace("{0}", "\r\n"); var confirm = Language.StringByID(R.MyInternationalizationString.SureCancel); var alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.NomallyOpenMode, msg, confirm); if (HaveLogicNormallyOpenMode) if (haveLogicNormallyOpenMode) { //有逻辑设置的弹窗 alert = new ShowDoorLockMsgControl(ShowDoorLockMsgControl.DoorLockMsgType.CancelNomallyOpenModeWithLogic, msg, confirm); @@ -1166,7 +1129,7 @@ UpdateNomallyOpenStatus(); }); //删除已经失效的“常开模式”的逻辑 if (HaveLogicNormallyOpenMode) if (haveLogicNormallyOpenMode) { var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3); //if (resTemp == 3) @@ -1194,7 +1157,7 @@ //上报“常开模式”已被取消 Application.RunOnMainThread(() => { CommonPage.Loading.Start(""); }); //先删除已失效的“常开模式”的逻辑 if (HaveLogicNormallyOpenMode) if (haveLogicNormallyOpenMode) { var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3); //if (resTemp == 3) @@ -1271,7 +1234,7 @@ }); //删除已经失效的“常开模式”的逻辑 if (HaveLogicNormallyOpenMode) if (haveLogicNormallyOpenMode) { var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3); //if (resTemp == 3) @@ -1310,7 +1273,7 @@ UpdateNomallyOpenStatus(); }); //删除设置常开模式创建的逻辑 if (HaveLogicNormallyOpenMode) if (haveLogicNormallyOpenMode) { var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(3); //因为目前机制问题,逻辑经常失败,所以不提示,后期机制要改,重新做一个这个界面 ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayInfoEditorForm.cs
@@ -403,7 +403,7 @@ else { //刷新主画面(不重新获取设备状态) this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame", false); this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame"); } }); } ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs
@@ -297,7 +297,7 @@ //关闭界面 this.CloseForm(); //刷新主画面(不重新获取设备状态) this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame", false); this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame"); } }); } @@ -363,7 +363,7 @@ string gwid = HdlGatewayLogic.Current.GetGatewayId(gateWay); if (this.dicRowContr.ContainsKey(gwid) == true && this.dicRowContr[gwid] != null) { this.dicRowContr[gwid].RefreshControl(gateWay); this.dicRowContr[gwid].IsOnline = online; } }); } ZigbeeApp/Shared/Phone/UserCenter/HideOption/HideOptionMainForm.cs
@@ -67,6 +67,15 @@ this.AddNormalRowControl("WIFI变量", 400, Shared.Application.IsWifi == true ? "true" : "false", 400); if (ZigBee.Common.Application.FindGateWaySocket.busSocket == null) { this.AddNormalRowControl("Socket链接", 400, "未初始化", 400); } else { this.AddNormalRowControl("Socket链接", 400, ZigBee.Common.Application.FindGateWaySocket.busSocket.Connected == true ? "true" : "false", 400); } int count = HdlGatewayLogic.Current.GetAllLocalGateway().Count; var row1 = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(row1); @@ -149,6 +158,16 @@ #endif row1 = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(row1); row1.AddLeftCaption("设备缓存变量", 500); row1.AddRightArrow(); row1.ButtonClickEvent += (sender, e) => { }; row1 = new FrameRowControl(listView.rowSpace / 2); listView.AddChidren(row1); row1.AddLeftCaption("上传Log", 500); row1.AddRightArrow(); row1.ButtonClickEvent += (sender, e) => ZigbeeApp/Shared/Phone/UserView/HomePage.cs
@@ -128,7 +128,7 @@ var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.UserLoginRes>(revertObj.ResponseData.ToString()); var revertData = responseDataObj; //标记上一次是不是同一个账号登陆 UserCenter.UserCenterResourse.ResidenceOption.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.TheSameLoginAccount = Config.Instance.Guid == revertData.Guid; Config.Instance.Account = revertData.Account; Config.Instance.Password = password; Config.Instance.MD5PWD = revertData.MD5PWD; ZigbeeApp/Shared/Phone/UserView/UserPage.csold mode 100644 new mode 100755
@@ -49,6 +49,10 @@ /// 控件缓存(看不懂的话,不要动它) /// </summary> private List<ButtonBase> listButton = new List<ButtonBase>(); /// <summary> /// 如果设置此变量为true,则在单击底部菜单时,强制无条件全部刷新 /// </summary> public bool RefreshForm = false; #endregion @@ -225,11 +229,22 @@ /// <param name="handClick">是否是手动点击</param> private void BottomMenuClickEvent(MenuSelectEnum selectEnum, bool handClick) { if (selectEnum == this.nowSelectMenu && handClick == true) if (this.RefreshForm == false && selectEnum == this.nowSelectMenu && handClick == true) { //手动点击同一个菜单,则不做处理 return; } //如果强制指定刷新界面的话 if (this.RefreshForm == true) { //全部刷新 this.listForm = new List<EditorCommonForm>() { null, null, null }; this.bodyFrameView.RemoveAll(); this.RefreshForm = false; } this.nowSelectMenu = selectEnum; //主页 ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs
@@ -104,18 +104,25 @@ { searchCount = 6; ZbGateway.IsRemote = false; //当网关的连接方式改变时,记录当前的连接方式 Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.WIFI); } else { if (searchCount < 0) { ZbGateway.IsRemote = true; //当网关的连接方式改变时,记录当前的连接方式 Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.Remote); } } } else { ZbGateway.IsRemote = true; //当网关的连接方式改变时,记录当前的连接方式 Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.Remote); for (int i = 0; i < ZbGateway.GateWayList.Count; i++) { ZbGateway.GateWayList[i].DisConnectLocalMqttClient("1"); @@ -304,47 +311,6 @@ { //定时检测远程连接情况 await ZbGateway.StartRemoteMqtt(); if (!ZbGateway.IsRemote) { System.Threading.Thread.Sleep(500); continue; } var gateWayList = ZbGateway.GateWayList.FindAll(obj => obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId); if (gateWayList.Count == 1) { gateWayList[0].getGatewayBaseInfo.IsMainGateWay = true; } else { if (gateWayList.Find((obj) => obj.getGatewayBaseInfo.IsMainGateWay) == null) { for (int i = 0; i < gateWayList.Count; i++) { var gateWay = gateWayList[i]; var info = await gateWay.GetZbGwInfoAsync(); if (info == null || info.getGwData == null) { continue; } if (info.getGwData.IsDominant == 1) { for (int j = 0; j < gateWayList.Count; j++) { if (gateWayList[i].getGatewayBaseInfo.gwID == info.getGwData.GwId) { gateWayList[i].getGatewayBaseInfo.IsMainGateWay = true; } else { gateWayList[i].getGatewayBaseInfo.IsMainGateWay = false; } } break; } } } } } catch { } System.Threading.Thread.Sleep(2000); ZigbeeApp/Shared/Phone/ZigBee/Common/Config.cs
@@ -101,6 +101,11 @@ /// </summary> [Newtonsoft.Json.JsonIgnore] public string ConnEmqClientId = string.Empty; /// <summary> /// 当前登录的账号是不是之前的账号 /// </summary> [Newtonsoft.Json.JsonIgnore] public bool TheSameLoginAccount = false; [Newtonsoft.Json.JsonIgnore] /// <summary> ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs
@@ -182,6 +182,10 @@ { return Newtonsoft.Json.JsonConvert.DeserializeObject<FreshAir>(strDeviceByte); } else if (strDeviceType == ZigBee.Device.DeviceType.PMSensor.ToString()) { return Newtonsoft.Json.JsonConvert.DeserializeObject<PMSensor>(strDeviceByte); } return null; } @@ -248,6 +252,11 @@ //新风 IconPath = "Device/FreshAirEpoint.png"; } else if (this.Type == DeviceType.FreshAir) { //PM2.5空气质量传感器 IconPath = "Device/FreshAirEpoint.png"; } else if (this.Type == DeviceType.FreshAirHumiditySensor) { //湿度传感器 ZigbeeApp/Shared/Phone/ZigBee/Device/DeviceType.cs
@@ -94,6 +94,12 @@ /// <para>定义对象:TemperatureSensor</para> /// </summary> TemperatureSensor = 770, /// <summary> /// <para>PM2.5传感器</para> /// <para>设备ID为777</para> /// <para>定义对象:PMSensor</para> /// </summary> PMSensor = 777, } /// <summary> ZigbeeApp/Shared/Phone/ZigBee/Device/PMSensor.cs
New file @@ -0,0 +1,16 @@ using System; using ZigBee.Device; namespace ZigBee.Device { public class PMSensor : CommonDevice { /// <summary> /// PM2.5传感器对象 /// </summary> public PMSensor() { this.Type = DeviceType.PMSensor; } } } ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
@@ -2702,7 +2702,6 @@ { DebugPrintLog($" 本地连接成功_网关IP:{brokerName}_网关是否加:{IsEncry}_当前密码:{Password}"); IsRemote = false; Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.WIFI); }); } @@ -2943,7 +2942,7 @@ await RemoteMqttClient.SubscribeAsync("/ZigbeeGateWayToClient/" + Config.Instance.ConnEmqClientId + "/Push/NotifySqueeze"); await initGateWayBaseInfomation(); Shared.Phone.UserCenter.HdlGatewayLogic.Current.CheckGatewayByConnectChanged(Shared.Phone.UserCenter.GatewayConnectMode.Remote); //没有主网关时主动读取,获取主网关信息 var gateWayList = GateWayList.FindAll(obj => obj.getGatewayBaseInfo.HomeId == Shared.Common.Config.Instance.HomeId); if (gateWayList.Find(obj => obj.getGatewayBaseInfo.IsMainGateWay == true) == null) ZigbeeApp/Shared/R.cs
@@ -330,7 +330,7 @@ /// </summary> public const int GetPanelProximityFail = 233; /// <summary> /// 按住面板模式 /// 按住面板模式按键5秒,绿色指示灯闪烁{0}进入配网状态;闪烁停止{0}指示灯变白色表示配网成功 /// </summary> public const int AddFreshAirPanelMsg = 235; /// <summary> @@ -566,6 +566,10 @@ /// PM2.5感器 -> 长按图示按键5秒以上,信号图标{0}快闪, 进入配网状态。信号图标常亮则配网成功 /// </summary> public const int AddSensorPMMsg = 313; /// <summary> /// 自动模式不支持操作 /// </summary> public const int AutoModeForbiddenOperate = 314; public readonly static int cancel = 5097; public readonly static int confrim = 5098; @@ -839,6 +843,13 @@ public readonly static int or = 5396; public readonly static int timeNull = 5397; public readonly static int numberInput = 5398; public readonly static int closeFailed = 5399; public readonly static int openFailed = 5400; public readonly static int addFailed = 5401; public readonly static int timeSensitive = 5402; public readonly static int executeSone = 5403; #region 登录注册 /// <summary> @@ -5962,15 +5973,15 @@ /// </summary> public const int uAddSensorTemperatureAndHumidityMsg = 21017; /// <summary> /// 方悦2按键轻触式面板 -> 按住面板左上角按键,所有按键指示灯{0}亮起,则配网成功 /// 单开双控面板 -> 长按BUTTON1按键5秒,所有指示灯{0}变为绿色并闪烁,进入配网状态 /// </summary> public const int uAddFangyueTwoButtonPanelMsg = 21018; /// <summary> /// 方悦4按键轻触式面板 -> 按住面板左上角按键,所有按键指示灯{0}亮起,则配网成功 /// 双开四控面板 -> 长按BUTTON1按键5秒,所有指示灯{0}变为绿色并闪烁,进入配网状态 /// </summary> public const int uAddFangyueFourButtonPanelMsg = 21019; /// <summary> /// 方悦8按键轻触式面板 -> 按住面板左上角按键,所有按键指示灯{0}亮起,则配网成功 /// 四开八控面板-> 长按BUTTON1按键5秒,所有指示灯{0}变为绿色并闪烁,进入配网状态 /// </summary> public const int uAddFangyueEightButtonPanelMsg = 21020; /// <summary> @@ -6148,6 +6159,10 @@ /// 镜像ID为1306的设备的默认名字:Zigbee吸顶燃气传感器 /// </summary> public const int uDeviceModelId1306 = 30039; /// <summary> /// 镜像ID为1307的设备的默认名字:PM2.5空气质量传感器 /// </summary> public const int uDeviceModelId1307 = 30040; //★★★★下面这些是设备所属种类的翻译名字,从40000开始★★★★ /// <summary> ZigbeeApp/Shared/Shared.projitems
@@ -402,6 +402,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Phone\ZigBee\Device\DoorLock.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\ZigBee\Device\FreshAir.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\ZigBee\Device\HumiditySensor.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\ZigBee\Device\PMSensor.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\ZigBee\Device\Repeater.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\ZigBee\Device\ThirdPartyModuleUpgrade.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Phone\ZigBee\Device\Transverter.cs" />