HDL Home App 第二版本 旧平台金堂用 正在使用
wjc
2022-12-01 351bdda734832d821a9764b0cde8be5d83c4ec50
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
@@ -252,11 +252,14 @@
            }
            var tempList = Common.LocalDevice.Current.GetDevicesByMac(report.DeviceAddr, false);
            var res = Common.LocalDevice.Current.GetMyDeviceEnumInfo(tempList);
            if (res.ConcreteType == Common.DeviceConcreteType.Airer)
            if (tempList.Count > 0)
            {
                //晾衣架特殊处理,本地只存了端点1,其余2~5端点都不存
                deviceEpoint = 1;
                var res = Common.LocalDevice.Current.GetMyDeviceEnumInfo(tempList);
                if (res.ConcreteType == Common.DeviceConcreteType.Airer)
                {
                    //晾衣架特殊处理,本地只存了端点1,其余2~5端点都不存
                    deviceEpoint = 1;
                }
            }
            //处理网关上报的数据,然后变更本地缓存
            var locadevice = Common.LocalDevice.Current.GetDevice(deviceAddr, deviceEpoint);
@@ -358,6 +361,20 @@
                            ((LightBase)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData;
                            //已经接收到状态
                            locadevice.HadReadDeviceStatu = true;
                        }
                        if (locadevice is TemperatureSensor)
                        {
                            //获取设备类型
                            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { locadevice });
                            //空气质量传感器
                            if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
                            {
                                locadevice.DeviceStatusReport = report.DeviceStatusReport;
                                ((TemperatureSensor)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData;
                                //已经接收到状态
                                locadevice.HadReadDeviceStatu = true;
                            }
                        }
                    }
                }
@@ -628,7 +645,7 @@
                                //小数点需要一位
                                string strValue = Convert.ToInt16(receiptData, 16).ToString();
                                strValue = strValue.Substring(0, strValue.Length - 1);
                                temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                temperatrue = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                            }
                            //无符号(不会出现负数)
                            else if (attData.AttriButeDataType == 32 || attData.AttriButeDataType == 33)
@@ -640,14 +657,14 @@
                                    string strValue = (shortData - 65536).ToString();
                                    //小数点需要一位
                                    strValue = strValue.Substring(0, strValue.Length - 1);
                                    temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                    temperatrue = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                }
                                else
                                {
                                    //小数点需要一位
                                    string strValue = shortData.ToString();
                                    strValue = strValue.Substring(0, strValue.Length - 1);
                                    temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                    temperatrue = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                }
                            }
@@ -692,7 +709,7 @@
                                //小数点需要一位
                                string strValue = Convert.ToInt16(receiptData, 16).ToString();
                                strValue = strValue.Substring(0, strValue.Length - 1);
                                humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                humidity = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                            }
                            //无符号(不会出现负数)
                            else if (attData.AttriButeDataType == 32 || attData.AttriButeDataType == 33)
@@ -700,7 +717,7 @@
                                //小数点需要一位 湿度不会出现负数
                                string strValue = Convert.ToUInt16(receiptData, 16).ToString();
                                strValue = strValue.Substring(0, strValue.Length - 1);
                                humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                humidity = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                            }
                            //湿度传感器
                            if (locadevice is TemperatureSensor)
@@ -735,10 +752,19 @@
                        //PM2.5
                        if (attData.AttributeId == (int)AttriButeId.MeasuredValue)
                        {
                            if (attData.AttriButeDataType == 57)
                            {
                                ((PMSensor)locadevice).currentPmData = attData.AttriButeData;
                                //获取设备类型
                                var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { locadevice });
                                //空气质量传感器
                                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
                                {
                                    ((TemperatureSensor)locadevice).currentPmData = attData.AttriButeData;
                                }
                                else
                                {
                                    ((PMSensor)locadevice).currentPmData = attData.AttriButeData;
                                }
                            }
                        }
                        //已经接收到状态
@@ -748,6 +774,30 @@
                #endregion
                #region ■ CO2数据
                else if (report.DeviceStatusReport.CluterID == 1037)
                {
                    foreach (var attData in report.DeviceStatusReport.AttriBute)
                    {
                        if (attData.AttributeId == (int)AttriButeId.MeasuredValue)
                        {
                            if (attData.AttriButeDataType == 57)
                            {
                                //获取设备类型
                                var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { locadevice });
                                //空气质量传感器
                                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
                                {
                                    ((TemperatureSensor)locadevice).currentCO2 = attData.AttriButeData;
                                }
                            }
                        }
                        //已经接收到状态
                        locadevice.HadReadDeviceStatu = true;
                    }
                }
                #endregion
                #region ■ 设备基础信息
                else if (report.DeviceStatusReport.CluterID == 0)