wxr
2024-07-16 cbc156bc38d8b8eae7aef60cb186ab2b52fa701f
HDL_ON/UI/UI2/FuntionControlView/Electrical/AirSwitchP3EnergyPage.cs
@@ -93,6 +93,7 @@
                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);
@@ -112,8 +113,11 @@
                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()
            {
@@ -129,8 +133,11 @@
                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()
            {
@@ -146,6 +153,7 @@
                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);
@@ -157,8 +165,6 @@
                {
                    return;
                }
                curQueryType = "total";
                (sender as Button).SelectedBackgroundColor = 0x1F5C62FE;
                (sender as Button).BackgroundColor = 0x1F5C62FE;
                (sender as Button).BorderColor = CSS_Color.MainColor;
@@ -183,7 +189,11 @@
                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_Day.MouseUpEventHandler = (sender, e) =>
@@ -216,6 +226,10 @@
                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 = "";
                LoadMothed_GetHistoryData();
@@ -251,6 +265,10 @@
                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 = "";
                LoadMothed_GetHistoryData();
@@ -262,7 +280,6 @@
                {
                    return;
                }
                (sender as Button).SelectedBackgroundColor = 0x1F5C62FE;
                (sender as Button).BackgroundColor = 0x1F5C62FE;
                (sender as Button).BorderColor = CSS_Color.MainColor;
@@ -287,6 +304,10 @@
                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";
                brokenLine.YvalueText = "";
@@ -319,7 +340,7 @@
            var btnTip = new Button()
            {
                Y = Application.GetRealHeight(289),
                Y = Application.GetRealWidth(289),
                Height = Application.GetRealHeight(41),
                Width = Application.GetRealWidth(300),
                TextAlignment = TextAlignment.Center,
@@ -452,19 +473,21 @@
            btnTitlea.MouseUpEventHandler = (sender, e) => {
                var skipView = new AirSwitchP3SubloopEnergyPage(device,FunctionAttributeKey.ElectricityA);
                MainPage.BasePageView.AddChidren(skipView);
                skipView.LoadPage();
                skipView.LoadPage(StringId.RealTimeElectricityConsumptionDataOfPhaseA);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnTitlea.MouseUpEventHandler = (sender, e) => {
            btnTitleb.MouseUpEventHandler = (sender, e) => {
                var skipView = new AirSwitchP3SubloopEnergyPage(device, FunctionAttributeKey.ElectricityB);
                MainPage.BasePageView.AddChidren(skipView);
                skipView.LoadPage();
                skipView.LoadPage(StringId.RealTimeElectricityConsumptionDataOfPhaseB);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnTitlea.MouseUpEventHandler = (sender, e) => {
            btnTitlec.MouseUpEventHandler = (sender, e) => {
                var skipView = new AirSwitchP3SubloopEnergyPage(device, FunctionAttributeKey.ElectricityC);
                MainPage.BasePageView.AddChidren(skipView);
                skipView.LoadPage();
                skipView.LoadPage(StringId.RealTimeElectricityConsumptionDataOfPhaseC);
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
@@ -493,6 +516,9 @@
            };
            totalElectricityView.AddChidren(btnTotalElectricity);
            double totalNumber = 0.00;
            double.TryParse(device.GetAttrState(FunctionAttributeKey.TotalElectricity), out totalNumber);
            var btnTotalNumber = new Button()
            {
                Y = Application.GetRealHeight(27),
@@ -501,43 +527,43 @@
                TextSize = 49,
                TextColor = 0xFF030D1C,
                TextAlignment = TextAlignment.Center,
                Text = device.GetAttrState(FunctionAttributeKey.TotalElectricity),
                Text = totalNumber.ToString("F2"),
            };
            totalElectricityView.AddChidren(btnTotalNumber);
            btnShowHistroyData_Day.MouseUpEventHandler += (sender, e) => {
                totalElectricityView.RemoveFromParent();
                historyDataView.AddChidren(myEchartsView_Line);
                viewa.Visible = true;
                viewb.Visible = true;
                viewc.Visible = true;
                //viewa.Visible = true;
                //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();
                historyDataView.AddChidren(myEchartsView_Line);
                viewa.Visible = true;
                viewb.Visible = true;
                viewc.Visible = true;
                //viewa.Visible = true;
                //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();
                historyDataView.AddChidren(myEchartsView_Line);
                viewa.Visible = false;
                viewb.Visible = false;
                viewc.Visible = false;
                //viewa.Visible = false;
                //viewb.Visible = false;
                //viewc.Visible = false;
                btnTip.TextID = StringId.AirSwitchP3HistroyTip3;
                historyDataView.Height = Application.GetRealHeight(330);
                historyDataView.Height = Application.GetRealWidth(330);
            };
            btnShowHistroyData_Total.MouseUpEventHandler += (sender, e) => {
                myEchartsView_Line.RemoveFromParent();
                historyDataView.AddChidren(totalElectricityView);
                viewa.Visible = false;
                viewb.Visible = false;
                viewc.Visible = false;
                //viewa.Visible = false;
                //viewb.Visible = false;
                //viewc.Visible = false;
                historyDataView.Height = Application.GetRealHeight(184);
            };
@@ -576,37 +602,25 @@
                    });
                    var sensorType = device.spk.Split(".")[1];
                    var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, device.deviceId, "power_a");
                    var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, device.deviceId, FunctionAttributeKey.TotalElectricity);
                    if (revertObj != null)
                    {
                        if (revertObj.Code == StateCode.SUCCESS)
                        {
                            var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString());
                            if (revertData == null || revertData.Count == 0) {
#if DEBUG
                            if (revertData == null || revertData.Count == 0) {
                                List<string> vs = new List<string>() {
                                    "813","313","213","123",
                                    "113","213","183","133",
                                    "133","513","133","413",
                                    "813","313","213","123",
                                    "113","213","183","133",
                                    "133","513","133","413",
                                    "1","2","3","4",
                                    "5","6","7","8",
                                    "9","10","11","12",
                                    //"13","14","15","16",
                                    //"17","18","19","20",
                                    //"21","22","23","24",
                                };
                                    brokenLine.InitXdataText(vs);
                                revertData = new List<EnvironmentalSensorHistor>()
                                {
                                    new EnvironmentalSensorHistor{ fieldValue = "100"},
                                    new EnvironmentalSensorHistor{ fieldValue = "200"},
                                    new EnvironmentalSensorHistor{ fieldValue = "300"},
                                    new EnvironmentalSensorHistor{ fieldValue = "400"},
                                    new EnvironmentalSensorHistor{ fieldValue = "500"},
                                    new EnvironmentalSensorHistor{ fieldValue = "400"},
                                    new EnvironmentalSensorHistor{ fieldValue = "100"},
                                    new EnvironmentalSensorHistor{ fieldValue = "200"},
                                    new EnvironmentalSensorHistor{ fieldValue = "300"},
                                    new EnvironmentalSensorHistor{ fieldValue = "400"},
                                    new EnvironmentalSensorHistor{ fieldValue = "500"},
                                    new EnvironmentalSensorHistor{ fieldValue = "400"},
                                    new EnvironmentalSensorHistor{ fieldValue = "100"},
                                    new EnvironmentalSensorHistor{ fieldValue = "200"},
                                    new EnvironmentalSensorHistor{ fieldValue = "300"},
@@ -626,9 +640,9 @@
                                }
                                device.SetAttrState("ydata", brokenLine.InitYdataText2(device.name, revertData, "#5C62FE", curQueryType == "year_month") + ", ");
                        }
                        else
#endif
                            }
                            else
                            {
                                List<string> vs = new List<string>();
                                if (brokenLine.YvalueText == "")
@@ -654,7 +668,7 @@
                        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);