using System; using System.Collections.Generic; using HDL_ON.DAL.Server; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public class CacDayHistoryPage : FrameLayout { CacDayHistoryPage bodyView; EchartsOption_BrokenLine brokenLine; MyEchartsViewOn myEchartsView_Line; string curQueryType = "hour"; public CacDayHistoryPage() { bodyView = this; } /// /// /// public void InitView() { new TopViewDiv(bodyView, Language.StringByID(StringId.StatisticalChart24Hour)).LoadTopView(); bodyView.BackgroundColor = CSS_Color.BackgroundColor; var contentView = new FrameLayout() { Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(603), }; bodyView.AddChidren(contentView); var historyDataView = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealWidth(52), Height = Application.GetRealWidth(350), }; contentView.AddChidren(historyDataView); brokenLine = new EchartsOption_BrokenLine(); myEchartsView_Line = new MyEchartsViewOn() { Y = Application.GetRealWidth(10), Height = Application.GetRealWidth(338), }; historyDataView.AddChidren(myEchartsView_Line); #if DEBUG List vs = new List() { "1","2","3","4","5","6","7","8","9","10","11","12","13","14" }; brokenLine.InitXdataText(vs); brokenLine.InitYdataText("yData", new List() { new EnvironmentalSensorHistor{ fieldName = "1", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "2", fieldValue= "22" }, new EnvironmentalSensorHistor{ fieldName = "3", fieldValue= "-11" }, new EnvironmentalSensorHistor{ fieldName = "4", fieldValue= "21" }, new EnvironmentalSensorHistor{ fieldName = "5", fieldValue= "-41" }, new EnvironmentalSensorHistor{ fieldName = "6", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "7", fieldValue= "-31" }, new EnvironmentalSensorHistor{ fieldName = "8", fieldValue= "-23" }, new EnvironmentalSensorHistor{ fieldName = "9", fieldValue= "-11" }, new EnvironmentalSensorHistor{ fieldName = "10", fieldValue= "-21" }, new EnvironmentalSensorHistor{ fieldName = "11", fieldValue= "24" }, new EnvironmentalSensorHistor{ fieldName = "12", fieldValue= "41" }, new EnvironmentalSensorHistor{ fieldName = "13", fieldValue= "32" }, new EnvironmentalSensorHistor{ fieldName = "14", fieldValue= "23" } }, "#FF9D54"); brokenLine.yTitle = "(℃)"; brokenLine.xTitle = ""; if (curQueryType != "hour") { brokenLine.xTitle = Language.StringByID(StringId.Date); } var opString = brokenLine.InitOption(); myEchartsView_Line.ShowWithOption(opString); #endif } /// /// 读取历史数据 /// void LoadMothed_GetHistoryData(Function sr, bool isDel) { var loadPage = new Loading() { LodingBackgroundColor = 0x88888888, }; bodyView.AddChidren(loadPage); new System.Threading.Thread(() => { try { Application.RunOnMainThread(() => { loadPage.Start(Language.StringByID(StringId.PleaseWait)); }); var sensorType = sr.spk.Split(".")[1]; var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, sr.deviceId, "total_electricity"); if (revertObj != null) { if (revertObj.Code == StateCode.SUCCESS) { var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject>(revertObj.Data.ToString()); List vs = new List(); if (brokenLine.YvalueText == "") { foreach (var data in revertData) { vs.Add(data.fieldName); } brokenLine.InitXdataText(vs); } if (sr.GetAttribute("ydata") == null) { sr.attributes.Add(new FunctionAttributes() { key = "ydata" }); } sr.SetAttrState("ydata", brokenLine.InitYdataText(sr.name, revertData, sr.GetAttrState("color")) + ","); } } brokenLine.yTitle = Language.StringByID(StringId.EnergyConsumption) + "(kW)"; brokenLine.xTitle = Language.StringByID(StringId.timeMode); if (curQueryType != "hour") { brokenLine.xTitle = Language.StringByID(StringId.Date); } var opString = brokenLine.InitOption(); Application.RunOnMainThread(() => { myEchartsView_Line.ShowWithOption(opString); }); } catch (Exception ex) { MainPage.Log($"sensor history error : {ex.Message}"); } finally { Application.RunOnMainThread(() => { loadPage.Hide(); }); } }) { IsBackground = true }.Start(); } } }