From a3dfbcd5218270f9a75e6e32807b08215270b657 Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期三, 11 九月 2024 11:48:23 +0800 Subject: [PATCH] Merge branch 'feature/v2.5_极光推送' into feature/V2.6.0_google --- HDL_ON/UI/UI2/FuntionControlView/Acst/InverterJinmaoPage.cs | 1541 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1,541 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Acst/InverterJinmaoPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Acst/InverterJinmaoPage.cs new file mode 100644 index 0000000..02bbf02 --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/Acst/InverterJinmaoPage.cs @@ -0,0 +1,1541 @@ +锘縰sing System; +using System.Collections.Generic; +using HDL_ON.DAL.Server; +using HDL_ON.DriverLayer; +using HDL_ON.Entity; +using HDL_ON.UI.CSS; +using Shared; + +namespace HDL_ON.UI +{ + public class InverterJinmaoPage : FrameLayout + { + static InverterJinmaoPage bodyView; + Function function; + /// <summary> + /// 浠婃棩鍙戠數閲忔暟鎹寜閽� + /// </summary> + Button pvGenerate_TodayValuesButton; + /// <summary> + /// 浠婃棩鍙戠數閲忓崟浣嶆寜閽� + /// </summary> + Button pvGenerate_todayUintButton; + /// <summary> + /// 绱鍙戠數閲忔暟鎹寜閽� + /// </summary> + Button pvGenerate_TotalValuesButton; + /// <summary> + /// 浠婃棩鐢ㄧ數閲忔暟鎹寜閽� + /// </summary> + Button pvLoad_TodayValuesButton; + /// <summary> + /// 浠婃棩鐢ㄧ數閲忓崟浣嶆寜閽� + /// </summary> + Button loadEle_TodayUintButton; + /// <summary> + /// 绱鐢ㄧ數閲忔暟鎹寜閽� + /// </summary> + Button pvLoad_TotalValuesButton; + /// <summary> + /// 鍏変紡杩愯鐘舵�佷俊鎭尯鍩� + /// </summary> + FrameLayout pvRunStatusInfoView; + /// <summary> + /// 鍏変紡杩愯鐘舵�佸浘鏍囨寜閽� + /// </summary> + Button pvRunStatus_IconButton; + /// <summary> + /// 鍏変紡杩愯鐘舵�佹枃鏈寜閽� + /// </summary> + Button pvRunStatus_TextButton; + /// <summary> + /// 鍏変紡鍙戠數鍔熻兘鏁版嵁鎸夐挳 + /// </summary> + Button pvPower_ValuesButton; + /// <summary> + /// 鍏変紡浠婃棩鍙戠數閲忔暟鎹寜閽� + /// </summary> + Button pvGeneration_TodayValuesButton; + /// <summary> + /// 鍏変紡鏈湀鍙戠數閲忔暟鎹寜閽� + /// </summary> + Button pvGeneration_MonthValuesButton; + /// <summary> + /// 鍏変紡瀹炴椂鐢ㄧ數鍔熺巼鏁版嵁鎸夐挳 + /// </summary> + Button loadElec_ValuesButton; + /// <summary> + /// 鍏変紡鐘舵�佷粖鏃ョ敤鐢甸噺鏁版嵁鎸夐挳 + /// </summary> + Button powerUsage_TodayValuesButton; + /// <summary> + /// 鍏変紡鐘舵�佹湰鏈堢敤鐢甸噺鏁版嵁鎸夐挳 + /// </summary> + Button loadElec_MonthValuesButton; + /// <summary> + /// 鍌ㄨ兘杩愯鐘舵�佷俊鎭尯鍩� + /// </summary> + FrameLayout esStatus_InfoView; + /// <summary> + /// 鍌ㄨ兘杩愯鐘舵�佸浘鏍囨寜閽� + /// </summary> + Button esRunStatus_Info_IconButton; + /// <summary> + /// 鍌ㄨ兘杩愯鐘舵�佹枃鏈寜閽� + /// </summary> + Button esRunStatus_Info_TextButton; + /// <summary> + /// 鍌ㄨ兘鐢垫睜鐘舵�佸浘鏍囨寜閽� + /// </summary> + Button esRunStatus_BatteryIconButton; + /// <summary> + /// 鍌ㄨ兘鐢垫睜鐘舵�佺櫨鍒嗘瘮鎸夐挳 + /// </summary> + Button esRunStatus_BatteryValuesButton; + /// <summary> + /// 鍌ㄨ兘瀹炴椂鍏呯數鍔熺巼 + /// </summary> + Button esRunStatus_ChargeValuesButton; + /// <summary> + /// 鍌ㄨ兘瀹炴椂鏀剧數鍔熺巼 + /// </summary> + Button esRunStatus_DischargeValuesButton; + + /// <summary> + /// </summary> + Button socialContribution_Info1_ValuesButton; + /// <summary> + /// </summary> + Button socialContribution_Info1_UintButton; + /// <summary> + /// </summary> + Button socialContribution_Info2_ValuesButton; + /// <summary> + /// </summary> + Button socialContribution_Info2_UintButton; + /// <summary> + /// </summary> + Button socialContribution_Info3_UintButton; + /// <summary> + /// </summary> + Button socialContribution_Info3_ValuesButton; + + + public InverterJinmaoPage() + { + bodyView = this; + try + { + function = FunctionList.List.GetInverterJinmaoList()[0]; + } + catch (Exception ex) + { + MainPage.Log($"{ex.Message}"); + this.RemoveFromParent(); + } + BackgroundColor = CSS_Color.BackgroundColor; + } + + public void LoadPage() + { + new TopViewDiv(bodyView, Language.StringByID(StringId.NewEnergy)) { maginY = 10 }.LoadTopView(); + + var contentView = new VerticalScrolViewLayout() + { + Y = Application.GetRealHeight(74), + Height = Application.GetRealHeight(Application.DesignHeight - 74), + }; + bodyView.AddChidren(contentView); + + contentView.AddChidren(new Button() + { + Height = Application.GetRealWidth(16), + }); + + #region 鍙戠數閲� 鐢ㄧ數閲� + var electricityQuantityView = new FrameLayout() + { + Width = Application.GetRealWidth(343), + Height = Application.GetRealWidth(99), + Gravity = Gravity.CenterHorizontal, + }; + contentView.AddChidren(electricityQuantityView); + + #region 鍙戠數閲� Electricity generation + var electricityGenerationView = new FrameLayout() + { + Width = Application.GetRealWidth(181), + Height = Application.GetRealWidth(99), + BackgroundImagePath = "FunctionIcon/Acst/Inverter/ElectricityGenerationBg.png" + }; + electricityQuantityView.AddChidren(electricityGenerationView); + + var pv_IconButton = new Button() + { + X = Application.GetRealWidth(14), + Y = Application.GetRealWidth(16), + Width = Application.GetRealWidth(12), + Height = Application.GetRealWidth(12), + UnSelectedImagePath = "FunctionIcon/Acst/Inverter/ElectricityGenerationIcon.png" + }; + electricityQuantityView.AddChidren(pv_IconButton); + + var pv_TextButton = new Button() + { + X = Application.GetRealWidth(32), + Y = Application.GetRealWidth(12), + Width = Application.GetRealWidth(140), + Height = Application.GetRealWidth(20), + Text = "浠婃棩鍙戠數閲�", + TextSize = CSS_FontSize.TextFontSize, + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.MainBackgroundColor, + }; + electricityGenerationView.AddChidren(pv_TextButton); + + pvGenerate_TodayValuesButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(34), + Height = Application.GetRealWidth(24), + Text = function.GetAttrState(InverterJinmao_AttrEnum.pv_electricity_today.ToString()), + TextColor = CSS_Color.MainBackgroundColor, + TextSize = 18, + IsBold = true, + }; + electricityGenerationView.AddChidren(pvGenerate_TodayValuesButton); + +#if __IOS__ + pvGenerate_TodayValuesButton.TextAlignment = TextAlignment.TopLeft; + pvGenerate_TodayValuesButton.Width = pvGenerate_TodayValuesButton.GetTextWidth() + Application.GetRealWidth(8); +#else + pvGenerate_TodayValuesButton.TextAlignment = TextAlignment.BottomLeft; + pvGenerate_TodayValuesButton.Y = Application.GetRealWidth(37); + pvGenerate_TodayValuesButton.Width = pvGenerate_TodayValuesButton.GetTextWidth() + Application.GetRealWidth(4); +#endif + pvGenerate_todayUintButton = new Button() + { + Y = Application.GetRealWidth(43), + Height = Application.GetRealWidth(17), + Text = "kwh", + TextColor = CSS_Color.MainBackgroundColor, + TextSize = 12, + TextAlignment = TextAlignment.CenterLeft, + }; + pvGenerate_todayUintButton.X = pvGenerate_TodayValuesButton.Right - Application.GetRealWidth(2); + electricityGenerationView.AddChidren(pvGenerate_todayUintButton); + + pvGenerate_TotalValuesButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(69), + Height = Application.GetRealWidth(18), + Text = "绱鍙戠數閲忥細" + function.GetAttrState(InverterJinmao_AttrEnum.pv_electricity.ToString()), + TextColor = CSS_Color.MainBackgroundColor, + TextSize = 12, + TextAlignment = TextAlignment.CenterLeft, + //IsBold = true, + }; + electricityGenerationView.AddChidren(pvGenerate_TotalValuesButton); + + + + #endregion + + #region 鐢ㄧ數閲� Electricity consumption + var loadEleView = new FrameLayout() + { + X = Application.GetRealWidth(178 - 16), + Width = Application.GetRealWidth(181), + Height = Application.GetRealWidth(99), + BackgroundImagePath = "FunctionIcon/Acst/Inverter/ElectricityConsumptionBg.png" + }; + electricityQuantityView.AddChidren(loadEleView); + + var loadEle_IconButton = new Button() + { + X = Application.GetRealWidth(155), + Y = Application.GetRealWidth(16), + Width = Application.GetRealWidth(12), + Height = Application.GetRealWidth(12), + UnSelectedImagePath = "FunctionIcon/Acst/Inverter/ElectricityConsumptionIcon.png" + }; + loadEleView.AddChidren(loadEle_IconButton); + + var loadEle_TodayTextButton = new Button() + { + //X = Application.GetRealWidth(181 - 32), + Y = Application.GetRealWidth(12), + Width = Application.GetRealWidth(181 - 32), + Height = Application.GetRealWidth(20), + Text = "浠婃棩鐢ㄧ數閲�", + TextSize = CSS_FontSize.TextFontSize, + TextAlignment = TextAlignment.CenterRight, + TextColor = CSS_Color.MainBackgroundColor, + }; + loadEleView.AddChidren(loadEle_TodayTextButton); + + + loadEle_TodayUintButton = new Button() + { + Y = Application.GetRealWidth(43), + Height = Application.GetRealWidth(17), + Text = "kwh", + TextColor = CSS_Color.MainBackgroundColor, + TextSize = 12, + TextAlignment = TextAlignment.CenterRight, + }; + loadEleView.AddChidren(loadEle_TodayUintButton); +#if __IOS__ + loadEle_TodayUintButton.Width = loadEle_TodayUintButton.GetTextWidth() + Application.GetRealWidth(8); +#else + loadEle_TodayUintButton.Width = loadEle_TodayUintButton.GetTextWidth(); +#endif + loadEle_TodayUintButton.X = Application.GetRealWidth(181 - 12) - loadEle_TodayUintButton.Width; + + pvLoad_TodayValuesButton = new Button() + { + X = Application.GetRealWidth(81 - 12) - loadEle_TodayUintButton.Width, + Y = Application.GetRealWidth(34), + Height = Application.GetRealWidth(53), + Width = Application.GetRealWidth(100), + Text = function.GetAttrState(InverterJinmao_AttrEnum.load_electricity_today.ToString()), + TextColor = CSS_Color.MainBackgroundColor, + TextSize = 18, + TextAlignment = TextAlignment.TopRight, + IsBold = true, + }; +#if __IOS__ + pvLoad_TodayValuesButton.Y = Application.GetRealWidth(34); + pvLoad_TodayValuesButton.X = Application.GetRealWidth(81 - 12) - loadEle_TodayUintButton.Width; +#else + pvLoad_TodayValuesButton.Y = Application.GetRealWidth(37); + pvLoad_TodayValuesButton.X = Application.GetRealWidth(81 - 16) - loadEle_TodayUintButton.Width; +#endif + loadEleView.AddChidren(pvLoad_TodayValuesButton); + + pvLoad_TotalValuesButton = new Button() + { + Y = Application.GetRealWidth(69), + Height = Application.GetRealWidth(18), + Width = Application.GetRealWidth(181 - 12), + Text = "绱鐢ㄧ數閲忥細" + function.GetAttrState(InverterJinmao_AttrEnum.load_electricity.ToString()), + TextColor = CSS_Color.MainBackgroundColor, + TextSize = 12, + TextAlignment = TextAlignment.CenterRight, + //IsBold = true, + }; + loadEleView.AddChidren(pvLoad_TotalValuesButton); + + #endregion + + var goHistroyButton = new Button(); + electricityQuantityView.AddChidren(goHistroyButton); + goHistroyButton.MouseUpEventHandler = (sender, e) => + { + var page = new InverterJinmaoHistroyPage(function); + MainPage.BasePageView.AddChidren(page); + page.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + + #endregion + contentView.AddChidren(new Button() + { + Height = Application.GetRealWidth(8), + }); + #region 鍏変紡杩愯鐘舵�� + var pvRunStatus_TitleButton = new Button() + { + X = Application.GetRealWidth(16), + Height = Application.GetRealWidth(47), + TextAlignment = TextAlignment.CenterLeft, + Text = "鍏変紡杩愯鐘舵��", + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 16, + IsBold = true, + }; + contentView.AddChidren(pvRunStatus_TitleButton); + + var pvEleGenerationInfoView = new FrameLayout() + { + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(343), + Height = Application.GetRealWidth(253), + BackgroundColor = CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealHeight(12), + BorderColor = 0x00FFFFFF, + BorderWidth = 0, + }; + contentView.AddChidren(pvEleGenerationInfoView); + + #region 鍏変紡杩愯鐘舵�� + pvRunStatusInfoView = new FrameLayout() + { + X = 0 - Application.GetRealWidth(14), + Y = Application.GetRealWidth(12), + Width = Application.GetRealWidth(68 + 14), + Height = Application.GetRealWidth(28), + BackgroundColor = 0x154484F4, + Radius = (uint)Application.GetRealHeight(14), + BorderColor = 0x00FFFFFF, + BorderWidth = 0, + }; + pvEleGenerationInfoView.AddChidren(pvRunStatusInfoView); + + pvRunStatus_IconButton = new Button() + { + X = Application.GetRealWidth(8 + 14), + Gravity = Gravity.CenterVertical, + Width = Application.GetRealWidth(12), + Height = Application.GetRealWidth(12), + UnSelectedImagePath = "FunctionIcon/Acst/Inverter/PvIconRun.png", + }; + pvRunStatusInfoView.AddChidren(pvRunStatus_IconButton); + + pvRunStatus_TextButton = new Button() + { + X = Application.GetRealWidth(8 + 14 + 4 + 12), + TextAlignment = TextAlignment.CenterLeft, + TextSize = 14, + TextColor = 0xFF4484F4, + Text = "杩愯", + }; + pvRunStatusInfoView.AddChidren(pvRunStatus_TextButton); + + var powerGenerationView = new FrameLayout() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(20), + Width = Application.GetRealWidth(151), + Height = Application.GetRealWidth(151), + }; + pvEleGenerationInfoView.AddChidren(powerGenerationView); + + var powerGenerationBg = new Button() + { + UnSelectedImagePath = "FunctionIcon/Acst/Inverter/PvBgRun.png" + }; + powerGenerationView.AddChidren(powerGenerationBg); + + new System.Threading.Thread(() => + { + try + { + int index = 1; + float pvPower = 0.00f; + while (index < 361) + { + float.TryParse(function.GetAttrState(InverterJinmao_AttrEnum.pv_power.ToString()), out pvPower); + if (pvPower > 0.00f) + { + Application.RunOnMainThread(() => + { + powerGenerationBg.SetRotation(1f * index++); + }); + System.Threading.Thread.Sleep(50); + if (index == 361) + { + index = 1; + } + } + } + } + catch (Exception ex) + { + MainPage.Log("Error", $"閲戣寕UI鎺т欢鏃嬭浆寮傚父:{ex.Message}"); + } + }) + { IsBackground = true }.Start(); + + #endregion + + #region 鍏変紡鍙戠數閲� + #region 鍏変紡鍙戠數鍔熺巼 + pvPower_ValuesButton = new Button() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(46), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(32), + Text = function.GetAttrState(InverterJinmao_AttrEnum.pv_power.ToString()), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 24, + IsBold = true, + }; + powerGenerationView.AddChidren(pvPower_ValuesButton); + + var powerGeneration_TextButton = new Button() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(78), + //Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(25), + Text = "瀹炴椂鍙戠數鍔熺巼 (kw)", + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + powerGenerationView.AddChidren(powerGeneration_TextButton); + #endregion + + #region 鍏変紡浠婃棩鍙戠數閲� + pvGeneration_TodayValuesButton = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(191), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(24), + Text = function.GetAttrState(InverterJinmao_AttrEnum.pv_electricity_today.ToString()), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 18, + IsBold = true, + }; + pvEleGenerationInfoView.AddChidren(pvGeneration_TodayValuesButton); + + var powerGeneration_TodayTextButton = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(220), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(17), + Text = "浠婃棩鍙戠數閲� (kwh)", + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + pvEleGenerationInfoView.AddChidren(powerGeneration_TodayTextButton); + #endregion + + #region 鍏変紡鏈湀鍙戠數閲� + pvGeneration_MonthValuesButton = new Button() + { + X = Application.GetRealWidth(16 + 105), + Y = Application.GetRealWidth(191), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(24), + Text = function.GetAttrState(InverterJinmao_AttrEnum.pv_electricity_month.ToString()), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 18, + IsBold = true, + }; + pvEleGenerationInfoView.AddChidren(pvGeneration_MonthValuesButton); + + var powerGeneration_MonthTextButton = new Button() + { + X = Application.GetRealWidth(16 + 105), + Y = Application.GetRealWidth(220), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(17), + Text = "鏈湀鍙戠數閲� (kwh)", + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + pvEleGenerationInfoView.AddChidren(powerGeneration_MonthTextButton); + #endregion + + #region 鍏変紡鏈勾鍙戠數閲� + var pvGeneration_YearValuesButton = new Button() + { + X = Application.GetRealWidth(16 + 212), + Y = Application.GetRealWidth(191), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(24), + Text = "---", + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 18, + IsBold = true, + }; + pvEleGenerationInfoView.AddChidren(pvGeneration_YearValuesButton); + + var powerGeneration_YearTextButton = new Button() + { + X = Application.GetRealWidth(16 + 212), + Y = Application.GetRealWidth(220), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(17), + Text = "鏈勾鍙戠數閲� (kwh)", + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + pvEleGenerationInfoView.AddChidren(powerGeneration_YearTextButton); + new System.Threading.Thread(() => + { + try + { + var revertObj = new HttpServerRequest().GetSensorHistory("custom_year", + function.deviceId, InverterJinmao_AttrEnum.pv_electricity.ToString(), DateTime.Now.Year.ToString()); + if (revertObj != null) + { + if (revertObj.Code == StateCode.SUCCESS) + { + var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString()); + double totalValues = 0.0; + double values = 0.0; + foreach (var data in revertData) + { + double.TryParse(data.fieldValue, out values); + totalValues += values; + } + Application.RunOnMainThread(() => + { + pvGeneration_YearValuesButton.Text = totalValues.ToString(); + while (true) + { + if (pvGeneration_YearValuesButton.Width < pvGeneration_YearValuesButton.GetTextWidth()) + { + pvGeneration_YearValuesButton.TextSize--; + } + else + { + break; + } + } + }); + } + } + } + catch (Exception ex) + { + MainPage.Log("Error", "璇诲彇閲戣寕鏈勾鍙戠數閲忔暟鎹紓甯革細" + ex.Message); + } + }) + { IsBackground = true }.Start(); + + #endregion + + #endregion + + contentView.AddChidren(new Button() + { + Height = Application.GetRealWidth(12), + }); + + #region 鐢ㄧ數閲忕姸鎬� electricity usage status + var electricityUsageStatusView = new FrameLayout() + { + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(343), + Height = Application.GetRealWidth(253), + BackgroundColor = CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealHeight(12), + BorderColor = 0x00FFFFFF, + BorderWidth = 0, + }; + contentView.AddChidren(electricityUsageStatusView); + + var powerUsageView = new FrameLayout() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(20), + Width = Application.GetRealWidth(151), + Height = Application.GetRealWidth(151), + }; + electricityUsageStatusView.AddChidren(powerUsageView); + + var powerUsageBg = new Button() + { + UnSelectedImagePath = "FunctionIcon/Acst/Inverter/PvBgDischarge.png" + }; + powerUsageView.AddChidren(powerUsageBg); + + new System.Threading.Thread(() => + { + try + { + int index = 1; + float loadPower = 0.00f; + while (index < 361) + { + float.TryParse(function.GetAttrState(InverterJinmao_AttrEnum.load_active_power.ToString()), out loadPower); + if (loadPower > 0.00f) + { + Application.RunOnMainThread(() => + { + powerUsageBg.SetRotation(1f * index++); + }); + System.Threading.Thread.Sleep(50); + if (index == 361) + { + index = 1; + } + } + } + } + catch (Exception ex) + { + MainPage.Log("Error", $"閲戣寕UI鎺т欢鏃嬭浆寮傚父2:{ex.Message}"); + } + }) + { IsBackground = true }.Start(); + + loadElec_ValuesButton = new Button() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(46), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(32), + Text = function.GetAttrState(InverterJinmao_AttrEnum.load_active_power.ToString()), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 24, + IsBold = true, + }; + powerUsageView.AddChidren(loadElec_ValuesButton); + + var powerUsage_TextButton = new Button() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(78), + //Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(25), + Text = "瀹炴椂鐢ㄧ數鍔熺巼 (kw)", + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + powerUsageView.AddChidren(powerUsage_TextButton); + + + powerUsage_TodayValuesButton = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(191), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(24), + Text = function.GetAttrState(InverterJinmao_AttrEnum.load_electricity_today.ToString()), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 18, + IsBold = true, + }; + electricityUsageStatusView.AddChidren(powerUsage_TodayValuesButton); + + var loadElec_TodayTextButton = new Button() + { + X = Application.GetRealWidth(16), + Y = Application.GetRealWidth(220), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(17), + Text = "浠婃棩鐢ㄧ數閲� (kwh)", + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + electricityUsageStatusView.AddChidren(loadElec_TodayTextButton); + + loadElec_MonthValuesButton = new Button() + { + X = Application.GetRealWidth(16 + 105), + Y = Application.GetRealWidth(191), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(24), + Text = function.GetAttrState(InverterJinmao_AttrEnum.load_electricity_month.ToString()), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 18, + IsBold = true, + }; + electricityUsageStatusView.AddChidren(loadElec_MonthValuesButton); + + var powerUsage_MonthTextButton = new Button() + { + X = Application.GetRealWidth(16 + 105), + Y = Application.GetRealWidth(220), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(17), + Text = "鏈湀鐢ㄧ數閲� (kwh)", + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + electricityUsageStatusView.AddChidren(powerUsage_MonthTextButton); + + + var powerUsage_YearValuesButton = new Button() + { + X = Application.GetRealWidth(16 + 212), + Y = Application.GetRealWidth(191), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(24), + Text = function.GetAttrState(InverterJinmao_AttrEnum.load_electricity.ToString()), + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 18, + IsBold = true, + }; + electricityUsageStatusView.AddChidren(powerUsage_YearValuesButton); + + var powerUsage_YearTextButton = new Button() + { + X = Application.GetRealWidth(16 + 212), + Y = Application.GetRealWidth(220), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(17), + Text = "鏈勾鐢ㄧ數閲� (kwh)", + TextAlignment = TextAlignment.Center, + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + electricityUsageStatusView.AddChidren(powerUsage_YearTextButton); + + + new System.Threading.Thread(() => + { + try + { + var revertObj = new HttpServerRequest().GetSensorHistory("custom_year", + function.deviceId, InverterJinmao_AttrEnum.load_electricity.ToString(), DateTime.Now.Year.ToString()); + if (revertObj != null) + { + if (revertObj.Code == StateCode.SUCCESS) + { + var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString()); + double totalValues = 0.0; + double values = 0.0; + foreach (var data in revertData) + { + double.TryParse(data.fieldValue, out values); + totalValues += values; + } + Application.RunOnMainThread(() => + { + powerUsage_YearValuesButton.Text = totalValues.ToString(); + while (true) + { + if (powerUsage_YearValuesButton.Width < powerUsage_YearValuesButton.GetTextWidth()) + { + powerUsage_YearValuesButton.TextSize--; + } + else + { + break; + } + } + }); + } + } + } + catch (Exception ex) + { + MainPage.Log("Error", "璇诲彇閲戣寕鏈勾鍙戠數閲忔暟鎹紓甯革細" + ex.Message); + } + }) + { IsBackground = true }.Start(); + + #endregion + + + #endregion + + if (function.attributes.Find((obj) => obj.key == InverterJinmao_AttrEnum.ess_status.ToString()) != null) + { + contentView.AddChidren(new Button() + { + Height = Application.GetRealWidth(8) + }); + + #region 鍌ㄨ兘杩愯鐘舵�� Energy storage + var esRunStatus_TitleButton = new Button() + { + X = Application.GetRealWidth(16), + Height = Application.GetRealWidth(47), + TextAlignment = TextAlignment.CenterLeft, + Text = "鍌ㄨ兘杩愯鐘舵��", + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 16, + IsBold = true, + }; + contentView.AddChidren(esRunStatus_TitleButton); + + #region + var esStatusView = new FrameLayout() + { + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(343), + Height = Application.GetRealWidth(194), + BackgroundColor = CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealHeight(12), + BorderColor = 0x00FFFFFF, + BorderWidth = 0, + }; + contentView.AddChidren(esStatusView); + + esStatus_InfoView = new FrameLayout() + { + X = 0 - Application.GetRealWidth(14), + Y = Application.GetRealWidth(12), + Width = Application.GetRealWidth(68 + 14), + Height = Application.GetRealWidth(28), + BackgroundColor = 0x1500C22D, + Radius = (uint)Application.GetRealHeight(14), + BorderColor = 0x00FFFFFF, + BorderWidth = 0, + }; + esStatusView.AddChidren(esStatus_InfoView); + + esRunStatus_Info_IconButton = new Button() + { + X = Application.GetRealWidth(8 + 14), + Gravity = Gravity.CenterVertical, + Width = Application.GetRealWidth(12), + Height = Application.GetRealWidth(12), + UnSelectedImagePath = "FunctionIcon/Acst/Inverter/EsIconCharg.png", + }; + esStatus_InfoView.AddChidren(esRunStatus_Info_IconButton); + + esRunStatus_Info_TextButton = new Button() + { + X = Application.GetRealWidth(8 + 14 + 4 + 12), + TextAlignment = TextAlignment.CenterLeft, + TextSize = 14, + TextColor = 0xFF00C22D, + Text = "鍏呯數", + }; + esStatus_InfoView.AddChidren(esRunStatus_Info_TextButton); + + esRunStatus_BatteryValuesButton = new Button() + { + Y = Application.GetRealWidth(18), + Height = Application.GetRealWidth(17), + TextAlignment = TextAlignment.CenterRight, + Text = function.GetAttrState(InverterJinmao_AttrEnum.battery_soc.ToString()) + "%", + TextSize = 12, + TextColor = 0xFF00C22D, + }; + esRunStatus_BatteryValuesButton.Width = esRunStatus_BatteryValuesButton.GetTextWidth() + Application.GetRealWidth(8); + esRunStatus_BatteryValuesButton.X = Application.GetRealWidth(343 - 12) - esRunStatus_BatteryValuesButton.Width; + esStatusView.AddChidren(esRunStatus_BatteryValuesButton); + + esRunStatus_BatteryIconButton = new Button() + { + X = Application.GetRealWidth(343 - 12 - 20) - esRunStatus_BatteryValuesButton.Width, + Y = Application.GetRealWidth(16), + Width = Application.GetRealWidth(20), + Height = Application.GetRealWidth(20), + UnSelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconCharg.png", + SelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconCharg100.png", + IsSelected = esRunStatus_BatteryValuesButton.Text == "100%" + }; + esStatusView.AddChidren(esRunStatus_BatteryIconButton); + + var esRunStatus_ValuesInfoView = new FrameLayout() + { + Width = Application.GetRealWidth(282), + Height = Application.GetRealWidth(153), + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(40), + BackgroundImagePath = "FunctionIcon/Acst/Inverter/EnergyStorageStatusBg.png", + }; + esStatusView.AddChidren(esRunStatus_ValuesInfoView); + + #region 瀹炴椂鍏呯數鍔熺巼 + var esRunStatus_ChargeValuesView = new FrameLayout() + { + X = Application.GetRealWidth(15), + Width = Application.GetRealWidth(128), + Height = Application.GetRealWidth(128), + }; + esRunStatus_ValuesInfoView.AddChidren(esRunStatus_ChargeValuesView); + + esRunStatus_ChargeValuesButton = new Button() + { + Y = Application.GetRealWidth(36), + Height = Application.GetRealWidth(32), + TextAlignment = TextAlignment.Center, + Text = function.GetAttrState(InverterJinmao_AttrEnum.ess_charge_power.ToString()), + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 24, + IsBold = true, + }; + esRunStatus_ChargeValuesView.AddChidren(esRunStatus_ChargeValuesButton); + + var esRunStatus_ChargeTextButton = new Button() + { + X = Application.GetRealWidth(1), + Y = Application.GetRealWidth(76), + Height = Application.GetRealWidth(17), + TextAlignment = TextAlignment.Center, + Text = "瀹炴椂鍏呯數鍔熺巼(kw)", + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + esRunStatus_ChargeValuesView.AddChidren(esRunStatus_ChargeTextButton); + #endregion + + #region 瀹炴椂鐢ㄧ數鍔熺巼 + var esRunStatus_DischargeValuesView = new FrameLayout() + { + X = Application.GetRealWidth(132 + 13), + Width = Application.GetRealWidth(128), + Height = Application.GetRealWidth(128), + }; + esRunStatus_ValuesInfoView.AddChidren(esRunStatus_DischargeValuesView); + + esRunStatus_DischargeValuesButton = new Button() + { + Y = Application.GetRealWidth(36), + Height = Application.GetRealWidth(32), + TextAlignment = TextAlignment.Center, + Text = function.GetAttrState(InverterJinmao_AttrEnum.ess_discharg_power.ToString()), + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = 24, + IsBold = true, + }; + esRunStatus_DischargeValuesView.AddChidren(esRunStatus_DischargeValuesButton); + + var esRunStatus_DischargeTextButton = new Button() + { + X = Application.GetRealWidth(1), + Y = Application.GetRealWidth(76), + Height = Application.GetRealWidth(17), + TextAlignment = TextAlignment.Center, + Text = "瀹炴椂鏀剧數鍔熺巼(kwh)", + TextColor = CSS_Color.TextualColor, + TextSize = 12, + }; + esRunStatus_DischargeValuesView.AddChidren(esRunStatus_DischargeTextButton); + #endregion + + #endregion + + #endregion + + } + + contentView.AddChidren(new Button() + { + Height = Application.GetRealWidth(8) + }); + + #region 绀句細璐$尞 Social contribution + contentView.AddChidren(new Button() + { + Height = Application.GetRealWidth(46), + Width = Application.GetRealWidth(100), + X = Application.GetRealWidth(16), + Text = "绀句細璐$尞", + TextAlignment = TextAlignment.CenterLeft, + TextSize = 16, + TextColor = CSS_Color.FirstLevelTitleColor, + IsBold = true + }); + + var socialContributionView = new HorizontalScrolViewLayout() + { + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(343), + Height = Application.GetRealHeight(142), + ScrollEnabled = false, + }; + contentView.AddChidren(socialContributionView); + + #region 鑺傜害鏍囧噯鐓� + var socialContribution_InfoView_1 = new FrameLayout() + { + Width = Application.GetRealWidth(109), + Height = Application.GetRealWidth(130), + BackgroundImagePath = "FunctionIcon/Acst/Inverter/SocialContributionInfoBg_Coal.png" + }; + socialContributionView.AddChidren(socialContribution_InfoView_1); + + var socialContribution_Info1_IconButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(16), + Width = Application.GetRealWidth(36), + Height = Application.GetRealWidth(36), + UnSelectedImagePath = "FunctionIcon/Acst/Inverter/SocialContributionInfoIcon_Coal.png" + }; + socialContribution_InfoView_1.AddChidren(socialContribution_Info1_IconButton); + + socialContribution_Info1_ValuesButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(68), + Width = Application.GetRealWidth(36), + Height = Application.GetRealWidth(25), + Text = function.GetAttrState(InverterJinmao_AttrEnum.coal.ToString()), + TextSize = 18, + TextColor = CSS_Color.FirstLevelTitleColor, + TextAlignment = TextAlignment.BottomLeft, + IsBold = true, + }; + socialContribution_Info1_ValuesButton.Width = socialContribution_Info1_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); + socialContribution_InfoView_1.AddChidren(socialContribution_Info1_ValuesButton); + + socialContribution_Info1_UintButton = new Button() + { + X = socialContribution_Info1_ValuesButton.Right - Application.GetRealWidth(4), + Y = Application.GetRealWidth(68), + Width = Application.GetRealWidth(50), + Height = Application.GetRealWidth(23), + Text = "鍚�", + TextSize = 12, + TextColor = CSS_Color.FirstLevelTitleColor, + TextAlignment = TextAlignment.BottomLeft, + }; +#if __IOS__ + socialContribution_Info1_UintButton.Y = Application.GetRealWidth(66); +#endif + socialContribution_InfoView_1.AddChidren(socialContribution_Info1_UintButton); + + var socialContribution_Info1_TipButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(98), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(17), + Text = "鑺傜害鏍囧噯鐓�", + TextSize = 12, + TextColor = 0xFF798394, + TextAlignment = TextAlignment.CenterLeft, + }; + socialContribution_InfoView_1.AddChidren(socialContribution_Info1_TipButton); + #endregion + + socialContributionView.AddChidren(new Button() + { + Width = Application.GetRealWidth(8), + }); + + #region CO2鍑忔帓閲� + var socialContribution_InfoView_2 = new FrameLayout() + { + Width = Application.GetRealWidth(109), + Height = Application.GetRealWidth(130), + BackgroundImagePath = "FunctionIcon/Acst/WaterHeater/SocialContributionInfoBg_2.png" + }; + socialContributionView.AddChidren(socialContribution_InfoView_2); + + var socialContribution_Info2_IconButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(16), + Width = Application.GetRealWidth(36), + Height = Application.GetRealWidth(36), + UnSelectedImagePath = "FunctionIcon/Acst/WaterHeater/SocialContributionInfoIcon_2.png" + }; + socialContribution_InfoView_2.AddChidren(socialContribution_Info2_IconButton); + + socialContribution_Info2_ValuesButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(68), + Width = Application.GetRealWidth(36), + Height = Application.GetRealWidth(25), + Text = function.GetAttrState(InverterJinmao_AttrEnum.co2.ToString()), + TextSize = 18, + TextColor = CSS_Color.FirstLevelTitleColor, + TextAlignment = TextAlignment.BottomLeft, + IsBold = true, + }; + socialContribution_Info2_ValuesButton.Width = socialContribution_Info2_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); + socialContribution_InfoView_2.AddChidren(socialContribution_Info2_ValuesButton); + + socialContribution_Info2_UintButton = new Button() + { + X = socialContribution_Info2_ValuesButton.Right - Application.GetRealWidth(4), + Y = Application.GetRealWidth(68), + Width = Application.GetRealWidth(50), + Height = Application.GetRealWidth(23), + Text = "鍚�", + TextSize = 12, + TextColor = CSS_Color.FirstLevelTitleColor, + TextAlignment = TextAlignment.BottomLeft, + }; +#if __IOS__ + socialContribution_Info2_UintButton.Y = Application.GetRealWidth(66); +#endif + socialContribution_InfoView_2.AddChidren(socialContribution_Info2_UintButton); + + var socialContribution_Info2_TipButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(98), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(17), + Text = "CO2鍑忔帓閲�", + TextSize = 12, + TextColor = 0xFF798394, + TextAlignment = TextAlignment.CenterLeft, + }; + socialContribution_InfoView_2.AddChidren(socialContribution_Info2_TipButton); + #endregion + + socialContributionView.AddChidren(new Button() + { + Width = Application.GetRealWidth(8), + }); + + #region 绛夋晥妞嶆爲閲� + var socialContribution_InfoView_3 = new FrameLayout() + { + Width = Application.GetRealWidth(109), + Height = Application.GetRealWidth(130), + BackgroundImagePath = "FunctionIcon/Acst/WaterHeater/SocialContributionInfoBg_3.png" + }; + socialContributionView.AddChidren(socialContribution_InfoView_3); + + var socialContribution_Info3_IconButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(16), + Width = Application.GetRealWidth(36), + Height = Application.GetRealWidth(36), + UnSelectedImagePath = "FunctionIcon/Acst/WaterHeater/SocialContributionInfoIcon_3.png" + }; + socialContribution_InfoView_3.AddChidren(socialContribution_Info3_IconButton); + + socialContribution_Info3_ValuesButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(68), + Width = Application.GetRealWidth(36), + Height = Application.GetRealWidth(25), + Text = function.GetAttrState(InverterJinmao_AttrEnum.trees.ToString()), + TextSize = 18, + TextColor = CSS_Color.FirstLevelTitleColor, + TextAlignment = TextAlignment.BottomLeft, + IsBold = true, + }; + socialContribution_Info3_ValuesButton.Width = socialContribution_Info3_ValuesButton.GetTextWidth() + Application.GetRealWidth(8); + socialContribution_InfoView_3.AddChidren(socialContribution_Info3_ValuesButton); + + socialContribution_Info3_UintButton = new Button() + { + X = socialContribution_Info3_ValuesButton.Right - Application.GetRealWidth(4), + Y = Application.GetRealWidth(68), + Width = Application.GetRealWidth(50), + Height = Application.GetRealWidth(23), + Text = "妫�", + TextSize = 12, + TextColor = CSS_Color.FirstLevelTitleColor, + TextAlignment = TextAlignment.BottomLeft, + }; + #if __IOS__ + socialContribution_Info3_UintButton.Y = Application.GetRealWidth(66); + #endif + socialContribution_InfoView_3.AddChidren(socialContribution_Info3_UintButton); + + var socialContribution_Info3_TipButton = new Button() + { + X = Application.GetRealWidth(12), + Y = Application.GetRealWidth(98), + Width = Application.GetRealWidth(100), + Height = Application.GetRealWidth(17), + Text = "绛夋晥妞嶆爲閲�", + TextSize = 12, + TextColor = 0xFF798394, + TextAlignment = TextAlignment.CenterLeft, + }; + socialContribution_InfoView_3.AddChidren(socialContribution_Info3_TipButton); + #endregion + + + + #endregion + + Control.Ins.SendReadCommand(function); + } + /// <summary> + /// 鏇存柊鐣岄潰鏁版嵁 + /// </summary> + /// <param name="temp"></param> + public static void UpdateStatus(Function temp) + { + if (bodyView == null) + { + return; + } + Application.RunOnMainThread(() => + { + try + { + /// 鏇存柊浠婃棩鍙戠數閲� + bodyView.upatePvGenerateTodayValues(); + /// 鏇存柊绱鍙戠數閲� + bodyView.upatePvGenerateTotalValues(); + /// 鏇存柊浠婃棩鐢ㄧ數閲� + bodyView.upatePvLoadTodayValues(); + /// 鏇存柊绱鐢ㄧ數閲� + bodyView.upatePvLoadTotalValues(); + /// 鏇存柊鍏変紡杩愯鐘舵�� + bodyView.upatePvRunStatus(); + /// 鏇存柊鍏変紡鍙戠數鍔熺巼 + bodyView.updatePvPower(); + /// 鏇存柊鍏変紡鏈湀鍙戠數閲� + bodyView.upatePvGenerateMonthValues(); + /// 鏇存柊鍏変紡鐢ㄧ數鍔熺巼 + bodyView.updateLoadElec(); + ///鏇存柊鍏変紡鐘舵�佹湰鏈堢敤鐢甸噺 + bodyView.updateLoadElecMonthValues(); + //鏇存柊鍌ㄨ兘杩愯鐘舵�� + bodyView.updateEsRunStates(); + //鏇存柊鍌ㄨ兘鐢垫睜鐧惧垎姣� + bodyView.updateEsBatterySoc(); + //鏇存柊鍌ㄨ兘瀹炴椂鍏呯數鐘舵�� + bodyView.updateEsCharge(); + //鏇存柊鍌ㄨ兘瀹炴椂鏀剧數鐘舵�� + bodyView.updateEsDischarge(); + bodyView.updateSocialContribution1(); + bodyView.updateSocialContribution2(); + bodyView.updateSocialContribution3(); + } + catch (Exception ex) + { + MainPage.Log("Error", $"閲戣寕鍏変紡鏇存柊寮傚父:{ex.StackTrace}"); + } + }); + } + + /// <summary> + /// 鏇存柊浠婃棩鍙戠數閲� + /// </summary> + private void upatePvGenerateTodayValues() + { + pvGenerate_TodayValuesButton.Text = pvGeneration_TodayValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.pv_electricity_today.ToString()); + +#if __IOS__ + pvGenerate_TodayValuesButton.TextAlignment = TextAlignment.TopLeft; + pvGenerate_TodayValuesButton.Width = pvGenerate_TodayValuesButton.GetTextWidth() + Application.GetRealWidth(8); +#else + pvGenerate_TodayValuesButton.TextAlignment = TextAlignment.BottomLeft; + pvGenerate_TodayValuesButton.Y = Application.GetRealWidth(37); + pvGenerate_TodayValuesButton.Width = pvGenerate_TodayValuesButton.GetTextWidth() + Application.GetRealWidth(4); +#endif + pvGenerate_todayUintButton.X = pvGenerate_TodayValuesButton.Right; + } + /// <summary> + /// 鏇存柊鍏変紡鏈湀鍙戠數閲� + /// </summary> + private void upatePvGenerateMonthValues() + { + pvGeneration_MonthValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.pv_electricity_month.ToString()); + } + /// <summary> + /// 鏇存柊绱鍙戠數閲� + /// </summary> + private void upatePvGenerateTotalValues() + { + pvGenerate_TotalValuesButton.Text = "绱鍙戠數閲�:" + function.GetAttrState(InverterJinmao_AttrEnum.pv_electricity.ToString()); + } + /// <summary> + /// 鏇存柊浠婃棩鐢ㄧ數閲� + /// </summary> + private void upatePvLoadTodayValues() + { + pvLoad_TodayValuesButton.Text = powerUsage_TodayValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.load_electricity_today.ToString()); + +#if __IOS__ + pvLoad_TodayValuesButton.Y = Application.GetRealWidth(34); + pvLoad_TodayValuesButton.X = Application.GetRealWidth(81 - 12) - loadEle_TodayUintButton.Width; +#else + pvLoad_TodayValuesButton.Y = Application.GetRealWidth(37); + pvLoad_TodayValuesButton.X = Application.GetRealWidth(81 - 16) - loadEle_TodayUintButton.Width; +#endif + } + /// <summary> + /// 鏇存柊鏈湀鐢ㄧ數閲� + /// </summary> + private void updateLoadElecMonthValues() + { + loadElec_MonthValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.load_electricity_month.ToString()); + } + /// <summary> + /// 鏇存柊绱鐢ㄧ數閲� + /// </summary> + private void upatePvLoadTotalValues() + { + pvLoad_TotalValuesButton.Text = "绱鐢ㄧ數閲忥細" + function.GetAttrState(InverterJinmao_AttrEnum.load_electricity.ToString()); + + } + /// <summary> + /// 鏇存柊鍏変紡杩愯鐘舵�� + /// </summary> + private void upatePvRunStatus() + { + switch (function.GetAttrState(InverterJinmao_AttrEnum.system_status.ToString())) + { + case "run": + pvRunStatusInfoView.BackgroundColor = 0x154484F4; + pvRunStatus_IconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/PvIconRun.png"; + pvRunStatus_TextButton.Text = "杩愯"; + pvRunStatus_TextButton.TextColor = 0xFF4484F4; + break; + case "fault": + pvRunStatusInfoView.BackgroundColor = 0x15FF4747; + pvRunStatus_IconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/PvIconFault.png"; + pvRunStatus_TextButton.Text = "鏁呴殰"; + pvRunStatus_TextButton.TextColor = 0xFFFF4747; + break; + case "standby": + pvRunStatusInfoView.BackgroundColor = 0x15798394; + pvRunStatus_IconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/PvIconStandby.png"; + pvRunStatus_TextButton.Text = "寰呮満"; + pvRunStatus_TextButton.TextColor = 0xFF798394; + break; + } + + } + /// <summary> + /// 鏇存柊鍏変紡鍙戠數鍔熺巼 + /// </summary> + private void updatePvPower() + { + pvPower_ValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.pv_power.ToString()); + } + /// <summary> + /// 鏇存柊鍏変紡鐢ㄧ數鍔熺巼 + /// </summary> + private void updateLoadElec() + { + loadElec_ValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.load_active_power.ToString()); + } + /// <summary> + /// 鏇存柊鍌ㄨ兘杩愯鐘舵�� + /// </summary> + private void updateEsRunStates() + { + if (function.attributes.Find((obj) => obj.key == InverterJinmao_AttrEnum.ess_status.ToString()) != null) + { + switch (function.GetAttrState(InverterJinmao_AttrEnum.ess_status.ToString())) + { + case "charge": + esStatus_InfoView.BackgroundColor = 0x1500C22D; + esRunStatus_Info_TextButton.TextColor = esRunStatus_BatteryValuesButton.TextColor = 0xFF00C22D; + esRunStatus_Info_IconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/EsIconCharg.png"; + esRunStatus_Info_TextButton.Text = "鍏呯數"; + esRunStatus_BatteryIconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconCharg.png"; + esRunStatus_BatteryIconButton.SelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconCharg100.png"; + break; + case "discharge": + esStatus_InfoView.BackgroundColor = 0x15FC9C04; + esRunStatus_Info_TextButton.TextColor = esRunStatus_BatteryValuesButton.TextColor = 0xFFFC9C04; + esRunStatus_Info_IconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/EsIconDischarge.png"; + esRunStatus_Info_TextButton.Text = "鏀剧數"; + esRunStatus_BatteryIconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconDischarg.png"; + esRunStatus_BatteryIconButton.SelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconDischarg100.png"; + break; + case "shutdown": + esStatus_InfoView.BackgroundColor = 0x15798394; + esRunStatus_Info_TextButton.TextColor = esRunStatus_BatteryValuesButton.TextColor = 0xFF798394; + esRunStatus_Info_IconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/EsIconShutdown.png"; + esRunStatus_Info_TextButton.Text = "鍋滄満"; + esRunStatus_BatteryIconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconShutdown.png"; + esRunStatus_BatteryIconButton.SelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconShutdown100.png"; + break; + case "fault": + esStatus_InfoView.BackgroundColor = 0x15FF4747; + esRunStatus_Info_TextButton.TextColor = esRunStatus_BatteryValuesButton.TextColor = 0xFFFF4747; + esRunStatus_Info_IconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/EsIconFault.png"; + esRunStatus_Info_TextButton.Text = "鏁呴殰"; + esRunStatus_BatteryIconButton.UnSelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconFault.png"; + esRunStatus_BatteryIconButton.SelectedImagePath = "FunctionIcon/Acst/Inverter/BatteryIconFault100.png"; + break; + } + } + } + /// <summary> + /// 鏇存柊鍌ㄨ兘鐢垫睜鐧惧垎姣旂姸鎬� + /// </summary> + private void updateEsBatterySoc() + { + if (function.attributes.Find((obj) => obj.key == InverterJinmao_AttrEnum.ess_status.ToString()) != null) + { + esRunStatus_BatteryValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.battery_soc.ToString()) + "%"; + if (esRunStatus_BatteryIconButton.Text == "100%") + { + esRunStatus_BatteryIconButton.IsSelected = true; + } + } + } + /// <summary> + /// 鏇存柊鍌ㄨ兘瀹炴椂鍏呯數鐘舵�� + /// </summary> + private void updateEsCharge() + { + if (function.attributes.Find((obj) => obj.key == InverterJinmao_AttrEnum.ess_status.ToString()) != null) + { + esRunStatus_ChargeValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.ess_charge_power.ToString()); + } + } + /// <summary> + /// 鏇存柊鍌ㄨ兘瀹炴椂鏀剧數鐘舵�� + /// </summary> + private void updateEsDischarge() + { + if (function.attributes.Find((obj) => obj.key == InverterJinmao_AttrEnum.ess_status.ToString()) != null) + { + esRunStatus_DischargeValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.ess_discharg_power.ToString()); + } + } + /// <summary> + /// 鏇存柊绀句細璐$尞1鏁版嵁UI + /// </summary> + private void updateSocialContribution1() + { + socialContribution_Info1_ValuesButton.Text = function.GetAttrState(InverterJinmao_AttrEnum.coal.ToString()); + socialContribution_Info1_ValuesButton.Width = socialContribution_Info1_ValuesButton.GetTextWidth(); + if (socialContribution_Info1_ValuesButton.Width > Application.GetRealWidth(61)) + { + socialContribution_Info1_ValuesButton.TextSize = 14; + socialContribution_Info1_ValuesButton.Width = socialContribution_Info1_ValuesButton.GetTextWidth(); + socialContribution_Info1_UintButton.Height = Application.GetRealWidth(25); + } +#if __IOS__ + socialContribution_Info1_ValuesButton.Width += Application.GetRealWidth(6); + socialContribution_Info1_UintButton.X = socialContribution_Info1_ValuesButton.Right - Application.GetRealWidth(4); +#else + socialContribution_Info1_UintButton.X = socialContribution_Info1_ValuesButton.Right +Application.GetRealWidth(2); +#endif + } + /// <summary> + /// 鏇存柊绀句細璐�2鐚暟鎹甎I + /// </summary> + private void updateSocialContribution2() + { + socialContribution_Info2_ValuesButton.Text = function.GetAttrState(WaterHeaterJinmao_AttrEnum.co2.ToString()); + socialContribution_Info2_ValuesButton.Width = socialContribution_Info2_ValuesButton.GetTextWidth(); + if (socialContribution_Info2_ValuesButton.Width > Application.GetRealWidth(61)) + { + socialContribution_Info2_ValuesButton.TextSize = 14; + socialContribution_Info2_ValuesButton.Width = socialContribution_Info2_ValuesButton.GetTextWidth(); + } +#if __IOS__ + socialContribution_Info2_ValuesButton.Width += Application.GetRealWidth(6); + socialContribution_Info2_UintButton.X = socialContribution_Info2_ValuesButton.Right - Application.GetRealWidth(4); +#else + socialContribution_Info2_UintButton.X = socialContribution_Info2_ValuesButton.Right +Application.GetRealWidth(2); +#endif + + } + /// <summary> + /// 鏇存柊绀句細璐�3鐚暟鎹甎I + /// </summary> + private void updateSocialContribution3() + { + socialContribution_Info3_ValuesButton.Text = function.GetAttrState(WaterHeaterJinmao_AttrEnum.trees.ToString()); + socialContribution_Info3_ValuesButton.Width = socialContribution_Info3_ValuesButton.GetTextWidth(); + if (socialContribution_Info3_ValuesButton.Width > Application.GetRealWidth(61)) + { + socialContribution_Info3_ValuesButton.TextSize = 14; + socialContribution_Info3_ValuesButton.Width = socialContribution_Info3_ValuesButton.GetTextWidth(); + socialContribution_Info3_UintButton.Height = Application.GetRealWidth(25); + } +#if __IOS__ + socialContribution_Info3_ValuesButton.Width += Application.GetRealWidth(6); + socialContribution_Info3_UintButton.X = socialContribution_Info3_ValuesButton.Right - Application.GetRealWidth(4); +#else + socialContribution_Info3_UintButton.X = socialContribution_Info3_ValuesButton.Right +Application.GetRealWidth(2); +#endif + } + } +} + -- Gitblit v1.8.0