| | |
| | | /// </summary> |
| | | TextButton btnTotalValue; |
| | | /// <summary> |
| | | /// 总功耗-饼图 |
| | | /// </summary> |
| | | MyEchartsViewOn myEchartsView_Pie; |
| | | /// <summary> |
| | | /// 历史数据区域 |
| | | /// </summary> |
| | | FrameLayout diagramView; |
| | | /// <summary> |
| | | /// 曲线图 |
| | | /// </summary> |
| | | MyEchartsViewOn myLineEchartsView; |
| | | /// <summary> |
| | | /// 曲线图数据string |
| | | /// </summary> |
| | |
| | | /// <summary> |
| | | /// 历史数据图表 |
| | | /// </summary> |
| | | MyEchartsViewOn myEchartsView; |
| | | MyEchartsViewOn myEchartsView_Line; |
| | | /// <summary> |
| | | /// 曲线图是否展开 |
| | | /// </summary> |
| | |
| | | public EnergyMainPage() |
| | | { |
| | | bodyView = this; |
| | | energyList = FunctionList.List.GetEnergyList(); |
| | | energyList = FunctionList.List.GetEnergyList(); |
| | | var breaker = FunctionList.List.Functions.FindAll((obj) => obj.spk == SPK.AirSwitch); |
| | | var energyBreker = breaker.FindAll((obj) => obj.GetAttribute("power") != null); |
| | | energyList.AddRange(energyBreker); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | generalTableView = new FrameLayout() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight(16), |
| | | Y = Application.GetRealWidth(16), |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealWidth(148),//419//148 |
| | | Radius = (uint)Application.GetRealWidth(5), |
| | |
| | | }; |
| | | generalTableView.AddChidren(btnRealTimeData); |
| | | |
| | | UpdataValue(); |
| | | |
| | | |
| | | var echartsView = new FrameLayout() |
| | | { |
| | |
| | | //Y = Application.GetRealWidth(16), |
| | | }; |
| | | generalTableView.AddChidren(echartsView); |
| | | myEchartsView = new MyEchartsViewOn() |
| | | myEchartsView_Pie = new MyEchartsViewOn() |
| | | { |
| | | Width = Application.GetRealWidth(118), |
| | | Height = Application.GetRealWidth(118), |
| | | }; |
| | | echartsView.AddChidren(myEchartsView_Pie); |
| | | |
| | | echartsView.AddChidren(myEchartsView); |
| | | Dictionary<string, string> list = new Dictionary<string, string>(); |
| | | |
| | | foreach(var ene in energyList) |
| | | { |
| | | double tt = 0; |
| | | double.TryParse(ene.GetAttrState(FunctionAttributeKey.TotalElectricity), out tt); |
| | | tt *= 100;//乘以100,小于1无法加载echart |
| | | |
| | | tt = Math.Round(tt, 2); |
| | | list.Add(ene.name, tt.ToString()); |
| | | } |
| | | |
| | | var echartsPie = new EchartsOption_Pie(); |
| | | var echartRootJson = echartsPie.InitDateJson(list); |
| | | //var echartRootJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(echartRootJson); |
| | | myEchartsView.ShowWithOption(echartRootJson); |
| | | |
| | | myEchartsView_Pie.ShowWithOption(new EchartsOption_Pie().InitDateJson(list)); |
| | | |
| | | btnDrodDown = new Button() |
| | | { |
| | |
| | | showDiagramView(); |
| | | }; |
| | | |
| | | UpdataValue(); |
| | | #endregion |
| | | |
| | | |
| | |
| | | { |
| | | EnergyRow(energy, energyListView, index); |
| | | index++; |
| | | Control.Ins.SendReadCommand(energy); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | Control.Ins.SendReadCommand(energy); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | if (isUnfoldOrStow)//展开 |
| | | { |
| | | generalTableView.Height = Application.GetRealHeight(419); |
| | | generalTableView.Height = Application.GetRealWidth(419); |
| | | btnDrodDown.Y = Application.GetRealWidth(389); |
| | | btnDrodDown.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | generalTableView.Height = Application.GetRealHeight(148); |
| | | generalTableView.Height = Application.GetRealWidth(148); |
| | | btnDrodDown.Y = Application.GetRealWidth(118); |
| | | btnDrodDown.IsSelected = false; |
| | | } |
| | |
| | | |
| | | diagramView = new FrameLayout() |
| | | { |
| | | Y = Application.GetRealHeight(136), |
| | | Y = Application.GetRealWidth(136), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealWidth(241), |
| | | Height = Application.GetRealWidth(281), |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | Radius = (uint)Application.GetRealWidth(12), |
| | | BorderColor = 0x00000000, |
| | |
| | | TextColor = CSS_Color.PromptingColor2, |
| | | SelectedTextColor = CSS_Color.MainColor, |
| | | TextSize = CSS_FontSize.PromptFontSize_FirstLevel, |
| | | Text = DateTime.Now.Month.ToString() + Language.StringByID(StringId.month), |
| | | Text = Language.StringByID(StringId.month),//DateTime.Now.Month.ToString() + |
| | | }; |
| | | showDataTypeView.AddChidren(btnShowHistroyData_Month); |
| | | |
| | |
| | | var historyDataView = new FrameLayout() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight(52), |
| | | //Width = Application.GetRealWidth(343 - 32), |
| | | Height = Application.GetRealHeight(178), |
| | | Y = Application.GetRealWidth(52), |
| | | Height = Application.GetRealWidth(190), |
| | | }; |
| | | diagramView.AddChidren(historyDataView); |
| | | |
| | | myEchartsView = new MyEchartsViewOn() { |
| | | Y = Application.GetRealHeight(10), |
| | | Height = Application.GetRealHeight(150), |
| | | myEchartsView_Line = new MyEchartsViewOn() |
| | | { |
| | | Y = Application.GetRealWidth(10), |
| | | Height = Application.GetRealWidth(180), |
| | | }; |
| | | |
| | | historyDataView.AddChidren(myEchartsView); |
| | | |
| | | historyDataView.AddChidren(myEchartsView_Line); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | myEchartsView.ShowWithOption(opString); |
| | | myEchartsView_Line.ShowWithOption(opString); |
| | | }); |
| | | |
| | | return; |
| | |
| | | sr.attributes.Add(new FunctionAttributes() { key = "ydata" }); |
| | | } |
| | | sr.SetAttrState("ydata", brokenLine.InitYdataText(sr.name, revertData, sr.GetAttrState("color")) + ","); |
| | | //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)"; |
| | |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | myEchartsView.ShowWithOption(opString); |
| | | myEchartsView_Line.ShowWithOption(opString); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | |
| | | row.Y = btnLine.Bottom; |
| | | view.AddChidren(row); |
| | | //记录需要更新的更新按钮 |
| | | listButton_value.Add(row.btnValue); |
| | | |
| | | Control.Ins.SendReadCommand(energy); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 记录需要更新的更新按钮 |
| | | /// </summary> |
| | | public List<Button> listButton_value = new List<Button>(); |
| | | |
| | | /// <summary> |
| | |
| | | var newValue = updataTemp.GetAttrState(FunctionAttributeKey.Power); |
| | | //if (newValue != btn.Text) |
| | | { |
| | | btn.Text = newValue; |
| | | btn.Text = Math.Round(double.Parse(newValue), 2).ToString();// +"W"; |
| | | UpdataValue(); |
| | | } |
| | | } |
| | |
| | | { |
| | | double totalValue = 0; |
| | | double realtimeValue = 0; |
| | | Dictionary<string, string> list = new Dictionary<string, string>();//饼图数据 |
| | | foreach (var ene in bodyView.energyList) |
| | | { |
| | | double power = 0; |
| | | double power = 0.00; |
| | | double.TryParse(ene.GetAttrState(FunctionAttributeKey.TotalElectricity), out power); |
| | | power = Math.Round(power, 2); |
| | | totalValue += power; |
| | | |
| | | int realTimePower = 0; |
| | | int.TryParse(ene.GetAttrState(FunctionAttributeKey.Power), out realTimePower); |
| | | double realTimePower = 0; |
| | | double.TryParse(ene.GetAttrState(FunctionAttributeKey.Power), out realTimePower); |
| | | realtimeValue += realTimePower; |
| | | realtimeValue = Math.Round(realtimeValue, 2); |
| | | |
| | | #region 饼图数据 |
| | | double tt = 0.00; |
| | | double.TryParse(ene.GetAttrState(FunctionAttributeKey.TotalElectricity), out tt); |
| | | tt = Math.Round(tt, 2); |
| | | tt *= 100;//乘以100,小于1无法加载echart |
| | | list.Add(ene.name, tt.ToString()); |
| | | #endregion |
| | | } |
| | | bodyView.btnTotalValue.Text = totalValue.ToString(); |
| | | realtimeValue /= 1000; |
| | |
| | | ///动态获取文本宽度 |
| | | bodyView.btnTotalValue.Width = bodyView.btnTotalValue.GetTextWidth() + Application.GetRealWidth(5); |
| | | bodyView.btnTotalValueUint.X = bodyView.btnTotalValue.Right; |
| | | //刷新饼图 |
| | | bodyView.myEchartsView_Pie.ShowWithOption(new EchartsOption_Pie().InitDateJson(list)); |
| | | |
| | | } |
| | | } |
| | | |