| | |
| | | using System;
|
| | | using Shared.Common;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
| | | rowMenu.InitControl();
|
| | | rowInfo.MenuRow = rowMenu;
|
| | | //向右图标
|
| | | var btnRight = rowMenu.frameTable.AddRightArrow();
|
| | | var btnRight = rowMenu.frameTable.AddMostRightEmptyIcon(58, 58);
|
| | | btnRight.UnSelectedImagePath = "Item/Next.png";
|
| | | btnRight.SelectedImagePath = "Item/Down.png";
|
| | | rowMenu.frameTable.ChangedChidrenBindMode(btnRight, ChidrenBindMode.NotBind);
|
| | |
|
| | | //提示新版本
|
| | | var btnNew = new InformationTipView(rowMenu.btnIcon);
|
| | |
| | | };
|
| | | }
|
| | |
|
| | | 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) =>
|
| | | {
|
| | | btnNew.Visible = false;
|
| | | var form = new DeviceMacInfoEditorForm();
|
| | | form.AddForm(deviceMac);
|
| | | //界面跳转,记录当前的正在操作的设备的Mac地址
|
| | | this.nowActionDeviceMac = deviceMac;
|
| | | };
|
| | | }
|
| | |
|
| | |
| | | //标题自己就是一个子控件
|
| | | 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.frameTable.AddBottomLine();
|
| | | //右箭头
|
| | | rowDevice.frameTable.AddRightArrow();
|
| | | //在线状态
|
| | | rowDevice.isOnline = device.IsOnline == 1;
|
| | |
|
| | | //保存控件
|
| | | string maikey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | |
| | |
|
| | | rowDevice.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new DeviceMacInfoEditorForm();
|
| | | form.AddForm(device.DeviceAddr);
|
| | | //界面跳转,记录当前的正在操作的设备的Mac地址
|
| | | this.nowActionDeviceMac = device.DeviceAddr;
|
| | | //显示设备功能配置界面
|
| | | this.ShowDeviceFunctionSettionForm(device, deviceEnumInfo);
|
| | | };
|
| | | }
|
| | |
|
| | | /// <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)
|
| | | {
|
| | | var form = new DevicePirSensor.PirSensorBindTargetSettionForm();
|
| | | form.AddForm((IASZone)device);
|
| | | }
|
| | | //中央空调
|
| | | else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.AirConditioner_ZbGateway)
|
| | | {
|
| | | var form = new DeviceAirConditioner.IndoorUnitSettionForm();
|
| | | form.AddForm((AC)device);
|
| | | }
|
| | | //面板设备
|
| | | 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 if (device.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | 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
|
| | |
| | | return;
|
| | | }
|
| | | 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);
|
| | | var result = Common.LocalDevice.Current.GetDeviceListFromGateway(zbway, false, this.ReceiveDeviceStatuPush, ShowErrorMode.NO);
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 接受设备在线推送(网关在线推送即在线)
|
| | | /// 接受设备在线推送
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void ReceiveDeviceStatuPush(CommonDevice device)
|
| | | {
|
| | | lock (dicRowInfo)
|
| | | {
|
| | | if (device == null || this.Parent == null)
|
| | | if (this.Parent == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | DeviceObjectControl row = null;
|
| | | DeviceObjRowInfo rowInfo = null;
|
| | | if (this.dicRowInfo.ContainsKey(device.DeviceAddr) == true)
|
| | | {
|
| | | row = this.dicRowInfo[device.DeviceAddr].MenuRow;
|
| | | rowInfo = this.dicRowInfo[device.DeviceAddr];
|
| | | }
|
| | | if (row == null)
|
| | | if (rowInfo == null || rowInfo.MenuRow == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
| | | localDevice.ReSave();
|
| | | }
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (row != null)
|
| | | if (rowInfo != null)
|
| | | {
|
| | | row.isOnline = device.IsOnline == 1;
|
| | | rowInfo.MenuRow.isOnline = device.IsOnline == 1;
|
| | | if (rowInfo.dicDetailRow != null)
|
| | | {
|
| | | foreach (var detailRow in rowInfo.dicDetailRow.Values)
|
| | | {
|
| | | detailRow.isOnline = rowInfo.MenuRow.isOnline;
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | /// <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)
|
| | | {
|
| | |
| | | /// </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];
|
| | | //检测这个设备是否被删除
|
| | | if (Common.LocalDevice.Current.GetDevicesByMac(nowActionDeviceMac).Count == 0)
|
| | | {
|
| | | 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();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | //获取本地网关对象
|
| | | ZbGateway zbway = HdlGatewayLogic.Current.GetLocalGateway(zbGatewayId);
|
| | | if (zbway == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | btnName.Text = HdlGatewayLogic.Current.GetGatewayName(zbway);
|
| | | if (HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(zbway) == false)
|
| | | {
|