From 593720d8cfa423242191a6d39c745053c08cf55e Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期一, 30 十二月 2019 13:56:38 +0800
Subject: [PATCH] 2019.12.30
---
ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs | 192 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 177 insertions(+), 15 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
index 2d8fdcb..e042f59 100644
--- a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
+++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
@@ -1,10 +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
@@ -15,6 +18,139 @@
/// </summary>
public Action action;
+ FrameLayout roomNameBackground;
+
+ FrameLayout roomTemperatureBackground;
+
+ 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
+ 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 = int.Parse(strValue) * 0.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 = int.Parse(strValue) * 0.1;
+ }
+ }
+ }
+ }
+ //}
+ }
+ catch (Exception ex)
+ {
+ System.Console.WriteLine($"Error:{ex.Message}");
+ }
+ });
+ }
+ }
+ #endregion
+
+ public override void RemoveFromParent()
+ {
+ ZbGateway.StatusList.Remove(this);
+ base.RemoveFromParent();
+ }
+
/// <summary>
/// RoomView
/// </summary>
@@ -24,8 +160,9 @@
{
X = Application.GetRealWidth(x);
Y = Application.GetRealHeight(y);
- Width = Application.GetRealWidth(487);
- Height = Application.GetRealHeight(348);
+ Width = Application.GetRealWidth(717);
+ Height = Application.GetRealHeight(478);
+ ZbGateway.StatusList.Add(this);
}
/// <summary>
@@ -35,6 +172,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()
{
@@ -50,7 +191,7 @@
};
roomBackView.AddChidren(roomImg);
- var roomNameBackground = new FrameLayout
+ roomNameBackground = new FrameLayout
{
X = Application.GetRealWidth(29),
Y = Application.GetRealHeight(282),
@@ -71,11 +212,11 @@
roomNameBackground.AddChidren(roomName);
- var roomTemperatureBackground = new FrameLayout
+ roomTemperatureBackground = new FrameLayout
{
X = Application.GetRealWidth(29),
Y = Application.GetRealHeight(374),
- Width = Application.GetRealWidth(340),
+ Width = Application.GetRealWidth(400),
Height = Application.GetRealHeight(80),
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor2
};
@@ -92,19 +233,19 @@
};
roomTemperatureBackground.AddChidren(temperatureIcon);
- var temperatureText = new Button
+ temperatureText = new Button
{
X = Application.GetRealWidth(69),
- Width = Application.GetRealWidth(86),
+ Width = Application.GetRealWidth(120),
Height = Application.GetRealHeight(58),
Gravity = Gravity.CenterVertical,
- Text = "26鈩�"
+ Text = Math.Abs(room.Temperatrue) <= 0 ? "--鈩�" : $"{room.Temperatrue}鈩�"
};
roomTemperatureBackground.AddChidren(temperatureText);
var humidityIcon = new Button
{
- X = Application.GetRealWidth(179),
+ X = Application.GetRealWidth(200),
Width = Application.GetMinRealAverage(58),
Height = Application.GetMinRealAverage(58),
Gravity = Gravity.CenterVertical,
@@ -112,18 +253,32 @@
};
roomTemperatureBackground.AddChidren(humidityIcon);
- var humidityText = new Button
+ humidityText = new Button
{
- X = Application.GetRealWidth(236),
- Width = Application.GetRealWidth(86),
+ X = Application.GetRealWidth(260),
+ Width = Application.GetRealWidth(120),
Height = Application.GetRealHeight(58),
Gravity = Gravity.CenterVertical,
- Text = "13%"
+ Text = Math.Abs(room.Temperatrue) <= 0 ? "--%" : $"{room.Humidity}%"
};
roomTemperatureBackground.AddChidren(humidityText);
- var roomListBtn = new Button()
+ if (string.IsNullOrEmpty(room.TemperatrueDevice) == false)
+ {
+ //鍙戦�佽幏鍙栨俯搴︾殑鍛戒护
+ var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice);
+ ReadDeviceAttributeLogic.Instance.SendTemperatureStatuComand(dev);
+ }
+
+ if (string.IsNullOrEmpty(room.HumidityDevice) == false)
+ {
+ var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice);
+ ReadDeviceAttributeLogic.Instance.SendHumidityStatuComand(dev);
+ }
+
+
+ roomListBtn = new Button()
{
X = roomBackView.Width - Application.GetRealWidth(100 + 20),
Y = Application.GetRealHeight(20),
@@ -145,7 +300,14 @@
action?.Invoke();
};
};
+ }
+ /// <summary>
+ /// HideName
+ /// </summary>
+ public void HideName(bool statu)
+ {
+ roomNameBackground.Visible = roomTemperatureBackground.Visible = roomListBtn.Visible = !statu;
}
}
}
--
Gitblit v1.8.0