Skip to content
Snippets Groups Projects
Commit fee4cb2e authored by Daniel Lorych's avatar Daniel Lorych :cookie:
Browse files

Merge branch '33-page-product-analysis' into 'main'

Resolve "Page: Product Analysis"

Closes #33

See merge request d2-lorych/helios!13
parents e6711c49 da509432
No related branches found
No related tags found
No related merge requests found
......@@ -24,11 +24,11 @@ namespace Helios.Controllers
return View();
}
public ActionResult SubmitSystem(ConfiguratorInput input)
public ActionResult ConfiguratorResult(ConfiguratorInput input)
{
_service.GetResults(input);
var model = _service.GetResults(input);
return View("Index");
return View(model);
}
}
......
......@@ -5,7 +5,7 @@ namespace Helios.Models
{
public class ConfiguratorInput
{
public Roof Roof { get; set; }
public List<Roof> Roofs { get; set; }
[DisplayName("Energy usage in KwH?")]
public int PowerRequired { get; set; }
......
using System;
using System.ComponentModel;
namespace Helios.Models
{
public class ConfiguratorResult
{
public List<RoofResults> RoofResults { get; set; }
public ConfiguratorResult() {
RoofResults = new List<RoofResults>();
}
}
public class RoofResults
{
public List<PanelPerformance> Panels { get; set; }
public double RoofAngle { get; set; }
public double RoofArea { get; set; }
public RoofResults() {
Panels = new List<PanelPerformance>();
}
}
public class PanelPerformance
{
public double RoofArea { get; set; }
public double RoofAngle { get; set; }
[DisplayName("Panel Efficiency")]
public double PanelEfficiency { get; set; }
[DisplayName("Installation Cost")]
public double InstallationCost { get; set; }
[DisplayName("Power Generated in Summer")]
public double PowerGeneratedSummer { get; set; }
[DisplayName("Power Generated in Winter")]
public double PowerGeneratedWinter { get; set; }
[DisplayName("Meets Energy Requirement")]
public bool GeneratesRequiredPower { get; set; }
[DisplayName("Exceeds Max Power")]
public bool ExceedsMaximumPower { get; set; }
[DisplayName("Is Within Budget")]
public bool WithinBudget { get; set; }
public ConfiguratorResult()
{
}
public PanelPerformance() { }
}
}
......@@ -18,31 +18,47 @@ namespace Helios.Source
this._maxElevation = GetSunElevation();
}
public List<ConfiguratorResult> GetResults(ConfiguratorInput input)
public ConfiguratorResult GetResults(ConfiguratorInput input)
{
List<ConfiguratorResult> results = new List<ConfiguratorResult>();
ConfiguratorResult result = new ConfiguratorResult();
foreach (SolarPanel panel in _solarPanels)
foreach (Roof roof in input.Roofs)
{
ConfiguratorResult result = new ConfiguratorResult();
RoofResults roofResult = new RoofResults();
int summerElevationAngle = input.Roof.GetElevationAngle(_maxElevation.SummerElevation);
int winterElevationAngle = input.Roof.GetElevationAngle(_maxElevation.WinterElevation);
roofResult.RoofAngle = roof.Elevation;
roofResult.RoofArea = roof.Area;
result.RoofArea = input.Roof.Area;
result.RoofAngle = input.Roof.Elevation;
result.PanelEfficiency = panel.Efficiency;
result.InstallationCost = panel.GetInstallationCost(input.Roof.Area);
result.PowerGeneratedSummer = panel.GetPowerOutput(input.Roof.Area, summerElevationAngle);
result.PowerGeneratedWinter = panel.GetPowerOutput(input.Roof.Area, winterElevationAngle);
result.GeneratesRequiredPower = GeneratesRequiredPower(input.PowerRequired, result.PowerGeneratedWinter);
result.ExceedsMaximumPower = ExceedsPowerLimit(input.MaximumPower, result.PowerGeneratedWinter);
result.WithinBudget = WithinBudget(input.Budget, result.InstallationCost);
foreach (SolarPanel panel in _solarPanels)
{
PanelPerformance performance = new PanelPerformance();
int summerElevationAngle = roof.GetElevationAngle(_maxElevation.SummerElevation);
int winterElevationAngle = roof.GetElevationAngle(_maxElevation.WinterElevation);
performance.RoofArea = roof.Area;
performance.RoofAngle = roof.Elevation;
performance.PanelEfficiency = panel.Efficiency * 100;
performance.InstallationCost = panel.GetInstallationCost(roof.Area);
performance.PowerGeneratedSummer = Math.Round(panel.GetPowerOutput(1000, roof.Area, summerElevationAngle), 2);
performance.PowerGeneratedWinter = Math.Round(panel.GetPowerOutput(1000, roof.Area, winterElevationAngle), 2);
performance.GeneratesRequiredPower = GeneratesRequiredPower(input.PowerRequired, performance.PowerGeneratedWinter);
performance.ExceedsMaximumPower = ExceedsPowerLimit(input.MaximumPower, performance.PowerGeneratedWinter);
performance.WithinBudget = WithinBudget(input.Budget, performance.InstallationCost);
if (performance.RoofAngle != 0)
{
roofResult.Panels.Add(performance);
}
}
results.Add(result);
if (roofResult.Panels.Count != 0)
{
result.RoofResults.Add(roofResult);
}
}
return results;
return result;
}
private bool WithinBudget(int budget, double installationCost)
......
......@@ -31,11 +31,12 @@ namespace Helios.Source
return installationCost;
}
public double GetPowerOutput(double roofArea, int roofElevation)
public double GetPowerOutput(int solarEnergy, double roofArea, int roofElevation)
{
double powerOutput;
powerOutput = Efficiency * 1000 * roofArea * Math.Sin(roofElevation);
powerOutput = Efficiency * solarEnergy * roofArea * Math.Sin(roofElevation);
this.PowerOutput = powerOutput;
......
@model Helios.Models.ConfiguratorResult
@{
ViewData["Title"] = "Configuration Results";
}
@foreach (var roofResult in Model.RoofResults)
{
<h5>Results for roof:</h5>
<ul>
<li>
Area: @roofResult.RoofArea
</li>
<li>
Angle: @roofResult.RoofAngle
</li>
</ul>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].PanelEfficiency)
</th>
<th>
@Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].InstallationCost)
</th>
<th>
@Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].PowerGeneratedSummer)
</th>
<th>
@Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].PowerGeneratedWinter)
</th>
<th>
@Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].GeneratesRequiredPower)
</th>
<th>
@Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].ExceedsMaximumPower)
</th>
<th>
@Html.DisplayNameFor(panelResult => panelResult.RoofResults[0].Panels[0].WithinBudget)
</th>
</tr>
@foreach (var panel in roofResult.Panels)
{
<tr>
<td>
@panel.PanelEfficiency
</td>
<td>
@panel.InstallationCost
</td>
<td>
@panel.PowerGeneratedSummer
</td>
<td>
@panel.PowerGeneratedWinter
</td>
<td>
@panel.GeneratesRequiredPower
</td>
<td>
@panel.ExceedsMaximumPower
</td>
<td>
@panel.WithinBudget
</td>
</tr>
}
</table>
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
ViewData["Title"] = "Configuration Page";
}
@using (Html.BeginForm(actionName: "SubmitSystem", controllerName: "Configurator", Model))
@using (Html.BeginForm(actionName: "ConfiguratorResult", controllerName: "Configurator", Model))
{
<div class="form-horizontal">
<h4>Configurator Input</h4>
......@@ -12,24 +12,51 @@
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="input-border">
<h5>Roof #1</h5>
<div class="form-group">
@Html.LabelFor(model => model.Roof.Area, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.LabelFor(model => model.Roofs[0].Area, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-10">
@Html.EditorFor(model => model.Roof.Area, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Roof.Area, "", new { @class = "text-danger" })
@Html.EditorFor(model => model.Roofs[0].Area, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Roofs[0].Area, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Roof.Elevation, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.LabelFor(model => model.Roofs[0].Elevation, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-10">
@Html.EditorFor(model => model.Roof.Elevation, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Roof.Elevation, "", new { @class = "text-danger" })
@Html.EditorFor(model => model.Roofs[0].Elevation, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Roofs[0].Elevation, "", new { @class = "text-danger" })
</div>
</div>
</div>
<div class="input-border">
<h5>Roof #2</h5>
<div class="form-group">
@Html.LabelFor(model => model.PowerRequired, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.LabelFor(model => model.Roofs[1].Area, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-10">
@Html.EditorFor(model => model.Roofs[1].Area, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Roofs[1].Area, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Roofs[1].Elevation, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-10">
@Html.EditorFor(model => model.Roofs[1].Elevation, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Roofs[1].Elevation, "", new { @class = "text-danger" })
</div>
</div>
</div>
<div class="input-border">
<h5>Energy Information</h5>
<div class="form-group">
@Html.LabelFor(model => model.PowerRequired, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-10">
@Html.EditorFor(model => model.PowerRequired, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.PowerRequired, "", new { @class = "text-danger" })
......@@ -37,7 +64,7 @@
</div>
<div class="form-group">
@Html.LabelFor(model => model.MaximumPower, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.LabelFor(model => model.MaximumPower, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-10">
@Html.EditorFor(model => model.MaximumPower, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MaximumPower, "", new { @class = "text-danger" })
......@@ -45,16 +72,16 @@
</div>
<div class="form-group">
@Html.LabelFor(model => model.Budget, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.LabelFor(model => model.Budget, htmlAttributes: new { @class = "control-label col-md-3" })
<div class="col-md-10">
@Html.EditorFor(model => model.Budget, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Budget, "", new { @class = "text-danger" })
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
<input type="submit" value="Submit" class="btn btn-primary" />
</div>
</div>
</div>
......
......@@ -16,3 +16,11 @@ html {
body {
margin-bottom: 60px;
}
.input-border {
border: gray;
border-style: solid;
border-radius: 10px;
padding: 20px;
margin-bottom: 20px;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment