| | |
| | | //添加缓存
|
| | | this.AddDeviceToMemory(ref device);
|
| | |
|
| | | //移除存在的设备内存 |
| | | //移除存在的设备内存
|
| | | string maikey = this.GetDeviceMainKeys(device);
|
| | | if (dicExist.ContainsKey(maikey) == true)
|
| | | {
|
| | |
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //修改设备名字的话,主页需要重新刷新
|
| | | Phone.UserView.UserPage.Instance.RefreshForm = true;
|
| | | Phone.UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | | //修改设备名字的话,主页需要重新刷新
|
| | | Phone.UserView.UserPage.Instance.RefreshForm = true;
|
| | | Phone.UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | //获取编辑设备Mac名字的命令字符
|
| | | var sendData = this.GetReDeviceMacNameCommandText(device.DeviceAddr, device.DeviceEpoint, macName);
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon");
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "MacRename", sendData, "MacRename_Respon", 8);
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return null;
|
| | |
| | | }
|
| | | //获取编辑设备端点名字的命令字符
|
| | | var sendData = this.GetReDeviceEpointNameCommandText(device.DeviceAddr, device.DeviceEpoint, deviceName);
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon");
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "DeviceRename", sendData, "DeviceRenameRespon", 8);
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return null;
|
| | |
| | | public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
|
| | | {
|
| | | //删除缓存设备的话,主页需要重新刷新
|
| | | Phone.UserView.UserPage.Instance.RefreshForm = true;
|
| | | Phone.UserView.UserPage.Instance.RefreshAllForm = true;
|
| | |
|
| | | if (deleteRoom == true)
|
| | | {
|
| | |
| | | //传感器除了Pir都没有定位功能
|
| | | return true;
|
| | | }
|
| | | else if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_SphericalMotion)
|
| | | {
|
| | | //球型移动传感器虽然是电池设备,但是它有定位功能
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | |
| | | { |
| | | return true; |
| | | } |
| | | return false;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 检测设备是否拥有一键同步功能
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public bool DeviceIsCanSynchronization(CommonDevice device)
|
| | | {
|
| | | //获取设备类型的
|
| | | var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
|
| | | if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | |
| | | public List<string> GetAllDeviceFile()
|
| | | {
|
| | | List<string> listDeviceFile = new List<string>();
|
| | | List<string> listAllFile = Global.FileListByHomeId(); |
| | | List<string> listAllFile = HdlFileLogic.Current.GetRootPathListFile(); |
| | | |
| | | foreach (string file in listAllFile)
|
| | | {
|
| | |
| | | info.ConcreteType = DeviceConcreteType.Sensor_DoorWindow;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1301;
|
| | | }
|
| | | else if (iasZone.IasDeviceType == 541)
|
| | | {
|
| | | //球型移动传感器
|
| | | info.ConcreteType = DeviceConcreteType.Sensor_SphericalMotion;
|
| | | info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1205;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | private void InitRealDeviceRoomId()
|
| | | {
|
| | | this.dicDeviceRoomId = new Dictionary<string, string>();
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
|
| | | var strData = UserCenterLogic.LoadFileContent(fullName);
|
| | | string fullName = DirNameResourse.DeviceRoomIdFile;
|
| | | var strData = HdlFileLogic.Current.ReadFileTextContent(fullName);
|
| | | if (strData != null)
|
| | | {
|
| | | this.dicDeviceRoomId = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(strData);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取全部物理设备所属房间的记录
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public Dictionary<string, string> GetAllRealDeviceRoomData()
|
| | | {
|
| | | return this.dicDeviceRoomId;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | if (save == true)
|
| | | {
|
| | | //保存记录
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
|
| | | UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
|
| | |
|
| | | //添加自动备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
|
| | |
| | | return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
|
| | | return HdlRoomLogic.Current.GetFloorRoomName(room);
|
| | | return HdlRoomLogic.Current.GetRoomName(room);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | return;
|
| | | }
|
| | | //保存记录
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
|
| | | UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
|
| | |
|
| | | //添加自动备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
|
| | |
| | |
|
| | | #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 listCheck = new HashSet<string>();
|
| | | var listReturn = new List<CommonDevice>();
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | if (listCheck.Contains(device.DeviceAddr) == false)
|
| | | {
|
| | | listCheck.Add(device.DeviceAddr);
|
| | | listReturn.Add(device);
|
| | | }
|
| | | }
|
| | | return listReturn;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | var listDevice = this.GetDevicesByMac(i_device.DeviceAddr, false);
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | | //0:离线 1:在线 2:正在刷新状态 |
| | | //0:离线 1:在线 2:正在刷新状态
|
| | | bool statu = i_device.IsOnline == 1 || i_device.IsOnline == 2;
|
| | | if (statu == true)
|
| | | {
|
| | |
| | | { |
| | | return false; |
| | | } |
| | | }
|
| | |
|
| | | //如果是新风面板或环境面板,则都不显示任何回路
|
| | | var myInfoTypeTemp = LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { i_device });
|
| | | if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir || myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleEnvironment)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (myInfoTypeTemp.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
|
| | | {
|
| | | if (i_device.Type != DeviceType.OnOffOutput)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
| | | mainDevice.ModelIdentifier = device.DeviceInfo.ModelIdentifier;
|
| | | //序列号
|
| | | mainDevice.SerialNumber = device.DeviceInfo.ProductCode;
|
| | | //设备功能类型
|
| | | mainDevice.DfunctionType = (DeviceFunctionType)device.DeviceInfo.FunctionType;
|
| | |
|
| | | mainDevice.InClusterList.Clear();
|
| | | mainDevice.InClusterList.AddRange(device.DeviceInfo.InClusterList);
|
| | |
| | | else if (mainDevice.Type == DeviceType.DimmableLight)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //调光器固定灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Light.png";
|
| | |
| | | else if (mainDevice.Type == DeviceType.ColorTemperatureLight)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //色温灯固定灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/ColorLightTemperature.png";
|
| | |
| | | else if (mainDevice.Type == DeviceType.OnOffOutput)
|
| | | {
|
| | | //2020.05.13变更:继电器都默认为灯光
|
| | | //var myType = this.GetHdlMyDeviceEnumInfo(mainDevice);
|
| | | //if (myType != null && myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad)
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | {
|
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Light.png";
|
| | | //继电器默认为灯光
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | }
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | }
|
| | | //如果是空气开关的话
|
| | | else if (mainDevice.Type == DeviceType.AirSwitch)
|
| | |
| | | if (mainDevice.DfunctionType == DeviceFunctionType.A未定义)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A开关;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A开关)
|
| | | {
|
| | | //空气开关默认为开关
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
|
| | | }
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/Switch.png";
|
| | | }
|
| | | //根据功能类型,重新设置设备回路图标
|
| | | this.ResetIconPathByDeviceFunctionType(mainDevice);
|
| | | }
|
| | | //如果是彩灯的话
|
| | | else if (mainDevice.Type == DeviceType.ColorDimmableLight)
|
| | | {
|
| | | mainDevice.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
|
| | | {
|
| | | //彩灯默认为开关
|
| | | this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A灯光);
|
| | | }
|
| | | if (mainDevice.IsCustomizeImage == false)
|
| | | {
|
| | | mainDevice.IconPath = "Device/ColorLight.png";
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 根据功能类型,重新设置设备回路图标
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | private void ResetIconPathByDeviceFunctionType(CommonDevice device)
|
| | | {
|
| | | if (device.IsCustomizeImage == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | device.IconPath = "Device/Switch.png";
|
| | | }
|
| | | else if (device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | device.IconPath = "Device/Socket1.png";
|
| | | }
|
| | | else
|
| | | {
|
| | | device.IconPath = "Device/Light.png";
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | //=========★★PIR传感器类(1200-1299)★★=========
|
| | | this.dicDeviceModelIdEnum["MSPIR01-ZB.10"] = "1200-1200-60000";//pir传感器220
|
| | | this.dicDeviceModelIdEnum["MSPIRB-ZB.10"] = "1205-1200-60000";//球型移动传感器
|
| | |
|
| | | //=========★★安防类传感器类(1300-2299)★★=========
|
| | | //这里是麦乐克的
|
| | |
| | | this.dicDeviceModelIdEnum["MGCD01/M-ZB.10"] = "1306-1200-60000";//吸顶燃气传感器
|
| | |
|
| | | //PM2.5空气质量传感器 【该设备属于第三方设备,没有镜像ID】
|
| | | this.dicDeviceModelIdEnum["MSPM25/M-ZB.10"] = "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路继电器小模块
|
| | |
| | | /// pir传感器220 镜像id:1200
|
| | | /// </summary>
|
| | | Sensor_Pir = 1200,
|
| | | /// <summary>
|
| | | /// 球形移动传感器 镜像id:1205
|
| | | /// </summary>
|
| | | Sensor_SphericalMotion = 1205,
|
| | |
|
| | | //=========★★安防类传感器类(1300-2299)★★=========
|
| | | /// <summary>
|