黄学彪
2020-07-09 5428935270159bfc42c2934ed7fb1091554fc9a4
ZigbeeApp/Shared/Common/Device.cs
@@ -2179,12 +2179,21 @@
        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>
@@ -2238,8 +2247,7 @@
            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);
@@ -2259,7 +2267,7 @@
                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>
@@ -2307,8 +2315,7 @@
                return;
            }
            //保存记录
            string fullName = UserCenterLogic.CombinePath(DirNameResourse.DeviceRoomIdFile);
            UserCenterLogic.SaveFileContent(fullName, this.dicDeviceRoomId);
            HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId);
            //添加自动备份
            HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile);
@@ -2891,23 +2898,17 @@
            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 (device.DeviceInfo.FunctionType != (int)DeviceFunctionType.A灯光)
                        {
                            //继电器默认为灯光
                            this.SendDeviceFunctionTypeToGateway(mainDevice, 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)
@@ -2922,10 +2923,8 @@
                        this.SendDeviceFunctionTypeToGateway(mainDevice, DeviceFunctionType.A开关);
                    }
                }
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/Switch.png";
                }
                //根据功能类型,重新设置设备回路图标
                this.ResetIconPathByDeviceFunctionType(mainDevice);
            }
            //如果是彩灯的话
            else if (mainDevice.Type == DeviceType.ColorDimmableLight)
@@ -2944,6 +2943,30 @@
        }
        /// <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";
            }
        }
        /// <summary>
        /// 根据设备Type创建对应的设备对象
        /// </summary>
        /// <param name="deviceType">设备Type</param>