diff --git a/Helios/Controllers/ConfiguratorController.cs b/Helios/Controllers/ConfiguratorController.cs index ac9b7e0e6560feaaaa9361337d16d911857c91c2..0fcb1b08c3fd0f6eec1fa3a3ad2895c25c455781 100644 --- a/Helios/Controllers/ConfiguratorController.cs +++ b/Helios/Controllers/ConfiguratorController.cs @@ -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); } } diff --git a/Helios/Models/ConfiguratorInput.cs b/Helios/Models/ConfiguratorInput.cs index bc10b3a5915bfd94a666d9002352917a4db4dc67..519758c1db8fa7772483e0dc36f6f6004a1ce2e4 100644 --- a/Helios/Models/ConfiguratorInput.cs +++ b/Helios/Models/ConfiguratorInput.cs @@ -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; } diff --git a/Helios/Models/ConfiguratorResult.cs b/Helios/Models/ConfiguratorResult.cs index c94ba9be5c2de98ceceedfa9210947048f521a9c..cb7ad1f834a7a76f8796b5115b3fad2bc82f9af1 100644 --- a/Helios/Models/ConfiguratorResult.cs +++ b/Helios/Models/ConfiguratorResult.cs @@ -1,21 +1,55 @@ using System; +using System.ComponentModel; + namespace Helios.Models { - public class ConfiguratorResult - { + 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() { } + } } diff --git a/Helios/Source/ConfiguratorService.cs b/Helios/Source/ConfiguratorService.cs index 8b26f0e0de851e08f791b31fa0fc5a6ae35e9c8a..ecc8ab1fd0bbe0ba199b0f3aafe21407206f48c3 100644 --- a/Helios/Source/ConfiguratorService.cs +++ b/Helios/Source/ConfiguratorService.cs @@ -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(); - - int summerElevationAngle = input.Roof.GetElevationAngle(_maxElevation.SummerElevation); - int winterElevationAngle = input.Roof.GetElevationAngle(_maxElevation.WinterElevation); - - 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); - - results.Add(result); + RoofResults roofResult = new RoofResults(); + + roofResult.RoofAngle = roof.Elevation; + roofResult.RoofArea = roof.Area; + + 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); + } + } + + if (roofResult.Panels.Count != 0) + { + result.RoofResults.Add(roofResult); + } } - return results; + return result; } private bool WithinBudget(int budget, double installationCost) diff --git a/Helios/Source/SolarPanel.cs b/Helios/Source/SolarPanel.cs index e2a09a3e0de9ef948c21a8e72eda5e15fe0ad78d..0e8e59df3c1fbb1f46be1d5e96b9bf8464e3edfb 100644 --- a/Helios/Source/SolarPanel.cs +++ b/Helios/Source/SolarPanel.cs @@ -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; diff --git a/Helios/Views/Configurator/ConfiguratorResult.cshtml b/Helios/Views/Configurator/ConfiguratorResult.cshtml new file mode 100644 index 0000000000000000000000000000000000000000..bb9acf50173f8ff3188bc51cb8efd831e974a172 --- /dev/null +++ b/Helios/Views/Configurator/ConfiguratorResult.cshtml @@ -0,0 +1,73 @@ +@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 diff --git a/Helios/Views/Configurator/Index.cshtml b/Helios/Views/Configurator/Index.cshtml index e95c488778e829b377d9d2f974ba8dbe0b98c951..f3a03eadcf864cebf017eee6a25bfaa5589e40bf 100644 --- a/Helios/Views/Configurator/Index.cshtml +++ b/Helios/Views/Configurator/Index.cshtml @@ -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,50 +12,77 @@ @Html.ValidationSummary(true, "", new { @class = "text-danger" }) - <div class="form-group"> - @Html.LabelFor(model => model.Roof.Area, htmlAttributes: new { @class = "control-label col-md-2" }) - <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" }) + <div class="input-border"> + <h5>Roof #1</h5> + + <div class="form-group"> + @Html.LabelFor(model => model.Roofs[0].Area, htmlAttributes: new { @class = "control-label col-md-3" }) + <div class="col-md-10"> + @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> - <div class="form-group"> - @Html.LabelFor(model => model.Roof.Elevation, htmlAttributes: new { @class = "control-label col-md-2" }) - <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" }) + <div class="form-group"> + @Html.LabelFor(model => model.Roofs[0].Elevation, htmlAttributes: new { @class = "control-label col-md-3" }) + <div class="col-md-10"> + @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="form-group"> - @Html.LabelFor(model => model.PowerRequired, htmlAttributes: new { @class = "control-label col-md-2" }) - <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" }) + <div class="input-border"> + <h5>Roof #2</h5> + + <div class="form-group"> + @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> - <div class="form-group"> - @Html.LabelFor(model => model.MaximumPower, htmlAttributes: new { @class = "control-label col-md-2" }) - <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" }) + <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="form-group"> - @Html.LabelFor(model => model.Budget, htmlAttributes: new { @class = "control-label col-md-2" }) - <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 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" }) + </div> + </div> + + <div class="form-group"> + @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" }) + </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" /> + <div class="form-group"> + @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="Submit" class="btn btn-primary" /> + </div> </div> </div> -</div> -} \ No newline at end of file + } diff --git a/Helios/wwwroot/css/site.css b/Helios/wwwroot/css/site.css index 3470064446490109f5dc33325495dc51c6d44dcd..154949f78cf1ab05e08a65dcbf80d2121bb9009d 100644 --- a/Helios/wwwroot/css/site.css +++ b/Helios/wwwroot/css/site.css @@ -16,3 +16,11 @@ html { body { margin-bottom: 60px; } + +.input-border { + border: gray; + border-style: solid; + border-radius: 10px; + padding: 20px; + margin-bottom: 20px; +}