From ec9347acf051595077de7c4d84bbbf5e1b2493bd Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 15 十一月 2023 10:42:24 +0800
Subject: [PATCH] 2023年11月15日10:41:37
---
HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs | 331 ++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 255 insertions(+), 76 deletions(-)
diff --git a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
index 43a2944..d47510b 100644
--- a/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
+++ b/HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -10,6 +10,52 @@
public partial class HomePage
{
/// <summary>
+ /// 鏇存柊璁惧鍦ㄧ嚎鐘舵��
+ /// </summary>
+ public static void LoadEvent_RefreshDevcieOnline(Function function)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ if (bodyView != null)
+ {
+ foreach (var view in bodyView.functionViews)
+ {
+ if (view.Tag.ToString() == function.sid)
+ {
+ for (int i = 0; i < view.ChildrenCount; i++)
+ {
+ if (view.GetChildren(i).GetType() == typeof(Button))
+ {
+ var btn = view.GetChildren(i) as Button;
+ if(btn.Tag == null)
+ {
+ continue;
+ }
+ if (btn.Tag.ToString() == function.sid)
+ {
+ if (function.isOnline())
+ {
+ btn.UnSelectedImagePath = "Collection/Functionbg.png";
+ btn.IsSelected = false;
+ }
+ else
+ {
+ btn.UnSelectedImagePath = "Collection/FunctionOfflineBg.png";
+ btn.IsSelected = false;
+ }
+ }
+ else if (btn.Tag.ToString() == "OnlineTag")
+ {
+ btn.Visible = !function.isOnline();
+ }
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+ /// <summary>
/// 鏇存柊涓婚〉澶╂皵
/// </summary>
public static void LoadEvent_RefreshAir()
@@ -192,6 +238,25 @@
}
/// <summary>
+ /// 鏇存柊鍔熻兘缁勬帶涓婚〉
+ /// </summary>
+ public static void RefreshGroupControlView()
+ {
+ if (bodyView != null)
+ {
+
+ if (FunctionList.List.groupControls.Count == 0)
+ {
+ bodyView.loadNavView();
+ bodyView.contentView.PageIndex = 0;
+ }
+ bodyView.LoadGroupControlFunctionControlZone();
+ }
+ }
+
+
+
+ /// <summary>
/// 鏇存柊杩炴帴鐘舵�佸浘鏍�
/// </summary>
void CheckLinkStatus()
@@ -204,15 +269,15 @@
if (!Control.Ins.GatewayOnline_Local && !Control.Ins.GatewayOnline_Cloud)
{
- bodyView.btnLinkStateTip.BackgroundColor = CSS.CSS_Color.LinkTipFail;
- bodyView.btnLinkStateTip.TextID = StringId.NetworkAnomaly;
- bodyView.environmentalView.Y = Application.GetRealHeight(8) + btnResidenceName.Bottom;
+ bodyView.divLinkStateTip.Visible = true;
}
+ //else if ()
+ //{
+ // bodyView.divLinkStateTip.Visible = true;
+ //}
else
{
- bodyView.btnLinkStateTip.BackgroundColor = 0x00000000;
- bodyView.btnLinkStateTip.Text = "";
- bodyView.environmentalView.Y = Application.GetRealHeight(1) + btnResidenceName.Bottom;
+ bodyView.divLinkStateTip.Visible = false;
}
}
@@ -223,9 +288,15 @@
{
Application.RunOnMainThread(() =>
{
- if (bodyView != null)
+ try
{
- bodyView.CheckLinkStatus();
+ if (bodyView != null)
+ {
+ bodyView.CheckLinkStatus();
+ }
+ }catch(Exception ex)
+ {
+ MainPage.Log($"LoadEvent_CheckLinkStatus : {ex.Message}");
}
});
}
@@ -273,65 +344,24 @@
/// </summary>
void LoadEvent_ChangeShowedFunctionType()
{
- btnChangeFunction.MouseUpEventHandler = (sender, e) =>
+
+ if (DB_ResidenceData.Instance.HomeGateway.isSupportGroupControl && FunctionList.List.groupControls.Count>0)
{
- btnChangeFunction.IsSelected = true;
- btnChangeFunction.TextSize = CSS.CSS_FontSize.HeadlineFontSize;
- btnChangeFunction.IsBold = true;
- btnChangeScene.TextSize = CSS.CSS_FontSize.TextFontSize;
- btnChangeScene.IsSelected = false;
- btnChangeScene.IsBold = false;
- CurShowTypeIsFunction = true;
- contentView.PageIndex = 0;
- };
- //var client = new BlufiClient();
- //client.PostPackageLengthLimit = 128;
- //client.RequestDeviceScan();
- //client.RequestDeviceStatus();
- //client.BlufiDelegate.Blufi_DidReceiveDeviceScanResponse();
-
-
- btnChangeScene.MouseUpEventHandler = (sender, e) =>
- {
- btnChangeScene.IsSelected = true;
- btnChangeScene.TextSize = CSS.CSS_FontSize.HeadlineFontSize;
- btnChangeScene.IsBold = true;
- btnChangeFunction.TextSize = CSS.CSS_FontSize.TextFontSize;
- btnChangeFunction.IsSelected = false;
- btnChangeFunction.IsBold = false;
- CurShowTypeIsFunction = false;
- contentView.PageIndex = 1;
- };
-
- contentView.PageChange = (sender, e) =>
- {
- if (contentView.PageIndex == 0)
- {
- btnChangeFunction.IsSelected = true;
- btnChangeFunction.TextSize = CSS.CSS_FontSize.HeadlineFontSize;
- btnChangeFunction.IsBold = true;
- btnChangeScene.TextSize = CSS.CSS_FontSize.TextFontSize;
- btnChangeScene.IsSelected = false;
- btnChangeScene.IsBold = false;
- }
- else
- {
- btnChangeScene.IsSelected = true;
- btnChangeScene.TextSize = CSS.CSS_FontSize.HeadlineFontSize;
- btnChangeScene.IsBold = true;
- btnChangeFunction.TextSize = CSS.CSS_FontSize.TextFontSize;
- btnChangeFunction.IsSelected = false;
- btnChangeFunction.IsBold = false;
- }
- };
+ }
}
+
+ object lockObj = new object();
/// <summary>
/// 鏇存柊鏄剧ず鐘舵��
/// </summary>
public static void UpdataFunctionStates(Function function)
{
+ if(bodyView == null)
+ {
+ return;
+ }
Application.RunOnMainThread(() =>
{
try
@@ -342,18 +372,86 @@
{
if (view.Tag.ToString() == function.sid)
{
+ //if (!function.online)
+ //{
+ // view.UnSelectedImagePath = "Collection/FunctionOfflineBg.png";
+ //}
+
var state = false;
if (function.spk == SPK.CurtainRoller || function.spk == SPK.CurtainShades || function.spk == SPK.CurtainTrietex ||
- function.spk == SPK.CurtainSwitch)//绐楀笜璁惧鏍规嵁鐧惧垎姣斿垽鏂紑鍏崇姸鎬�
+ function.spk == SPK.CurtainSwitch || function.spk == SPK.CurtainDream)//绐楀笜璁惧鏍规嵁鐧惧垎姣斿垽鏂紑鍏崇姸鎬�
{
if (function.GetAttribute(FunctionAttributeKey.Percent) != null)
{
state = function.GetAttrState(FunctionAttributeKey.Percent) != "0";
- }else
+ }
+ else
{
if (function.GetAttrState(FunctionAttributeKey.OnOff) == "stop")
return;
state = function.trait_on_off.curValue.ToString() == "on";
+ }
+ }
+ else if (function.spk == SPK.SenesorMegahealth || function.spk == SPK.SensorMmvPose)
+ {
+
+ var tempStatus = function.attributes.Find((sta) => sta.key == FunctionAttributeKey.TargetStatus);
+ if (tempStatus != null)
+ {
+ switch (tempStatus.state)
+ {//0绌猴紝1璧帮紝2璺戯紝3鍧愶紝4璺屽�掞紝5绔�
+ case "0":
+ state = false;
+ break;
+ case "1":
+ state = true;
+ break;
+ case "2":
+ if (function.extSet.labModel)
+ {
+ state = true;
+ }
+ break;
+ case "3":
+ if (function.extSet.labModel)
+ {
+ state = true;
+ }
+ break;
+ case "4":
+ state = true;
+ break;
+ case "5":
+ if (function.extSet.labModel)
+ {
+ state = true;
+ }
+ break;
+ }
+ }
+ }
+ else if (function.spk == SPK.SensorHelp)
+ {
+ var tempStatus = function.attributes.Find((sta) => sta.key == FunctionAttributeKey.AlarmStatus);
+ if (tempStatus != null)
+ {
+ state = tempStatus.curValue.ToString() == "alarm";
+ }
+ }
+ else if (function.spk == SPK.SensorPir || function.spk == SPK.SensorPirHold)
+ {
+ var tempStatus = function.attributes.Find((sta) => sta.key == "people_status");
+ if (tempStatus != null)
+ {
+ state = tempStatus.curValue.ToString() == "true";
+ }
+ }
+ else if (function.spk == SPK.SensorDryContact || function.spk == SPK.SensorDryContact2)
+ {
+ var tempStatus = function.attributes.Find((sta) => sta.key == "contact_status");
+ if (tempStatus != null)
+ {
+ state = tempStatus.curValue.ToString() == "open";
}
}
else
@@ -376,7 +474,14 @@
{
if (function.spk != SPK.LightSwitch)
{
- btn.Text = function.lastState;
+ if (function.spk == SPK.SensorHelp)
+ {
+ btn.TextID = StringId.InAlarming;
+ }
+ else
+ {
+ btn.Text = function.lastState;
+ }
}
}
}
@@ -463,6 +568,16 @@
{
btnSwitch.MouseUpEventHandler = (sender, e) =>
{
+ if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣�
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+ Direction = AMPopTipDirection.None,
+ }.Show(MainPage.BaseView);
+ return;
+ }
btnSwitch.IsSelected = !btnSwitch.IsSelected;
new System.Threading.Thread(() =>
{
@@ -473,6 +588,7 @@
btnSwitch.IsSelected = !btnSwitch.IsSelected;
});
}
+
function.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
Dictionary<string, string> d = new Dictionary<string, string>();
if (function.spk == SPK.LightDimming || function.spk == SPK.LightRGB)
@@ -489,13 +605,18 @@
d.Add(FunctionAttributeKey.FadeTime, function.GetAttrState(FunctionAttributeKey.FadeTime));
Control.Ins.SendWriteCommand(function, d);
}
- else if (function.spk == SPK.PanelSocket)
+ //else if (function.spk == SPK.PanelSocket)//鍘绘帀锛岀粺涓�澶勭悊鎬绘帶
+ //{
+ // if (function.attributes.Find((obj) => obj.key == "on_off_usb") != null)
+ // {
+ // d.Add("on_off_usb", function.trait_on_off.curValue.ToString());
+ // }
+ // Control.Ins.SendWriteCommand(function, d);
+ //}
+ else if (function.spk == SPK.GroupControl)
{
- if (function.attributes.Find((obj) => obj.key == "on_off_usb") != null)
- {
- d.Add("on_off_usb", function.trait_on_off.curValue.ToString());
- }
- Control.Ins.SendWriteCommand(function, d);
+ d.Add("on_off", function.trait_on_off.curValue.ToString());
+ (function as GroupControl).Control(d);
}
else
{
@@ -516,6 +637,16 @@
{
btnSwitch.MouseUpEventHandler = (sender, e) =>
{
+ if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣�
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+ Direction = AMPopTipDirection.None,
+ }.Show(MainPage.BaseView);
+ return;
+ }
if (DB_ResidenceData.Instance.GatewayType == 1)
{
btnSwitch.IsSelected = !btnSwitch.IsSelected;
@@ -550,6 +681,16 @@
{
btnClose.MouseUpEventHandler = (sender, e) =>
{
+ //if (!curtain.isOnline())//绂荤嚎涓嶅厑璁告搷浣�
+ //{
+ // new Tip()
+ // {
+ // CloseTime = 1,
+ // Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+ // Direction = AMPopTipDirection.None,
+ // }.Show(MainPage.BaseView);
+ // return;
+ //}
btnClose.IsSelected = true;
curtain.trait_on_off.curValue = "off";
curtain.SetAttrState(FunctionAttributeKey.Percent, 0);
@@ -557,13 +698,23 @@
d.Add(FunctionAttributeKey.OnOff, curtain.trait_on_off.curValue.ToString());
Control.Ins.SendWriteCommand(curtain, d);
};
-
btnOpen.MouseUpEventHandler = (sender, e) =>
{
+ //if (!curtain.isOnline())//绂荤嚎涓嶅厑璁告搷浣�
+ //{
+ // new Tip()
+ // {
+ // CloseTime = 1,
+ // Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+ // Direction = AMPopTipDirection.None,
+ // }.Show(MainPage.BaseView);
+ // return;
+ //}
btnOpen.IsSelected = true;
+ Dictionary<string, string> d = new Dictionary<string, string>();
+
curtain.trait_on_off.curValue = "on";
curtain.SetAttrState(FunctionAttributeKey.Percent, 100);
- Dictionary<string, string> d = new Dictionary<string, string>();
d.Add(FunctionAttributeKey.OnOff, curtain.trait_on_off.curValue.ToString());
Control.Ins.SendWriteCommand(curtain, d);
};
@@ -580,6 +731,16 @@
};
btnUp.MouseUpEventHandler = (sender, e) =>
{
+ if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣�
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+ Direction = AMPopTipDirection.None,
+ }.Show(MainPage.BaseView);
+ return;
+ }
new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(2000);
@@ -601,6 +762,16 @@
};
btnDown.MouseUpEventHandler = (sender, e) =>
{
+ if (!function.isOnline())//绂荤嚎涓嶅厑璁告搷浣�
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+ Direction = AMPopTipDirection.None,
+ }.Show(MainPage.BaseView);
+ return;
+ }
new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(2000);
@@ -636,9 +807,9 @@
skipPage.LoadPage(backAction);
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
};
- btnMsgBg.MouseUpEventHandler = eventHandler;
- btnMsgTime.MouseUpEventHandler = eventHandler;
- btnMsg.MouseUpEventHandler = eventHandler;
+ //btnMsgBg.MouseUpEventHandler = eventHandler;
+ //btnMsgTime.MouseUpEventHandler = eventHandler;
+ //btnMsg.MouseUpEventHandler = eventHandler;
btnMsgIcon.MouseUpEventHandler = eventHandler;
}
@@ -653,6 +824,10 @@
/// </summary>
void GetUnreadPushMessages()
{
+ if (MainPage.NoLoginMode)
+ {
+ return;
+ }
System.Threading.Tasks.Task.Run(() =>
{
try
@@ -719,8 +894,8 @@
void ShowMesBtnState(PushMessageInfo pushMessageInfo, bool allRead)
{
if (bodyView == null) return;
- btnMsg.Text = pushMessageInfo.messageTitle + ": " + pushMessageInfo.messageContent;
- btnMsgTime.Text = GetUnixToDateTime(pushMessageInfo.createTime);
+ //btnMsg.Text = pushMessageInfo.messageTitle + ": " + pushMessageInfo.messageContent;
+ //btnMsgTime.Text = GetUnixToDateTime(pushMessageInfo.createTime);
btnMsgIcon.IsSelected = !allRead;
}
@@ -730,8 +905,8 @@
void ResetMesBtnRead()
{
if (bodyView == null) return;
- btnMsg.Text = "...";
- btnMsgTime.Text = "00:00";
+ //btnMsg.Text = "...";
+ //btnMsgTime.Text = "00:00";
btnMsgIcon.IsSelected = false;
}
@@ -757,6 +932,10 @@
/// </summary>
void RegisterGetPushMessageAction()
{
+ if (MainPage.NoLoginMode)
+ {
+ return;
+ }
Action RegisterGetPushMessageAction = () => {
if (bodyView != null)
{
--
Gitblit v1.8.0