| | |
| | | }
|
| | | }
|
| | | /// <summary>
|
| | | /// 本地所有设备的缓存(排序)
|
| | | /// 本地所有设备的缓存
|
| | | /// </summary>
|
| | | public List<CommonDevice> listAllDevice
|
| | | {
|
| | |
| | | {
|
| | | lock (dicAllDevice)
|
| | | {
|
| | | var list = new List<CommonDevice>();
|
| | | foreach (var device in dicAllDevice.Values)
|
| | | //先获取全部的Mac
|
| | | var listMac = new List<string>();
|
| | | foreach (var strMac in this.dicDeviceEpoint.Keys)
|
| | | {
|
| | | list.Add(device);
|
| | | listMac.Add(strMac);
|
| | | }
|
| | | return list;
|
| | | //根据MAC地址,获取全部回路的设备对象(强制排序)
|
| | | return this.GetDevicesByMac(listMac);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | //获取这个网关的本地所有设备
|
| | | string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
|
| | | List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID);
|
| | | //获取ota设备
|
| | | foreach (var ota in this.dicOTADevice.Values)
|
| | | {
|
| | | if (ota.CurrentGateWayId == gwID)
|
| | | {
|
| | | listLocalDevices.Add(ota);
|
| | | }
|
| | | }
|
| | |
|
| | | Dictionary<string, CommonDevice> dicExist = new Dictionary<string, CommonDevice>();
|
| | | foreach (var device in listLocalDevices)
|
| | | {
|
| | |
| | | for (int i = 0; i < listDevice.Count; i++)
|
| | | {
|
| | | var device = listDevice[i];
|
| | | //对未命名的设备重新命名
|
| | | if (this.GetSimpleEpointName(device) == string.Empty)
|
| | | //对未命名的虚拟设备重新命名
|
| | | if (device.DriveCode > 0 && this.GetSimpleEpointName(device) == string.Empty)
|
| | | {
|
| | | //根据设备类型获取名称
|
| | | var dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
|
| | | //虚拟设备的话,附加回路号
|
| | | if (device.DriveCode > 0)
|
| | | {
|
| | | //在端点名字的后面附加【回路】字样
|
| | | dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
|
| | | }
|
| | | //多回路设备的话,附加回路号
|
| | | else if (dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && dicDeviceEpoint[device.DeviceAddr].Count > 1)
|
| | | {
|
| | | var arry = dName.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | dName = arry[0].Trim();
|
| | | //在端点名字的后面附加【回路】字样
|
| | | dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
|
| | | }
|
| | | //在端点名字的后面附加【回路】字样
|
| | | dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | //只有完全获取的时候,才会去处理删除的问题
|
| | | if (statu == 1)
|
| | | if (statu != 1)
|
| | | {
|
| | | //如果本地和网关的设备不一致的时候,删除本地的设备
|
| | | foreach (var device in dicExist.Values)
|
| | | return statu;
|
| | | }
|
| | |
|
| | | //如果本地和网关的设备不一致的时候,删除本地的设备
|
| | | foreach (var device in dicExist.Values)
|
| | | {
|
| | | if (device is OTADevice)
|
| | | {
|
| | | this.DeleteMemmoryOtaDevice(device.DeviceAddr);
|
| | | }
|
| | | else
|
| | | {
|
| | | this.DeleteMemmoryDevice(device, true);
|
| | | }
|
| | |
| | | //备份数据
|
| | | await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac名称, newMacName);
|
| | | //如果它只有一个回路,则更改端点名字
|
| | | if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
|
| | | if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
|
| | | {
|
| | | return await this.ReName(device, newMacName);
|
| | | //只有一个端点
|
| | | if (this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
|
| | | {
|
| | | return await this.ReName(device, newMacName);
|
| | | }
|
| | | //如果它有两个端点时,pir传感器特殊处理
|
| | | else if (this.dicDeviceEpoint[device.DeviceAddr].Count == 2)
|
| | | {
|
| | | var myType = this.GetMyDeviceEnumInfo(listDevice);
|
| | | if (myType.ConcreteType == DeviceConcreteType.Sensor_Pir)
|
| | | {
|
| | | foreach (var myDevice in listDevice)
|
| | | {
|
| | | if (myDevice.Type == DeviceType.IASZone)
|
| | | {
|
| | | return await this.ReName(myDevice, newMacName);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return true;
|
| | |
| | | lock (dicAllDevice)
|
| | | {
|
| | | string mainKeys = this.GetDeviceMainKeys(device);
|
| | | if (this.dicAllDevice.ContainsKey(mainKeys) == false)
|
| | | if (this.dicAllDevice.ContainsKey(mainKeys) == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | this.dicAllDevice[mainKeys] = device;
|
| | | device.ReSave();
|
| | | //一般设备
|
| | | this.dicAllDevice[mainKeys] = device;
|
| | | device.ReSave();
|
| | |
|
| | | //添加自动备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
|
| | | //添加自动备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
|
| | | }
|
| | | else if (this.dicOTADevice.ContainsKey(mainKeys) == true)
|
| | | {
|
| | | //Ota设备
|
| | | this.dicOTADevice[mainKeys] = (OTADevice)device;
|
| | | device.ReSave();
|
| | |
|
| | | //添加自动备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | //删除文件
|
| | | //删除缓存的Ota设备
|
| | | this.DeleteMemmoryOtaDevice(listdevice[0].DeviceAddr);
|
| | | //删除一般设备文件
|
| | | foreach (CommonDevice device in listdevice)
|
| | | {
|
| | | this.DeleteMemmoryDevice(device);
|
| | | }
|
| | |
|
| | | if (this.dicDeviceRoomId.ContainsKey(listdevice[0].DeviceAddr) == true)
|
| | | {
|
| | | //移除真实设备的房间索引
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 删除缓存的设备
|
| | | /// 删除缓存的一般设备
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <param name="deleteRoom">是否从房间删除</param>
|
| | | public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
|
| | | {
|
| | | if (deleteRoom == true && Room.CurrentRoom != null)
|
| | | if (deleteRoom == true && HdlRoomLogic.Current.CurrentRoom != null)
|
| | | {
|
| | | //从房间中删除
|
| | | Room.CurrentRoom.DeleteDevice(device);
|
| | | HdlRoomLogic.Current.DeleteDevice(device);
|
| | | //删除我的喜爱的设备
|
| | | Room.CurrentRoom.DeleteLoveDevice(device);
|
| | | HdlRoomLogic.Current.DeleteLoveDevice(device);
|
| | | }
|
| | |
|
| | | //删除缓存
|
| | |
| | | if (this.dicAllDevice.ContainsKey(mainKeys) == true)
|
| | | {
|
| | | this.dicAllDevice.Remove(mainKeys);
|
| | | }
|
| | | if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
|
| | | {
|
| | | //变更端点数
|
| | | this.dicDeviceEpoint[device.DeviceAddr].Remove(device.DeviceEpoint);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | HdlAutoBackupLogic.DeleteFile(device.FilePath);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 删除缓存的Ota设备
|
| | | /// </summary>
|
| | | /// <param name="macAdrr"></param>
|
| | | /// <param name="ePoint"></param>
|
| | | public void DeleteMemmoryOtaDevice(string macAdrr, int ePoint = 200)
|
| | | {
|
| | | //删除200端口文件
|
| | | string otaKeys = this.GetDeviceMainKeys(device.DeviceAddr, 200);
|
| | | string otaKeys = this.GetDeviceMainKeys(macAdrr, ePoint);
|
| | | if (this.dicOTADevice.ContainsKey(otaKeys) == true)
|
| | | {
|
| | | string otaFile = this.dicOTADevice[otaKeys].FilePath;
|
| | |
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 3)
|
| | | {
|
| | | //成员的话,直接删除,没有商量的余地
|
| | | Global.DeleteFilebyHomeId(filePath);
|
| | | Global.DeleteFilebyHomeId(otaFile);
|
| | | }
|
| | | else
|
| | | {
|
| | | //变更:搞掉它,不留了
|
| | | Global.DeleteFilebyHomeId(filePath);
|
| | | Global.DeleteFilebyHomeId(otaFile);
|
| | | //删除自动备份
|
| | | HdlAutoBackupLogic.DeleteFile(otaFile);
|
| | | }
|
| | |
| | | /// <summary>
|
| | | /// 根据网关ID获取所有的设备
|
| | | /// </summary>
|
| | | /// <param name="gwId">网关ID</param>
|
| | | /// <param name="gwId">网关ID</param>>
|
| | | /// <returns></returns>
|
| | | public List<CommonDevice> GetDeviceByGatewayID(string gwId)
|
| | | {
|
| | | List<CommonDevice> list = new List<CommonDevice>();
|
| | | lock (dicAllDevice)
|
| | | {
|
| | | //各网关的所有设备
|
| | | var listMac = new List<string>();
|
| | | //各网关的所有设备的Mac
|
| | | foreach (CommonDevice device in this.dicAllDevice.Values)
|
| | | {
|
| | | if (gwId == device.CurrentGateWayId)
|
| | | {
|
| | | list.Add(device);
|
| | | listMac.Add(device.DeviceAddr);
|
| | | }
|
| | | }
|
| | | return this.GetDevicesByMac(listMac);
|
| | | }
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据MAC地址,获取全部回路的设备对象(强制排序)
|
| | | /// </summary>
|
| | | /// <param name="DeviceAddr">Mac地址</param>
|
| | | /// <returns></returns>
|
| | | public List<CommonDevice> GetDevicesByMac(List<string> listMacAddr)
|
| | | {
|
| | | //先排序
|
| | | listMacAddr.Sort();
|
| | |
|
| | | var list = new List<CommonDevice>();
|
| | | foreach (string strMac in listMacAddr)
|
| | | {
|
| | | var listEpoint = new List<int>();
|
| | | //获取全部的端点
|
| | | foreach (int epoint in this.dicDeviceEpoint[strMac])
|
| | | {
|
| | | listEpoint.Add(epoint);
|
| | | }
|
| | | //然后排序
|
| | | listEpoint.Sort();
|
| | | foreach (int epoint in listEpoint)
|
| | | {
|
| | | var device = this.GetDevice(strMac, epoint);
|
| | | if (device != null)
|
| | | {
|
| | | list.Add(device);
|
| | | }
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据MAC地址,获取全部回路的数量
|
| | | /// </summary>
|
| | | /// <param name="DeviceAddr">Mac地址</param>
|
| | |
| | | return this.dicOTADevice[mainkeys];
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取特殊的,没有其他回路,单纯只有200端点的OTA设备
|
| | | /// </summary>
|
| | | /// <param name="gwId">网关ID</param>
|
| | | /// <returns></returns>
|
| | | public List<OTADevice> GetSpecialOtaDevice(string gwId)
|
| | | {
|
| | | var list = new List<OTADevice>();
|
| | | foreach (var ota in this.dicOTADevice.Values)
|
| | | {
|
| | | if (ota.CurrentGateWayId != gwId)
|
| | | {
|
| | | //不是同一个网关
|
| | | continue;
|
| | | }
|
| | | //没有其他回路
|
| | | if (dicDeviceEpoint.ContainsKey(ota.DeviceAddr) == false
|
| | | || dicDeviceEpoint[ota.DeviceAddr].Count == 0)
|
| | | {
|
| | | //目前只针对中央空调
|
| | | if (ota.ModelIdentifier == "MAC/GW-ZB.10")
|
| | | {
|
| | | list.Add(ota);
|
| | | }
|
| | | }
|
| | | }
|
| | | return list;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取设备名称_______________________
|
| | |
| | | return dName;
|
| | | }
|
| | | //根据设备类型获取名称
|
| | | dName = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
|
| | | var tempValue = this.GetDeviceObjectText(new List<CommonDevice>() { device }, false);
|
| | | var arry = tempValue.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | dName = arry[0].Trim();
|
| | |
|
| | | //如果是虚拟设备
|
| | | if (device.DriveCode > 0
|
| | | || (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count > 1))
|
| | | if (device.DriveCode > 0)
|
| | | {
|
| | | var arry = dName.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | dName = arry[0].Trim();
|
| | | //在端点名字的后面附加【回路】字样
|
| | | dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
|
| | | return dName;
|
| | | }
|
| | |
|
| | | //获取设备类型
|
| | | var deviceInfoType = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
|
| | | if (deviceInfoType.BeloneType == Common.DeviceBeloneType.A按键面板 && device.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | //面板的最后一个回路是温度传感器
|
| | | dName += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId11);
|
| | | }
|
| | | else if (deviceInfoType.ConcreteType == Common.DeviceConcreteType.Sensor_Pir)
|
| | | {
|
| | | //pir传感器,它又搞特殊东西,传感器自身用自己的名字,继电器回路的话……
|
| | | if (device.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | dName += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2300);
|
| | | }
|
| | | }
|
| | | else if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true && this.dicDeviceEpoint[device.DeviceAddr].Count > 1)
|
| | | {
|
| | | //XXXXX(N回路)
|
| | | dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
|
| | | }
|
| | |
|
| | | return dName;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | //获取设备【图标】
|
| | | this.GetDeviceIcon(device, ref unSelectFilePath, ref selectFilePath);
|
| | | if (btnIcon.UnSelectedImagePath != unSelectFilePath)
|
| | | {
|
| | | btnIcon.UnSelectedImagePath = unSelectFilePath;
|
| | | }
|
| | | if (btnIcon.SelectedImagePath != selectFilePath)
|
| | | {
|
| | | btnIcon.SelectedImagePath = selectFilePath;
|
| | | }
|
| | | }
|
| | |
|
| | | btnIcon.UnSelectedImagePath = unSelectFilePath;
|
| | | btnIcon.SelectedImagePath = selectFilePath;
|
| | | /// <summary>
|
| | | /// 设置设备【图标】到指定的控件(注意,此函数设置的选择状态的图片是白色的)
|
| | | /// </summary>
|
| | | /// <param name="btnIcon">控件对象</param>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <returns></returns>
|
| | | public void SetDeviceIconToControl2(Button btnIcon, CommonDevice device)
|
| | | {
|
| | | if (device == null)
|
| | | {
|
| | | btnIcon.UnSelectedImagePath = "Device/ThirdPartyDevice.png";
|
| | | return;
|
| | | }
|
| | | string unSelectFilePath = device.IconPath;
|
| | | string selectFilePath = unSelectFilePath.Replace(".png", "Selected2.png");
|
| | |
|
| | | //获取设备【图标】
|
| | | if (btnIcon.UnSelectedImagePath != unSelectFilePath)
|
| | | {
|
| | | btnIcon.UnSelectedImagePath = unSelectFilePath;
|
| | | }
|
| | | if (btnIcon.SelectedImagePath != selectFilePath)
|
| | | {
|
| | | btnIcon.SelectedImagePath = selectFilePath;
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备UI相关_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备所匹配的设备UI对象
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public DeviceUI GetDeviceUI(CommonDevice device)
|
| | | {
|
| | | //创建一个新的东西给过去
|
| | | var deviceUi = new DeviceUI();
|
| | | deviceUi.DeviceAddr = device.DeviceAddr;
|
| | | deviceUi.DeviceEpoint = device.DeviceEpoint;
|
| | | return deviceUi;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备所匹配的设备UI对象
|
| | | /// </summary>
|
| | | /// <param name="filePath"></param>
|
| | | /// <returns></returns>
|
| | | public DeviceUI GetDeviceUI(string filePath)
|
| | | {
|
| | | string[] arry = filePath.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | if (arry.Length != 4)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | //创建一个新的东西给过去
|
| | | var deviceUi = new DeviceUI();
|
| | | deviceUi.DeviceAddr = arry[2];
|
| | | deviceUi.DeviceEpoint = Convert.ToInt32(arry[3]);
|
| | | return deviceUi;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取自定义的设备类型_______________
|
| | |
|
| | | /// <summary>
|
| | |
| | | return info;
|
| | | }
|
| | | //获取第三方设备的【设备类型】
|
| | | return this.GetNotHdlMyDeviceEnumInfo(listdevice);
|
| | | info = this.GetNotHdlMyDeviceEnumInfo(listdevice);
|
| | | //这里再次判断是否是河东设备,有可能它的模块ID写错了
|
| | | info.IsHdlDevice = this.IsHdlDevice(checkDevice);
|
| | |
|
| | | return info;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | return null;
|
| | | }
|
| | | string modelKeys = device.ModelIdentifier;
|
| | | //交换一下模块ID(麦乐克那边的传感器)
|
| | | this.ChangedDeviceModeId(ref modelKeys);
|
| | |
|
| | | if (this.dicDeviceModelIdEnum.ContainsKey(modelKeys) == false)
|
| | | {
|
| | | //没有匹配到模块ID,则直接走第三方设备的判断
|
| | |
| | | //如果设备只有一个回路,如果改变了真实设备区域,则它的回路的区域也一起改了
|
| | | if (saveRoadDevice == true && listDevice != null && listDevice.Count == 1)
|
| | | {
|
| | | Common.Room.CurrentRoom.ChangedRoom(listDevice[0], roomId, false);
|
| | | if (listDevice[0] is OTADevice)
|
| | | {
|
| | | //单纯只是Ota设备则不处理
|
| | | return;
|
| | | }
|
| | | HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | //未分配区域
|
| | | return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | var room = Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | if (room != null)
|
| | | {
|
| | | return room.Name;
|
| | |
| | | {
|
| | | return null;
|
| | | }
|
| | | return Room.CurrentRoom.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | return HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备排序___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备排序
|
| | | /// </summary>
|
| | | /// <param name="i_listDevice">请确保这个东西已经按mac和端点排序了</param>
|
| | | /// <returns></returns>
|
| | | public List<CommonDevice> SortDeviceByBelongType(List<CommonDevice> i_listDevice)
|
| | | {
|
| | | //获取排序规则
|
| | | var listRule = this.GetBelongTypeSortRule();
|
| | | var dicDevice = new Dictionary<DeviceBeloneType, List<CommonDevice>>();
|
| | | dicDevice[DeviceBeloneType.A未知设备] = new List<CommonDevice>();
|
| | |
|
| | | foreach (var device in i_listDevice)
|
| | | {
|
| | | //获取所属类型
|
| | | var typeInfo = this.GetDeviceBelongEnumInfo(device);
|
| | | if (listRule.Contains(typeInfo.BeloneType) == false)
|
| | | {
|
| | | //不在排序范围内,都丢在最后面
|
| | | dicDevice[DeviceBeloneType.A未知设备].Add(device);
|
| | | continue;
|
| | | }
|
| | | if (dicDevice.ContainsKey(typeInfo.BeloneType) == false)
|
| | | {
|
| | | dicDevice[typeInfo.BeloneType] = new List<CommonDevice>();
|
| | | }
|
| | | dicDevice[typeInfo.BeloneType].Add(device);
|
| | | }
|
| | |
|
| | | var listSort = new List<CommonDevice>();
|
| | | foreach (var myType in listRule)
|
| | | {
|
| | | //根据规则顺序,添加设备
|
| | | if (dicDevice.ContainsKey(myType) == false || dicDevice[myType].Count == 0)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | listSort.AddRange(dicDevice[myType]);
|
| | | }
|
| | |
|
| | | return listSort;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备所属类型的的排序规则
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public HashSet<DeviceBeloneType> GetBelongTypeSortRule()
|
| | | {
|
| | | //谁在前面,谁就优先显示
|
| | | var list = new HashSet<DeviceBeloneType>();
|
| | | list.Add(DeviceBeloneType.A灯光);
|
| | | list.Add(DeviceBeloneType.A彩灯);
|
| | | list.Add(DeviceBeloneType.A开关);
|
| | | list.Add(DeviceBeloneType.A插座);
|
| | | list.Add(DeviceBeloneType.A调光器);
|
| | | list.Add(DeviceBeloneType.A窗帘);
|
| | | list.Add(DeviceBeloneType.A空调);
|
| | | list.Add(DeviceBeloneType.A继电器);
|
| | | list.Add(DeviceBeloneType.A干接点);
|
| | | list.Add(DeviceBeloneType.A智能门锁);
|
| | | list.Add(DeviceBeloneType.A智能空开);
|
| | | list.Add(DeviceBeloneType.A传感器);
|
| | |
|
| | | //其他的看着办呗,都是排在后面的,都归为这个属性
|
| | | list.Add(DeviceBeloneType.A未知设备);
|
| | | |
| | | return list;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <returns></returns>
|
| | | public string GetDeviceMainKeys(CommonDevice device)
|
| | | {
|
| | | return device.DeviceAddr + device.DeviceEpoint;
|
| | | return this.GetDeviceMainKeys(device.DeviceAddr, device.DeviceEpoint);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public string GetDeviceMainKeys(string DeviceAddr, int DeviceEpoint)
|
| | | {
|
| | | return DeviceAddr + DeviceEpoint;
|
| | | return DeviceAddr + "_" + DeviceEpoint;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | statu = 2;
|
| | | }
|
| | | } |
| | | |
| | | statu = 1; |
| | | return listDevice; |
| | | }
|
| | |
|
| | |
| | | //*********************************************************************
|
| | | //新设备添加方法:
|
| | | //1、在这里填写上模块ID,然后是 DeviceConcreteType ,然后是 DeviceBeloneType
|
| | | //2、然后在最下面添加【设备的具体类型】,【设备的所属类型】
|
| | | //3、已设备的具体类型为名字(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
|
| | | //4、添加R文件,添加Language文件
|
| | | //2、然后在最下面的【自定义设备类型】折叠栏里添加【设备的具体类型】,【设备的所属类型】
|
| | | //3、以设备的具体类型为名字(去掉【-】)添加设备的【所属图片】,【真实物理图片】。回路图片需要特殊处理
|
| | | //4、添加R文件(uDeviceModelId),添加Language文件
|
| | | //5、如果需要共有图片,则在这个函数的最底下添加
|
| | | //*********************************************************************
|
| | |
|
| | | //=========★★开合帘类(100-199)★★=========
|
| | |
| | | this.dicDeviceModelIdEnum["MPT4R4L/S-ZB.18"] = "220-200";//简约4按键面板
|
| | | this.dicDeviceModelIdEnum["MPT3R3L/S-ZB.18"] = "221-200";//简约3按键面板
|
| | | this.dicDeviceModelIdEnum["MPT2R2L/S-ZB.18"] = "222-200";//简约2按键面板
|
| | | this.dicDeviceModelIdEnum["MPT4SC/S-ZB.18"] = "224-200";//简约4按键场景面板
|
| | | this.dicDeviceModelIdEnum["MPT2W/S-ZB.18"] = "226-200";//简约2路窗帘面板
|
| | | this.dicDeviceModelIdEnum["MP2B/TILE-ZB.18"] = "240-200";//方悦单开双控面板
|
| | | this.dicDeviceModelIdEnum["MP4B/TILE-ZB.18"] = "241-200";//方悦双开四控面板
|
| | | this.dicDeviceModelIdEnum["MP8B/TILE-ZB.18"] = "242-200";//方悦四开八控面板
|
| | | this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200";//方悦新风面板
|
| | | this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200";//方悦环境面板
|
| | | this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200";//窗帘面板
|
| | |
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200";//pir传感器220
|
| | |
| | |
|
| | | //=========★★继电器类(2300-2499)★★=========
|
| | | this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300";//3路继电器小模块
|
| | | this.dicDeviceModelIdEnum["MFA01-ZB1.0"] = "2310-2300";//方悦新风小模块
|
| | |
|
| | | //=========★★调光器类(2500-2799)★★=========
|
| | | this.dicDeviceModelIdEnum["MPD0101-ZB.10"] = "2500-2500";//1路调光器小模块
|
| | |
|
| | | //=========★★智能门锁类(2800-????)★★=========
|
| | | this.dicDeviceModelIdEnum["H06C"] = "2800-2800";//智能门锁(H06C)
|
| | | this.dicDeviceModelIdEnum["S-one"] = "2802-2800";//智能门锁(S-one)
|
| | |
|
| | | //=========★★空调类(3600-3899)★★=========
|
| | | this.dicDeviceModelIdEnum["MAC/GW-ZB.10"] = "3600-3600";//zigbee空调网关模块
|
| | |
| | |
|
| | |
|
| | | //✩✩✩✩✩需要共有的图片对象✩✩✩✩✩
|
| | | //两者都是DeviceConcreteType
|
| | | //Keys:指定的设备 value:沿用的图片是哪款设备的
|
| | | this.dicPictrueShard = new Dictionary<string, string>();
|
| | | this.dicPictrueShard["ButtonPanel_SimpleFour"] = "ButtonPanel_Four";//简约4按键面板 沿用 4按键的图标
|
| | | this.dicPictrueShard["ButtonPanel_SimpleThree"] = "ButtonPanel_Three";//简约3按键面板 沿用 3按键的图标
|
| | | this.dicPictrueShard["ButtonPanel_SimpleTwo"] = "ButtonPanel_Two";//简约2按键面板 沿用 2按键的图标
|
| | | this.dicPictrueShard["IntelligentLocks_Sone"] = "IntelligentLocks_H06C";//S-one的门锁图片沿用H06C的图标
|
| | |
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | #region ■ 自定义设备类型_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// <para>仅限底层使用:设备的具体【设备类型】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的值)</para>
|
| | | /// <para>仅限底层使用:设备的具体【设备类型】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值)</para>
|
| | | /// <para>变量名可以作为【设备类型】图片,这个值是瞎写的,没什么特殊意义</para>
|
| | | /// </summary>
|
| | | public enum DeviceConcreteType
|
| | | {
|
| | | //定义规则:【设备类型】图片名字=LocalDevice里面dicDeviceModelIdEnum所指定的值
|
| | | //定义规则:【设备类型】图片名字=LocalDevice里面dicDeviceModelIdEnum所指定的DeviceConcreteType值
|
| | |
|
| | | /// <summary>
|
| | | /// 未知设备
|
| | |
| | | /// 简约2按键面板 镜像id:222
|
| | | /// </summary>
|
| | | ButtonPanel_SimpleTwo = 222,
|
| | | /// <summary>
|
| | | /// 简约4按键场景面板 镜像id:224
|
| | | /// </summary>
|
| | | ButtonPanel_FourButtonScene = 224,
|
| | | /// <summary>
|
| | | /// 简约2路窗帘面板 镜像id:226
|
| | | /// </summary>
|
| | | ButtonPanel_TwoButtonCurtain = 226,
|
| | | /// <summary>
|
| | | /// 方悦2按键轻触式面板 镜像id:240
|
| | | /// </summary>
|
| | | ButtonPanel_FangyueTwo = 240,
|
| | | /// <summary>
|
| | | /// 方悦4按键轻触式面板 镜像id:241
|
| | | /// </summary>
|
| | | ButtonPanel_FangyueFour = 241,
|
| | | /// <summary>
|
| | | /// 方悦8按键轻触式面板 镜像id:242
|
| | | /// </summary>
|
| | | ButtonPanel_FangyueEight = 242,
|
| | | /// <summary>
|
| | | /// 方悦新风面板 镜像id:250
|
| | | /// </summary>
|
| | | ButtonPanel_FangyueFreshAir = 250,
|
| | | /// <summary>
|
| | | /// 方悦环境面板 镜像id:253
|
| | | /// </summary>
|
| | | ButtonPanel_FangyueEnvironment = 253,
|
| | | /// <summary>
|
| | | /// 窗帘面板 镜像id:256
|
| | | /// </summary>
|
| | | ButtonPanel_Curtain = 256,
|
| | |
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | /// <summary>
|
| | |
| | | /// 三路继电器 镜像id:2300
|
| | | /// </summary>
|
| | | Relay_ThreeLoad = 2300,
|
| | |
|
| | | /// <summary>
|
| | | /// 方悦新风小模块 镜像id:2310
|
| | | /// </summary>
|
| | | Relay_FangyueFreshAirModul = 2310,
|
| | | |
| | | //=========★★调光器类(2500-2799)★★=========
|
| | | /// <summary>
|
| | | /// 调光器
|
| | |
| | | /// H06C
|
| | | /// </summary>
|
| | | IntelligentLocks_H06C = 2800,
|
| | | /// <summary>
|
| | | /// S-one
|
| | | /// </summary>
|
| | | IntelligentLocks_Sone = 2802,
|
| | |
|
| | | //=========★★彩灯类(????-????)★★=========
|
| | | /// <summary>
|
| | |
| | |
|
| | | //=========★★其他类(????-????)★★=========
|
| | | /// <summary>
|
| | | /// 干接点
|
| | | /// 干接点(注意,它属于其他类,不是设备类型)
|
| | | /// </summary>
|
| | | DryContact = -10000,
|
| | | /// <summary>
|
| | | /// 灯光(注意,它输入其他类,不是设备类型)
|
| | | /// 灯光(注意,它属于其他类,不是设备类型)
|
| | | /// </summary>
|
| | | Light = -10001,
|
| | | /// <summary>
|
| | | /// 插座
|
| | | /// 插座(注意,它属于其他类,不是设备类型)
|
| | | /// </summary>
|
| | | Socket1 = -10002,
|
| | | /// <summary>
|
| | | /// 开关
|
| | | /// 开关(注意,它属于其他类,不是设备类型)
|
| | | /// </summary>
|
| | | Switch = -10003,
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// <para>仅限底层使用:设备所属的【设备种类】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的值)</para>
|
| | | /// <para>仅限底层使用:设备所属的【设备种类】,自定义与模块id关联的枚举(值为LocalDevice里面dicDeviceModelIdEnum所指定的DeviceBeloneType值)</para>
|
| | | /// <para>这个值是瞎写的,没什么特殊意义</para>
|
| | | /// </summary>
|
| | | public enum DeviceBeloneType
|