From 080c80af2b63363637e2724fb22466a25de8e8cb Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Sun, 3 May 2020 01:36:57 -0400 Subject: [PATCH 1/3] Adjusts ExportView --- DistrictEnergy/Views/ExportView.xaml | 95 ++++++++++--------- .../Views/PlantSettings/NetworkView.xaml.cs | 2 +- 2 files changed, 50 insertions(+), 47 deletions(-) diff --git a/DistrictEnergy/Views/ExportView.xaml b/DistrictEnergy/Views/ExportView.xaml index f03c874..9a760ff 100644 --- a/DistrictEnergy/Views/ExportView.xaml +++ b/DistrictEnergy/Views/ExportView.xaml @@ -30,51 +30,54 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + diff --git a/DistrictEnergy/Views/PlantSettings/NetworkView.xaml.cs b/DistrictEnergy/Views/PlantSettings/NetworkView.xaml.cs index 57508a8..f131ed1 100644 --- a/DistrictEnergy/Views/PlantSettings/NetworkView.xaml.cs +++ b/DistrictEnergy/Views/PlantSettings/NetworkView.xaml.cs @@ -21,7 +21,7 @@ public NetworkView() private void LoadThis(object sender, UmiContext e) { - foreach (var export in DistrictControl.Instance.ListOfPlantSettings.OfType()) + foreach (var export in DistrictControl.Instance.ListOfDistrictLoads.OfType()) { Exports.Children.Add(new ExportView(export)); } From 71c9d5d9177a99cc988679af284897e0288c757f Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Sun, 3 May 2020 02:04:03 -0400 Subject: [PATCH 2/3] Adds Export Costs to CostView --- .../Networks/ThermalPlants/Dispatchable.cs | 20 +++++++++++++++ .../Networks/ThermalPlants/Exportable.cs | 4 ++- DistrictEnergy/ViewModels/CostsViewModel.cs | 25 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/DistrictEnergy/Networks/ThermalPlants/Dispatchable.cs b/DistrictEnergy/Networks/ThermalPlants/Dispatchable.cs index d8b8397..b6add14 100644 --- a/DistrictEnergy/Networks/ThermalPlants/Dispatchable.cs +++ b/DistrictEnergy/Networks/ThermalPlants/Dispatchable.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Media; +using Deedle; using DistrictEnergy.Helpers; using LiveCharts.Defaults; using Newtonsoft.Json; @@ -45,6 +46,16 @@ public FixedCost(IThermalPlantSettings plant, byte alpha = 255) Cost = plant.Output.Max() * DistrictControl.PlanningSettings.AnnuityFactor * plant.F / (8760 / DistrictControl.PlanningSettings.TimeSteps); } + + public FixedCost(Exportable plant, byte alpha = 255) + { + var color = plant.Fill.Color; + Fill = new SolidColorBrush(Color.FromArgb(alpha, color.R, color.G, color.B)); + Name = plant.Name + " Fixed Cost"; + if (plant.Input != null) + Cost = plant.Input.Max() * DistrictControl.PlanningSettings.AnnuityFactor * plant.F / + (8760 / DistrictControl.PlanningSettings.TimeSteps); + } } public class VariableCost : GraphCost @@ -63,6 +74,15 @@ public VariableCost(IThermalPlantSettings plant, byte alpha = 255) if (plant.Output != null) Cost = plant.Output.Select(x => x.Value * plant.V).Sum(); } + + public VariableCost(Exportable plant, byte alpha = 255) + { + var color = plant.Fill.Color; + Fill = new SolidColorBrush(Color.FromArgb(alpha, color.R, color.G, color.B)); + Name = plant.Name + " Variable Cost"; + if (plant.Input != null) + Cost = plant.Input.Select(x => x * plant.V).Sum(); + } } public class GraphCost diff --git a/DistrictEnergy/Networks/ThermalPlants/Exportable.cs b/DistrictEnergy/Networks/ThermalPlants/Exportable.cs index 1d92a5d..ee8e97d 100644 --- a/DistrictEnergy/Networks/ThermalPlants/Exportable.cs +++ b/DistrictEnergy/Networks/ThermalPlants/Exportable.cs @@ -11,6 +11,8 @@ public abstract class Exportable : AbstractDistrictLoad { public abstract double F { get; set; } public abstract double V { get; set; } - + public GraphCost FixedCost => new FixedCost(this); + public GraphCost VariableCost => new VariableCost(this, 200); + public double TotalCost => FixedCost.Cost + VariableCost.Cost; } } \ No newline at end of file diff --git a/DistrictEnergy/ViewModels/CostsViewModel.cs b/DistrictEnergy/ViewModels/CostsViewModel.cs index 9b6d46e..766102f 100644 --- a/DistrictEnergy/ViewModels/CostsViewModel.cs +++ b/DistrictEnergy/ViewModels/CostsViewModel.cs @@ -99,6 +99,31 @@ private void UpdateCostsChart(object sender, EventArgs e) TotalCost += supplyModule.TotalCost; } + foreach (var supplyModule in DistrictControl.Instance.ListOfDistrictLoads.OfType()) + { + if (supplyModule.FixedCost.Cost > 0) + { + SeriesCollection.Add(new PieSeries + { + Title = supplyModule.FixedCost.Name, + Values = new ChartValues { supplyModule.FixedCost.Cost }, + LabelPoint = CostLabelPointFormatter, + Fill = supplyModule.FixedCost.Fill + }); + } + if (supplyModule.VariableCost.Cost > 0) + { + SeriesCollection.Add(new PieSeries + { + Title = supplyModule.VariableCost.Name, + Values = new ChartValues { supplyModule.VariableCost.Cost }, + LabelPoint = CostLabelPointFormatter, + Fill = supplyModule.VariableCost.Fill + }); + } + TotalCost += supplyModule.TotalCost; + } + NormalizedTotalCost = TotalCost / FloorArea; } From b737988cc42a0f924397d281960a8b62b62bbb8e Mon Sep 17 00:00:00 2001 From: Samuel Letellier-Duchesne Date: Sun, 3 May 2020 02:04:09 -0400 Subject: [PATCH 3/3] UI Tweak --- DistrictEnergy/Views/ExportView.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DistrictEnergy/Views/ExportView.xaml b/DistrictEnergy/Views/ExportView.xaml index 9a760ff..1930654 100644 --- a/DistrictEnergy/Views/ExportView.xaml +++ b/DistrictEnergy/Views/ExportView.xaml @@ -30,20 +30,20 @@ - + - + + Text="{Binding Name}" Margin="-15,0,0,0"> - +