| | |
| | | //面板的温度探头叫 面板名字+温度 |
| | | return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.uTemperature); |
| | | } |
| | | else if (deviceInfoType.BeloneType == DeviceBeloneType.A空气质量) |
| | | { |
| | | |
| | | //空气质量传感器的温度探头叫空气质量传感器+温度 |
| | | return deviceInfoType.DeviceDefultName + Language.StringByID(R.MyInternationalizationString.TemperatureSensor); |
| | | } |
| | | else if (((TemperatureSensor)device).SensorDiv == 1) |
| | | { |
| | | //温度传感器 |
| | |
| | | { |
| | | bool temperatrue = false; |
| | | bool humidity = false; |
| | | bool airQualitySensor = false; |
| | | //获取全部的回路 |
| | | var listTemp = this.GetDevicesByMac(listdevice[0].DeviceAddr, false); |
| | | foreach (var device in listTemp) |
| | | { |
| | | if (device is TemperatureSensor) |
| | | { |
| | | //空气质量传感器 |
| | | if (device.isAirQualitySensor(device)) |
| | | { |
| | | airQualitySensor = true; |
| | | } |
| | | //温度传感器 |
| | | if (((TemperatureSensor)device).SensorDiv == 1) |
| | | { |
| | |
| | | info.ConcreteType = DeviceConcreteType.Sensor_Humidity; |
| | | } |
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A411"].A类型名字;//传感器 |
| | | |
| | | //空气质量传感器 |
| | | if (airQualitySensor == true) |
| | | { |
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A422"].A官方名字; |
| | | info.BeloneType = DeviceBeloneType.A空气质量; |
| | | info.ConcreteType = DeviceConcreteType.AirQualitySensor; |
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A422"].A类型名字; |
| | | } |
| | | } |
| | | //14新风设备 |
| | | else if (dicType.ContainsKey(DeviceType.FreshAir) == true) |
| | |
| | | info.BeloneType = DeviceBeloneType.A晾衣架; |
| | | info.ConcreteType = DeviceConcreteType.Airer; |
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A421"].A类型名字; |
| | | } |
| | | //18空气质量传感器 |
| | | else if (dicType.ContainsKey(DeviceType.AirQualitySensor) == true) |
| | | { |
| | | info.ConcreteText = this.dicDeviceModelIdEnum["A422"].A官方名字; |
| | | info.BeloneType = DeviceBeloneType.A空气质量; |
| | | info.ConcreteType = DeviceConcreteType.AirQualitySensor; |
| | | info.ObjectTypeName = this.dicDeviceModelIdEnum["A422"].A类型名字; |
| | | } |
| | | |
| | | //设备所属类型的翻译名字 |
| | |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 处理网关返回的湿度值 |
| | | /// </summary> |
| | | /// <param name="value">网关返回的属性值</param> |
| | | public decimal AdjustHumidityValue(int value) |
| | | { |
| | | if (value == 0) |
| | | { |
| | | //0% |
| | | return 0; |
| | | } |
| | | //不会出现负数 |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = value.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | //记录温度 |
| | | return strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 处理网关返回的温度值 |
| | | /// </summary> |
| | | /// <param name="value">网关返回的属性值</param> |
| | | public decimal AdjustTemperatrueValue(int value) |
| | | { |
| | | if (value == 0) |
| | | { |
| | | //0℃ |
| | | return 0; |
| | | } |
| | | else if (value > 32767) |
| | | { |
| | | //负数(特殊处理) |
| | | string strValue = (value - 65536).ToString(); |
| | | //小数点需要一位 |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | //记录温度 |
| | | return strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = value.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | //记录温度 |
| | | return strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, ".")); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | //----------------------------------分割线(自定义接口)--------------------------------------------- |
| | |
| | | ((TemperatureSensor)mainDevice).SensorDiv = 1; |
| | | } |
| | | } |
| | | if (((TemperatureSensor)mainDevice).SensorDiv == 1) |
| | | { |
| | | //变更一下温度的值 |
| | | foreach (var data in mainDevice.AttributeStatus) |
| | | { |
| | | if (data.ClusterId == 1026 |
| | | && data.AttributeId == (int)AttriButeId.MeasuredValue) |
| | | { |
| | | //处理网关返回的温度值 |
| | | decimal temperatrue = this.AdjustTemperatrueValue(data.AttributeData); |
| | | ((TemperatureSensor)mainDevice).currentTemperature = temperatrue; |
| | | } |
| | | } |
| | | } |
| | | else if (((TemperatureSensor)mainDevice).SensorDiv == 2) |
| | | { |
| | | //变更一下湿度的值 |
| | | foreach (var data in mainDevice.AttributeStatus) |
| | | { |
| | | if (data.ClusterId == 1029 |
| | | && data.AttributeId == (int)AttriButeId.MeasuredValue) |
| | | { |
| | | //处理网关返回的温度值 |
| | | decimal humidity = this.AdjustHumidityValue(data.AttributeData); |
| | | ((TemperatureSensor)mainDevice).currentHumidity = humidity; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |