| | |
| | | using System; |
| | | using Shared.Common; |
| | | using Shared.Phone.UserCenter; |
| | | using Shared.Phone.UserView; |
| | | |
| | | namespace Shared.Phone.Device.CommonForm |
| | |
| | | /// </summary> |
| | | public Action action; |
| | | |
| | | public override void RemoveFromParent()
|
| | | {
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
|
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
|
| | | base.RemoveFromParent();
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// RoomView |
| | | /// </summary> |
| | |
| | | { |
| | | X = Application.GetRealWidth(x); |
| | | Y = Application.GetRealHeight(y); |
| | | Width = Application.GetRealWidth(487); |
| | | Height = Application.GetRealHeight(348); |
| | | Width = Application.GetRealWidth(717); |
| | | Height = Application.GetRealHeight(478); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | roomTemperatureBackground.AddChidren(humidityText); |
| | | |
| | | |
| | | if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) |
| | | { |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | HdlDeviceAttributeLogic.Current.AddAttributeEvent("TemperatrueDevice", "DeviceStatusReport", (Action<ZigBee.Device.CommonDevice>)((report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.TemperatrueDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice"); |
| | | |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0℃ |
| | | temperatureText.Text = "0.0℃"; |
| | | } |
| | | else if (data.AttriButeData > 32767) |
| | | { |
| | | //负数(特殊处理) |
| | | string strValue = (data.AttriButeData - 65536).ToString(); |
| | | //小数点需要一位 |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位 |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | temperatureText.Text = strValue.Insert(strValue.Length - 1, ".") + "℃"; |
| | | } |
| | | } |
| | | } |
| | | })); |
| | | //发送获取温度的命令 |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); |
| | | if (dev != null) |
| | | { |
| | | (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | } |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(room.HumidityDevice) == false) |
| | | { |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); |
| | | HdlDeviceAttributeLogic.Current.AddAttributeEvent("HumidityDevice", "DeviceStatusReport", (report) => |
| | | { |
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); |
| | | if (room.HumidityDevice != mainKeys) |
| | | { |
| | | return; |
| | | } |
| | | //移除掉事件 |
| | | HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice"); |
| | | foreach (var data in report.DeviceStatusReport.AttriBute) |
| | | { |
| | | if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue) |
| | | { |
| | | if (data.AttriButeData == 0) |
| | | { |
| | | //0 |
| | | humidityText.Text = "0.0%"; |
| | | } |
| | | else |
| | | { |
| | | //小数点需要一位(湿度没有负数) |
| | | string strValue = data.AttriButeData.ToString(); |
| | | strValue = strValue.Substring(0, strValue.Length - 1); |
| | | humidityText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | //发送获取湿度的命令 |
| | | var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice); |
| | | if (dev != null) |
| | | { |
| | | (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity(); |
| | | } |
| | | } |
| | | |
| | | var roomListBtn = new Button() |
| | | { |
| | | X = roomBackView.Width - Application.GetRealWidth(100 + 20), |