| | |
| | | //在端点名字的后面附加【回路】字样
|
| | | dName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | await this.ReName(device, dName, ShowErrorMode.NO);
|
| | | this.ReName(device, dName, ShowErrorMode.NO);
|
| | | });
|
| | | }
|
| | | }
|
| | |
| | | /// <param name="device">设备对象</param>
|
| | | /// <param name="newName">新名字</param>
|
| | | /// <param name="mode">是否显示错误</param>
|
| | | public async Task<bool> ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES)
|
| | | public bool ReName(CommonDevice device, string newName, ShowErrorMode mode = ShowErrorMode.YES)
|
| | | {
|
| | | //先别管那么多,更改名字后,刷新设备缓存
|
| | | this.SetEpointName(device, newName);
|
| | |
| | | //成员只能修改自己本地的名字
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 3)
|
| | | {
|
| | | var result = await device.RenameDeviceNameAsync(device.DeviceAddr, device.DeviceEpoint, newName);
|
| | | var result = this.RenameDeviceNameAsync(device, newName);
|
| | | if (result == null || result.deviceRenameData == null || result.deviceRenameData.Result == 1)
|
| | | {
|
| | | //设备名称修改失败
|
| | |
| | | }
|
| | | return false;
|
| | | }
|
| | | //备份数据
|
| | | await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A端点名称, newName);
|
| | | }
|
| | | //修改设备名字的话,主页需要重新刷新
|
| | | Phone.UserView.UserPage.Instance.RefreshForm = true;
|
| | |
| | | /// <param name="listDevice">设备对象</param>
|
| | | /// <param name="newMacName">新名字</param>
|
| | | /// <param name="mode">是否显示错误</param>
|
| | | public async Task<bool> ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES)
|
| | | public bool ReMacName(List<CommonDevice> listDevice, string newMacName, ShowErrorMode mode = ShowErrorMode.YES)
|
| | | {
|
| | | if (listDevice.Count == 0)
|
| | | {
|
| | |
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 3)
|
| | | {
|
| | | //修改物理名字
|
| | | var result = await device.RenameDeviceMacNameAsync(device.DeviceAddr, device.DeviceEpoint, newMacName);
|
| | | var result = this.RenameDeviceMacNameAsync(device, newMacName);
|
| | | if (result == null || result.renameDeviceMacNameData == null || result.renameDeviceMacNameData.Result != 0)
|
| | | {
|
| | | //设备名称修改失败
|
| | |
| | | }
|
| | | return false;
|
| | | }
|
| | | //备份数据
|
| | | await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.AMac名称, newMacName);
|
| | | //如果它只有一个回路,则更改端点名字
|
| | | if (this.dicDeviceEpoint.ContainsKey(device.DeviceAddr) == true)
|
| | | {
|
| | | //只有一个端点
|
| | | if (this.dicDeviceEpoint[device.DeviceAddr].Count == 1)
|
| | | {
|
| | | return await this.ReName(device, newMacName);
|
| | | return this.ReName(device, newMacName);
|
| | | }
|
| | | //如果它有两个端点时,pir传感器特殊处理
|
| | | else if (this.dicDeviceEpoint[device.DeviceAddr].Count == 2)
|
| | |
| | | {
|
| | | if (myDevice.Type == DeviceType.IASZone)
|
| | | {
|
| | | return await this.ReName(myDevice, newMacName);
|
| | | return this.ReName(myDevice, newMacName);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | ///<summary >
|
| | | /// 修改设备mac名称
|
| | | /// <para>macName:设备名称</para>
|
| | | /// </summary>
|
| | | private CommonDevice.RenameDeviceMacNameAllData RenameDeviceMacNameAsync(CommonDevice device, string macName)
|
| | | {
|
| | | //如果当前是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename");
|
| | | }
|
| | |
|
| | | //获取编辑设备Mac名字的命令字符
|
| | | var sendData = this.GetReDeviceMacNameCommandText(device.DeviceAddr, device.DeviceEpoint, macName);
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon");
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | //加缓存
|
| | | Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceMacName(device, macName, "MacRename");
|
| | |
|
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.RenameDeviceMacNameData>(result.ReceiptData);
|
| | | return new CommonDevice.RenameDeviceMacNameAllData { renameDeviceMacNameData = tempData };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 修改设备端口(按键)名称
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <param name="deviceName">设备端点名字</param>
|
| | | /// <returns></returns>
|
| | | private CommonDevice.DeviceRenameAllData RenameDeviceNameAsync(CommonDevice device, string deviceName)
|
| | | {
|
| | | //如果当前是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename");
|
| | | }
|
| | | //获取编辑设备端点名字的命令字符
|
| | | var sendData = this.GetReDeviceEpointNameCommandText(device.DeviceAddr, device.DeviceEpoint, deviceName);
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon");
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | //加缓存
|
| | | Phone.ModelData.DeviceModelDataLogic.Current.ReDeviceEpointName(device, deviceName, "DeviceRename");
|
| | |
|
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceRenameResponseData>(result.ReceiptData);
|
| | | return new CommonDevice.DeviceRenameAllData { deviceRenameData = tempData };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取编辑设备Mac名字的命令字符
|
| | | /// </summary>
|
| | | /// <param name="deviceAddr"></param>
|
| | | /// <param name="deviceEpoint"></param>
|
| | | /// <param name="deviceName"></param>
|
| | | /// <returns></returns>
|
| | | public string GetReDeviceMacNameCommandText(string deviceAddr, int deviceEpoint, string deviceName)
|
| | | {
|
| | | var bytes = new byte[64];
|
| | | var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName);
|
| | | System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length);
|
| | | deviceName = Encoding.UTF8.GetString(bytes);
|
| | |
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 100 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "MacName", deviceName } };
|
| | | jObject.Add("Data", data);
|
| | | return jObject.ToString();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取编辑设备端点名字的命令字符
|
| | | /// </summary>
|
| | | /// <param name="deviceAddr"></param>
|
| | | /// <param name="deviceEpoint"></param>
|
| | | /// <param name="deviceName"></param>
|
| | | /// <returns></returns>
|
| | | public string GetReDeviceEpointNameCommandText(string deviceAddr, int deviceEpoint, string deviceName)
|
| | | {
|
| | | var bytes = new byte[64];
|
| | | var reamarkGwBytes = Encoding.UTF8.GetBytes(deviceName);
|
| | | System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 64 < reamarkGwBytes.Length ? 64 : reamarkGwBytes.Length);
|
| | | deviceName = Encoding.UTF8.GetString(bytes);
|
| | |
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", deviceAddr }, { "Epoint", deviceEpoint }, { "Cluster_ID", 0 }, { "Command", 96 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "DeviceName", deviceName } };
|
| | | jObject.Add("Data", data);
|
| | |
|
| | | return jObject.ToString();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="listdevice">设备对象(MAC地址必须要相同)</param>
|
| | | public async Task<bool> DeleteDevice(List<CommonDevice> listdevice)
|
| | | {
|
| | | var data = new CommonDevice.RemoveDeviceData();
|
| | | var info = new CommonDevice.RemoveDeviceListInfo();
|
| | | info.DeviceAddr = listdevice[0].DeviceAddr;
|
| | | data.DeviceAddrList.Add(info);
|
| | |
|
| | | //删一次的时候,它会把MAC地址下面全部的设备都删除
|
| | | var result = await listdevice[0].DeleteDeviceAsync(data);
|
| | | if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0)
|
| | | //虚拟住宅的话,不需要删除网关的设备
|
| | | if (Config.Instance.Home.IsVirtually == false)
|
| | | {
|
| | | //设备删除失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail);
|
| | | //拼接上【网关回复超时】的Msg
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
|
| | | var data = new CommonDevice.RemoveDeviceData();
|
| | | var info = new CommonDevice.RemoveDeviceListInfo();
|
| | | info.DeviceAddr = listdevice[0].DeviceAddr;
|
| | | data.DeviceAddrList.Add(info);
|
| | |
|
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | //删一次的时候,它会把MAC地址下面全部的设备都删除
|
| | | var result = await listdevice[0].DeleteDeviceAsync(data);
|
| | | if (result == null || result.removeDeviceResponseData == null || result.removeDeviceResponseData.Result != 0)
|
| | | {
|
| | | //设备删除失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail);
|
| | | //拼接上【网关回复超时】的Msg
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
|
| | |
|
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | //删除缓存的Ota设备
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据MAC地址,获取简约面板全部回路的设备对象
|
| | | /// </summary>
|
| | | /// <param name="listDevice"></param>
|
| | | /// <returns></returns>
|
| | | public List<CommonDevice> GetMutilfunctionPanelByMac(List<CommonDevice> listDevice, bool sort = true)
|
| | | {
|
| | | //和彪哥、设备和产品部同事确认:
|
| | | //简约多功能面板[不显示多余的回路,只显示携带的2个继电器和1个温湿度传感器
|
| | | var list = new List<CommonDevice>();
|
| | | foreach (var dev in listDevice)
|
| | | {
|
| | | if (dev.Type == DeviceType.TemperatureSensor)
|
| | | {
|
| | | if (dev.DeviceEpoint == 64)
|
| | | {
|
| | | list.Add(dev);
|
| | | }
|
| | | }
|
| | | else if (dev.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | list.Add(dev);
|
| | | }
|
| | | }
|
| | |
|
| | | if (sort == false)
|
| | | {
|
| | | return list;
|
| | | }
|
| | | list.Sort((obj1, obj2) =>
|
| | | {
|
| | | if (obj1.DeviceEpoint > obj2.DeviceEpoint)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | return -1;
|
| | | });
|
| | |
|
| | | return list;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据MAC地址,获取全部回路的设备对象(强制排序)
|
| | | /// </summary>
|
| | | /// <param name="DeviceAddr">Mac地址</param>
|
| | |
| | | {
|
| | | return dName;
|
| | | }
|
| | | if (this.IsMiniLight(device) == true)
|
| | | {
|
| | | //Mini夜灯
|
| | | return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
|
| | | }
|
| | |
|
| | | //如果这个设备只有一个回路的话,返回Mac名字给它
|
| | | if (this.GetDevicesCountByMac(device.DeviceAddr) <= 1)
|
| | | {
|
| | |
| | | unSelectPath = imageFilePath;
|
| | | selectPath = imageSelectFilePath;
|
| | | }
|
| | |
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | {
|
| | | //2020.05.18追加:如果记录的房间ID是不存在的话,则重新覆盖
|
| | | var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]);
|
| | | if (room == null)
|
| | | if (room == null || this.dicDeviceRoomId[listDevice[0].DeviceAddr] != roomId)
|
| | | {
|
| | | this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
|
| | | save = true;
|
| | |
| | | public bool IsHdlDevice(CommonDevice device)
|
| | | {
|
| | | return device.ManufacturerName == "HDL";
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 是否是Mini夜灯
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public bool IsMiniLight(CommonDevice device)
|
| | | {
|
| | | return device.DeviceAddr == "3737363534333231";
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Light.png";
|
| | | if (this.IsMiniLight(mainDevice) == true)
|
| | | {
|
| | | //mini夜灯
|
| | | mainDevice.IconPath = "Device/MiniNightLight.png";
|
| | | }
|
| | | }
|
| | | }
|
| | | //如果是三路继电器的回路的话,默认为灯光
|
| | |
| | | this.dicDeviceModelIdEnum["MPFA/TILE-ZB.18"] = "250-200-60003";//方悦新风面板
|
| | | this.dicDeviceModelIdEnum["MPTE3/TILE-ZB.18"] = "253-200-60003";//方悦环境面板
|
| | | this.dicDeviceModelIdEnum["MP2W/TILE-ZB.18"] = "256-200-60003";//窗帘面板
|
| | | this.dicDeviceModelIdEnum["MPTL4C/S-ZB.18"] = "212-200-60003";//简约多功能面板
|
| | | this.dicDeviceModelIdEnum["MPTE3/S-ZB.18"] = "230-200-60003";//简约环境面板
|
| | |
|
| | |
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200-60000";//pir传感器220
|
| | |
| | | this.dicDeviceModelIdEnum["MGCD01/ZB.10"] = "1306-1200-60000";//吸顶燃气传感器
|
| | |
|
| | | //PM2.5空气质量传感器 【该设备属于第三方设备,没有镜像ID】
|
| | | this.dicDeviceModelIdEnum["SZ_PM100"] = "1307-1200-60000";//PM2.5空气质量传感器 |
| | | this.dicDeviceModelIdEnum["MSPM25/M-ZB.10"] = "1307-1200-60000";//PM2.5空气质量传感器 |
| | |
|
| | | //=========★★继电器类(2300-2499)★★=========
|
| | | this.dicDeviceModelIdEnum["MPR0310-ZB.10"] = "2300-2300-60001";//3路继电器小模块
|
| | |
| | | /// 窗帘面板 镜像id:256
|
| | | /// </summary>
|
| | | ButtonPanel_Curtain = 256,
|
| | |
|
| | | /// <summary>
|
| | | /// 简约多功能面板 镜像ID:212
|
| | | /// </summary>
|
| | | ButtonPanel_SimpleMultifunction = 212,
|
| | | /// <summary>
|
| | | /// 简约环境面板
|
| | | /// </summary>
|
| | | ButtonPanel_SimpleEnvironment = 230,
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | /// <summary>
|
| | | /// 传感器
|