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/UserView/UserPage.cs | 221 ++++++++++++++++++++++++++++++++++---------------------
1 files changed, 136 insertions(+), 85 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserView/UserPage.cs b/ZigbeeApp/Shared/Phone/UserView/UserPage.cs
old mode 100755
new mode 100644
index 6f8fb12..39d7770
--- a/ZigbeeApp/Shared/Phone/UserView/UserPage.cs
+++ b/ZigbeeApp/Shared/Phone/UserView/UserPage.cs
@@ -3,7 +3,9 @@
using Shared.Common;
using ZigBee.Device;
using Shared.Phone.Device.AC;
-
+using System.Text;
+using Shared.Phone.Device.Account;
+
namespace Shared.Phone.UserView
{
/// <summary>
@@ -39,7 +41,7 @@
/// <summary>
/// 搴曢儴鎸夐挳鏂囧瓧鐨刌鍊�
/// </summary>
- private static readonly int tabBarEnumName_Y = 104;
+ private static readonly int tabBarEnumName_Y = 98;
#endregion
#region 鈼� 鎺ュ彛____________________________
@@ -77,6 +79,10 @@
{
try
{
+ if (common.DeviceStatusReport.AttriBute == null || common.DeviceStatusReport.AttriBute.Count == 0)
+ {
+ return;
+ }
switch (myDevice.Type)
{
case DeviceType.OnOffOutput:
@@ -85,11 +91,6 @@
{
var onOffOutputLight = (ToggleLight)myDevice;
onOffOutputLight.DeviceStatusReport = common.DeviceStatusReport;
- //璁板綍銆佹洿鏂扮姸鎬�
- if (onOffOutputLight.DeviceStatusReport.AttriBute == null || onOffOutputLight.DeviceStatusReport.AttriBute.Count == 0)
- {
- return;
- }
onOffOutputLight.OnOffStatus = onOffOutputLight.DeviceStatusReport.AttriBute[0].AttriButeData;
onOffOutputLight.LastDateTime = DateTime.Now;
}
@@ -107,13 +108,8 @@
{
var airSwitch = (AirSwitch)myDevice;
airSwitch.DeviceStatusReport = common.DeviceStatusReport;
- if (airSwitch.DeviceStatusReport.AttriBute == null || airSwitch.DeviceStatusReport.AttriBute.Count == 0)
- {
- return;
- }
airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData;
airSwitch.LastDateTime = DateTime.Now;
-
}
//褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁�
if (common.DeviceStatusReport.CluterID == 3)
@@ -129,10 +125,6 @@
var rollershade = (Rollershade)myDevice;
rollershade.DeviceStatusReport = common.DeviceStatusReport;
var attriButeList = rollershade.DeviceStatusReport.AttriBute;
- if (attriButeList == null || attriButeList.Count == 0)
- {
- return;
- }
switch (attriButeList[0].AttributeId)
{
case 0:
@@ -155,75 +147,68 @@
var ac = (AC)myDevice;
ac.DeviceStatusReport = common.DeviceStatusReport;
var attriButeList = ac.DeviceStatusReport.AttriBute;
- if (attriButeList == null || attriButeList.Count == 0)
- {
- return;
- }
- //姝ゅ睘鎬ц〃鏄庡鍐呭綋鍓嶇殑娓╁害 * 100锛屽疄闄呮俯搴︿负鈥淟ocalTemperature / 100鈥濓紝鍗曚綅锛氣剝
- var curTemp = (attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
- switch (attriButeList[0].AttributeId)
- {
- case 0:
- ac.currentLocalTemperature = curTemp;
- ac.LastDateTime = DateTime.Now;
- break;
-
- case 17:
- ac.currentCoolingSetpoint = curTemp;
- ac.LastDateTime = DateTime.Now;
- break;
-
- case 18:
- ac.currentHeatingSetpoint = curTemp;
- ac.LastDateTime = DateTime.Now;
- break;
-
- case 4096:
- ac.currentAutoSetpoint = curTemp;
- ac.LastDateTime = DateTime.Now;
- break;
-
- case 28:
- ac.currentSystemMode = attriButeList[0].AttriButeData;
- ac.LastDateTime = DateTime.Now;
- break;
- case 4099:
- var value = Convert.ToString(attriButeList[0].AttriButeData, 2).PadLeft(16, '0');
- var modeStr = value.Substring(value.Length - 5, 5);
- for (int j = 0; j < modeStr.Length; j++)
- {
- ac.listSupportMode[j] = Convert.ToInt32(modeStr[j]) == 49 ? 1 : 0;
- }
- break;
-
- case 4097:
- ac.CleanStatu = attriButeList[0].AttriButeData == 42;
- break;
+ foreach (var attList in attriButeList)
+ {
+ //姝ゅ睘鎬ц〃鏄庡鍐呭綋鍓嶇殑娓╁害 * 100锛屽疄闄呮俯搴︿负鈥淟ocalTemperature / 100鈥濓紝鍗曚綅锛氣剝
+ var curTemp = (attList.AttriButeData / 100 < ACControlBase.Temperature_High && attList.AttriButeData / 100 > ACControlBase.Temperature_Low) ? attList.AttriButeData / 100 : ACControlBase.Temperature_Default;
+ switch (attList.AttributeId)
+ {
+ case 0:
+ ac.currentLocalTemperature = curTemp;
+ ac.LastDateTime = DateTime.Now;
+ break;
+ case 17:
+ ac.currentCoolingSetpoint = curTemp;
+ ac.LastDateTime = DateTime.Now;
+ break;
+ case 18:
+ ac.currentHeatingSetpoint = curTemp;
+ ac.LastDateTime = DateTime.Now;
+ break;
+ case 4096:
+ ac.currentAutoSetpoint = curTemp;
+ ac.LastDateTime = DateTime.Now;
+ break;
+ case 28:
+ ac.currentSystemMode = attList.AttriButeData;
+ ac.LastDateTime = DateTime.Now;
+ break;
+ case 4099:
+ var value = Convert.ToString(attList.AttriButeData, 2).PadLeft(16, '0');
+ var modeStr = value.Substring(value.Length - 5, 5);
+ for (int j = 0; j < modeStr.Length; j++)
+ {
+ ac.listSupportMode[j] = Convert.ToInt32(modeStr[j]) == 49 ? 1 : 0;
+ }
+ break;
+ case 4097:
+ ac.CleanStatu = attList.AttriButeData == 42;
+ break;
+ }
}
- }
+ }
if (common.DeviceStatusReport.CluterID == 514)
{
var ac = (AC)myDevice;
var attriButeList = common.DeviceStatusReport.AttriBute;
- if (attriButeList == null || attriButeList.Count == 0)
- {
- return;
- }
ac.DeviceStatusReport = common.DeviceStatusReport;
- switch (attriButeList[0].AttributeId)
- {
- case 0:
- ac.currentFanMode = attriButeList[0].AttriButeData;
- ac.LastDateTime = DateTime.Now;
- break;
- case 4096:
- ac.currentFanSwingMode = attriButeList[0].AttriButeData;
- ac.LastDateTime = DateTime.Now;
- break;
+ foreach (var attList in attriButeList)
+ {
+ switch (attList.AttributeId)
+ {
+ case 0:
+ ac.currentFanMode = attList.AttriButeData;
+ ac.LastDateTime = DateTime.Now;
+ break;
+ case 4096:
+ ac.currentFanSwingMode = attList.AttriButeData;
+ ac.LastDateTime = DateTime.Now;
+ break;
+ }
}
}
-
+
//褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁�
if (common.DeviceStatusReport.CluterID == 3)
{
@@ -239,11 +224,6 @@
{
var dimmableLight = (DimmableLight)myDevice;
dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
- //璁板綍銆佹洿鏂扮姸鎬�
- if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0)
- {
- return;
- }
dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData;
dimmableLight.LastDateTime = DateTime.Now;
}
@@ -253,10 +233,6 @@
var dimmableLight = (DimmableLight)myDevice;
dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
var attriButeList = dimmableLight.DeviceStatusReport.AttriBute;
- if (attriButeList == null || attriButeList.Count == 0)
- {
- return;
- }
switch (attriButeList[0].AttributeId)
{
case 0:
@@ -271,6 +247,62 @@
myDevice.IsOnline = 1;
myDevice.LastDateTime = DateTime.Now;
}
+ break;
+
+ case DeviceType.TemperatureSensor:
+ //娓╁害
+ if (common.DeviceStatusReport.CluterID == 1026)
+ {
+ var tempera = (TemperatureSensor)myDevice;
+ foreach (var data in common.DeviceStatusReport.AttriBute)
+ {
+ if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
+ {
+ if (data.AttriButeData == 0)
+ {
+ tempera.Temperatrue = 0;
+ }
+ else if (data.AttriButeData > 32767)
+ {
+ //璐熸暟(鐗规畩澶勭悊)
+ string strValue = (data.AttriButeData - 65536).ToString();
+ //灏忔暟鐐归渶瑕佷竴浣�
+ strValue = strValue.Substring(0, strValue.Length - 1);
+ tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+ }
+ else
+ {
+ //灏忔暟鐐归渶瑕佷竴浣�
+ string strValue = data.AttriButeData.ToString();
+ strValue = strValue.Substring(0, strValue.Length - 1);
+ tempera.Temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+ }
+ }
+ }
+ }
+ //婀垮害
+ if (common.DeviceStatusReport.CluterID == 1029)
+ {
+ var tempera = (TemperatureSensor)myDevice;
+ foreach (var data in common.DeviceStatusReport.AttriBute)
+ {
+ if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
+ {
+ if (data.AttriButeData == 0)
+ {
+ tempera.Humidity = 0;
+ }
+ else
+ {
+ //灏忔暟鐐归渶瑕佷竴浣�(婀垮害娌℃湁璐熸暟)
+ string strValue = data.AttriButeData.ToString();
+ strValue = strValue.Substring(0, strValue.Length - 1);
+ tempera.Humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+ tempera.LastDateTime = DateTime.Now;
+ }
+ }
+ }
+ }
break;
}
}
@@ -285,6 +317,21 @@
myDevice.IsOnline = common.IsOnline;
//璁板綍鍥炲鏃堕棿
myDevice.LastDateTime = DateTime.Now;
+ }
+ else if (typeTag == "IASInfoReport")
+ {
+ try
+ {
+ switch (myDevice.Type)
+ {
+ case DeviceType.IASZone:
+ var iAS = (IASZone)myDevice;
+ iAS.iASInfo = (common as IASZone).iASInfo;
+ iAS.LastDateTime = DateTime.Now;
+ break;
+ }
+ }
+ catch { }
}
}
/// <summary>
@@ -328,6 +375,10 @@
{
BackgroundColor = Shared.Common.ZigbeeColor.Current.MainColor;
ZbGateway.StatusList.Add(this);
+ Shared.Application.LocationAction += (lon, lat) =>
+ {
+ AccountLogic.Instance.ReceiveAppLatAndLon(lon.ToString(), lat.ToString());
+ };
}
/// <summary>
--
Gitblit v1.8.0