Skip to content

Commit

Permalink
Merge branch 'feature/exports2view' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelduchesne committed May 3, 2020
2 parents c80e15a + b737988 commit 61a777b
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 48 deletions.
20 changes: 20 additions & 0 deletions DistrictEnergy/Networks/ThermalPlants/Dispatchable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion DistrictEnergy/Networks/ThermalPlants/Exportable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
25 changes: 25 additions & 0 deletions DistrictEnergy/ViewModels/CostsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,31 @@ private void UpdateCostsChart(object sender, EventArgs e)
TotalCost += supplyModule.TotalCost;
}

foreach (var supplyModule in DistrictControl.Instance.ListOfDistrictLoads.OfType<Exportable>())
{
if (supplyModule.FixedCost.Cost > 0)
{
SeriesCollection.Add(new PieSeries
{
Title = supplyModule.FixedCost.Name,
Values = new ChartValues<double> { 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<double> { supplyModule.VariableCost.Cost },
LabelPoint = CostLabelPointFormatter,
Fill = supplyModule.VariableCost.Fill
});
}
TotalCost += supplyModule.TotalCost;
}

NormalizedTotalCost = TotalCost / FloorArea;
}

Expand Down
95 changes: 49 additions & 46 deletions DistrictEnergy/Views/ExportView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,51 +30,54 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="1">
<Expander BorderBrush="{DynamicResource MaterialDesignBody}">
<Expander.Header>
<TextBlock Grid.Row="0" Style="{DynamicResource MaterialDesignSubtitle1TextBlock}" Text="{Binding Name}"></TextBlock>
</Expander.Header>
<StackPanel>
<materialDesign:ColorPicker Color="{Binding Color}" HueSliderPosition="Bottom" />
<Grid Margin="0,8,0,0" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" MinWidth="30" />
<ColumnDefinition Width="Auto" MinWidth="40" />
</Grid.ColumnDefinitions>
<Label Content="Fixed cost per capacity unit"
ToolTip="The installed capital cost of the technology per capacity unit" />
<Label Content="$/kW"
VerticalContentAlignment="Center"
HorizontalAlignment="Center" Grid.Column="1" />
<TextBox
Text="{Binding F, BindsDirectlyToSource=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="2" />
</Grid>
<Grid Margin="0,8,0,0" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" MinWidth="30" />
<ColumnDefinition Width="Auto" MinWidth="40" />
</Grid.ColumnDefinitions>
<Label Content="Variable cost per energy unit"
ToolTip="The annual O&amp;M costs of the technology per energy unit" />
<Label Content="$/kWh"
VerticalContentAlignment="Center"
HorizontalAlignment="Center" Grid.Column="1" />
<TextBox
Text="{Binding V, BindsDirectlyToSource=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="2" />
</Grid>
</StackPanel>
<materialDesign:Card Padding="0" Margin="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel>
<Expander BorderBrush="{DynamicResource MaterialDesignBody}">
<Expander.Header>
<TextBlock Grid.Row="0" Style="{DynamicResource MaterialDesignSubtitle1TextBlock}"
Text="{Binding Name}" Margin="-15,0,0,0">
</TextBlock>
</Expander.Header>
<StackPanel Margin="5,0,10,10">
<materialDesign:ColorPicker Color="{Binding Color}" HueSliderPosition="Bottom" />
<Grid Margin="0,8,0,0" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" MinWidth="30" />
<ColumnDefinition Width="Auto" MinWidth="40" />
</Grid.ColumnDefinitions>
<Label Content="Fixed cost per capacity unit"
ToolTip="The installed capital cost of the technology per capacity unit" />
<Label Content="$/kW"
VerticalContentAlignment="Center"
HorizontalAlignment="Center" Grid.Column="1" />
<TextBox
Text="{Binding F, BindsDirectlyToSource=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="2" />
</Grid>
<Grid Margin="0,8,0,0" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" MinWidth="30" />
<ColumnDefinition Width="Auto" MinWidth="40" />
</Grid.ColumnDefinitions>
<Label Content="Variable cost per energy unit"
ToolTip="The annual O&amp;M costs of the technology per energy unit" />
<Label Content="$/kWh"
VerticalContentAlignment="Center"
HorizontalAlignment="Center" Grid.Column="1" />
<TextBox
Text="{Binding V, BindsDirectlyToSource=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Column="2" />
</Grid>
</StackPanel>

</Expander>
</StackPanel>
</Grid>
</Expander>
</StackPanel>
</Grid></materialDesign:Card>
</UserControl>
2 changes: 1 addition & 1 deletion DistrictEnergy/Views/PlantSettings/NetworkView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public NetworkView()

private void LoadThis(object sender, UmiContext e)
{
foreach (var export in DistrictControl.Instance.ListOfPlantSettings.OfType<Exportable>())
foreach (var export in DistrictControl.Instance.ListOfDistrictLoads.OfType<Exportable>())
{
Exports.Children.Add(new ExportView(export));
}
Expand Down

0 comments on commit 61a777b

Please sign in to comment.