From 34e965100d635346e2d4cd6e6013bdaed66b3004 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 02 一月 2020 19:52:13 +0800
Subject: [PATCH] 2019.1.2-3
---
ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs | 258 ++++++++++++++++++++++++++++++++-------------------
1 files changed, 160 insertions(+), 98 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
index ebede4c..ee2e08c 100644
--- a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
+++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
@@ -1,11 +1,13 @@
锘縰sing System;
using Shared.Common;
+using Shared.Phone.Device.DeviceLogic;
using Shared.Phone.UserCenter;
using Shared.Phone.UserView;
+using ZigBee.Device;
namespace Shared.Phone.Device.CommonForm
{
- public class RoomView:FrameLayout
+ public class RoomView:FrameLayout, ZigBee.Common.IStatus
{
/// <summary>
/// Room
@@ -22,10 +24,139 @@
Button roomListBtn;
+ Button temperatureText;
+
+ Button humidityText;
+
+ CommonDevice temperDevice;
+
+ CommonDevice humidDevice;
+
+ #region 鈼� 鎺ュ彛__________________________
+ /// <summary>
+ /// 澶勭悊鍙樺寲浜嬩欢 --灏嗗純鐢� 鏀圭敤DeviceInfoChange()
+ /// </summary>
+ /// <returns>The changed.</returns>
+ /// <param name="common">Common.</param>
+ public void Changed(CommonDevice common)
+ {
+
+ }
+ /// <summary>
+ /// Changeds the IL ogic status.
+ /// </summary>
+ /// <param name="logic">Logic.</param>
+ public void ChangedILogicStatus(ZigBee.Device.Logic logic)
+ {
+ //throw new NotImplementedException();
+ }
+ /// <summary>
+ /// Changeds the IS cene status.
+ /// </summary>
+ /// <param name="scene">Scene.</param>
+ public void ChangedISceneStatus(Scene scene)
+ {
+ //throw new NotImplementedException();
+ }
+ /// <summary>
+ /// 璁惧鐘舵�佹洿鏂版帴鍙�
+ /// <para>type锛氬鏋滀负 DeviceInComingRespon:璁惧鏂颁笂鎶�</para>
+ /// <para>type锛氬鏋滀负 IASInfoReport:RemoveDeviceRespon</para>
+ /// <para>type锛氬鏋滀负 DeviceStatusReport:璁惧涓婃姤</para>
+ /// <para>type锛氬鏋滀负 IASInfoReport:IAS瀹夐槻淇℃伅涓婃姤</para>
+ /// <para>type锛氬鏋滀负 OnlineStatusChange: 璁惧鍦ㄧ嚎鐘舵�佹洿鏂�</para>
+ /// </summary>
+ /// <param name="common">Common.</param>
+ /// <param name="typeTag">Type tag.</param>
+ public void DeviceInfoChange(CommonDevice common, string typeTag)
+ {
+ if (typeTag == "DeviceStatusReport")
+ {
+ Application.RunOnMainThread(() =>
+ {
+ try
+ {
+ if (common.DeviceStatusReport.AttriBute == null || common.DeviceStatusReport.AttriBute.Count == 0)
+ {
+ return;
+ }
+ //鏄惁涓哄綋鍓嶈澶�
+ if ((temperDevice?.DeviceEpoint != common.DeviceEpoint || temperDevice?.DeviceAddr != common.DeviceAddr) && (humidDevice?.DeviceEpoint != common.DeviceEpoint || humidDevice?.DeviceAddr != common.DeviceAddr) )
+ {
+ //return;
+ }
+
+ //if (common.Type == DeviceType.TemperatureSensor)
+ //{
+ if (common.DeviceStatusReport.CluterID == 1026)
+ {
+ foreach (var data in common.DeviceStatusReport.AttriBute)
+ {
+ if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
+ {
+ if (data.AttriButeData == 0)
+ {
+ //0鈩�
+ temperatureText.Text = "0.0鈩�";
+ room.Temperatrue = 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, ".") + "鈩�";
+ room.Temperatrue = Convert.ToDecimal(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, ".") + "鈩�";
+ room.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+ }
+ }
+ }
+ }
+ else if (common.DeviceStatusReport.CluterID == 1029)
+ {
+ foreach (var data in common.DeviceStatusReport.AttriBute)
+ {
+ if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
+ {
+ if (data.AttriButeData == 0)
+ {
+ //0
+ humidityText.Text = "--%";
+ room.Humidity = 0;
+ }
+ else
+ {
+ //灏忔暟鐐归渶瑕佷竴浣�(婀垮害娌℃湁璐熸暟)
+ string strValue = data.AttriButeData.ToString();
+ strValue = strValue.Substring(0, strValue.Length - 1);
+ humidityText.Text = strValue.Insert(strValue.Length - 1, ".") + "%";
+ room.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+ }
+ }
+ }
+ }
+ //}
+ }
+ catch (Exception ex)
+ {
+ System.Console.WriteLine($"Error:{ex.Message}");
+ }
+ });
+ }
+ }
+ #endregion
+
public override void RemoveFromParent()
{
- HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
- HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
+ ZbGateway.StatusList.Remove(this);
base.RemoveFromParent();
}
@@ -40,6 +171,7 @@
Y = Application.GetRealHeight(y);
Width = Application.GetRealWidth(717);
Height = Application.GetRealHeight(478);
+ ZbGateway.StatusList.Add(this);
}
/// <summary>
@@ -49,6 +181,10 @@
public void Init(Common.Room r)
{
this.room = r;
+
+ this.temperDevice= Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice);
+
+ this.humidDevice= Common.LocalDevice.Current.GetDevice(room.HumidityDevice);
var roomBackView = new FrameLayout()
{
@@ -77,13 +213,17 @@
var roomName = new Button()
{
- X = Application.GetRealWidth(5),
+ X = Application.GetRealWidth(29),
Width = Application.GetRealWidth(190),
Text = room.Name,
TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
+ TextSize = 10,
+ TextAlignment=TextAlignment.CenterLeft,
+ IsBold = true
};
roomNameBackground.AddChidren(roomName);
-
+ roomNameBackground.Width = (roomName.GetTextWidth() + Application.GetRealWidth(100)) > Application.GetRealWidth(600) ? Application.GetRealWidth(600) : roomName.GetTextWidth() + Application.GetRealWidth(100);
+ roomName.Width = roomNameBackground.Width - Application.GetRealWidth(40);
roomTemperatureBackground = new FrameLayout
{
@@ -106,19 +246,20 @@
};
roomTemperatureBackground.AddChidren(temperatureIcon);
- var temperatureText = new Button
+ temperatureText = new Button
{
X = Application.GetRealWidth(69),
Width = Application.GetRealWidth(120),
- Height = Application.GetRealHeight(58),
- Gravity = Gravity.CenterVertical,
- Text = $"{room.Temperatrue}鈩�"
+ Text = room.Temperatrue == 0 ? "--鈩�" : $"{room.Temperatrue}鈩�",
+ TextSize = 14,
+ TextAlignment=TextAlignment.CenterLeft
};
roomTemperatureBackground.AddChidren(temperatureText);
+ temperatureText.Width = temperatureText.GetTextWidth() + Application.GetRealWidth(60);
var humidityIcon = new Button
{
- X = Application.GetRealWidth(200),
+ X = temperatureText.Right,
Width = Application.GetMinRealAverage(58),
Height = Application.GetMinRealAverage(58),
Gravity = Gravity.CenterVertical,
@@ -126,109 +267,30 @@
};
roomTemperatureBackground.AddChidren(humidityIcon);
- var humidityText = new Button
+ humidityText = new Button
{
- X = Application.GetRealWidth(260),
+ X = humidityIcon.Right,
Width = Application.GetRealWidth(120),
- Height = Application.GetRealHeight(58),
- Gravity = Gravity.CenterVertical,
- Text = $"{room.Humidity}%"
+ Text = room.Humidity == 0 ? "--%" : $"{room.Humidity}%",
+ TextSize = 14,
+ TextAlignment = TextAlignment.CenterLeft
};
roomTemperatureBackground.AddChidren(humidityText);
-
+ humidityText.Width = humidityText.GetTextWidth() + Application.GetRealWidth(60);
+ roomTemperatureBackground.Width = (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150)) > Application.GetRealWidth(600) ? Application.GetRealWidth(600) : (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150));
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鈩�";
- room.Temperatrue = 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, ".") + "鈩�";
- room.Temperatrue = int.Parse(strValue) * 0.1;
- }
- else
- {
- //灏忔暟鐐归渶瑕佷竴浣�
- string strValue = data.AttriButeData.ToString();
- strValue = strValue.Substring(0, strValue.Length - 1);
- temperatureText.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�";
- room.Temperatrue = int.Parse(strValue) * 0.1;
- }
- }
- }
- }));
//鍙戦�佽幏鍙栨俯搴︾殑鍛戒护
var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice);
- if (dev != null)
- {
- (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity();
- }
+ ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(dev);
}
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%";
- room.Humidity = 0;
- }
- else
- {
- //灏忔暟鐐归渶瑕佷竴浣�(婀垮害娌℃湁璐熸暟)
- string strValue = data.AttriButeData.ToString();
- strValue = strValue.Substring(0, strValue.Length - 1);
- humidityText.Text = strValue.Insert(strValue.Length - 1, ".") + "%";
- room.Humidity = int.Parse(strValue) * 0.1;
- }
- }
- }
- });
- //鍙戦�佽幏鍙栨箍搴︾殑鍛戒护
var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice);
- if (dev != null)
- {
- (dev as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity();
- }
+ ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(dev);
}
-
roomListBtn = new Button()
{
--
Gitblit v1.8.0