HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-06-10 dce6c3481a37216292724013ff9d2b75ceb82f86
ZigbeeApp/Shared/Common/Device.cs
@@ -123,12 +123,6 @@
                if (device == null || device.CurrentGateWayId == null)
                {
#if DEBUG
                    //调查,为什么它会把全部设备删掉?
                    string file1 = UserCenterLogic.CombinePath(file);
                    string file2 = UserCenterLogic.CombinePath("Back_" + file);
                    System.IO.File.Copy(file1, file2, true);
#endif
                    //失效的文件,没有网关id的都删除掉
                    Global.DeleteFilebyHomeId(file);
                    continue;
@@ -143,12 +137,6 @@
                    }
                    else
                    {
#if DEBUG
                        //调查,为什么它会把全部设备删掉?
                        string file1 = UserCenterLogic.CombinePath(file);
                        string file2 = UserCenterLogic.CombinePath("Back_" + file);
                        System.IO.File.Copy(file1, file2, true);
#endif
                        //如果是主人,或者管理员,那么这个文件是非法的,直接删除
                        Global.DeleteFilebyHomeId(file);
                        continue;
@@ -211,7 +199,7 @@
            var listGateway = HdlGatewayLogic.Current.GetAllLocalGateway();
            foreach (var gateway in listGateway)
            {
                string gwId = HdlGatewayLogic.Current.GetGatewayId(gateway);
                string gwId = gateway.GwId;
                if (listId.Contains(gwId) == false)
                {
                    //这个网关对于当前这个成员来说是非法的
@@ -242,7 +230,7 @@
            listDevice.AddRange(list);
            //获取这个网关的本地所有设备
            string gwID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
            string gwID = zbGateway.GwId;
            List<CommonDevice> listLocalDevices = this.GetDeviceByGatewayID(gwID);
            //获取ota设备
            foreach (var ota in this.dicOTADevice.Values)
@@ -1182,7 +1170,9 @@
            }
            if (device.Type == DeviceType.OnOffOutput
                || device.Type == DeviceType.DimmableLight || device.Type == DeviceType.ColorDimmableLight)
                || device.Type == DeviceType.DimmableLight
                || device.Type == DeviceType.ColorDimmableLight
                || device.Type == DeviceType.ColorTemperatureLight)
            {
                //继电器,掉光器都叫回路
                return Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + epointNo;
@@ -1246,6 +1236,11 @@
            if (string.IsNullOrEmpty(dName) == false)
            {
                return dName;
            }
            if (this.IsMiniLight(device) == true)
            {
                //Mini夜灯
                return Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
            }
            //获取设备类型
@@ -1996,6 +1991,14 @@
                info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive;
                info.ObjectTypeNameId = 60000;//传感器
            }
            //16色温灯
            else if (dicType.ContainsKey(DeviceType.ColorTemperatureLight) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId20000;
                info.BeloneType = DeviceBeloneType.A彩灯;
                info.ConcreteType = DeviceConcreteType.ColorLight_Temperature;
                info.ObjectTypeNameId = 60007;//调光模块
            }
            int value = (int)info.BeloneType;
            if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
@@ -2380,7 +2383,8 @@
            if (i_device.Type == DeviceType.OnOffOutput || i_device.Type == DeviceType.AirSwitch)
            {
                //2020.03.23追加式样:未指定类型的继电器,不显示
                if (i_device.DfunctionType == DeviceFunctionType.A未定义)
                if (i_device.DfunctionType == DeviceFunctionType.A未定义
                    || i_device.DfunctionType == DeviceFunctionType.A不指定)
                {
                    return false;
                }
@@ -2402,6 +2406,11 @@
                {
                    return false;
                }
            }
            else if (i_device.Type == DeviceType.FreshAirHumiditySensor)
            {
                //新风的湿度传感器不显示
                return false;
            }
            return true;
        }
