黄学彪
2020-07-24 0087dd7734e71dfcfd1bb54db394ad7855021ffd
ZigbeeApp/Shared/Common/Device.cs
old mode 100644 new mode 100755
@@ -267,22 +267,8 @@
                    listDriveDevice.Add(device);
                }
            }
            if (listDriveDevice.Count > 0)
            {
                //如果虚拟设备还没有名字的话
                HdlThreadLogic.Current.RunThread(() =>
                {
                    //如果不这样放在一个线程里,有可能对Dictionary产生影响
                    foreach (var myDevice in listDriveDevice)
                    {
                        //根据设备类型获取名称
                        var dName = this.GetDeviceObjectText(new List<CommonDevice>() { myDevice }, false);
                        //在端点名字的后面附加【回路】字样
                        dName += "(" + myDevice.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                        this.ReName(myDevice, dName, ShowErrorMode.NO);
                    }
                });
            }
            //设置虚拟设备的默认名字
            this.SetDriveDeviceDefultName(listDriveDevice);
            //只有完全获取的时候,才会去处理删除的问题
            if (statu != 1)
@@ -532,6 +518,42 @@
                }
            }
            return true;
        }
        /// <summary>
        /// 设置虚拟设备的默认名字
        /// </summary>
        /// <param name="listDriveDevice">虚拟设备列表</param>
        private void SetDriveDeviceDefultName(List<CommonDevice> listDriveDevice)
        {
            if (listDriveDevice.Count == 0)
            {
                return;
            }
            //如果虚拟设备还没有名字的话
            HdlThreadLogic.Current.RunThread(() =>
            {
                //如果不这样放在一个线程里,有可能对Dictionary产生影响
                foreach (var myDevice in listDriveDevice)
                {
                    string dName = string.Empty;
                    if (this.IsMiniLight(myDevice) == true)
                    {
                        //Mini夜灯
                        dName = Language.StringByID(R.MyInternationalizationString.uMiniNightLight);
                    }
                    else
                    {
                        //根据设备类型获取名称
                        dName = this.GetDeviceObjectText(new List<CommonDevice>() { myDevice }, false);
                        //在端点名字的后面附加【回路】字样
                        dName += "(" + myDevice.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                    }
                    this.ReName(myDevice, dName, ShowErrorMode.NO);
                    System.Threading.Thread.Sleep(100);
                }
            });
        }
        ///<summary >
@@ -847,9 +869,9 @@
                //门锁没有定位功能
                return false;
            }
            var myTypeInfo = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
            if (device.Type == DeviceType.IASZone)
            {
                var myTypeInfo = this.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_Pir)
                {
                    //传感器除了Pir都没有定位功能
@@ -860,6 +882,11 @@
                    //球型移动传感器虽然是电池设备,但是它有定位功能
                    return true;
                }
                return false;
            }
            //温湿度传感器没有定位功能
            if (myTypeInfo.ConcreteType == DeviceConcreteType.Sensor_TemperatrueHumidity)
            {
                return false;
            }
@@ -1854,7 +1881,8 @@
                info.ObjectTypeName = this.dicDeviceModelIdEnum["A418"].A类型名字;//调光模块
            }
            else if (info.BeloneType == DeviceBeloneType.A传感器
                || device.Type == DeviceType.TemperatureSensor)
                || device.Type == DeviceType.TemperatureSensor
                || device.Type == DeviceType.FreshAirHumiditySensor)
            {
                //传感器合并
                info.ConcreteType = DeviceConcreteType.Sensor;
@@ -2051,14 +2079,14 @@
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A温湿度传感器;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A411"].A官方名字;
                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatureHumidity;
                    info.ConcreteType = DeviceConcreteType.Sensor_TemperatrueHumidity;
                }
                else if (temperatrue == true && humidity == false)
                {
                    //设置传感器具体的类型
                    info.BeloneType = DeviceBeloneType.A温度传感器;
                    info.ConcreteText = this.dicDeviceModelIdEnum["A412"].A官方名字;
                    info.ConcreteType = DeviceConcreteType.Sensor_Temperature;
                    info.ConcreteType = DeviceConcreteType.Sensor_Temperatrue;
                }
                else if (temperatrue == false && humidity == true)
                {
@@ -2563,7 +2591,7 @@
        {
            if (this.dicDeviceModelIdEnum.ContainsKey(strKey) == false)
            {
                return null;
                return new DeviceNameContent();
            }
            return this.dicDeviceModelIdEnum[strKey];
        }
@@ -2707,15 +2735,14 @@
                                    listCheck.Add(mainkeys);
                                    //刷新一下本地缓存
                                    var localDevice = this.GetDevice(mainkeys);
                                    if (localDevice != null)
                                    var tempDevice = localDevice == null ? device : localDevice;
                                    //刷新属性
                                    this.SetDeviceInfoToMain(tempDevice, device);
                                    if (this.RefreshDeviceFunctionType(tempDevice, device, false) == true)
                                    {
                                        //刷新属性
                                        this.SetDeviceInfoToMain(localDevice, device);
                                        if (this.RefreshDeviceFunctionType(localDevice, device, false) == true)
                                        {
                                            //需要发送功能类型给网关
                                            listFucDevice.Add(localDevice);
                                        }
                                        //需要发送功能类型给网关
                                        listFucDevice.Add(tempDevice);
                                    }
                                }
                            }
@@ -3178,18 +3205,18 @@
            System.IO.StreamReader streamReader = null;
            var listText = new List<string>();
            try
            {
#if iOS
                string textFile = Foundation.NSBundle.MainBundle.PathForResource("DeviceName.ini", null);
                streamReader = new System.IO.StreamReader(textFile, Encoding.UTF8);
            {
#if iOS
                string textFile = Foundation.NSBundle.MainBundle.PathForResource("DeviceName.ini", null);
                streamReader = new System.IO.StreamReader(textFile, Encoding.UTF8);
                string text;
                while ((text = streamReader.ReadLine()) != null)
                {
                    listText.Add(text.Trim());
                }
                return listText;
#endif
#if Android
                return listText;
#endif
#if Android
                var stream = Application.Activity.Assets.Open("DeviceName.ini");
                streamReader = new System.IO.StreamReader(stream, Encoding.UTF8);
                string text;
@@ -3217,10 +3244,10 @@
            }
        }
#endregion
        #endregion
    }
#region ■ 自定义设备类型_________________________
    #region ■ 自定义设备类型_________________________
    /// <summary>
    /// <para>设备的具体【设备类型】,变量名可以作为【设备类型】图片,这个值是瞎写的,没什么特殊意义</para>
@@ -3371,6 +3398,10 @@
        /// PM2.5空气质量传感器
        /// </summary>
        Sensor_PMTwoPointFive = 1307,
        /// <summary>
        /// 温湿度传感器
        /// </summary>
        Sensor_TemperatrueHumidity = 1308,
        /// <summary>
        /// 运动传感器
@@ -3381,13 +3412,9 @@
        /// </summary>
        Sensor_Keyfob = -1307,
        /// <summary>
        /// 温湿度传感器
        /// </summary>
        Sensor_TemperatureHumidity = -1308,
        /// <summary>
        /// 温度传感器
        /// </summary>
        Sensor_Temperature = -1309,
        Sensor_Temperatrue = -1309,
        /// <summary>
        /// 湿度传感器
        /// </summary>
@@ -3595,5 +3622,5 @@
        A干接点 = 16,
    }
#endregion
    #endregion
}