From 452e8cef1c740d18ee398be6971d9952e41dbd4a Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 12 四月 2023 16:11:50 +0800
Subject: [PATCH] 1
---
HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 203 insertions(+), 0 deletions(-)
diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs
index 24734bf..c5c93da 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/SocketPage.cs
@@ -2,6 +2,7 @@
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
+using HDL_ON.DriverLayer;
namespace HDL_ON.UI
{
@@ -132,6 +133,94 @@
};
controlView.AddChidren(btnSwitch);
+ if (function.attributes.Find((obj) => obj.key == "active_power" || obj.key == "voltage" || obj.key == "current") != null)
+ {
+ //鍔犺浇鐬椂鍊�
+ var btnInstantaneousValue = new Button()
+ {
+ X = Application.GetRealWidth(67),
+ Y = Application.GetRealHeight(377),
+ Width = Application.GetMinRealAverage(32),
+ Height = Application.GetMinRealAverage(32),
+ UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/DiagramIconOn.png",
+ };
+ controlView.AddChidren(btnInstantaneousValue);
+ var btnInstantaneousValueText = new Button()
+ {
+ X = Application.GetRealWidth(35),
+ Y = btnInstantaneousValue.Bottom,
+ Width = Application.GetRealWidth(96),
+ Height = Application.GetRealHeight(29),
+ TextAlignment = TextAlignment.Center,
+ TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+ TextColor = CSS_Color.TextualColor,
+ TextID = StringId.InstantaneousValue,
+ IsMoreLines = true
+ };
+ controlView.AddChidren(btnInstantaneousValueText);
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+ var page = new SocketPage_InstantaneousValue(function);
+ MainPage.BasePageView.AddChidren(page);
+ page.LoadPage();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ };
+ btnInstantaneousValue.MouseUpEventHandler = eventHandler;
+ btnInstantaneousValueText.MouseUpEventHandler = eventHandler;
+ }
+ if(function.attributes.Find((obj)=>obj.key == "total_electricity") != null)
+ {
+ //鍔犺浇绱鐢ㄧ數
+ var btnTotalElectricity = new Button()
+ {
+ X = Application.GetRealWidth(200),
+ Y = Application.GetRealHeight(377),
+ Height = Application.GetMinRealAverage(32),
+ TextColor = CSS_Color.MainColor,
+ TextSize = CSS_FontSize.EmphasisFontSize_Secondary,
+ Text = function.GetAttrState("total_electricity"),
+ TextAlignment = TextAlignment.BottomLeft,
+ };
+ btnTotalElectricity.Width = btnTotalElectricity.GetTextWidth()+ Application.GetRealWidth(5);
+ controlView.AddChidren(btnTotalElectricity);
+ var btnTotalElectricityUnit = new Button()
+ {
+ X = btnTotalElectricity.Right,
+ Y = Application.GetRealHeight(377),
+ Width = Application.GetRealWidth(100),
+ Height = Application.GetMinRealAverage(32),
+ TextColor = CSS_Color.TextualColor,
+ TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
+ Text = "kW路h",
+ TextAlignment = TextAlignment.BottomLeft,
+ };
+ controlView.AddChidren(btnTotalElectricityUnit);
+
+ var btnTotalElectricityText = new Button()
+ {
+ X = Application.GetRealWidth(200),
+ Y = btnTotalElectricity.Bottom,
+ Width = Application.GetRealWidth(100),
+ Height = Application.GetRealHeight(29),
+ TextAlignment = TextAlignment.CenterLeft,
+ TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+ TextColor = CSS_Color.TextualColor,
+ TextID = StringId.CumulativePowerConsumption,
+ IsMoreLines = true
+ };
+ controlView.AddChidren(btnTotalElectricityText);
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+ var page = new SocketPage_CumulativePowerConsumption(function);
+ MainPage.BasePageView.AddChidren(page);
+ page.LoadPage();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ };
+ btnTotalElectricity.MouseUpEventHandler = eventHandler;
+ btnTotalElectricityUnit.MouseUpEventHandler = eventHandler;
+ btnTotalElectricityText.MouseUpEventHandler = eventHandler;
+
+ }
+
+
LoadEventList();
new TopViewDiv(bodyView, Language.StringByID(StringId.Socket)).LoadTopView_FunctionTop(function, actionRefresh);
@@ -143,4 +232,118 @@
}
}
+
+
+
+ public partial class SocketPage
+ {
+ /// <summary>
+ /// 鏇存柊鐏厜鐘舵��
+ /// </summary>
+ public static void UpdataState(Function uFan)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ try
+ {
+ if (bodyView == null)
+ return;
+ bodyView.btnSwitch.IsSelected = bodyView.btnSwitchIcon.IsSelected = uFan.trait_on_off.curValue.ToString() == "on";
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"RelayPage error {ex.Message}");
+ }
+ });
+ }
+ /// <summary>
+ /// 鍔犺浇浜嬩欢鍒楄〃
+ /// </summary>
+ void LoadEventList()
+ {
+ LoadSwitchEvent();
+ LoadCollectionEvent();
+
+ //鍥為��鍒锋柊淇℃伅浜嬩欢
+ actionRefresh = () => {
+ btnFunctionName.Text = btnFunctionName_Out.Text = function.name;
+ btnFromFloor_Out.Text = btnFromFoorAndRoom.Text = function.GetRoomListName();
+ function.UpdataFuncitonInfo();
+ };
+ }
+
+ /// <summary>
+ /// 鏀惰棌鍔熻兘鎸夐挳浜嬩欢
+ /// </summary>
+ void LoadCollectionEvent()
+ {
+ btnCollection.MouseUpEventHandler += (sender, e) => {
+ btnCollection.IsSelected = function.collect = btnCollection_Out.IsSelected = !btnCollection.IsSelected;
+ function.CollectFunction();
+ };
+ }
+
+ /// <summary>
+ /// 鍔犺浇寮�鍏充簨浠�
+ /// </summary>
+ void LoadSwitchEvent()
+ {
+ btnSwitchIcon.MouseUpEventHandler += (sender, e) =>
+ {
+ if (!function.online)
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+ Direction = AMPopTipDirection.None,
+ }.Show(MainPage.BaseView);
+ return;
+ }
+ btnSwitchIcon.IsSelected = btnSwitch.IsSelected = !btnSwitchIcon.IsSelected;
+
+ new System.Threading.Thread(() =>
+ {
+ function.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
+ System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
+ d.Add("on_off", function.trait_on_off.curValue.ToString());
+ 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);
+ })
+ { IsBackground = true }.Start();
+ };
+ btnSwitch.MouseUpEventHandler += (sender, e) =>
+ {
+ if (!function.online)
+ {
+ new Tip()
+ {
+ CloseTime = 1,
+ Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+ Direction = AMPopTipDirection.None,
+ }.Show(MainPage.BaseView);
+ return;
+ }
+ btnSwitch.IsSelected = btnSwitchIcon.IsSelected = !btnSwitch.IsSelected;
+
+ new System.Threading.Thread(() =>
+ {
+ function.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
+ System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
+ d.Add("on_off", function.trait_on_off.curValue.ToString());
+ 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);
+ })
+ { IsBackground = true }.Start();
+ };
+
+ }
+
+ }
+
}
--
Gitblit v1.8.0