@@ -2470,16 +2479,22 @@
        /// <returns></returns>
        public string AppendVersion(int versionValue)
        {
            //10101 3个byte  显示为:ver.1.01.01
            //中间那个byte为奇数时,代表是测试版本,在显示最新版本时,不需要显示,但是在历史版本那里可以显示
            //中间那个byte为偶数时, 代表是正式版本
            //直接是10进制
            string txt10 = Convert.ToString(versionValue).PadLeft(4, '0');
            //这个是小数点前面的值
            int value1 = Convert.ToInt32(txt10.Substring(0, txt10.Length - 2));
            //这个是小数点后面的值
            int value2 = Convert.ToInt32(txt10.Substring(txt10.Length - 2, 2));
            string txt10 = Convert.ToString(versionValue).PadLeft(6, '0');
            //这个是第一位
            int value1 = Convert.ToInt32(txt10.Substring(0, 2));
            //这个是第二位
            string value2 = txt10.Substring(2, 2);
            //这个是第三位
            string value3 = txt10.Substring(4, 2);
            //Ver.
            string ver = Language.StringByID(R.MyInternationalizationString.uVersionAbbreviation);
            return ver + value1 + "." + value2.ToString().PadLeft(2, '0');
            return ver + value1 + "." + value2 + "." + value3;
        }
        /// <summary>
@@ -2531,7 +2546,7 @@
                {
                    //不无视时间,返回本地设备列表
                    statu = 1;
                    return this.GetDeviceByGatewayID(HdlGatewayLogic.Current.GetGatewayId(zbGateway));
                    return this.GetDeviceByGatewayID(zbGateway.GwId);
                }
            }
            zbGateway.LastDateTime = DateTime.Now;
@@ -2555,7 +2570,7 @@
            //是否达成中断的时机
            bool canBreak = false;
            //网关ID
            string gatewayID = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
            string gatewayID = zbGateway.GwId;
            //超时时间
            int TimeOut = 0;
            //设备总数
@@ -2692,7 +2707,7 @@
        /// <returns></returns>
        private CommonDevice NewDeviceObjectByDeviceId(DeviceType deviceType, Newtonsoft.Json.Linq.JObject jobject, ZbGateway zbGateway)
        {
            string gwId = HdlGatewayLogic.Current.GetGatewayId(zbGateway);
            string gwId = zbGateway.GwId;
            //根据设备类型创建设备对象的实例
            CommonDevice device = this.NewDeviceObjectByDeviceId(deviceType);
@@ -2784,11 +2799,15 @@
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/Light.png";
                    if (this.IsMiniLight(mainDevice) == true)
                    {
                        //mini夜灯
                        mainDevice.IconPath = "Device/MiniNightLight.png";
                    }
                }
            }
            //如果是色温灯
            else if (mainDevice.Type == DeviceType.ColorTemperatureLight)
            {
                mainDevice.DfunctionType = DeviceFunctionType.A灯光;
                if (mainDevice.IsCustomizeImage == false)
                {
                    mainDevice.IconPath = "Device/ColorLightTemperature.png";
                }
            }
            //如果是三路继电器的回路的话,默认为灯光
@@ -2856,6 +2875,7 @@
            else if (deviceType == DeviceType.TemperatureSensor) { device = new TemperatureSensor(); }
            else if (deviceType == DeviceType.PMSensor) { device = new PMSensor(); }
            else if (deviceType == DeviceType.FreshAirHumiditySensor) { device = new HumiditySensor(); }
            else if (deviceType == DeviceType.ColorTemperatureLight) { device = new ColorTemperatureLight(); }
            else if (deviceType == DeviceType.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
            else { return null; }
@@ -2960,7 +2980,7 @@
            this.dicDeviceModelIdEnum["MSPIR01/M-ZB.10"] = "1303-1200-60000";//红外传感器
            this.dicDeviceModelIdEnum["MSW01/M-ZB.10"] = "1304-1200-60000";//水浸传感器
            this.dicDeviceModelIdEnum["MBU01/M-ZB.10"] = "1305-1200-60000";//紧急按键
            this.dicDeviceModelIdEnum["MGCD01/ZB.10"] = "1306-1200-60000";//吸顶燃气传感器
            this.dicDeviceModelIdEnum["MGCD01/M-ZB.10"] = "1306-1200-60000";//吸顶燃气传感器
            //PM2.5空气质量传感器 【该设备属于第三方设备,没有镜像ID】
            this.dicDeviceModelIdEnum["MSPM25/M-ZB.10"] = "1307-1200-60000";//PM2.5空气质量传感器 
@@ -3123,6 +3143,7 @@
        /// 简约环境面板
        /// </summary>
        ButtonPanel_SimpleEnvironment = 230,
        //=========★★PIR传感器类(1200-1299)★★=========
        /// <summary>
        /// 传感器
@@ -3231,6 +3252,10 @@
        /// 彩灯
        /// </summary>
        ColorLight = -10,
        /// <summary>
        /// 色温灯(它的镜像ID未定,暂定20000)
        /// </summary>
        ColorLight_Temperature = 20000,
        //=========★★空调(3600-3899)★★=========
        /// <summary>