| | |
| | | using System;
|
| | | using Shared.Common;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalListControl listView = null;
|
| | | private VerticalListRefreshControl listView = null;
|
| | | /// <summary>
|
| | | /// 前一次显示出左滑菜单的RowLayout
|
| | | /// </summary>
|
| | | private RowLayoutControl oldShowRightMuneRow = null;
|
| | | /// <summary>
|
| | | /// 行控件的信息(Keys:Mac地址)
|
| | | /// </summary>
|
| | |
| | | /// </summary>
|
| | | public void ShowForm()
|
| | | {
|
| | | this.ScrollEnabled = false;
|
| | |
|
| | | //设置标题信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.DeviceManagement));
|
| | |
|
| | |
| | | this.gatewayViewRow = new MyGatewayControl(GatewayResourse.NowSelectGateway);
|
| | | bodyFrameLayout.AddChidren(gatewayViewRow);
|
| | | gatewayViewRow.InitControl();
|
| | | //设置网关接受在线状态推送
|
| | | this.AddGatewayOnlinePush();
|
| | |
|
| | | //初始化搜索控件
|
| | | this.InitSearchControl();
|
| | |
| | | txtSearchControl.BindEvent(this.SetRowDataBySearchKeys);
|
| | |
|
| | | //列表控件
|
| | | listView = new VerticalListControl(29);
|
| | | listView = new VerticalListRefreshControl(29);
|
| | | listView.Y = txtSearchControl.Bottom + Application.GetRealHeight(29);
|
| | | listView.Height = frame.Height - txtSearchControl.Bottom - Application.GetRealHeight(29);
|
| | | frame.AddChidren(listView);
|
| | | listView.BeginHeaderRefreshingAction += () =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //下拉刷新
|
| | | this.ListViewBeginHeaderRefreshing();
|
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | //获取设备列表
|
| | | string gwID = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
|
| | | var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(gwID);
|
| | | var listSpecialOta = Common.LocalDevice.Current.GetSpecialOtaDevice(gwID);
|
| | | listDevice.AddRange(listSpecialOta);
|
| | |
|
| | | this.dicRowInfo.Clear();
|
| | |
|
| | |
| | | //根据MAC合并设备列表
|
| | | this.MargeAllDeviceByMac(listDevice);
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | if (this.Parent == null)
|
| | | {
|
| | | if (this.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | return;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var listOta = new List<OTADevice>();
|
| | | foreach (var macAddress in this.dicRowInfo.Keys)
|
| | | {
|
| | |
| | | //添加设备的菜单行
|
| | | this.AddDeviceMenuRow(macAddress);
|
| | | }
|
| | | //添加底部间隙
|
| | | var frameTemp = new FrameLayout();
|
| | | frameTemp.Height = Application.GetRealHeight(23);
|
| | | listView.AddChidren(frameTemp);
|
| | |
|
| | | //开启设备属性变更监听
|
| | | this.AddDeviceAttributePush();
|
| | | //开启网关在线监测的线程
|
| | | this.StartGatewayOnlieCheckThread();
|
| | | //检测设备新版本
|
| | |
| | |
|
| | | //控件
|
| | | var rowMenu = new DeviceObjectControl(deviceMac, listView.rowSpace / 2);
|
| | | rowMenu.MainKeys = deviceMac;
|
| | | frameTable.AddChidren(rowMenu);
|
| | | rowMenu.InitControl();
|
| | | rowInfo.MenuRow = rowMenu;
|
| | | //向右图标
|
| | | var btnRight = rowMenu.frameTable.AddRightArrow();
|
| | | var btnRight = rowMenu.frameTable.AddMostRightEmptyIcon(58, 58);
|
| | | btnRight.UnSelectedImagePath = "Item/RightNext.png";
|
| | | btnRight.SelectedImagePath = "Item/Down.png";
|
| | | rowMenu.frameTable.ChangedChidrenBindMode(btnRight, ChidrenBindMode.NotBind);
|
| | |
|
| | | //提示新版本
|
| | | var btnNew = new InformationTipView(rowMenu.btnIcon);
|
| | |
| | |
|
| | | //检测设备是否拥有定位的功能
|
| | | var listdevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
|
| | | if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(listdevice[0]) == true)
|
| | | if (listdevice.Count > 0 && Common.LocalDevice.Current.DeviceIsCanFixedPosition(listdevice[0]) == true)
|
| | | {
|
| | | //定位
|
| | | var btnPosition = new NormalViewControl(Application.GetRealWidth(184), rowMenu.Height, false);
|
| | | var btnPosition = rowMenu.AddEditorControl(false);
|
| | | btnPosition.TextID = R.MyInternationalizationString.uFixedPosition;
|
| | | btnPosition.TextAlignment = TextAlignment.Center;
|
| | | btnPosition.TextSize = 12;
|
| | | btnPosition.TextColor = UserCenterColor.Current.White;
|
| | | btnPosition.BackgroundColor = 0xff4a4a4a;
|
| | | rowMenu.AddRightView(btnPosition);
|
| | | btnPosition.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //定位
|
| | |
| | | };
|
| | | }
|
| | |
|
| | | rowMenu.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | //展开,折叠
|
| | | btnRight.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //多回路的情况下,才会展开
|
| | | if (Common.LocalDevice.Current.GetDevicesByMac(deviceMac).Count == 1)
|
| | | {
|
| | | var form = new DeviceMacInfoEditorForm();
|
| | | form.AddForm(deviceMac);
|
| | | //界面跳转,记录当前的正在操作的设备的Mac地址
|
| | | this.nowActionDeviceMac = deviceMac;
|
| | | }
|
| | | else
|
| | | //回路数大于1才展开
|
| | | if (Common.LocalDevice.Current.GetDevicesCountByMac(deviceMac) > 1)
|
| | | {
|
| | | btnRight.IsSelected = !btnRight.IsSelected;
|
| | | //展开或者折叠明细列表
|
| | | this.ShowDetailList(deviceMac, btnRight.IsSelected);
|
| | | }
|
| | | else
|
| | | {
|
| | | btnNew.Visible = false;
|
| | | var form = new DeviceMacInfoEditorForm();
|
| | | form.AddForm(deviceMac);
|
| | | //界面跳转,记录当前的正在操作的设备的Mac地址
|
| | | this.nowActionDeviceMac = deviceMac;
|
| | | }
|
| | | };
|
| | |
|
| | | rowMenu.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //隐藏菜单
|
| | | rowMenu.HideMenu();
|
| | | //强制跳转真实设备界面
|
| | | if (UserCenterResourse.HideOption.GotoRealDeviceForm == 1)
|
| | | {
|
| | | var form2 = new DeviceAddSuccessForm();
|
| | | form2.AddForm(deviceMac);
|
| | | return;
|
| | | }
|
| | | btnNew.Visible = false;
|
| | | var form = new DeviceMacInfoEditorForm();
|
| | | form.AddForm(deviceMac);
|
| | | //界面跳转,记录当前的正在操作的设备的Mac地址
|
| | | this.nowActionDeviceMac = deviceMac;
|
| | | };
|
| | | //左滑菜单事件
|
| | | rowMenu.OpenMenuAction += () =>
|
| | | {
|
| | | if (this.oldShowRightMuneRow != null && this.oldShowRightMuneRow.MainKeys != rowMenu.MainKeys)
|
| | | {
|
| | | //左滑菜单只能滑一个
|
| | | this.oldShowRightMuneRow.HideMenu();
|
| | | }
|
| | | this.oldShowRightMuneRow = rowMenu;
|
| | | };
|
| | | }
|
| | |
|
| | |
| | | //标题自己就是一个子控件
|
| | | if (rowInfo.frameTable.ChildrenCount == 1)
|
| | | {
|
| | | //获取这一堆设备时属于什么类型的
|
| | | var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
|
| | | foreach (CommonDevice info in listDevice)
|
| | | {
|
| | | //加载它的列表
|
| | | this.AddDeviceDetailRow(rowInfo.frameTable, info);
|
| | | this.AddDeviceDetailRow(rowInfo.frameTable, info, deviceEnumInfo);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | /// </summary>
|
| | | /// <param name="frame">容器</param>
|
| | | /// <param name="device"></param>
|
| | | private void AddDeviceDetailRow(FrameListControl frame, CommonDevice device)
|
| | | /// <param name="deviceEnumInfo"></param>
|
| | | private void AddDeviceDetailRow(FrameListControl frame, CommonDevice device, DeviceEnumInfo deviceEnumInfo)
|
| | | {
|
| | | var rowInfo = this.dicRowInfo[device.DeviceAddr];
|
| | | rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>();
|
| | | if (rowInfo.dicDetailRow == null)
|
| | | {
|
| | | rowInfo.dicDetailRow = new Dictionary<string, DeviceRoomControl>();
|
| | | }
|
| | |
|
| | | //行控件
|
| | | var rowDevice = new DeviceRoomControl(device, frame.rowSpace / 2);
|
| | | rowDevice.MainKeys = LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | frame.AddChidren(rowDevice);
|
| | | rowDevice.frameTable.LeftOffset = Application.GetRealWidth(173) - ControlCommonResourse.XXLeft;
|
| | | rowDevice.InitControl();
|
| | |
| | | rowDevice.frameTable.AddBottomLine();
|
| | | //右箭头
|
| | | rowDevice.frameTable.AddRightArrow();
|
| | | //在线状态
|
| | | rowDevice.isOnline = device.IsOnline == 1;
|
| | |
|
| | | //保存控件
|
| | | string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | |
| | | if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(device) == true)
|
| | | {
|
| | | //定位
|
| | | var btnPosition = new NormalViewControl(Application.GetRealWidth(184), rowDevice.Height, false);
|
| | | var btnPosition = rowDevice.AddEditorControl(false);
|
| | | btnPosition.TextID = R.MyInternationalizationString.uFixedPosition;
|
| | | btnPosition.TextAlignment = TextAlignment.Center;
|
| | | btnPosition.TextSize = 12;
|
| | | btnPosition.TextColor = UserCenterColor.Current.White;
|
| | | btnPosition.BackgroundColor = 0xff4a4a4a;
|
| | | rowDevice.AddRightView(btnPosition);
|
| | | btnPosition.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //定位
|
| | |
| | |
|
| | | rowDevice.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new DeviceMacInfoEditorForm();
|
| | | form.AddForm(device.DeviceAddr);
|
| | | //隐藏菜单
|
| | | rowDevice.HideMenu();
|
| | | //界面跳转,记录当前的正在操作的设备的Mac地址
|
| | | this.nowActionDeviceMac = device.DeviceAddr;
|
| | | //显示设备功能配置界面
|
| | | this.ShowDeviceFunctionSettionForm(device, deviceEnumInfo);
|
| | | };
|
| | | //左滑菜单事件
|
| | | rowDevice.OpenMenuAction += () =>
|
| | | {
|
| | | if (this.oldShowRightMuneRow != null && this.oldShowRightMuneRow.MainKeys != rowDevice.MainKeys)
|
| | | {
|
| | | //左滑菜单只能滑一个
|
| | | this.oldShowRightMuneRow.HideMenu();
|
| | | }
|
| | | this.oldShowRightMuneRow = rowDevice;
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 显示设备功能配置界面
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="deviceEnumInfo"></param>
|
| | | private void ShowDeviceFunctionSettionForm(CommonDevice device, DeviceEnumInfo deviceEnumInfo)
|
| | | {
|
| | | //智能门锁
|
| | | if (deviceEnumInfo.BeloneType == DeviceBeloneType.A智能门锁)
|
| | | {
|
| | | var form = new DeviceMacInfoEditorForm();
|
| | | form.AddForm(device.DeviceAddr);
|
| | | }
|
| | | else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A窗帘)
|
| | | {
|
| | | var form = new DeviceMacInfoEditorForm();
|
| | | form.AddForm(device.DeviceAddr);
|
| | | }
|
| | | //pir传感器
|
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Sensor_Pir)
|
| | | {
|
| | | if (device is IASZone)
|
| | | {
|
| | | var form = new DevicePirSensor.PirSensorBindTargetSettionForm();
|
| | | form.AddForm((IASZone)device);
|
| | | }
|
| | | else
|
| | | {
|
| | | //pir传感器,他们又搞了个继电器在里面
|
| | | var form = new DeviceFunctionSettionForm();
|
| | | form.AddForm(device, true);
|
| | | }
|
| | | }
|
| | | //中央空调
|
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.AirConditioner_ZbGateway)
|
| | | {
|
| | | var form = new DeviceAirConditioner.IndoorUnitSettionForm();
|
| | | form.AddForm((AC)device);
|
| | | }
|
| | | //环境面板
|
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment)
|
| | | {
|
| | | var form = new DeviceFunctionSettionForm();
|
| | | form.AddForm(device, true);
|
| | | }
|
| | | //新风面板
|
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
|
| | | {
|
| | | //方悦新风面板的按键配置
|
| | | var form = new DevicePanel.PanelFangyueFreshAirButtonSettionForm();
|
| | | form.AddForm(device);
|
| | | }
|
| | | //方悦面板
|
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueTwo
|
| | | || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFour
|
| | | || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEight)
|
| | | {
|
| | | //干接点
|
| | | if (device.Type == DeviceType.OnOffSwitch)
|
| | | {
|
| | | //方悦面板的按键配置
|
| | | var form = new DevicePanel.PanelFangyueButtonSettionForm();
|
| | | form.AddForm(device);
|
| | | }
|
| | | //继电器
|
| | | else if (device.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | //方悦面板的功能配置
|
| | | var form = new DevicePanel.PanelFangyueFunctionSettionForm();
|
| | | form.AddForm(device);
|
| | | }
|
| | | else
|
| | | {
|
| | | var form = new DeviceFunctionSettionForm();
|
| | | form.AddForm(device, true);
|
| | | }
|
| | | }
|
| | | //面板设备
|
| | | else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A按键面板)
|
| | | {
|
| | | //干接点
|
| | | if (device.Type == DeviceType.OnOffSwitch)
|
| | | {
|
| | | //河东设备
|
| | | if (deviceEnumInfo.IsHdlDevice == true)
|
| | | {
|
| | | var form = new DevicePanel.PanelButtonSettionForm();
|
| | | form.AddForm(device);
|
| | | }
|
| | | else
|
| | | {
|
| | | var form = new DeviceDryContactSettionForm();
|
| | | form.AddForm(device);
|
| | | }
|
| | | }
|
| | | //继电器
|
| | | else if (device.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | //河东设备
|
| | | if (deviceEnumInfo.IsHdlDevice == true)
|
| | | {
|
| | | var form = new DevicePanel.PanelFunctionSettionForm();
|
| | | form.AddForm(device);
|
| | | }
|
| | | else
|
| | | {
|
| | | var form = new DeviceFunctionSettionForm();
|
| | | form.AddForm(device, true);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | var form = new DeviceFunctionSettionForm();
|
| | | form.AddForm(device, true);
|
| | | }
|
| | | }
|
| | | //如果是干接点
|
| | | else if (device.Type == DeviceType.OnOffSwitch)
|
| | | {
|
| | | var form = new DeviceDryContactSettionForm();
|
| | | form.AddForm(device);
|
| | | }
|
| | | else
|
| | | {
|
| | | var form = new DeviceFunctionSettionForm();
|
| | | form.AddForm(device, true);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 下拉刷新___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 滑动控件下拉刷新
|
| | | /// </summary>
|
| | | private async void ListViewBeginHeaderRefreshing()
|
| | | {
|
| | | //如果是在线的
|
| | | if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(GatewayResourse.NowSelectGateway) == true)
|
| | | {
|
| | | //检测广播到的这个网关是否拥有住宅ID
|
| | | ZbGateway realWay = null;
|
| | | if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, GatewayResourse.NowSelectGateway) == true)
|
| | | {
|
| | | //重新设置住宅ID(这个应该是不经过APP,直接把网关恢复了出厂设置)
|
| | | if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true)
|
| | | {
|
| | | //显示进度条
|
| | | ProgressBar.Show();
|
| | | int result2 = await HdlGatewayLogic.Current.ReBindNewGateway(realWay);
|
| | | //关闭进度条
|
| | | ProgressBar.Close();
|
| | | if (result2 == -1)
|
| | | {
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | if (this.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //获取全部设备
|
| | | int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(GatewayResourse.NowSelectGateway);
|
| | | if (this.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //隐藏下拉刷新特效
|
| | | listView.EndHeaderRefreshing();
|
| | | if (result != -1)
|
| | | {
|
| | | //重新刷新界面
|
| | | this.InitMiddleFrame(false);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备属性变更推送___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备属性变更推送
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | public override void DeviceAttributePush(CommonDevice device)
|
| | | {
|
| | | if (dicRowInfo.ContainsKey(device.DeviceAddr) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | var rowInfo = dicRowInfo[device.DeviceAddr];
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //刷新菜单
|
| | | rowInfo.MenuRow?.RefreshControlInfo(false);
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 开启设备在线线程___________________
|
| | | #region ■ 设备在线检测_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 开启设备在线线程
|
| | |
| | | this.StartCheckDeviceOnline();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备在线___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 开启设备在线监测
|
| | | /// </summary>
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //添加接收设备在线上报的监听
|
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormReceivePushOnline", ReceiveComandDiv.A设备在线上报, this.ReceiveDeviceStatu);
|
| | |
|
| | | string gwId = HdlGatewayLogic.Current.GetGatewayId(GatewayResourse.NowSelectGateway);
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //这里主要只是获取在线状态
|
| | | var zbway = HdlGatewayLogic.Current.GetLocalGateway(gwId);
|
| | | var result = await Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, this.ReceiveDeviceStatuPush);
|
| | | int statu = 0;
|
| | | var list = LocalDevice.Current.GetDeviceListFromGateway(zbway, ref statu, false, ShowErrorMode.NO);
|
| | | if (statu != -1)
|
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | //设置设备在线状态
|
| | | this.ReceiveDeviceStatu(list[i]);
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 接受设备在线推送(网关在线推送即在线)
|
| | | /// 接受设备状态
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void ReceiveDeviceStatuPush(CommonDevice device)
|
| | | private void ReceiveDeviceStatu(CommonDevice device)
|
| | | {
|
| | | lock (dicRowInfo)
|
| | | DeviceObjRowInfo rowInfo = null;
|
| | | if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true)
|
| | | {
|
| | | if (device == null || this.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | DeviceObjectControl row = null;
|
| | | if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true)
|
| | | {
|
| | | row = this.dicRowInfo[device.DeviceAddr].MenuRow;
|
| | | }
|
| | | if (row == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //刷新设备的在线状态
|
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
|
| | | if (localDevice != null)
|
| | | {
|
| | | //在线状态一样的话,不需要刷新
|
| | | if (localDevice.IsOnline == device.IsOnline)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //保存状态
|
| | | localDevice.IsOnline = device.IsOnline;
|
| | | localDevice.ReSave();
|
| | | }
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | if (row != null)
|
| | | {
|
| | | row.isOnline = device.IsOnline == 1;
|
| | | }
|
| | | });
|
| | | rowInfo = this.dicRowInfo[device.DeviceAddr];
|
| | | }
|
| | | if (rowInfo == null || rowInfo.MenuRow == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //刷新设备的在线状态
|
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
|
| | | if (localDevice != null)
|
| | | {
|
| | | //在线状态一样的话,不需要刷新
|
| | | if (localDevice.IsOnline == device.IsOnline)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //保存状态
|
| | | localDevice.IsOnline = device.IsOnline;
|
| | | localDevice.ReSave();
|
| | | }
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (rowInfo != null)
|
| | | {
|
| | | rowInfo.MenuRow.isOnline = device.IsOnline == 1;
|
| | | if (rowInfo.dicDetailRow != null)
|
| | | {
|
| | | foreach (var detailRow in rowInfo.dicDetailRow.Values)
|
| | | {
|
| | | detailRow.isOnline = rowInfo.MenuRow.isOnline;
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | });
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 传感器报警_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 开启传感器报警监视
|
| | | /// </summary>
|
| | | private void StartCheckDeviceAlarm()
|
| | | {
|
| | | HdlGatewayReceiveLogic.Current.AddAttributeEvent("DeviceListFormSensor", ReceiveComandDiv.A传感器上报, (device) =>
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //显示传感器上报的特效
|
| | | this.dicRowInfo[device.DeviceAddr].MenuRow?.StartSensorPushAppeal();
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 传感器报警_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 开启传感器报警监视
|
| | | /// </summary>
|
| | | private void StartCheckDeviceAlarm()
|
| | | {
|
| | | HdlDeviceAttributeLogic.Current.AddAttributeEvent("DeviceListFormSensor", "IASInfoReport", (device) =>
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | var row = this.dicRowInfo[device.DeviceAddr].MenuRow;
|
| | | if (row != null)
|
| | | {
|
| | | row.frameTable.StartSelectStatuAppeal(3000);
|
| | | }
|
| | | });
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 实现外部调用_______________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | if (this.dicRowInfo.ContainsKey(deviceAddr) == false)
|
| | | {
|
| | | var localDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceAddr);
|
| | | if (localDevice.Count == 0)
|
| | | {
|
| | | //针对单纯只有一个200端点的设备
|
| | | var ota = Common.LocalDevice.Current.GetOTADevice(deviceAddr);
|
| | | if (ota == null)
|
| | | {
|
| | | //入网之后,又把它删了
|
| | | return;
|
| | | }
|
| | | localDevice.Add(ota);
|
| | | }
|
| | | var rowNewInfo = new DeviceObjRowInfo();
|
| | | rowNewInfo.DeviceMac = deviceAddr;
|
| | | rowNewInfo.MacName = Common.LocalDevice.Current.GetDeviceMacName(localDevice[0]);
|
| | |
| | |
|
| | | //创建新的行
|
| | | this.AddDeviceMenuRow(deviceAddr);
|
| | |
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | /// <param name="listDevice"></param>
|
| | | private void MargeAllDeviceByMac(List<CommonDevice> listDevice)
|
| | | {
|
| | | //设备排序
|
| | | List<CommonDevice> listSort = Common.LocalDevice.Current.SortDeviceList(listDevice);
|
| | | //根据Mac全部分组
|
| | | var dic = new Dictionary<string, List<CommonDevice>>();
|
| | | foreach (CommonDevice device in listSort)
|
| | | foreach (CommonDevice device in listDevice)
|
| | | {
|
| | | if (device == null || device.DeviceAddr == null)
|
| | | {
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 关闭界面___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面关闭
|
| | | /// </summary>
|
| | | public override void CloseForm()
|
| | | {
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("DeviceListFormSensor");
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline");
|
| | |
|
| | | GatewayResourse.NowSelectGateway = null;
|
| | |
|
| | | base.CloseForm();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 界面重新激活事件___________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | public override int FormActionAgainEvent()
|
| | | {
|
| | | if (this.nowActionDeviceMac == null)
|
| | | if (this.nowActionDeviceMac != null)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | var rowInfo = this.dicRowInfo[nowActionDeviceMac];
|
| | | //检测这个设备是否被删除
|
| | | if (Common.LocalDevice.Current.GetDevicesByMac(nowActionDeviceMac).Count == 0)
|
| | | {
|
| | | //移除控件
|
| | | rowInfo.dicDetailRow = null;
|
| | | rowInfo.frameTable.RemoveFromParent();
|
| | |
|
| | | this.dicRowInfo.Remove(nowActionDeviceMac);
|
| | | rowInfo = null;
|
| | | }
|
| | | else
|
| | | {
|
| | | //刷新设备信息
|
| | | rowInfo.MenuRow?.RefreshControlInfo(true);
|
| | | if (rowInfo.dicDetailRow != null)
|
| | | var rowInfo = this.dicRowInfo[nowActionDeviceMac];
|
| | | //检测这个设备是否被删除 2020.01.13变更:追加Ota设备的判断
|
| | | if (Common.LocalDevice.Current.GetDevicesByMac(nowActionDeviceMac).Count == 0
|
| | | && Common.LocalDevice.Current.GetOTADevice(nowActionDeviceMac) == null)
|
| | | {
|
| | | foreach (var contr in rowInfo.dicDetailRow.Values)
|
| | | //移除控件
|
| | | rowInfo.dicDetailRow = null;
|
| | | rowInfo.frameTable.RemoveFromParent();
|
| | |
|
| | | this.dicRowInfo.Remove(nowActionDeviceMac);
|
| | | rowInfo = null;
|
| | | }
|
| | | else
|
| | | {
|
| | | //刷新设备信息
|
| | | rowInfo.MenuRow?.RefreshControlInfo(true);
|
| | | if (rowInfo.dicDetailRow != null)
|
| | | {
|
| | | contr?.RefreshControlInfo();
|
| | | foreach (var contr in rowInfo.dicDetailRow.Values)
|
| | | {
|
| | | contr?.RefreshControlInfo();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | this.gatewayViewRow.RefreshControl();
|
| | |
|
| | | return 1;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 关闭界面___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面关闭
|
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormSensor");
|
| | | HdlGatewayReceiveLogic.Current.RemoveEvent("DeviceListFormReceivePushOnline");
|
| | |
|
| | | GatewayResourse.NowSelectGateway = null;
|
| | |
|
| | | base.CloseFormBefore();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | //获取本地网关对象
|
| | | ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId);
|
| | | if (zbway == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway);
|
| | | if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false)
|
| | | {
|