xm
2020-05-13 da3634e011bbda29cf4e1c168997b780fe795b20
ZigbeeApp/Shared/Common/Device.cs
@@ -628,6 +628,9 @@
        /// <param name="deleteRoom">是否从房间删除</param>
        public void DeleteMemmoryDevice(CommonDevice device, bool deleteRoom = true)
        {
            //删除缓存设备的话,主页需要重新刷新
            Phone.UserView.UserPage.Instance.RefreshForm = true;
            if (deleteRoom == true)
            {
                //从房间中删除
@@ -1811,6 +1814,14 @@
                info.ConcreteType = DeviceConcreteType.Relay_FangyueFreshAirModul;
                info.ObjectTypeNameId = 60011;//新风
            }
            //15 PM2.5传感器设备
            else if (dicType.ContainsKey(DeviceType.PMSensor) == true)
            {
                info.ConcreteTextId = R.MyInternationalizationString.uDeviceModelId1307;
                info.BeloneType = DeviceBeloneType.A传感器;
                info.ConcreteType = DeviceConcreteType.Sensor_PMTwoPointFive;
                info.ObjectTypeNameId = 60000;//传感器
            }
            int value = (int)info.BeloneType;
            if (dicDeviceAllNameID.ContainsKey("uDeviceBelongId" + value) == true)
@@ -2082,6 +2093,50 @@
            list.Add(DeviceBeloneType.A未知设备);
            return list;
        }
        #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 dicDevice = new Dictionary<string, CommonDevice>();
            foreach (var device in listDevice)
            {
                if (dicDevice.ContainsKey(device.DeviceAddr) == false)
                {
                    dicDevice[device.DeviceAddr] = device;
                    continue;
                }
                //设备是否处于在线状态
                bool online = this.CheckDeviceIsOnline(device);
                if (online == true)
                {
                    //如果设备回路在线,则优先使用在线的回路,后来的直接覆盖
                    dicDevice[device.DeviceAddr] = device;
                }
            }
            var listReturn = new List<CommonDevice>();
            foreach (var device in dicDevice.Values)
            {
                listReturn.Add(device);
            }
            return listReturn;
        }
        #endregion
@@ -2454,6 +2509,7 @@
                mainDevice.DeviceEpointName = device.DeviceInfo.DeviceName;
            }
            mainDevice.CurrentGateWayId = device.CurrentGateWayId;
            mainDevice.ZigbeeType = device.DeviceInfo.ZigbeeType;
            mainDevice.IsOnline = device.DeviceInfo.IsOnline;
            mainDevice.DriveCode = device.DeviceInfo.DriveCode;
            mainDevice.IasDeviceType = device.DeviceInfo.DeviceType;
@@ -2567,6 +2623,7 @@
            else if (deviceType == DeviceType.FreshAir) { device = new FreshAir(); }
            else if (deviceType == DeviceType.DoorLock) { device = new DoorLock(); }
            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.OtaDevice || deviceType == DeviceType.OtaPanelDevice) { device = new OTADevice(); }
            else { return null; }
@@ -2865,12 +2922,12 @@
        /// <summary>
        /// 吸顶燃气传感器
        /// </summary>
        Sensor_CeilingGas = 1306,
        /// <summary>
        /// PM2.5空气质量传感器
        /// </summary>
        Sensor_CeilingGas = 1306,
        /// <summary>
        /// PM2.5空气质量传感器
        /// </summary>
        Sensor_PMTwoPointFive = 1307,
        /// <summary>
        /// 运动传感器
        /// </summary>