From 20028dc8e2b9d88cbde917621c0a180eab95f5fb Mon Sep 17 00:00:00 2001 From: "Burns, Terry" <Terry.Burns@ricardo.com> Date: Fri, 27 Feb 2015 16:31:26 +0000 Subject: [PATCH] SSM - WIP git-tfs-id: [http://tfs00.element.root.com:8080/tfs/TFSCollection]$/VECTO;C1793 --- HVACTOOL/Module1.vb | 2 +- .../VectoAuxiliaries/Hvac/ISSMGenInputs.vb | 1 + VECTOAux/VectoAuxiliaries/Hvac/ISSMTOOL.vb | 5 + .../VectoAuxiliaries/Hvac/SSMGenInputs.vb | 7 +- VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb | 205 ++++++---- .../UI/frmHVACTool.Designer.vb | 362 +++++++++++++++++- VECTOAux/VectoAuxiliaries/UI/frmHVACTool.resx | 6 + VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb | 77 +++- .../UnitTests/SSMTOOLTests.vb | 157 +++++++- 9 files changed, 718 insertions(+), 104 deletions(-) diff --git a/HVACTOOL/Module1.vb b/HVACTOOL/Module1.vb index f84677f0cf..434fc033e7 100644 --- a/HVACTOOL/Module1.vb +++ b/HVACTOOL/Module1.vb @@ -4,7 +4,7 @@ module Main Sub main() - Dim frm As New Form1'frmHVACTool("BusDatabase.csv") + Dim frm As New frmHVACTool("BusDatabase.csv", "ssm.Ahsm") frm.ShowDialog diff --git a/VECTOAux/VectoAuxiliaries/Hvac/ISSMGenInputs.vb b/VECTOAux/VectoAuxiliaries/Hvac/ISSMGenInputs.vb index e083470071..5f6889c134 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/ISSMGenInputs.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/ISSMGenInputs.vb @@ -4,6 +4,7 @@ Namespace Hvac Public Interface ISSMGenInputs 'Bus Parameterisation + Property BP_BusModel As String Property BP_NumberOfPassengers As Double Property BP_BusFloorType As string Readonly Property BP_BusFloorSurfaceArea As Double diff --git a/VECTOAux/VectoAuxiliaries/Hvac/ISSMTOOL.vb b/VECTOAux/VectoAuxiliaries/Hvac/ISSMTOOL.vb index 13ecf0dac5..5fc781a1b2 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/ISSMTOOL.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/ISSMTOOL.vb @@ -17,6 +17,11 @@ Function Load(filePath As String) As Boolean Function Save(filePath As String) As Boolean +Function IsEqualTo( source As ISSMTOOL) As Boolean + + + + End Interface diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMGenInputs.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMGenInputs.vb index 6c9ab5a0e6..0231393312 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMGenInputs.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/SSMGenInputs.vb @@ -3,11 +3,14 @@ Namespace Hvac Public Class SSMGenInputs Implements ISSMGenInputs + 'BUS Parameterisation '******************** - 'D5/C5 + 'C4/D4 + Public Property BP_BusModel As String Implements ISSMGenInputs.BP_BusModel + 'D5/C5 Public Property BP_NumberOfPassengers As Double Implements ISSMGenInputs.BP_NumberOfPassengers 'D6/C6 Public Property BP_BusFloorType As String Implements ISSMGenInputs.BP_BusFloorType @@ -206,6 +209,7 @@ Namespace Hvac 'BUS Parameterisation '******************** + BP_BusModel = "DummyBus" BP_NumberOfPassengers =47R BP_BusFloorType ="raised floor" 'BP_BusFloorSurfaceArea : Calculated @@ -279,6 +283,7 @@ Namespace Hvac End Sub + End Class End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb index 643b1eacfb..b6845fe700 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb @@ -2,150 +2,213 @@ Imports VectoAuxiliaries.Hvac Imports Newtonsoft.Json Imports System.IO +Imports System.Reflection Namespace Hvac - - Public Class SSMTOOL Implements ISSMTOOL + Private filePath As String Public genInputs As ISSMGenInputs - Public techList As ISSMTechList - + Public techList As ISSMTechList - Public ReadOnly Property ElectricalWAdjusted As Single Implements ISSMTOOL.ElectricalWAdjusted - Get + 'Public facing properties, final results from calculations. + Public ReadOnly Property ElectricalWAdjusted As Single Implements ISSMTOOL.ElectricalWAdjusted + Get - End Get - End Property - Public ReadOnly Property ElectricalWBase As Single Implements ISSMTOOL.ElectricalWBase - Get + End Get + End Property + Public ReadOnly Property ElectricalWBase As Single Implements ISSMTOOL.ElectricalWBase + Get End Get - End Property - Public ReadOnly Property FuelLPerHBase As Single Implements ISSMTOOL.FuelLPerHBase - Get + End Property + Public ReadOnly Property FuelLPerHBase As Single Implements ISSMTOOL.FuelLPerHBase + Get End Get - End Property + End Property - Public ReadOnly Property FuelLPerHBaseAdjusted As Single Implements ISSMTOOL.FuelLPerHBaseAdjusted - Get + Public ReadOnly Property FuelLPerHBaseAdjusted As Single Implements ISSMTOOL.FuelLPerHBaseAdjusted + Get End Get - End Property - Public ReadOnly Property MechanicalWBase As Single Implements ISSMTOOL.MechanicalWBase - Get + End Property + Public ReadOnly Property MechanicalWBase As Single Implements ISSMTOOL.MechanicalWBase + Get End Get - End Property - Public ReadOnly Property MechanicalWBaseAdjusted As Single Implements ISSMTOOL.MechanicalWBaseAdjusted - Get + End Property + Public ReadOnly Property MechanicalWBaseAdjusted As Single Implements ISSMTOOL.MechanicalWBaseAdjusted + Get End Get - End Property + End Property + + 'Constructors + Sub New() - Sub New() + End Sub + Sub New(filePath As String) + Me.filePath = filePath - End Sub + genInputs = New SSMGenInputs(True) + techList = New SSMTechList(filePath, genInputs) - Sub New(filePath As String) - Me.filePath = filePath + End Sub - genInputs = New SSMGenInputs(True) - techList = New SSMTechList(filePath, genInputs) + 'Clone values from another object of same type + Public Sub Clone(from As ISSMTOOL) Implements ISSMTOOL.Clone + Dim feedback As String = String.Empty - End Sub + genInputs.InjectFrom(DirectCast(from, SSMTOOL).genInputs) + techList.InjectFrom(DirectCast(from, SSMTOOL).techList) + techList.Clear() - Public Sub Clone(from As ISSMTOOL) Implements ISSMTOOL.Clone + For Each line As TechListBenefitLine In DirectCast(from, SSMTOOL).techList.TechLines - Dim feedback As String = String.Empty + Dim newLine As ITechListBenefitLine = New TechListBenefitLine(Me.genInputs) + newLine.InjectFrom(line) + techList.Add(newLine, feedback) - genInputs.InjectFrom(DirectCast(from, SSMTOOL).genInputs) + Next - techList.InjectFrom(DirectCast(from, SSMTOOL).techList) - techList.Clear() + End Sub - For Each line As TechListBenefitLine In DirectCast(from, SSMTOOL).techList.TechLines + 'Persistance Functions + Public Function Save(filePath As String) As Boolean Implements ISSMTOOL.Save - Dim newLine As ITechListBenefitLine = New TechListBenefitLine(Me.genInputs) - newLine.InjectFrom(line) - techList.Add(newLine, feedback) + Dim returnValue As Boolean = True + Dim settings As JsonSerializerSettings = New JsonSerializerSettings() + settings.TypeNameHandling = TypeNameHandling.Objects - Next + 'JSON METHOD + Try - End Sub + Dim output As String = JsonConvert.SerializeObject(Me, Formatting.Indented, settings) + File.WriteAllText(filePath, output) + Catch ex As Exception -'Persistance Functions -Public Function Save(filePath As String) As Boolean Implements ISSMTOOL.Save + 'TODO:Do something meaningfull here perhaps logging + returnValue = False - Dim returnValue As Boolean = True - Dim settings As JsonSerializerSettings = New JsonSerializerSettings() - settings.TypeNameHandling = TypeNameHandling.Objects + End Try - 'JSON METHOD - Try + Return returnValue + +End Function + Public Function Load(filePath As String) As Boolean Implements ISSMTOOL.Load - Dim output As String = JsonConvert.SerializeObject(Me, Formatting.Indented, settings) + Dim returnValue As Boolean = True + Dim settings As JsonSerializerSettings = New JsonSerializerSettings() + Dim tmpAux As SSMTOOL = New SSMTOOL() - File.WriteAllText(filePath, output) + settings.TypeNameHandling = TypeNameHandling.Objects + + 'JSON METHOD + Try + + Dim output As String = File.ReadAllText(filePath) + + + tmpAux = JsonConvert.DeserializeObject(Of SSMTOOL)(output, settings) + + 'This is where we Assume values of loaded( Deserialized ) object. + Clone(tmpAux) Catch ex As Exception 'TODO:Do something meaningfull here perhaps logging - returnValue = False - End Try + returnValue = False + End Try - Return returnValue + Return returnValue End Function -Public Function Load(filePath As String) As Boolean Implements ISSMTOOL.Load - Dim returnValue As Boolean = True - Dim settings As JsonSerializerSettings = New JsonSerializerSettings() - Dim tmpAux As SSMTOOL = New SSMTOOL() - settings.TypeNameHandling = TypeNameHandling.Objects + 'Comparison + Public Function IsEqualTo(source As ISSMTOOL) As Boolean Implements ISSMTOOL.IsEqualTo - 'JSON METHOD - Try + 'In this methods we only want to compare the non Static , non readonly public properties of + 'The class's General, User Inputs and Tech Benefit members. - Dim output As String = File.ReadAllText(filePath) + Return compareGenUserInputs(source) AndAlso compareTechListBenefitLines(source) - tmpAux = JsonConvert.DeserializeObject(Of SSMTOOL)(output, settings) + End Function - 'This is where we Assume values of loaded( Deserialized ) object. - Clone(tmpAux) + Private Function compareGenUserInputs(source As ISSMTOOL) As Boolean - Catch ex As Exception + Dim src As SSMTOOL = DirectCast(source, SSMTOOL) - 'TODO:Do something meaningfull here perhaps logging + Dim returnValue As Boolean = True - returnValue = False - End Try + Dim properties As PropertyInfo() = Me.genInputs.GetType.GetProperties - Return returnValue + For Each prop As propertyinfo In properties + + If Not prop.GetAccessors.IsReadOnly + + if prop.GetValue(Me.genInputs,nothing)<> prop.GetValue(src.genInputs,nothing) then + returnValue=False + End If + + End If + + Next -End Function + Return returnValue + End Function + Private Function compareTechListBenefitLines(source As ISSMTOOL) As Boolean -End Class + Dim src As SSMTOOL = DirectCast( source, SSMTOOL) + + 'Equal numbers of lines check + If Me.techList.TechLines.Count<> src.techList.TechLines.Count then return false + + For Each tl As ITechListBenefitLine In Me.techList.TechLines.OrderBy( Function(o) o.Category).ThenBy( Function(n) n.BenefitName) + + 'First Check line exists in other + If src.techList.TechLines.Where( Function(w) w.BenefitName= tl.BenefitName AndAlso w.Category=tl.Category).Count<>1 then + + Return False + Else + + 'check are equal + + If Not src.techList.TechLines.first( Function(w) w.BenefitName= tl.BenefitName AndAlso w.Category=tl.Category).IsEqualTo( tl ) then + Return False + End If + End If + + + Next + + 'All Looks OK + Return true + + End Function + + + +End Class End Namespace diff --git a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb index bfd410b607..a9f9d2547b 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb @@ -22,63 +22,371 @@ Partial Class frmHVACTool 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container() Me.TabControl1 = New System.Windows.Forms.TabControl() Me.tabBusParameters = New System.Windows.Forms.TabPage() - Me.tabTechListInput = New System.Windows.Forms.TabPage() + Me.GroupBox1 = New System.Windows.Forms.GroupBox() + Me.txtBusModel = New System.Windows.Forms.TextBox() + Me.lblBusModel = New System.Windows.Forms.Label() + Me.txtBusFloorType = New System.Windows.Forms.TextBox() + Me.lblBusFloorType = New System.Windows.Forms.Label() + Me.lblUnitsBW = New System.Windows.Forms.Label() + Me.lblUnitsBSA = New System.Windows.Forms.Label() + Me.lblUnitsBWSA = New System.Windows.Forms.Label() + Me.lblUnitsBV = New System.Windows.Forms.Label() + Me.lblUnitsBL = New System.Windows.Forms.Label() + Me.lblUnitsBFSA = New System.Windows.Forms.Label() + Me.txtBusWidth = New System.Windows.Forms.TextBox() + Me.txtBusLength = New System.Windows.Forms.TextBox() + Me.txtBusVolume = New System.Windows.Forms.TextBox() + Me.lblBusVolume = New System.Windows.Forms.Label() + Me.lblBusLength = New System.Windows.Forms.Label() + Me.lblBusWidth = New System.Windows.Forms.Label() + Me.txtBusWindowSurfaceArea = New System.Windows.Forms.TextBox() + Me.lblBusWindowSurfaceArea = New System.Windows.Forms.Label() + Me.txtBusSurfaceArea = New System.Windows.Forms.TextBox() + Me.lblBusSurfaceArea = New System.Windows.Forms.Label() + Me.txtBusFloorSurfaceArea = New System.Windows.Forms.TextBox() + Me.lblBusFloorSurfaceArea = New System.Windows.Forms.Label() + Me.txtRegisteredPassengers = New System.Windows.Forms.TextBox() + Me.lblRegisteredPassengers = New System.Windows.Forms.Label() Me.cboBuses = New System.Windows.Forms.ComboBox() + Me.tabTechListInput = New System.Windows.Forms.TabPage() + Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components) Me.TabControl1.SuspendLayout Me.tabBusParameters.SuspendLayout + Me.GroupBox1.SuspendLayout Me.SuspendLayout ' 'TabControl1 ' Me.TabControl1.Controls.Add(Me.tabBusParameters) Me.TabControl1.Controls.Add(Me.tabTechListInput) - Me.TabControl1.Location = New System.Drawing.Point(53, 37) + Me.TabControl1.Location = New System.Drawing.Point(8, 33) Me.TabControl1.Name = "TabControl1" Me.TabControl1.SelectedIndex = 0 - Me.TabControl1.Size = New System.Drawing.Size(648, 415) + Me.TabControl1.Size = New System.Drawing.Size(945, 623) Me.TabControl1.TabIndex = 0 ' 'tabBusParameters ' + Me.tabBusParameters.Controls.Add(Me.GroupBox1) Me.tabBusParameters.Controls.Add(Me.cboBuses) + Me.tabBusParameters.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) Me.tabBusParameters.Location = New System.Drawing.Point(4, 22) Me.tabBusParameters.Name = "tabBusParameters" Me.tabBusParameters.Padding = New System.Windows.Forms.Padding(3) - Me.tabBusParameters.Size = New System.Drawing.Size(640, 389) + Me.tabBusParameters.Size = New System.Drawing.Size(937, 597) Me.tabBusParameters.TabIndex = 0 Me.tabBusParameters.Text = "INP BusParameters" Me.tabBusParameters.UseVisualStyleBackColor = true ' - 'tabTechListInput + 'GroupBox1 ' - Me.tabTechListInput.Location = New System.Drawing.Point(4, 22) - Me.tabTechListInput.Name = "tabTechListInput" - Me.tabTechListInput.Padding = New System.Windows.Forms.Padding(3) - Me.tabTechListInput.Size = New System.Drawing.Size(640, 389) - Me.tabTechListInput.TabIndex = 1 - Me.tabTechListInput.Text = "Tech List Input" - Me.tabTechListInput.UseVisualStyleBackColor = true + Me.GroupBox1.BackColor = System.Drawing.Color.Transparent + Me.GroupBox1.Controls.Add(Me.txtBusModel) + Me.GroupBox1.Controls.Add(Me.lblBusModel) + Me.GroupBox1.Controls.Add(Me.txtBusFloorType) + Me.GroupBox1.Controls.Add(Me.lblBusFloorType) + Me.GroupBox1.Controls.Add(Me.lblUnitsBW) + Me.GroupBox1.Controls.Add(Me.lblUnitsBSA) + Me.GroupBox1.Controls.Add(Me.lblUnitsBWSA) + Me.GroupBox1.Controls.Add(Me.lblUnitsBV) + Me.GroupBox1.Controls.Add(Me.lblUnitsBL) + Me.GroupBox1.Controls.Add(Me.lblUnitsBFSA) + Me.GroupBox1.Controls.Add(Me.txtBusWidth) + Me.GroupBox1.Controls.Add(Me.txtBusLength) + Me.GroupBox1.Controls.Add(Me.txtBusVolume) + Me.GroupBox1.Controls.Add(Me.lblBusVolume) + Me.GroupBox1.Controls.Add(Me.lblBusLength) + Me.GroupBox1.Controls.Add(Me.lblBusWidth) + Me.GroupBox1.Controls.Add(Me.txtBusWindowSurfaceArea) + Me.GroupBox1.Controls.Add(Me.lblBusWindowSurfaceArea) + Me.GroupBox1.Controls.Add(Me.txtBusSurfaceArea) + Me.GroupBox1.Controls.Add(Me.lblBusSurfaceArea) + Me.GroupBox1.Controls.Add(Me.txtBusFloorSurfaceArea) + Me.GroupBox1.Controls.Add(Me.lblBusFloorSurfaceArea) + Me.GroupBox1.Controls.Add(Me.txtRegisteredPassengers) + Me.GroupBox1.Controls.Add(Me.lblRegisteredPassengers) + Me.GroupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup + Me.GroupBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10!) + Me.GroupBox1.ForeColor = System.Drawing.Color.Green + Me.GroupBox1.Location = New System.Drawing.Point(34, 80) + Me.GroupBox1.Name = "GroupBox1" + Me.GroupBox1.Size = New System.Drawing.Size(416, 294) + Me.GroupBox1.TabIndex = 1 + Me.GroupBox1.TabStop = false + Me.GroupBox1.Text = "Bus Parameterisation" + ' + 'txtBusModel + ' + Me.txtBusModel.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.txtBusModel.Location = New System.Drawing.Point(179, 30) + Me.txtBusModel.Name = "txtBusModel" + Me.txtBusModel.Size = New System.Drawing.Size(208, 21) + Me.txtBusModel.TabIndex = 25 + ' + 'lblBusModel + ' + Me.lblBusModel.AutoSize = true + Me.lblBusModel.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.lblBusModel.ForeColor = System.Drawing.Color.Black + Me.lblBusModel.Location = New System.Drawing.Point(14, 33) + Me.lblBusModel.Name = "lblBusModel" + Me.lblBusModel.Size = New System.Drawing.Size(138, 15) + Me.lblBusModel.TabIndex = 24 + Me.lblBusModel.Text = "Registered Passengers " + ' + 'txtBusFloorType + ' + Me.txtBusFloorType.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.txtBusFloorType.Location = New System.Drawing.Point(179, 90) + Me.txtBusFloorType.Name = "txtBusFloorType" + Me.txtBusFloorType.ReadOnly = true + Me.txtBusFloorType.Size = New System.Drawing.Size(97, 21) + Me.txtBusFloorType.TabIndex = 23 + ' + 'lblBusFloorType + ' + Me.lblBusFloorType.AutoSize = true + Me.lblBusFloorType.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.lblBusFloorType.ForeColor = System.Drawing.Color.Black + Me.lblBusFloorType.Location = New System.Drawing.Point(14, 88) + Me.lblBusFloorType.Name = "lblBusFloorType" + Me.lblBusFloorType.Size = New System.Drawing.Size(88, 15) + Me.lblBusFloorType.TabIndex = 22 + Me.lblBusFloorType.Text = "Bus Floor Type" + ' + 'lblUnitsBW + ' + Me.lblUnitsBW.AutoSize = true + Me.lblUnitsBW.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.lblUnitsBW.Location = New System.Drawing.Point(283, 261) + Me.lblUnitsBW.Name = "lblUnitsBW" + Me.lblUnitsBW.Size = New System.Drawing.Size(18, 15) + Me.lblUnitsBW.TabIndex = 21 + Me.lblUnitsBW.Text = "m" + Me.ToolTip1.SetToolTip(Me.lblUnitsBW, "Linear Metres") + ' + 'lblUnitsBSA + ' + Me.lblUnitsBSA.AutoSize = true + Me.lblUnitsBSA.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.lblUnitsBSA.Location = New System.Drawing.Point(283, 146) + Me.lblUnitsBSA.Name = "lblUnitsBSA" + Me.lblUnitsBSA.Size = New System.Drawing.Size(31, 15) + Me.lblUnitsBSA.TabIndex = 20 + Me.lblUnitsBSA.Text = "m^2" + Me.ToolTip1.SetToolTip(Me.lblUnitsBSA, "Metres Squared") + ' + 'lblUnitsBWSA + ' + Me.lblUnitsBWSA.AutoSize = true + Me.lblUnitsBWSA.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.lblUnitsBWSA.Location = New System.Drawing.Point(283, 175) + Me.lblUnitsBWSA.Name = "lblUnitsBWSA" + Me.lblUnitsBWSA.Size = New System.Drawing.Size(31, 15) + Me.lblUnitsBWSA.TabIndex = 19 + Me.lblUnitsBWSA.Text = "m^2" + Me.ToolTip1.SetToolTip(Me.lblUnitsBWSA, "Metres Squared") + ' + 'lblUnitsBV + ' + Me.lblUnitsBV.AutoSize = true + Me.lblUnitsBV.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.lblUnitsBV.Location = New System.Drawing.Point(283, 202) + Me.lblUnitsBV.Name = "lblUnitsBV" + Me.lblUnitsBV.Size = New System.Drawing.Size(31, 15) + Me.lblUnitsBV.TabIndex = 18 + Me.lblUnitsBV.Text = "m^3" + Me.ToolTip1.SetToolTip(Me.lblUnitsBV, "Metres Cubed") + ' + 'lblUnitsBL + ' + Me.lblUnitsBL.AutoSize = true + Me.lblUnitsBL.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.lblUnitsBL.Location = New System.Drawing.Point(283, 230) + Me.lblUnitsBL.Name = "lblUnitsBL" + Me.lblUnitsBL.Size = New System.Drawing.Size(18, 15) + Me.lblUnitsBL.TabIndex = 17 + Me.lblUnitsBL.Text = "m" + Me.ToolTip1.SetToolTip(Me.lblUnitsBL, "Linear Metres") + ' + 'lblUnitsBFSA + ' + Me.lblUnitsBFSA.AutoSize = true + Me.lblUnitsBFSA.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte)) + Me.lblUnitsBFSA.Location = New System.Drawing.Point(283, 120) + Me.lblUnitsBFSA.Name = "lblUnitsBFSA" + Me.lblUnitsBFSA.Size = New System.Drawing.Size(31, 15) + Me.lblUnitsBFSA.TabIndex = 16 + Me.lblUnitsBFSA.Text = "m^2" + Me.ToolTip1.SetToolTip(Me.lblUnitsBFSA, "Metres Squared") + ' + 'txtBusWidth + ' + Me.txtBusWidth.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.txtBusWidth.Location = New System.Drawing.Point(179, 258) + Me.txtBusWidth.Name = "txtBusWidth" + Me.txtBusWidth.Size = New System.Drawing.Size(97, 21) + Me.txtBusWidth.TabIndex = 15 + ' + 'txtBusLength + ' + Me.txtBusLength.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.txtBusLength.Location = New System.Drawing.Point(179, 229) + Me.txtBusLength.Name = "txtBusLength" + Me.txtBusLength.Size = New System.Drawing.Size(97, 21) + Me.txtBusLength.TabIndex = 14 + ' + 'txtBusVolume + ' + Me.txtBusVolume.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.txtBusVolume.Location = New System.Drawing.Point(179, 202) + Me.txtBusVolume.Name = "txtBusVolume" + Me.txtBusVolume.Size = New System.Drawing.Size(97, 21) + Me.txtBusVolume.TabIndex = 13 + ' + 'lblBusVolume + ' + Me.lblBusVolume.AutoSize = true + Me.lblBusVolume.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.lblBusVolume.ForeColor = System.Drawing.Color.Black + Me.lblBusVolume.Location = New System.Drawing.Point(14, 205) + Me.lblBusVolume.Name = "lblBusVolume" + Me.lblBusVolume.Size = New System.Drawing.Size(73, 15) + Me.lblBusVolume.TabIndex = 12 + Me.lblBusVolume.Text = "Bus Volume" + ' + 'lblBusLength + ' + Me.lblBusLength.AutoSize = true + Me.lblBusLength.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.lblBusLength.ForeColor = System.Drawing.Color.Black + Me.lblBusLength.Location = New System.Drawing.Point(14, 232) + Me.lblBusLength.Name = "lblBusLength" + Me.lblBusLength.Size = New System.Drawing.Size(72, 15) + Me.lblBusLength.TabIndex = 11 + Me.lblBusLength.Text = "Bus Length" + ' + 'lblBusWidth + ' + Me.lblBusWidth.AutoSize = true + Me.lblBusWidth.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.lblBusWidth.ForeColor = System.Drawing.Color.Black + Me.lblBusWidth.Location = New System.Drawing.Point(14, 261) + Me.lblBusWidth.Name = "lblBusWidth" + Me.lblBusWidth.Size = New System.Drawing.Size(65, 15) + Me.lblBusWidth.TabIndex = 10 + Me.lblBusWidth.Text = "Bus Width" + ' + 'txtBusWindowSurfaceArea + ' + Me.txtBusWindowSurfaceArea.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.txtBusWindowSurfaceArea.Location = New System.Drawing.Point(179, 173) + Me.txtBusWindowSurfaceArea.Name = "txtBusWindowSurfaceArea" + Me.txtBusWindowSurfaceArea.ReadOnly = true + Me.txtBusWindowSurfaceArea.Size = New System.Drawing.Size(97, 21) + Me.txtBusWindowSurfaceArea.TabIndex = 9 + ' + 'lblBusWindowSurfaceArea + ' + Me.lblBusWindowSurfaceArea.AutoSize = true + Me.lblBusWindowSurfaceArea.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.lblBusWindowSurfaceArea.ForeColor = System.Drawing.Color.Black + Me.lblBusWindowSurfaceArea.Location = New System.Drawing.Point(14, 176) + Me.lblBusWindowSurfaceArea.Name = "lblBusWindowSurfaceArea" + Me.lblBusWindowSurfaceArea.Size = New System.Drawing.Size(151, 15) + Me.lblBusWindowSurfaceArea.TabIndex = 8 + Me.lblBusWindowSurfaceArea.Text = "Bus Window Surface Area" + ' + 'txtBusSurfaceArea + ' + Me.txtBusSurfaceArea.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.txtBusSurfaceArea.Location = New System.Drawing.Point(179, 145) + Me.txtBusSurfaceArea.Name = "txtBusSurfaceArea" + Me.txtBusSurfaceArea.Size = New System.Drawing.Size(97, 21) + Me.txtBusSurfaceArea.TabIndex = 7 + ' + 'lblBusSurfaceArea + ' + Me.lblBusSurfaceArea.AutoSize = true + Me.lblBusSurfaceArea.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.lblBusSurfaceArea.ForeColor = System.Drawing.Color.Black + Me.lblBusSurfaceArea.Location = New System.Drawing.Point(14, 148) + Me.lblBusSurfaceArea.Name = "lblBusSurfaceArea" + Me.lblBusSurfaceArea.Size = New System.Drawing.Size(104, 15) + Me.lblBusSurfaceArea.TabIndex = 6 + Me.lblBusSurfaceArea.Text = "Bus Surface Area" + ' + 'txtBusFloorSurfaceArea + ' + Me.txtBusFloorSurfaceArea.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.txtBusFloorSurfaceArea.Location = New System.Drawing.Point(179, 117) + Me.txtBusFloorSurfaceArea.Name = "txtBusFloorSurfaceArea" + Me.txtBusFloorSurfaceArea.Size = New System.Drawing.Size(97, 21) + Me.txtBusFloorSurfaceArea.TabIndex = 5 + ' + 'lblBusFloorSurfaceArea + ' + Me.lblBusFloorSurfaceArea.AutoSize = true + Me.lblBusFloorSurfaceArea.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.lblBusFloorSurfaceArea.ForeColor = System.Drawing.Color.Black + Me.lblBusFloorSurfaceArea.Location = New System.Drawing.Point(14, 120) + Me.lblBusFloorSurfaceArea.Name = "lblBusFloorSurfaceArea" + Me.lblBusFloorSurfaceArea.Size = New System.Drawing.Size(132, 15) + Me.lblBusFloorSurfaceArea.TabIndex = 4 + Me.lblBusFloorSurfaceArea.Text = "Bus Floor Surface Area" + ' + 'txtRegisteredPassengers + ' + Me.txtRegisteredPassengers.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.txtRegisteredPassengers.Location = New System.Drawing.Point(179, 59) + Me.txtRegisteredPassengers.Name = "txtRegisteredPassengers" + Me.txtRegisteredPassengers.Size = New System.Drawing.Size(97, 21) + Me.txtRegisteredPassengers.TabIndex = 1 + ' + 'lblRegisteredPassengers + ' + Me.lblRegisteredPassengers.AutoSize = true + Me.lblRegisteredPassengers.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!) + Me.lblRegisteredPassengers.ForeColor = System.Drawing.Color.Black + Me.lblRegisteredPassengers.Location = New System.Drawing.Point(14, 62) + Me.lblRegisteredPassengers.Name = "lblRegisteredPassengers" + Me.lblRegisteredPassengers.Size = New System.Drawing.Size(138, 15) + Me.lblRegisteredPassengers.TabIndex = 0 + Me.lblRegisteredPassengers.Text = "Registered Passengers " ' 'cboBuses ' Me.cboBuses.FormattingEnabled = true Me.cboBuses.Location = New System.Drawing.Point(34, 30) Me.cboBuses.Name = "cboBuses" - Me.cboBuses.Size = New System.Drawing.Size(558, 21) + Me.cboBuses.Size = New System.Drawing.Size(361, 23) Me.cboBuses.TabIndex = 0 ' + 'tabTechListInput + ' + Me.tabTechListInput.Location = New System.Drawing.Point(4, 22) + Me.tabTechListInput.Name = "tabTechListInput" + Me.tabTechListInput.Padding = New System.Windows.Forms.Padding(3) + Me.tabTechListInput.Size = New System.Drawing.Size(937, 597) + Me.tabTechListInput.TabIndex = 1 + Me.tabTechListInput.Text = "Tech List Input" + Me.tabTechListInput.UseVisualStyleBackColor = true + ' 'frmHVACTool ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(773, 510) + Me.ClientSize = New System.Drawing.Size(965, 712) Me.Controls.Add(Me.TabControl1) Me.Name = "frmHVACTool" Me.Text = "frmHVACTool" Me.TabControl1.ResumeLayout(false) Me.tabBusParameters.ResumeLayout(false) + Me.GroupBox1.ResumeLayout(false) + Me.GroupBox1.PerformLayout Me.ResumeLayout(false) End Sub @@ -86,4 +394,30 @@ End Sub Friend WithEvents tabBusParameters As System.Windows.Forms.TabPage Friend WithEvents tabTechListInput As System.Windows.Forms.TabPage Friend WithEvents cboBuses As System.Windows.Forms.ComboBox + Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox + Friend WithEvents lblBusVolume As System.Windows.Forms.Label + Friend WithEvents lblBusLength As System.Windows.Forms.Label + Friend WithEvents lblBusWidth As System.Windows.Forms.Label + Friend WithEvents txtBusWindowSurfaceArea As System.Windows.Forms.TextBox + Friend WithEvents lblBusWindowSurfaceArea As System.Windows.Forms.Label + Friend WithEvents txtBusSurfaceArea As System.Windows.Forms.TextBox + Friend WithEvents lblBusSurfaceArea As System.Windows.Forms.Label + Friend WithEvents txtBusFloorSurfaceArea As System.Windows.Forms.TextBox + Friend WithEvents lblBusFloorSurfaceArea As System.Windows.Forms.Label + Friend WithEvents txtRegisteredPassengers As System.Windows.Forms.TextBox + Friend WithEvents lblRegisteredPassengers As System.Windows.Forms.Label + Friend WithEvents txtBusVolume As System.Windows.Forms.TextBox + Friend WithEvents txtBusWidth As System.Windows.Forms.TextBox + Friend WithEvents txtBusLength As System.Windows.Forms.TextBox + Friend WithEvents lblUnitsBW As System.Windows.Forms.Label + Friend WithEvents lblUnitsBSA As System.Windows.Forms.Label + Friend WithEvents lblUnitsBWSA As System.Windows.Forms.Label + Friend WithEvents lblUnitsBV As System.Windows.Forms.Label + Friend WithEvents lblUnitsBL As System.Windows.Forms.Label + Friend WithEvents lblUnitsBFSA As System.Windows.Forms.Label + Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip + Friend WithEvents txtBusFloorType As System.Windows.Forms.TextBox + Friend WithEvents lblBusFloorType As System.Windows.Forms.Label + Friend WithEvents txtBusModel As System.Windows.Forms.TextBox + Friend WithEvents lblBusModel As System.Windows.Forms.Label End Class diff --git a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.resx b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.resx index 1af7de150c..5e85258293 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.resx +++ b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.resx @@ -117,4 +117,10 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> + <metadata name="ToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> + <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>25</value> + </metadata> </root> \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb index cf2a516951..76ab3f7837 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb @@ -6,51 +6,98 @@ Imports VectoAuxiliaries.Hvac Public Class frmHVACTool -Private filePath As string +Private busDatabasePath As string +Private ahsmFilePath As String + Private buses As IBusDatabase +Private ssmTOOL As SSMTOOL -Public Sub new ( filePath As String ) +Public Sub new ( busDatabasePath As String, ahsmFilePath As String ) ' This call is required by the designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. + Me.busDatabasePath = busDatabasePath + Me.ahsmFilePath = ahsmFilePath - Me.filePath = filePath + ssmTOOL = New SSMTOOL(ahsmFilePath) + setupBuses() + setupControls() + setupBindings() + +End Sub - Initlialise() - + + +Private Sub setupBuses() + + 'Setup Buses + buses = New BusDatabase() + If Not buses.Initialise( busDatabasePath ) then + MessageBox.Show("Problems initialising the Bus Database, some buses may not appear") + End If + + cboBuses.DataSource=buses.GetBuses(String.Empty,True) + cboBuses.DisplayMember="Model" + End Sub -Private Sub Initlialise() +private Sub setupControls() - 'Instantial Buses - buses = New BusDatabase() - If Not buses.Initialise( filePath ) then - MessageBox.Show("Problems initialising the Bus Database, some buses may not appear") - End If - +End Sub + - cboBuses.DataSource=buses.GetBuses(String.Empty,True) - cboBuses.DisplayMember="Model" +private Sub setupBindings() + + 'BParameterisation + txtBusFloorSurfaceArea.DataBindings.Add("Text", ssmTOOL.genInputs,"BP_BusFloorSurfaceArea",False,DataSourceUpdateMode.OnPropertyChanged) End Sub +'GeneralInputControlEvents +Private Sub cboBuses_SelectedIndexChanged( sender As Object, e As EventArgs) Handles cboBuses.SelectedIndexChanged + If cboBuses.SelectedIndex>0 then -End Class + dim bus As IBus = DirectCast(cboBuses.SelectedItem, IBus) + + ssmTOOL.genInputs.BP_BusModel= bus.Model + ssmTOOL.genInputs.BP_NumberOfPassengers= bus.RegisteredPassengers + ssmTOOL.genInputs.BP_BusFloorType = bus.FloorType + 'ssmTOOL.genInputs.BP_BusFloorSurfaceArea Calculated + ssmTOOL.genInputs.BP_BusSurfaceAreaM2 = bus.AreaInMetresSquared + 'ssmTOOL.genInputs.BP_BusWindowSurface Calculated + ssmTOOL.genInputs.BP_BusVolume= bus.VolumneInMetresQubed + ssmTOOL.genInputs.BP_BusLength= bus.LengthInMetres + ssmTOOL.genInputs.BP_BusWidth= bus.WidthInMetres + + + End If + + +End Sub + + + + + + + + +End Class diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb index 5abca22f90..302c63c478 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb @@ -15,6 +15,42 @@ Namespace UnitTests Private Const GOODTechListALLOFF As String = "TestFiles\testSSMTechBenefitsALLOFF.csv" Private Const GOODTechListEMPTYLIST As String = "TestFiles\testSSMTechBenefitsEMPTYLIST.csv" + 'Helpers + Private Function AddDefaultTechLine( source As ISSMTOOL ) As ITechListBenefitLine + + + Dim src As SSMTOOL = DirectCast( source, SSMTOOL) + + Dim newItem As ITechListBenefitLine = New TechListBenefitLine( src.genInputs) + + newItem.Units = "fraction" + newItem.Category = "Insulation" + newItem.BenefitName= "Benefit1" + + newItem.LowFloorH =0.1 + newItem.LowFloorV =0.1 + newItem.LowFloorC =0.1 + + newItem.SemiLowFloorH =0.1 + newItem.SemiLowFloorV =0.1 + newItem.SemiLowFloorC =0.1 + + newItem.RaisedFloorH =0.1 + newItem.RaisedFloorV =0.1 + newItem.RaisedFloorC =0.1 + + newItem.OnVehicle = true + newItem.ActiveVH = true + newItem.ActiveVV = true + newItem.ActiveVC = true + newItem.LineType = TechLineType.Normal + + Dim feedback As String = String.Empty + + Assert.istrue(src.techList.Add( newItem, feedback)) + + End Function + 'SSMGenInputTests <Test()> _ <TestCase("BusParameterisation")> _ @@ -521,9 +557,8 @@ End Sub End Sub - 'SSMTOOL Persistance - <Test()> + <Test()> Public Sub SaveAndRetreiveTest() const filePath as string = "SSMTOOLTestSaveRetreive.json" @@ -550,8 +585,126 @@ End Sub End Sub + + 'GenInputs Comparison + <Test()> + Public Sub SSMTOOL_COMPARISON_GENINPUTS_EQUAL() + + const filePath as string = "SSMTOOLTestSaveRetreive.json" + + + Dim ssmTool1 As SSMTOOL = New SSMTOOL(filePath ) + Dim ssmTool2 As SSMTOOL = New SSMTOOL(filePath ) + + + Assert.IsTrue ( ssmTool1.IsEqualTo( ssmTool2)) + + + End Sub + <Test()> + Public Sub SSMTOOL_COMPARISON_GENINPUTS_UNEQUAL() + + const filePath as string = "SSMTOOLTestSaveRetreive.json" + + + Dim ssmTool1 As SSMTOOL = New SSMTOOL(filePath ) + + 'Alter somthing + ssmTool1.genInputs.BP_BusLength=11 + + Dim ssmTool2 As SSMTOOL = New SSMTOOL(filePath ) + + + Assert.IsFalse ( ssmTool1.IsEqualTo( ssmTool2)) + End Sub + + 'TechListBenefitLine Comparison + <Test()> + Public Sub SSMTOOL_COMPARISON_TECHLIST_EQUAL() + + const filePath as string = "SSMTOOLTestSaveRetreive.json" + + + Dim ssmTool1 As SSMTOOL = New SSMTOOL(filePath ) + Dim ssmTool2 As SSMTOOL = New SSMTOOL(filePath ) + + + Assert.IsTrue ( ssmTool1.IsEqualTo( ssmTool2)) + + + End Sub + <Test()> + Public Sub SSMTOOL_COMPARISON_TECHLIST_EMPTYLISTS_UNEQUALCOUNT() + + const filePath as string = "SSMTOOLTestSaveRetreive.json" + + + Dim ssmTool1 As SSMTOOL = New SSMTOOL(filePath ) + Dim ssmTool2 As SSMTOOL = New SSMTOOL(filePath ) + + 'Change something on techlist + AddDefaultTechLine( ssmTool1) + + Assert.IsFalse ( ssmTool1.IsEqualTo( ssmTool2)) + + End Sub + <Test()> + Public Sub SSMTOOL_COMPARISON_TECHLIST_IDENTICAL_EQUAL() + + const filePath as string = "SSMTOOLTestSaveRetreive.json" + + + Dim ssmTool1 As SSMTOOL = New SSMTOOL(filePath ) + Dim ssmTool2 As SSMTOOL = New SSMTOOL(filePath ) + + 'Change something on techlist + AddDefaultTechLine( ssmTool1) + AddDefaultTechLine( ssmTool2) + + Assert.IsTrue ( ssmTool1.IsEqualTo( ssmTool2)) + + End Sub + <Test()> + Public Sub SSMTOOL_COMPARISON_TECHLIST_IDENTICAL_SINGLEKeyValueDifference() + + const filePath as string = "SSMTOOLTestSaveRetreive.json" + + + Dim ssmTool1 As SSMTOOL = New SSMTOOL(filePath ) + Dim ssmTool2 As SSMTOOL = New SSMTOOL(filePath ) + + 'Change something on techlist + AddDefaultTechLine( ssmTool1) + AddDefaultTechLine( ssmTool2) + + 'Make Unequal + ssmTool2.techList.TechLines(0).BenefitName="Doobie" + + Assert.IsFalse ( ssmTool1.IsEqualTo( ssmTool2)) + + End Sub + <Test()> + Public Sub SSMTOOL_COMPARISON_TECHLIST_IDENTICAL_SINGLEValueDifference() + + const filePath as string = "SSMTOOLTestSaveRetreive.json" + + + Dim ssmTool1 As SSMTOOL = New SSMTOOL(filePath ) + Dim ssmTool2 As SSMTOOL = New SSMTOOL(filePath ) + + 'Change something on techlist + AddDefaultTechLine( ssmTool1) + AddDefaultTechLine( ssmTool2) + + 'Make Unequal + ssmTool2.techList.TechLines(0).ActiveVV=False + + Assert.IsFalse ( ssmTool1.IsEqualTo( ssmTool2)) + + End Sub + End Class End Namespace -- GitLab