From eb424d24e39bab4a245725f35deab3f234ea0f13 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 13 十二月 2019 10:48:50 +0800
Subject: [PATCH] 2019.12.13
---
ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs | 101 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 98 insertions(+), 3 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
index 2d8fdcb..e024c63 100644
--- a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
+++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
@@ -1,5 +1,6 @@
锘縰sing System;
using Shared.Common;
+using Shared.Phone.UserCenter;
using Shared.Phone.UserView;
namespace Shared.Phone.Device.CommonForm
@@ -15,6 +16,13 @@
/// </summary>
public Action action;
+ public override void RemoveFromParent()
+ {
+ HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
+ HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
+ base.RemoveFromParent();
+ }
+
/// <summary>
/// RoomView
/// </summary>
@@ -24,8 +32,8 @@
{
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>
@@ -95,7 +103,7 @@
var temperatureText = new Button
{
X = Application.GetRealWidth(69),
- Width = Application.GetRealWidth(86),
+ Width = Application.GetRealWidth(100),
Height = Application.GetRealHeight(58),
Gravity = Gravity.CenterVertical,
Text = "26鈩�"
@@ -123,6 +131,93 @@
roomTemperatureBackground.AddChidren(humidityText);
+ if (string.IsNullOrEmpty(room.TemperatrueDevice) == false)
+ {
+ HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
+ HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (Action<ZigBee.Device.CommonDevice>)((report) =>
+ {
+ string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
+ if (room.TemperatrueDevice != mainKeys)
+ {
+ return;
+ }
+ //绉婚櫎鎺変簨浠�
+ HdlGatewayReceiveLogic.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)
+ {
+ HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
+ HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) =>
+ {
+ string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
+ if (room.HumidityDevice != mainKeys)
+ {
+ return;
+ }
+ //绉婚櫎鎺変簨浠�
+ HdlGatewayReceiveLogic.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),
--
Gitblit v1.8.0