| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Net; |
| | | using HDL_ON.Common; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON.DriverLayer; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI.CSS; |
| | | using Newtonsoft.Json; |
| | | //using OpenTK; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.UI |
| | |
| | | public class AirSwitchP3SubloopEnergyPage : FrameLayout |
| | | { |
| | | static AirSwitchP3SubloopEnergyPage bodyView; |
| | | |
| | | Button btnRighta; |
| | | |
| | | Button btnRightb; |
| | | |
| | | Button btnRightc; |
| | | |
| | | /// <summary> |
| | | /// 曲线图数据string |
| | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public void LoadPage() |
| | | public void LoadPage(int titleId) |
| | | { |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.EnergyMonitoring)).LoadTopView(0xFFF7F7F7); |
| | | new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView(0xFFF7F7F7); |
| | | bodyView.BackgroundColor = 0xFFF5F7FA; |
| | | |
| | | var contentView = new VerticalScrolViewLayout() |
| | |
| | | }; |
| | | contentView.AddChidren(viewa); |
| | | |
| | | Button btnRighta = new Button() |
| | | btnRighta = new Button() |
| | | { |
| | | X = Application.GetRealWidth(201), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | }; |
| | | contentView.AddChidren(viewb); |
| | | |
| | | Button btnRightb = new Button() |
| | | btnRightb = new Button() |
| | | { |
| | | X = Application.GetRealWidth(201), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | }; |
| | | contentView.AddChidren(viewc); |
| | | |
| | | Button btnRightc = new Button() |
| | | btnRightc = new Button() |
| | | { |
| | | X = Application.GetRealWidth(201), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | BackgroundColor = 0x1F5C62FE, |
| | | BorderColor = CSS_Color.MainColor, |
| | | BorderWidth = 2, |
| | | Radius = 1, |
| | | }; |
| | | showDataTypeView.AddChidren(btnShowHistroyData_Day); |
| | | btnShowHistroyData_Day.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomLeft); |
| | |
| | | IsSelected = false, |
| | | BorderWidth = 1, |
| | | BorderColor = CSS_Color.PromptingColor1, |
| | | Radius = 1, |
| | | }; |
| | | showDataTypeView.AddChidren(btnShowHistroyData_Month); |
| | | btnShowHistroyData_Month.BorderWidth = 1; |
| | | btnShowHistroyData_Month.BorderColor = CSS_Color.PromptingColor1; |
| | | |
| | | var btnShowHistroyData_Year = new Button() |
| | | { |
| | |
| | | IsSelected = false, |
| | | BorderWidth = 1, |
| | | BorderColor = CSS_Color.PromptingColor1, |
| | | Radius = 1, |
| | | }; |
| | | showDataTypeView.AddChidren(btnShowHistroyData_Year); |
| | | btnShowHistroyData_Year.BorderWidth = 1; |
| | | btnShowHistroyData_Year.BorderColor = CSS_Color.PromptingColor1; |
| | | |
| | | var btnShowHistroyData_Total = new Button() |
| | | { |
| | |
| | | IsSelected = false, |
| | | BorderWidth = 1, |
| | | BorderColor = CSS_Color.PromptingColor1, |
| | | Radius = 1, |
| | | }; |
| | | showDataTypeView.AddChidren(btnShowHistroyData_Total); |
| | | btnShowHistroyData_Total.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerBottomRight | HDLUtils.RectCornerTopRight); |
| | |
| | | btnShowHistroyData_Day.BackgroundColor = 0x00000000; |
| | | btnShowHistroyData_Day.SelectedBackgroundColor = 0x00000000; |
| | | |
| | | #if __IOS__ |
| | | btnShowHistroyData_Day.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomLeft); |
| | | btnShowHistroyData_Total.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerBottomRight | HDLUtils.RectCornerTopRight); |
| | | #endif |
| | | |
| | | }; |
| | | |
| | |
| | | btnShowHistroyData_Total.BorderColor = CSS_Color.PromptingColor1; |
| | | btnShowHistroyData_Total.BackgroundColor = 0x00000000; |
| | | btnShowHistroyData_Total.SelectedBackgroundColor = 0x00000000; |
| | | #if __IOS__ |
| | | btnShowHistroyData_Day.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomLeft); |
| | | btnShowHistroyData_Total.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerBottomRight | HDLUtils.RectCornerTopRight); |
| | | #endif |
| | | |
| | | curQueryType = "hour"; |
| | | brokenLine.YvalueText = ""; |
| | |
| | | btnShowHistroyData_Total.BorderColor = CSS_Color.PromptingColor1; |
| | | btnShowHistroyData_Total.BackgroundColor = 0x00000000; |
| | | btnShowHistroyData_Total.SelectedBackgroundColor = 0x00000000; |
| | | #if __IOS__ |
| | | btnShowHistroyData_Day.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomLeft); |
| | | btnShowHistroyData_Total.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerBottomRight | HDLUtils.RectCornerTopRight); |
| | | #endif |
| | | |
| | | curQueryType = "month"; |
| | | brokenLine.YvalueText = ""; |
| | |
| | | btnShowHistroyData_Total.BorderColor = CSS_Color.PromptingColor1; |
| | | btnShowHistroyData_Total.BackgroundColor = 0x00000000; |
| | | btnShowHistroyData_Total.SelectedBackgroundColor = 0x00000000; |
| | | #if __IOS__ |
| | | btnShowHistroyData_Day.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomLeft); |
| | | btnShowHistroyData_Total.SetCornerWithSameRadius((uint)Application.GetRealHeight(6), HDLUtils.RectCornerBottomRight | HDLUtils.RectCornerTopRight); |
| | | #endif |
| | | |
| | | |
| | | curQueryType = "year_month"; |
| | |
| | | |
| | | var btnTip = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(289), |
| | | Y = Application.GetRealWidth(289), |
| | | Height = Application.GetRealHeight(41), |
| | | Width = Application.GetRealWidth(300), |
| | | TextAlignment = TextAlignment.Center, |
| | |
| | | }; |
| | | totalElectricityView.AddChidren(btnTotalElectricity); |
| | | |
| | | |
| | | double totalNumber = 0.00; |
| | | double.TryParse(device.GetAttrState(key), out totalNumber); |
| | | var btnTotalNumber = new Button() |
| | | { |
| | | Y = Application.GetRealHeight(27), |
| | |
| | | TextSize = 49, |
| | | TextColor = 0xFF030D1C, |
| | | TextAlignment = TextAlignment.Center, |
| | | Text = device.GetAttrState(key), |
| | | Text = totalNumber.ToString("F2"), |
| | | }; |
| | | totalElectricityView.AddChidren(btnTotalNumber); |
| | | |
| | |
| | | //viewb.Visible = true; |
| | | //viewc.Visible = true; |
| | | btnTip.TextID = StringId.AirSwitchP3HistroyTip1; |
| | | historyDataView.Height = Application.GetRealHeight(330); |
| | | historyDataView.Height = Application.GetRealWidth(330); |
| | | }; |
| | | btnShowHistroyData_Month.MouseUpEventHandler += (sender, e) => { |
| | | totalElectricityView.RemoveFromParent(); |
| | |
| | | //viewb.Visible = true; |
| | | //viewc.Visible = true; |
| | | btnTip.TextID = StringId.AirSwitchP3HistroyTip2; |
| | | historyDataView.Height = Application.GetRealHeight(330); |
| | | historyDataView.Height = Application.GetRealWidth(330); |
| | | }; |
| | | btnShowHistroyData_Year.MouseUpEventHandler += (sender, e) => { |
| | | totalElectricityView.RemoveFromParent(); |
| | |
| | | //viewb.Visible = true; |
| | | //viewc.Visible = true; |
| | | btnTip.TextID = StringId.AirSwitchP3HistroyTip3; |
| | | historyDataView.Height = Application.GetRealHeight(330); |
| | | historyDataView.Height = Application.GetRealWidth(330); |
| | | }; |
| | | btnShowHistroyData_Total.MouseUpEventHandler += (sender, e) => { |
| | | myEchartsView_Line.RemoveFromParent(); |
| | |
| | | historyDataView.Height = Application.GetRealHeight(184); |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | if (Control.Ins.GatewayOnline_Local == true) |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | Control.Ins.SendReadCommand(device); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | else |
| | | { |
| | | if (Control.Ins.GatewayOnline_Cloud) |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | var deviceResult = ApiUtlis.Ins.HttpRequest.GetDeviceInfo(device.deviceId); |
| | | |
| | | if (deviceResult != null) |
| | | { |
| | | if (deviceResult.Code == StateCode.SUCCESS) |
| | | { |
| | | if (deviceResult.Data != null) |
| | | { |
| | | var packList = JsonConvert.DeserializeObject<List<Function>>(deviceResult.Data.ToString()); |
| | | if (packList != null) |
| | | { |
| | | if (packList.Count > 0) |
| | | { |
| | | if (packList[0].isOnline()) |
| | | { |
| | | Control.Ins.SendReadCommand(device); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }catch(Exception ex) |
| | | { |
| | | |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | brokenLine.xTitle = Language.StringByID(StringId.Date); |
| | | } |
| | | |
| | | var opString = brokenLine.InitOption(50, curQueryType == "year_month"); |
| | | var opString = brokenLine.InitOption(100, curQueryType == "year_month"); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | myEchartsView_Line.ShowWithOption(opString); |
| | |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public static void UpdataStatus(Function updataTemp) |
| | | { |
| | | if (!updataTemp.online)//设备不在线不更新状态 |
| | | { |
| | | return; |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | try |
| | | { |
| | | if (bodyView != null) |
| | | { |
| | | double power = 0.00; |
| | | double voltage = 0.00; |
| | | double current = 0.00; |
| | | switch (bodyView.key) |
| | | { |
| | | case FunctionAttributeKey.ElectricityA: |
| | | double.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.PowerA), out power); |
| | | double.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.VoltageA),out voltage); |
| | | double.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.CurrentA),out current); |
| | | break; |
| | | case FunctionAttributeKey.ElectricityB: |
| | | double.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.PowerB), out power); |
| | | double.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.VoltageB), out voltage); |
| | | double.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.CurrentB), out current); |
| | | break; |
| | | case FunctionAttributeKey.ElectricityC: |
| | | double.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.PowerC), out power); |
| | | double.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.VoltageC), out voltage); |
| | | double.TryParse(updataTemp.GetAttrState(FunctionAttributeKey.CurrentC), out current); |
| | | break; |
| | | } |
| | | bodyView.btnRighta.Text = voltage.ToString("F2") + "V"; |
| | | bodyView.btnRightb.Text = current.ToString("F2") + "A"; |
| | | bodyView.btnRightc.Text = power.ToString("F2") + "W"; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"更新三相子项异常:{ex.Message}"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public override void RemoveFromParent() |
| | | { |
| | | base.RemoveFromParent(); |
| | | bodyView = null; |
| | | } |
| | | |
| | | } |
| | | } |