diff --git a/HVACTOOL/HVACTOOL.vbproj b/HVACTOOL/HVACTOOL.vbproj index 3b8f886576dc5686fb6872ecb0b3ac723a7c3667..43be7dfd281d2ff1e90dd1e77c5bb9142a16a881 100644 --- a/HVACTOOL/HVACTOOL.vbproj +++ b/HVACTOOL/HVACTOOL.vbproj @@ -27,7 +27,7 @@ <UpdatePeriodically>false</UpdatePeriodically> <UpdateRequired>false</UpdateRequired> <MapFileExtensions>true</MapFileExtensions> - <ApplicationRevision>7</ApplicationRevision> + <ApplicationRevision>8</ApplicationRevision> <ApplicationVersion>1.0.0.%2a</ApplicationVersion> <UseApplicationTrust>false</UseApplicationTrust> <PublishWizardCompleted>true</PublishWizardCompleted> @@ -140,6 +140,9 @@ <Content Include="BusDatabase.abdb"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> + <Content Include="bin\Debug\ssm.Ahsm"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> <None Include="HVACTOOL_TemporaryKey.pfx" /> <None Include="My Project\Application.myapp"> <Generator>MyApplicationCodeGenerator</Generator> diff --git a/HVACTOOL/Module1.vb b/HVACTOOL/Module1.vb index 2543252562757a45c8613604d4fed630713dace8..b3fe4ede16ac0f9b41d02a125082ea1f9c118906 100644 --- a/HVACTOOL/Module1.vb +++ b/HVACTOOL/Module1.vb @@ -9,8 +9,8 @@ Sub main() - 'frm.ShowDialog() - frmAlt.ShowDialog() + frm.ShowDialog() + 'frmAlt.ShowDialog() frm.Dispose diff --git a/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb index 61e317dad35f4df493fb37dc3f0fe9c1b6b6ebb6..6537511f98655cd84cb839860cef86613d396a7a 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb @@ -60,18 +60,29 @@ Public Class Alternator Sub new() End Sub - Sub new( isignals As ICombinedAlternatorSignals, pulleyRatio As single, altName As string ) + Sub new( isignals As ICombinedAlternatorSignals, inputs as List(Of ICombinedAlternatorMapRow)) If isignals is Nothing then Throw New ArgumentException("Alternator - ISignals supplied is nothing") signals = isignals - Me.AlternatorName= altName + Me.AlternatorName= inputs.First().AlternatorName + Me.PulleyRatio = inputs.First().PulleyRatio + + 'Dim values2k As Dictionary(Of single,single) = (From x In inputs where x.RPM=2000 Select new KeyValuePair(of single,single)(x.Amps,x.Efficiency) + 'Dim values4k As Dictionary(Of single,single) = From x In inputs where x.RPM=2000 Select new KeyValuePair(of single,single)(x.Amps,x.Efficiency) + 'Dim values6k As Dictionary(Of single,single) = From x In inputs where x.RPM=2000 Select new KeyValuePair(of single,single)(x.Amps,x.Efficiency) + + + 'BuildInputTable( values2k, InputTable2000) + 'BuildInputTable( values4k, InputTable2000) + 'BuildInputTable( values6k, InputTable2000) End Sub + public Sub BuildInputTable( inputs As Dictionary(of Single, single), targetTable As List (Of AltUserInput )) diff --git a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb index 5c5134c129dfce866827ef4405215afb16e8c33c..05836225e9eef2185f7228844b8dd0c655cc09ca 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb @@ -10,18 +10,23 @@ Imports SpreadsheetLight Imports Newtonsoft.Json Imports VectoAuxiliaries + Namespace Electrics Public Class CombinedAlternator + Private map As new List(Of ICombinedAlternatorMapRow) + Private Alternators As New List(Of IAlternator) Private OriginalAlternators As New List(Of IAlternator) Private FilePath As String + Private altSignals As ICombinedAlternatorSignals + - public sub new( filePath as String) + public sub new( filePath as String, altSignals As ICombinedAlternatorSignals) Dim feedback As String = String.Empty @@ -30,24 +35,63 @@ Public Class CombinedAlternator Else me.filePath = filePath End If - + + + Me.altSignals= altSignals + + + 'IF file exists then read it otherwise create a default. + + If File.Exists( filePath ) andAlso InitialiseMap( filePath) then + + Initialise() + + + + else + + + + End If End Sub - Public Sub Clone( other As CombinedAlternator) + private Function Initialise() As Boolean + 'From the map we construct this CombinedAlternator object and original CombinedAlternator Object - For Each Alternator As IAlternator In Alternators + Alternators.Clear + OriginalAlternators.Clear - Alternator.Clone( other ) + 'Set Number of alternators in AltSignals. + altSignals.NumberOfAlternators= map.Count/9 - Next + For Each alt As IEnumerable(Of ICombinedAlternatorMapRow) In map.GroupBy( Function(g) g.AlternatorName) + + Dim altName As String = alt.First().AlternatorName + Dim pulleyRatio As Single = alt.First().PulleyRatio + + + Dim alternator As IAlternator = New Alternator(altSignals, alt.ToList()) + + Alternators.Add( alternator ) + + + Next + + + End Function + Public Sub Clone( other As CombinedAlternator) + For Each Alternator As IAlternator In Alternators + Alternator.Clone( other ) + + Next End Sub @@ -78,38 +122,64 @@ Public Class CombinedAlternator Return returnValue End Function - Public Function Load(filePath As String) As Boolean + private Function Load() As Boolean - Dim returnValue As Boolean = True - Dim settings As JsonSerializerSettings = New JsonSerializerSettings() - Dim tmpAux As CombinedAlternator = New CombinedAlternator(filePath) + If Not InitialiseMap(filePath) then Return False + + + Return true - settings.TypeNameHandling = TypeNameHandling.Objects + End Function - 'JSON METHOD - Try + 'Initialises the map. + Public Function InitialiseMap(filePath As string) As Boolean - Dim output As String = File.ReadAllText(filePath) + Dim returnValue As Boolean = false + If File.Exists(filePath) Then + Using sr As StreamReader = New StreamReader(filePath) + 'get array og lines fron csv + Dim lines() As String = sr.ReadToEnd().Split(CType(Environment.NewLine, Char()), StringSplitOptions.RemoveEmptyEntries) - tmpAux = JsonConvert.DeserializeObject(Of CombinedAlternator)(output, settings) + 'Must have at least 2 entries in map to make it usable [dont forget the header row] + If (lines.Count() < 10) Then + Throw New ArgumentException("Insufficient rows in csv to build a usable map") + End If + map = new List(Of ICombinedAlternatorMapRow) + Dim firstline As Boolean = True + For Each line As String In lines + If Not firstline Then - 'This is where we Assume values of loaded( Deserialized ) object. - Clone(tmpAux) + 'Advanced Alternator Source Check. + If line.contains("[MODELSOURCE") then Exit For - Catch ex As Exception + 'split the line + Dim elements() As String = line.Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries) + '3 entries per line required + If (elements.Length <> 5) Then + Throw New ArgumentException("Incorrect number of values in csv file") + End If + 'add values to map - 'TODO:Do something meaningfull here perhaps logging + map.Add( New CombinedAlternatorMapRow(elements(0),elements(1),elements(2),elements(3),elements(4))) - returnValue = False - End Try + Else + firstline = False + End If + Next line + End Using + Return True + Else + Throw New ArgumentException("Supplied input file does not exist") + End If Return returnValue -End Function + + End Function diff --git a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorMapRow.vb b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorMapRow.vb new file mode 100644 index 0000000000000000000000000000000000000000..11271358bc34a2a4cb40faa87ee68884bf103e1f --- /dev/null +++ b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorMapRow.vb @@ -0,0 +1,41 @@ +Namespace Electrics + + + Public Class CombinedAlternatorMapRow + Implements ICombinedAlternatorMapRow + + public property AlternatorName As String implements ICombinedAlternatorMapRow.AlternatorName + public property RPM As Single implements ICombinedAlternatorMapRow.RPM + public property Amps As Single implements ICombinedAlternatorMapRow.Amps + public property Efficiency As Single implements ICombinedAlternatorMapRow.Efficiency + public property PulleyRatio As Single implements ICombinedAlternatorMapRow.PulleyRatio + + Sub new () + + + End Sub + + Sub new (AlternatorName As string, RPM As single ,Amps As single, Efficiency As single , PulleyRatio As single ) + + 'Sanity Check + If AlternatorName.Trim.Length=0 then Throw New ArgumentException("Alternator name cannot be zero length") + If Efficiency<0 or Efficiency>100 then Throw New ArgumentException("Efficiency must be between 0 and 100") + If PulleyRatio<=0 then Throw New ArgumentException("Pully ratio must be a positive number") + + 'Assignments + Me.AlternatorName = AlternatorName + Me.RPM = RPM + Me.Amps = Amps + Me.Efficiency = Efficiency + Me.PulleyRatio = PulleyRatio + + End Sub + + +End Class + + +End Namespace + + + diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorMapRow.vb b/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorMapRow.vb new file mode 100644 index 0000000000000000000000000000000000000000..0b937fb15326f1693d7516df4d745ac6916a2da1 --- /dev/null +++ b/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorMapRow.vb @@ -0,0 +1,11 @@ +Public Interface ICombinedAlternatorMapRow + + + property AlternatorName As String + property RPM As Single + property Amps As Single + property Efficiency As Single + property PulleyRatio As Single + + +End Interface diff --git a/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb b/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb index f5092dcc7171b7db13c4a48f8cc9e1986c19c02a..5a1139b820a7276b0a93f467e31bcb8dd31d1e2b 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb @@ -29,17 +29,17 @@ Return _engineType End Get End Property - Public Readonly Property LengthInMetres As Single Implements IBus.LengthInMetres + Public Readonly Property LengthInMetres As Double Implements IBus.LengthInMetres Get Return _lengthInMetres End Get End Property - Public Readonly Property WidthInMetres As Single Implements IBus.WidthInMetres + Public Readonly Property WidthInMetres As Double Implements IBus.WidthInMetres Get Return _widthInMetres End Get End Property - Public Readonly Property HeightInMetres As Single Implements IBus.HeightInMetres + Public Readonly Property HeightInMetres As Double Implements IBus.HeightInMetres Get Return _heightInMetres End Get @@ -51,12 +51,12 @@ End Property 'Caculated Property - Public Readonly Property AreaInMetresSquared As Single Implements IBus.AreaInMetresSquared + Public Readonly Property AreaInMetresSquared As Double Implements IBus.AreaInMetresSquared Get Return Math.Round( 2*(LengthInMetres * WidthInMetres + WidthInMetres * HeightInMetres + LengthInMetres * HeightInMetres),1) End Get End Property - Public Readonly Property VolumneInMetresQubed As Single Implements IBus.VolumneInMetresQubed + Public Readonly Property VolumneInMetresQubed As Double Implements IBus.VolumneInMetresQubed Get Return Math.Round(LengthInMetres * WidthInMetres * HeightInMetres ,1) End Get @@ -127,7 +127,7 @@ Return true End Function - Private Function DimensionOK( byval dimension as Single ) as boolean + Private Function DimensionOK( byval dimension as Double ) as boolean Return dimension> 0.5 diff --git a/VECTOAux/VectoAuxiliaries/Hvac/IBus.vb b/VECTOAux/VectoAuxiliaries/Hvac/IBus.vb index 7dfa80c6d0b54a71266aa52e48549df2e761a0f6..c7afbfc986f76e6492619a2914af46c93defc200 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/IBus.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/IBus.vb @@ -6,13 +6,13 @@ Namespace Hvac Readonly Property Model As String Readonly Property FloorType As String Readonly Property EngineType As String - Readonly Property LengthInMetres As Single - Readonly Property WidthInMetres As Single - Readonly Property HeightInMetres As Single + Readonly Property LengthInMetres As Double + Readonly Property WidthInMetres As Double + Readonly Property HeightInMetres As Double Readonly Property RegisteredPassengers As integer - Readonly Property AreaInMetresSquared As Single - Readonly Property VolumneInMetresQubed As Single + Readonly Property AreaInMetresSquared As Double + Readonly Property VolumneInMetresQubed As Double End Interface diff --git a/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.Designer.vb b/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.Designer.vb index fcdd420f11eb1d29bcae906d89578b8ed5a8f892..9c94b35f3c1c007d4cc000f5a15aae58b44a230e 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.Designer.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.Designer.vb @@ -398,7 +398,7 @@ Partial Class frmCombinedAlternators 'gvAlternators ' Me.gvAlternators.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize - Me.gvAlternators.Location = New System.Drawing.Point(38, 277) + Me.gvAlternators.Location = New System.Drawing.Point(38, 276) Me.gvAlternators.Name = "gvAlternators" Me.gvAlternators.Size = New System.Drawing.Size(417, 140) Me.gvAlternators.TabIndex = 38 diff --git a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb index b6d06fa6692a9ea981b91ca07fb6e779226de6ae..70af9c492e50b20abc4b19cc993820e97a1e5c7b 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb @@ -507,6 +507,7 @@ Partial Class frmHVACTool 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.ReadOnly = true Me.txtBusFloorSurfaceArea.Size = New System.Drawing.Size(97, 21) Me.txtBusFloorSurfaceArea.TabIndex = 5 ' diff --git a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.resx b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.resx index 35978344d23aaef0b4ccd6d2605aae58a01a179a..aa44697951617948028d759496a36be860703123 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.resx +++ b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.resx @@ -120,9 +120,6 @@ <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="ToolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>17, 17</value> - </metadata> <metadata name="ErrorProvider1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>116, 17</value> </metadata> diff --git a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb index 03e73b9b31e45b5d9526ef0c1f0f50943e0cb3d6..52c7ac257324c4c8a141a746f113c6b05eeb65a2 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb @@ -298,7 +298,33 @@ End Sub txtBusLength.Text = bus.LengthInMetres txtBusWidth.Text = bus.WidthInMetres - txtRegisteredPassengers.Focus() + ssmTOOL.GenInputs.BP_BusModel = bus.Model + ssmTOOL.GenInputs.BP_NumberOfPassengers= bus.RegisteredPassengers + ssmTOOL.GenInputs.BP_BusFloorType = bus.FloorType + ssmTOOL.GenInputs.BP_BusSurfaceAreaM2= bus.AreaInMetresSquared + ssmTOOL.GenInputs.BP_BusVolume = bus.VolumneInMetresQubed + ssmTOOL.GenInputs.BP_BusLength = bus.LengthInMetres + ssmTOOL.GenInputs.BP_BusWidth = bus.WidthInMetres + + + txtBusFloorSurfaceArea.Text= ssmTOOL.GenInputs.BP_BusFloorSurfaceArea + txtBusWindowSurfaceArea.text = ssmTOOL.GenInputs.BP_BusWindowSurface + + ' txtBusWidth.Refresh + + + 'txtRegisteredPassengers.Focus() + 'txtBusModel.focus() + 'txtRegisteredPassengers.Focus() + 'txtBusFloorType.focus() + 'txtBusSurfaceArea.focus() + 'txtBusVolume.focus() + 'txtBusLength.focus() + 'txtBusWidth.Focus() + 'txtRegisteredPassengers.Focus() + + + End If diff --git a/VECTOAux/VectoAuxiliaries/VectoAuxiliaries.vbproj b/VECTOAux/VectoAuxiliaries/VectoAuxiliaries.vbproj index 02142ef490bcc890b3e9d5713f834d6ce8d5fde8..9ae6c54f890d4571b183cc5fe6e6abfc06557fb7 100644 --- a/VECTOAux/VectoAuxiliaries/VectoAuxiliaries.vbproj +++ b/VECTOAux/VectoAuxiliaries/VectoAuxiliaries.vbproj @@ -114,9 +114,11 @@ <Compile Include="Electrics\AltUserInput.vb" /> <Compile Include="Electrics\CombinedAltEntry.vb" /> <Compile Include="Electrics\CombinedAlternator.vb" /> + <Compile Include="Electrics\CombinedAlternatorMapRow.vb" /> <Compile Include="Electrics\CombinedAlternatorSignals.vb" /> <Compile Include="Electrics\ElectricsUserInputsConfig.vb" /> <Compile Include="Electrics\IAlternator.vb" /> + <Compile Include="Electrics\ICombinedAlternatorMapRow.vb" /> <Compile Include="Electrics\ICombinedAlternatorSignals.vb" /> <Compile Include="Electrics\IElectricsUserInputsConfig.vb" /> <Compile Include="Electrics\IM0_5_SmartAlternatorSetEfficiency.vb" /> diff --git a/VECTOAux/VectoAuxiliariesTests/TestFiles/testCombinedAlternatorMap.aalt b/VECTOAux/VectoAuxiliariesTests/TestFiles/testCombinedAlternatorMap.aalt new file mode 100644 index 0000000000000000000000000000000000000000..92954f08c513f01c8c2e26cba99a1fa11d2c6994 --- /dev/null +++ b/VECTOAux/VectoAuxiliariesTests/TestFiles/testCombinedAlternatorMap.aalt @@ -0,0 +1,42 @@ +[AlternatorName],[RPM],[Amps],[Efficiency],[PulleyRatio] +Alt1,2000,10,50,3 +Alt1,2000,40,50,3 +Alt1,2000,60,50,3 +Alt1,4000,10,70,3 +Alt1,4000,40,70,3 +Alt1,4000,60,70,3 +Alt1,6000,10,60,3 +Alt1,6000,40,60,3 +Alt1,6000,60,60,3 +Alt2,2000,10,80,2.5 +Alt2,2000,40,80,2.5 +Alt2,2000,60,80,2.5 +Alt2,4000,10,40,2.5 +Alt2,4000,40,40,2.5 +Alt2,4000,60,40,2.5 +Alt2,6000,10,60,2.5 +Alt2,6000,40,60,2.5 +Alt2,6000,60,60,2.5 +Alt3,2000,10,95,3.5 +Alt3,2000,40,50,3.5 +Alt3,2000,60,90,3.5 +Alt3,4000,10,99,3.5 +Alt3,4000,40, 1,3.5 +Alt3,4000,60,55,3.5 +Alt3,6000,10,94,3.5 +Alt3,6000,40,86,3.5 +Alt3,6000,60,13,3.5 +Alt4,2000,10,55,2 +Alt4,2000,40,45,2 +Alt4,2000,60,67,2 +Alt4,4000,10,77,2 +Alt4,4000,40,39,2 +Alt4,4000,60,23,2 +Alt4,6000,10,34,2 +Alt4,6000,40,67,2 +Alt4,6000,60,35,2 +[MODELSOURCE] + + + + diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb index 2cff41f8ffa1c75c1768713ae71bae3e23e9b16f..6c02f890b20df5a53db0faceafafecfadd0cef81 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb @@ -25,6 +25,9 @@ Namespace UnitTests + Private Const COMBINEDALT_GOODMAP = "testfiles\testCombinedAlternatorMap.aalt" + + Sub new () Alt1ExpectedTable2000 = New List(Of AltUserInput)() from { New AltUserInput( 0,50), _ @@ -145,16 +148,34 @@ Namespace UnitTests <Test()> Public Sub Alt1TableConstructTest() - Dim inputs2000 As New Dictionary(Of single,single)() From {{10,50}, {40,50}, {60,50}} - Dim inputs4000 As New Dictionary(Of single,single)() From {{10,70}, {40,70}, {60,70}} - Dim inputs6000 As New Dictionary(Of single,single)() From {{10,60}, {40,60}, {60,60}} + 'Dim inputs2000 As New Dictionary(Of single,single)() From {{10,50}, {40,50}, {60,50}} + 'Dim inputs4000 As New Dictionary(Of single,single)() From {{10,70}, {40,70}, {60,70}} + 'Dim inputs6000 As New Dictionary(Of single,single)() From {{10,60}, {40,60}, {60,60}} + + + Dim inputs As New List(Of ICombinedAlternatorMapRow) + Dim pulleyRatio As Single =3 + + + inputs.Add( New CombinedAlternatorMapRow("alt1",2000,10,50,pulleyRatio)) + inputs.Add( New CombinedAlternatorMapRow("alt1",2000,40,50,pulleyRatio)) + inputs.Add( New CombinedAlternatorMapRow("alt1",2000,60,50,pulleyRatio)) + + inputs.Add( New CombinedAlternatorMapRow("alt1",4000,10,70,pulleyRatio)) + inputs.Add( New CombinedAlternatorMapRow("alt1",4000,40,70,pulleyRatio)) + inputs.Add( New CombinedAlternatorMapRow("alt1",4000,60,70,pulleyRatio)) + + inputs.Add( New CombinedAlternatorMapRow("alt1",6000,10,60,pulleyRatio)) + inputs.Add( New CombinedAlternatorMapRow("alt1",6000,40,60,pulleyRatio)) + inputs.Add( New CombinedAlternatorMapRow("alt1",6000,60,60,pulleyRatio)) - Dim Alt As New Alternator( New CombinedAlternatorSignals(), 3,"Alt1") + Dim Alt As New Alternator( New CombinedAlternatorSignals(),inputs) - Alt.BuildInputTable( inputs2000, Alt.InputTable2000) - Alt.BuildInputTable( inputs4000, Alt.InputTable4000) - Alt.BuildInputTable( inputs6000, Alt.InputTable6000) + + 'Alt.BuildInputTable( inputs2000, Alt.InputTable2000) + 'Alt.BuildInputTable( inputs4000, Alt.InputTable4000) + 'Alt.BuildInputTable( inputs6000, Alt.InputTable6000) Dim idx As integer @@ -172,19 +193,21 @@ Namespace UnitTests End Sub - <Test()> + + <Test()> Public Sub Alt2TableConstructTest() - Dim inputs2000 As New Dictionary(Of single,single)() From {{10,80}, {40,80}, {60,80}} - Dim inputs4000 As New Dictionary(Of single,single)() From {{10,40}, {40,40}, {60,40}} - Dim inputs6000 As New Dictionary(Of single,single)() From {{10,60}, {40,60}, {60,60}} + Dim inputs As New Dictionary(Of single,single)() From {{10,80}, {40,80}, {60,80}, _ + {10,40}, {40,40}, {60,40}, _ + {10,60}, {40,60}, {60,60}} - Dim Alt As New Alternator( New CombinedAlternatorSignals(), 2.5,"Alt2") + Dim Alt= Nothing ' As New Alternator( New CombinedAlternatorSignals(), 2.5,"Alt2", inputs) + - Alt.BuildInputTable( inputs2000, Alt.InputTable2000) - Alt.BuildInputTable( inputs4000, Alt.InputTable4000) - Alt.BuildInputTable( inputs6000, Alt.InputTable6000) + 'Alt.BuildInputTable( inputs2000, Alt.InputTable2000) + 'Alt.BuildInputTable( inputs4000, Alt.InputTable4000) + 'Alt.BuildInputTable( inputs6000, Alt.InputTable6000) Dim idx As integer @@ -205,16 +228,16 @@ Namespace UnitTests <Test()> Public Sub Alt3TableConstructTest() - Dim inputs2000 As New Dictionary(Of single,single)() From {{10,95}, {40,50}, {60,90}} - Dim inputs4000 As New Dictionary(Of single,single)() From {{10,99}, {40, 1}, {60,55}} - Dim inputs6000 As New Dictionary(Of single,single)() From {{10,94}, {40,86}, {60,13}} + Dim inputs As New Dictionary(Of single,single)() From {{10,95}, {40,50}, {60,90}, _ + {10,99}, {40, 1}, {60,55}, _ + {10,94}, {40,86}, {60,13}} - Dim Alt As New Alternator( New CombinedAlternatorSignals(), 3.5,"Alt3") + Dim Alt = Nothing' As New Alternator( New CombinedAlternatorSignals(), 3.5,"Alt3",inputs) - Alt.BuildInputTable( inputs2000, Alt.InputTable2000) - Alt.BuildInputTable( inputs4000, Alt.InputTable4000) - Alt.BuildInputTable( inputs6000, Alt.InputTable6000) + 'Alt.BuildInputTable( inputs2000, Alt.InputTable2000) + 'Alt.BuildInputTable( inputs4000, Alt.InputTable4000) + 'Alt.BuildInputTable( inputs6000, Alt.InputTable6000) Dim idx As integer @@ -235,16 +258,16 @@ Namespace UnitTests <Test()> Public Sub Alt4TableConstructTest() - Dim inputs2000 As New Dictionary(Of single,single)() From {{10,55}, {40,45}, {60,67}} - Dim inputs4000 As New Dictionary(Of single,single)() From {{10,77}, {40,39}, {60,23}} - Dim inputs6000 As New Dictionary(Of single,single)() From {{10,34}, {40,67}, {60,35}} + Dim inputs As New Dictionary(Of single,single)() From {{10,55}, {40,45}, {60,67}, _ + {10,77}, {40,39}, {60,23}, _ + {10,34}, {40,67}, {60,35}} - Dim Alt As New Alternator( New CombinedAlternatorSignals(), 3.5,"Alt4") + Dim Alt = Nothing 'As New Alternator( New CombinedAlternatorSignals(), 3.5,"Alt4", inputs) - Alt.BuildInputTable( inputs2000, Alt.InputTable2000) - Alt.BuildInputTable( inputs4000, Alt.InputTable4000) - Alt.BuildInputTable( inputs6000, Alt.InputTable6000) + 'Alt.BuildInputTable( inputs2000, Alt.InputTable2000) + 'Alt.BuildInputTable( inputs4000, Alt.InputTable4000) + 'Alt.BuildInputTable( inputs6000, Alt.InputTable6000) Dim idx As integer @@ -261,6 +284,32 @@ Namespace UnitTests Next + End Sub + + + 'testCombinedAlternatorMap + <Test()> + Public Sub InitialiseCombinedAlternatorMap() + + Dim inputs2000 As New Dictionary(Of single,single)() From {{10,55}, {40,45}, {60,67}} + Dim inputs4000 As New Dictionary(Of single,single)() From {{10,77}, {40,39}, {60,23}} + Dim inputs6000 As New Dictionary(Of single,single)() From {{10,34}, {40,67}, {60,35}} + + 'Arrange + Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals + + + 'Act + Dim target As new CombinedAlternator(COMBINEDALT_GOODMAP, signals) + + + + 'Assert + + + + + End Sub diff --git a/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj b/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj index 834218aee489c0b484011b54d2484d24fed19332..fdf5db6305cdf40cc387eae4d96b723cd7e7c235 100644 --- a/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj +++ b/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj @@ -290,6 +290,9 @@ <Content Include="TestFiles\BusDatabase.abdb"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> + <None Include="TestFiles\testCombinedAlternatorMap.aalt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </None> <None Include="TestFiles\testAlternatorMapAsymetricalXYPairsCombined.aalt"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None>