| | |
| | | } |
| | | |
| | | 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); |
| | |
| | | ((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; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | //小数点需要一位 |
| | | 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) |
| | |
| | | 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, ".")); |
| | | } |
| | | } |
| | | |
| | |
| | | //小数点需要一位 |
| | | 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) |
| | |
| | | //小数点需要一位 湿度不会出现负数 |
| | | 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) |
| | |
| | | //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; |
| | | } |
| | | } |
| | | } |
| | | //已经接收到状态 |
| | |
| | | |
| | | #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) |