From 73ac2bc4cd45b24aed7fb9fb1f1e8c8db7b10584 Mon Sep 17 00:00:00 2001
From: "Burns, Terry" <Terry.Burns@ricardo.com>
Date: Tue, 7 Oct 2014 11:18:28 +0000
Subject: [PATCH] git-tfs-id:
 [http://tfs00.element.root.com:8080/tfs/TFSCollection]$/VECTO;C1629

---
 MapTests/AlternatorMapInterpolated.vb         | 237 ++++++++++++++++++
 MapTests/AlternatorMapNonInterpolated.vb      | 173 +++++++++++++
 MapTests/App.config                           |   6 +
 MapTests/MapTests.vbproj                      | 126 ++++++++++
 MapTests/Module1.vb                           |  99 ++++++++
 MapTests/My Project/Application.Designer.vb   |  13 +
 MapTests/My Project/Application.myapp         |  10 +
 MapTests/My Project/AssemblyInfo.vb           |  35 +++
 MapTests/My Project/Resources.Designer.vb     |  63 +++++
 MapTests/My Project/Resources.resx            | 117 +++++++++
 MapTests/My Project/Settings.Designer.vb      |  73 ++++++
 MapTests/My Project/Settings.settings         |   7 +
 VECTO/GUI/F_VECTO.vb                          |   8 +-
 ...AlternatoMap.csv => testAlternatorMap.csv} |   0
 .../VectoAuxiliariesTests.vbproj              |   2 +-
 15 files changed, 965 insertions(+), 4 deletions(-)
 create mode 100644 MapTests/AlternatorMapInterpolated.vb
 create mode 100644 MapTests/AlternatorMapNonInterpolated.vb
 create mode 100644 MapTests/App.config
 create mode 100644 MapTests/MapTests.vbproj
 create mode 100644 MapTests/Module1.vb
 create mode 100644 MapTests/My Project/Application.Designer.vb
 create mode 100644 MapTests/My Project/Application.myapp
 create mode 100644 MapTests/My Project/AssemblyInfo.vb
 create mode 100644 MapTests/My Project/Resources.Designer.vb
 create mode 100644 MapTests/My Project/Resources.resx
 create mode 100644 MapTests/My Project/Settings.Designer.vb
 create mode 100644 MapTests/My Project/Settings.settings
 rename VECTOAux/VectoAuxiliariesTests/TestFiles/{testAlternatoMap.csv => testAlternatorMap.csv} (100%)

diff --git a/MapTests/AlternatorMapInterpolated.vb b/MapTests/AlternatorMapInterpolated.vb
new file mode 100644
index 0000000000..beb9158f27
--- /dev/null
+++ b/MapTests/AlternatorMapInterpolated.vb
@@ -0,0 +1,237 @@
+Imports System.IO
+
+
+
+    ''' <summary>
+    ''' Alternator Efficiency Map
+    ''' </summary>
+    ''' <remarks></remarks>
+    Public Class AlternatorMapInterpolated
+
+
+        ''' <summary>
+        ''' path to csv file containing map data
+        ''' expects header row
+        ''' Columns - [rpm - integer], [efficiency float, range 0-1], [max regen power float]
+        ''' </summary>
+        ''' <remarks></remarks>
+        Private ReadOnly filePath As String
+
+        Public map As Dictionary(Of AlternatorMapKey, AlternatorMapValues)
+
+        ''' <summary>
+        ''' Creates a new instance of AlternatorMap class
+        ''' </summary>
+        ''' <param name="filePath">full path to csv data</param>
+        ''' <remarks></remarks>
+        Public Sub New(ByVal filePath As String)
+            Me.filePath = filePath
+        End Sub
+
+        ''' <summary>
+        ''' Initialise the map from supplied csv data
+        ''' </summary>
+        ''' <returns>Boolean - true if map is created successfully</returns>
+        ''' <remarks></remarks>
+        Public Function Initialise() As Boolean
+            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)
+
+                    'Must have at least 2 entries in map to make it usable [dont forget the header row]
+                    If (lines.Count() < 3) Then
+                        Throw New ArgumentException("Insufficient rows in csv to build a usable map")
+                    End If
+
+                    map = New Dictionary(Of AlternatorMapKey, AlternatorMapValues)()
+                    Dim firstline As Boolean = True
+
+                    For Each line As String In lines
+                        If Not firstline Then
+                            'split the line
+                            Dim elements() As String = line.Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries)
+                            '3 entries per line required
+                            If (elements.Length <> 3) Then
+                                Throw New ArgumentException("Incorrect number of values in csv file")
+                            End If
+                            'add values to map
+
+                            'Create AlternatorKey
+                            Dim aKey As AlternatorMapKey = New AlternatorMapKey(elements(0), elements(1))
+                            Dim aValue As AlternatorMapValues = New AlternatorMapValues()
+
+                            'Add Efficiency Value to Key.
+                            map.Add(aKey, New AlternatorMapValues(elements(2)))
+
+                        Else
+                            firstline = False
+                        End If
+                    Next line
+                End Using
+                Return True
+            Else
+                Throw New ArgumentException("Supplied input file does not exist")
+            End If
+        End Function
+
+        ''' <summary>
+        ''' Returns the alternator efficiency at given rpm
+        ''' </summary>
+        ''' <param name="rpm">alternator rotation speed</param>
+        ''' <returns>Single</returns>
+        ''' <remarks></remarks>
+        Public Function GetEfficiency(ByVal rpm As Integer) As Single
+            'Dim tupleValue As AlternatorMapValues = GetValueOrInterpolate(rpm)
+            'Dim value As Single = tupleValue.Efficiency
+            'Return value
+            Return 0 'TODO:FIX THIS
+        End Function
+
+        ''' <summary>
+        ''' Returns the alternator Maximum Regeneration Power at given rpm
+        ''' </summary>
+        ''' <param name="rpm">alternator rotation speed</param>
+        ''' <returns>Single</returns>
+        ''' <remarks></remarks>
+        Public Function GetMaximumRegenerationPower(ByVal rpm As Integer) As Single
+            'Dim value As AlternatorMapValues = GetValueOrInterpolate(rpm)
+            'Return value.Amps
+            Return 0 'TODO:FIX THIS
+        End Function
+
+        ''' <summary>
+        ''' Returns a AlternatorMapValues instance containing the entries at a given key, or new interpolated values
+        ''' </summary>
+        ''' <returns>AlternatorMapValues</returns>
+        ''' <remarks>Throws exception if rpm are outside map</remarks>
+        Public Function GetValueOrInterpolate(mapKey As AlternatorMapKey) As AlternatorMapValues
+            'check the rpm is within the map
+
+
+            'Dim min As AlternatorMapKey = map.Keys.Min()
+            'Dim max As AlternatorMapKey = map.Keys.Max()
+
+            'If mapKey.amps < 0 OrElse mapKey.amps > max.amps OrElse mapKey.rpm < 0 OrElse mapKey.rpm > max.rpm Then
+            '    Throw New ArgumentOutOfRangeException(String.Format("Extrapolation - Amp/Rpm Values should should be in the range {0} to {1}", min.ToString(), max.ToString()))
+            'End If
+
+            'Check if the rpm is in the current memo
+            'If supplied present key, we can just return the values
+            If map.ContainsKey(mapKey) Then
+                Return map(mapKey)
+            End If
+
+
+            'Get Pre and Post Keys.
+            Dim rpmEfficiency As Single
+            Dim ampsEfficiency As Single
+            Dim rpmPre As AlternatorMapValues
+            Dim rpmPost As AlternatorMapValues
+            Dim ampsPre As AlternatorMapValues
+            Dim ampsPost As AlternatorMapValues
+
+            Dim intRpmPre As Integer
+            Dim intRpmPost As Integer
+            Dim intAmpsPre As Integer
+            Dim intAmpsPost As Integer
+
+            intRpmPre = (From m In map Where m.Key.rpm < mapKey.rpm Select m.Key.rpm).Last()
+            intRpmPost = (From m In map Where m.Key.rpm > mapKey.rpm Select m.Key.rpm).First()
+            intAmpsPre = (From m In map Where m.Key.amps < mapKey.amps Select m.Key.amps).Last()
+            intAmpsPost = (From m In map Where m.Key.amps > mapKey.amps Select m.Key.amps).First()
+
+            rpmPre = map(New AlternatorMapKey(intAmpsPre, intRpmPre))
+            rpmPost = map(New AlternatorMapKey(intAmpsPre, intRpmPost))
+
+            ampsPre = map(New AlternatorMapKey(intAmpsPost, intRpmPre))
+            ampsPost = map(New AlternatorMapKey(intAmpsPost, intRpmPost))
+
+
+            '**********     A-B  Efficiency  ( Lower Amps )  ************
+            'get the delta values for rpm and the values
+             Dim dRpm As Integer = intRpmPost - intRpmPre
+             Dim dRpmEfficiency As Single = rpmPost.Efficiency - rpmPre.Efficiency
+
+            'calculate the slopes
+             Dim rpmEfficiencySlope As Single = dRpmEfficiency / dRpm
+
+            'calculate the new values
+             Dim AB_Efficiency As Single = ((mapKey.rpm - intRpmPre) * rpmEfficiencySlope) + rpmPre.Efficiency
+
+             '**********     C-D Efficiency  ( Higher Amps )  ************
+            'get the delta values for rpm and the values
+             dRpm = intRpmPost - intRpmPre
+             dRpmEfficiency = ampsPost.Efficiency - ampsPre.Efficiency
+
+            'calculate the slopes
+             rpmEfficiencySlope = dRpmEfficiency / dRpm
+
+            'calculate the new values
+             Dim CD_Efficiency As Single = ((mapKey.rpm - intRpmPre) * rpmEfficiencySlope) + ampsPre.Efficiency
+
+
+             '(C-D) - (A-B) Efficiency
+             'Deltas
+             Dim dAmps = intAmpsPost - intAmpsPre
+             Dim dAmpEfficiency = CD_Efficiency - AB_Efficiency
+
+             'slopes
+             Dim ampsEfficiencySlope As Single = dAmpEfficiency / dAmps
+
+             'calculate final Values
+             Dim ABCDEfficiency = ((mapKey.amps - intAmpsPre) * ampsEfficiencySlope) + AB_Efficiency
+
+
+            Return New AlternatorMapValues(ABCDEfficiency)
+
+
+
+        End Function
+
+        ''' <summary>
+        ''' Encapsulates Efficiency and Maximum Regeneration Power values for Alternator
+        ''' </summary>
+        Public Structure AlternatorMapValues
+
+
+            Public ReadOnly Efficiency As Single
+
+
+
+            Public Sub New(ByVal efficiency As Single)
+                Me.Efficiency = efficiency
+            End Sub
+
+        End Structure
+
+
+       Public Structure AlternatorMapKey
+
+
+           Public amps As Integer
+           Public rpm As Integer
+
+
+
+        Public Sub New(ByVal amps As Integer, ByVal rpm As Integer)
+
+        Me.amps = amps
+        Me.rpm = rpm
+
+
+        End Sub
+
+        Public Overrides Function ToString() As String
+
+          Return "Amps:" & amps & " / " & "Rpm:" & rpm
+
+        End Function
+
+       End Structure
+
+
+    End Class
+
+
+
diff --git a/MapTests/AlternatorMapNonInterpolated.vb b/MapTests/AlternatorMapNonInterpolated.vb
new file mode 100644
index 0000000000..7453b57c02
--- /dev/null
+++ b/MapTests/AlternatorMapNonInterpolated.vb
@@ -0,0 +1,173 @@
+Imports System.IO
+
+
+
+    ''' <summary>
+    ''' Alternator Efficiency Map
+    ''' </summary>
+    ''' <remarks></remarks>
+    Public Class AlternatorMapInterpolated
+
+
+        ''' <summary>
+        ''' path to csv file containing map data
+        ''' expects header row
+        ''' Columns - [rpm - integer], [efficiency float, range 0-1], [max regen power float]
+        ''' </summary>
+        ''' <remarks></remarks>
+        Private ReadOnly filePath As String
+
+        Public map As List(Of AlternatorMapValues)
+
+        ''' <summary>
+        ''' Creates a new instance of AlternatorMap class
+        ''' </summary>
+        ''' <param name="filePath">full path to csv data</param>
+        ''' <remarks></remarks>
+        Public Sub New(ByVal filePath As String)
+            Me.filePath = filePath
+        End Sub
+
+        ''' <summary>
+        ''' Initialise the map from supplied csv data
+        ''' </summary>
+        ''' <returns>Boolean - true if map is created successfully</returns>
+        ''' <remarks></remarks>
+        Public Function Initialise() As Boolean
+            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)
+
+                    'Must have at least 2 entries in map to make it usable [dont forget the header row]
+                    If (lines.Count() < 3) Then
+                        Throw New ArgumentException("Insufficient rows in csv to build a usable map")
+                    End If
+
+                    map = New List(Of AlternatorMapValues)()
+                    Dim firstline As Boolean = True
+
+                    For Each line As String In lines
+                        If Not firstline Then
+                            'split the line
+                            Dim elements() As String = line.Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries)
+                            '3 entries per line required
+                            If (elements.Length <> 3) Then
+                                Throw New ArgumentException("Incorrect number of values in csv file")
+                            End If
+                            'add values to map
+                            map.Add(New AlternatorMapValues(elements(0), elements(2), elements(1)))
+                        Else
+                            firstline = False
+                        End If
+                    Next line
+                End Using
+                Return True
+            Else
+                Throw New ArgumentException("Supplied input file does not exist")
+            End If
+        End Function
+
+        ''' <summary>
+        ''' Returns the alternator efficiency at given rpm
+        ''' </summary>
+        ''' <param name="rpm">alternator rotation speed</param>
+        ''' <returns>Single</returns>
+        ''' <remarks></remarks>
+        Public Function GetEfficiency(ByVal rpm As Integer) As Single
+            Dim tupleValue As AlternatorMapValues = GetValueOrInterpolate(rpm)
+            Dim value As Single = tupleValue.Efficiency
+            Return value
+        End Function
+
+        ''' <summary>
+        ''' Returns the alternator Maximum Regeneration Power at given rpm
+        ''' </summary>
+        ''' <param name="rpm">alternator rotation speed</param>
+        ''' <returns>Single</returns>
+        ''' <remarks></remarks>
+        Public Function GetMaximumRegenerationPower(ByVal rpm As Integer) As Single
+            Dim value As AlternatorMapValues = GetValueOrInterpolate(rpm)
+            Return value.Amps
+        End Function
+
+        ''' <summary>
+        ''' Returns a AlternatorMapValues instance containing the entries at a given key, or new interpolated values
+        ''' </summary>
+        ''' <returns>AlternatorMapValues</returns>
+        ''' <remarks>Throws exception if rpm are outside map</remarks>
+        Private Function GetValueOrInterpolate(ByVal rpm As Integer) As AlternatorMapValues
+            'check the rpm is within the map
+            Dim min As Integer = map.Keys.Min()
+            Dim max As Integer = map.Keys.Max()
+            If rpm < min OrElse rpm > max Then
+                Throw New ArgumentOutOfRangeException(String.Format("Extrapolation - rpm should be in the range {0} to {1}", min, max), rpm)
+            End If
+
+            'Check if the rpm is in the current memo
+            'If supplied rpm is a key, we can just return the values
+            If map.ContainsKey(rpm) Then
+                Return map(rpm)
+            End If
+
+            'Not a key value, interpolate
+            'get the entries before and after the supplied rpm
+            Dim pre As KeyValuePair(Of Integer, AlternatorMapValues) = (From m In map Where m.Key < rpm Select m).Last()
+            Dim post As KeyValuePair(Of Integer, AlternatorMapValues) = (From m In map Where m.Key > rpm Select m).First()
+
+            'get the delta values for rpm and the values
+            Dim dRpm As Integer = post.Key - pre.Key
+            Dim dEfficiency As Single = post.Value.Efficiency - pre.Value.Efficiency
+            Dim dPower As Single = post.Value.Amps - pre.Value.Amps
+
+            'calculate the slopes
+            Dim efficiencySlope As Single = dEfficiency / dRpm
+            Dim powerSlope As Single = dPower / dRpm
+
+            'calculate the new values
+            Dim efficiency As Single = ((rpm - pre.Key) * efficiencySlope) + pre.Value.Efficiency
+            Dim regenPower As Single = ((rpm - pre.Key) * powerSlope) + pre.Value.Amps
+
+            'Build a new AlternatorMapValues instance
+            Return New AlternatorMapValues(efficiency, regenPower, rpm)
+
+
+        End Function
+
+        ''' <summary>
+        ''' Encapsulates Efficiency and Maximum Regeneration Power values for Alternator
+        ''' </summary>
+        Public Structure AlternatorMapValues
+
+
+
+            Public ReadOnly RPM As Integer
+
+
+            ''' <summary>
+            ''' Efficiency of alternator at a given rotation speed
+            ''' </summary>
+            Public ReadOnly Efficiency As Single
+
+            ''' <summary>
+            ''' Maximum regeneration rower of alternator at a given rotation speed
+            ''' </summary>
+            Public ReadOnly Amps As Single
+
+            ''' <summary>
+            ''' Creates a new instance of AlternatorMapValues
+            ''' </summary>
+            ''' <param name="efficiency">Efficiency Value</param>
+            ''' <param name="maxRegenPower">Maximum Regeneration Power value</param>
+            Public Sub New(ByVal rpm As Integer, ByVal amps As Single, efficiency As Single)
+                Me.Efficiency = efficiency
+                Me.Amps = amps
+                Me.RPM = rpm
+            End Sub
+
+        End Structure
+
+    End Class
+
+
+
diff --git a/MapTests/App.config b/MapTests/App.config
new file mode 100644
index 0000000000..74ade9db53
--- /dev/null
+++ b/MapTests/App.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
+    </startup>
+</configuration>
diff --git a/MapTests/MapTests.vbproj b/MapTests/MapTests.vbproj
new file mode 100644
index 0000000000..05fe880c53
--- /dev/null
+++ b/MapTests/MapTests.vbproj
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{29E00F22-74A9-47F4-8A09-C68B42AF45AA}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <StartupObject>MapTests.Module1</StartupObject>
+    <RootNamespace>MapTests</RootNamespace>
+    <AssemblyName>MapTests</AssemblyName>
+    <FileAlignment>512</FileAlignment>
+    <MyType>Console</MyType>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <SccProjectName>SAK</SccProjectName>
+    <SccLocalPath>SAK</SccLocalPath>
+    <SccAuxPath>SAK</SccAuxPath>
+    <SccProvider>SAK</SccProvider>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <DefineDebug>true</DefineDebug>
+    <DefineTrace>true</DefineTrace>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DocumentationFile>MapTests.xml</DocumentationFile>
+    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <DefineDebug>false</DefineDebug>
+    <DefineTrace>true</DefineTrace>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DocumentationFile>MapTests.xml</DocumentationFile>
+    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
+  </PropertyGroup>
+  <PropertyGroup>
+    <OptionExplicit>On</OptionExplicit>
+  </PropertyGroup>
+  <PropertyGroup>
+    <OptionCompare>Binary</OptionCompare>
+  </PropertyGroup>
+  <PropertyGroup>
+    <OptionStrict>Off</OptionStrict>
+  </PropertyGroup>
+  <PropertyGroup>
+    <OptionInfer>On</OptionInfer>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Xml" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+  </ItemGroup>
+  <ItemGroup>
+    <Import Include="Microsoft.VisualBasic" />
+    <Import Include="System" />
+    <Import Include="System.Collections" />
+    <Import Include="System.Collections.Generic" />
+    <Import Include="System.Data" />
+    <Import Include="System.Diagnostics" />
+    <Import Include="System.Linq" />
+    <Import Include="System.Xml.Linq" />
+    <Import Include="System.Threading.Tasks" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AlternatorMapInterpolated.vb" />
+    <Compile Include="Module1.vb" />
+    <Compile Include="My Project\AssemblyInfo.vb" />
+    <Compile Include="My Project\Application.Designer.vb">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Application.myapp</DependentUpon>
+    </Compile>
+    <Compile Include="My Project\Resources.Designer.vb">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <Compile Include="My Project\Settings.Designer.vb">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="My Project\Resources.resx">
+      <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.vb</LastGenOutput>
+      <CustomToolNamespace>My.Resources</CustomToolNamespace>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="bin\Debug\nonInterpolated.csv">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <None Include="My Project\Application.myapp">
+      <Generator>MyApplicationCodeGenerator</Generator>
+      <LastGenOutput>Application.Designer.vb</LastGenOutput>
+    </None>
+    <None Include="My Project\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <CustomToolNamespace>My</CustomToolNamespace>
+      <LastGenOutput>Settings.Designer.vb</LastGenOutput>
+    </None>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="bin\Debug\" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/MapTests/Module1.vb b/MapTests/Module1.vb
new file mode 100644
index 0000000000..2029780df0
--- /dev/null
+++ b/MapTests/Module1.vb
@@ -0,0 +1,99 @@
+
+
+Imports System.IO
+Imports System.Text
+
+Module Module1
+
+    Sub Main()
+
+
+       'CreateBigFile()
+
+
+
+
+        'Dim NonInterpolated As New AlternatorMapNonInterpolated("nonInterpolated.csv")
+
+        'Dim nonIntReadStart = New TimeSpan(DateTime.Now.Ticks)
+        'NonInterpolated.Initialise()
+        'Dim nonIntReadStop = New TimeSpan(DateTime.Now.Ticks)
+
+        'Console.WriteLine("NONE INTERP 56*200")
+        'Console.WriteLine("___________________")
+        'Console.WriteLine("Started Initialise {0}", nonIntReadStart.ToString("fff"))
+        'Console.WriteLine("Stopped Initialise {0}", nonIntReadStop.ToString("fff"))
+        'Console.WriteLine("Delta ( ms ) {0}", (nonIntReadStop - nonIntReadStart).ToString("fff"))
+
+
+        Dim map As AlternatorMapInterpolated = New AlternatorMapInterpolated("interpolated.csv")
+
+        Dim efficiency As AlternatorMapInterpolated.AlternatorMapValues
+
+        map.Initialise()
+
+         Dim nonIntReadStart = New TimeSpan(DateTime.Now.Ticks)
+
+        For rpm As Integer = 2100 To 3099 Step 1
+
+              efficiency = map.GetValueOrInterpolate(New AlternatorMapInterpolated.AlternatorMapKey(15, rpm))
+        Next
+
+        Dim nonIntReadStop = New TimeSpan(DateTime.Now.Ticks)
+
+        Console.WriteLine("Interpolated Values - 1000 Interpolations between 2100 and 3099")
+        Console.WriteLine("___________________")
+        Console.WriteLine("Started  {0}", nonIntReadStart.ToString("fff"))
+        Console.WriteLine("Stopped  {0}", nonIntReadStop.ToString("fff"))
+        Console.WriteLine("Delta ( ms ) {0}", (nonIntReadStop - nonIntReadStart).ToString("fff"))
+
+        Console.ReadLine()
+
+    End Sub
+
+
+
+
+
+     'Function getNearestValues(ByVal rpm As Integer, ByVal amps As Integer, ByRef map As AlternatorMapNonInterpolated) As Single
+
+     '   Dim efficiency As Single
+
+     '     If (rpm Mod 100 = 0 AndAlso Math.Floor(amps) = amps) Then
+
+     '        efficiency = (From values In map.map Where values.RPM = rpm And values.Efficiency = amps).First.Amps
+
+     '        Return efficiency / 100
+
+     '     End If
+
+
+     '   Dim positionRpm As Integer = rpm Mod 100
+
+     '   If positionRpm <= 50 Then
+     '       positionRpm = rpm - positionRpm
+     '       Else
+     '       positionRpm = rpm - positionRpm + 100
+     '   End If
+
+     '   Dim positionAmps As Single
+
+     '   If amps - Math.Floor(amps) <= 0.5 Then
+
+     '   positionAmps = Math.Floor(amps)
+
+     '   Else
+     '      positionAmps = Math.Ceiling(amps)
+     '   End If
+
+
+     '    efficiency = (From values In map.map Where values.RPM = positionRpm And values.Efficiency = positionAmps).First.Amps
+
+     '   Return efficiency / 100
+
+     'End Function
+
+
+
+
+End Module
diff --git a/MapTests/My Project/Application.Designer.vb b/MapTests/My Project/Application.Designer.vb
new file mode 100644
index 0000000000..0aecefe664
--- /dev/null
+++ b/MapTests/My Project/Application.Designer.vb	
@@ -0,0 +1,13 @@
+'------------------------------------------------------------------------------
+' <auto-generated>
+'     This code was generated by a tool.
+'     Runtime Version:4.0.30319.18444
+'
+'     Changes to this file may cause incorrect behavior and will be lost if
+'     the code is regenerated.
+' </auto-generated>
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
diff --git a/MapTests/My Project/Application.myapp b/MapTests/My Project/Application.myapp
new file mode 100644
index 0000000000..e62f1a5338
--- /dev/null
+++ b/MapTests/My Project/Application.myapp	
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  <MySubMain>false</MySubMain>
+  <SingleInstance>false</SingleInstance>
+  <ShutdownMode>0</ShutdownMode>
+  <EnableVisualStyles>true</EnableVisualStyles>
+  <AuthenticationMode>0</AuthenticationMode>
+  <ApplicationType>2</ApplicationType>
+  <SaveMySettingsOnExit>true</SaveMySettingsOnExit>
+</MyApplicationData>
diff --git a/MapTests/My Project/AssemblyInfo.vb b/MapTests/My Project/AssemblyInfo.vb
new file mode 100644
index 0000000000..374888ce72
--- /dev/null
+++ b/MapTests/My Project/AssemblyInfo.vb	
@@ -0,0 +1,35 @@
+Imports System
+Imports System.Reflection
+Imports System.Runtime.InteropServices
+
+' General Information about an assembly is controlled through the following 
+' set of attributes. Change these attribute values to modify the information
+' associated with an assembly.
+
+' Review the values of the assembly attributes
+
+<Assembly: AssemblyTitle("MapTests")> 
+<Assembly: AssemblyDescription("")> 
+<Assembly: AssemblyCompany("AEA Group")> 
+<Assembly: AssemblyProduct("MapTests")> 
+<Assembly: AssemblyCopyright("Copyright © AEA Group 2014")> 
+<Assembly: AssemblyTrademark("")> 
+
+<Assembly: ComVisible(False)>
+
+'The following GUID is for the ID of the typelib if this project is exposed to COM
+<Assembly: Guid("4e59cec7-1742-4b12-bc7a-3bb161793f40")> 
+
+' Version information for an assembly consists of the following four values:
+'
+'      Major Version
+'      Minor Version 
+'      Build Number
+'      Revision
+'
+' You can specify all the values or you can default the Build and Revision Numbers 
+' by using the '*' as shown below:
+' <Assembly: AssemblyVersion("1.0.*")> 
+
+<Assembly: AssemblyVersion("1.0.0.0")> 
+<Assembly: AssemblyFileVersion("1.0.0.0")> 
diff --git a/MapTests/My Project/Resources.Designer.vb b/MapTests/My Project/Resources.Designer.vb
new file mode 100644
index 0000000000..9235fbabd9
--- /dev/null
+++ b/MapTests/My Project/Resources.Designer.vb	
@@ -0,0 +1,63 @@
+'------------------------------------------------------------------------------
+' <auto-generated>
+'     This code was generated by a tool.
+'     Runtime Version:4.0.30319.18444
+'
+'     Changes to this file may cause incorrect behavior and will be lost if
+'     the code is regenerated.
+' </auto-generated>
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+Imports System
+
+Namespace My.Resources
+    
+    'This class was auto-generated by the StronglyTypedResourceBuilder
+    'class via a tool like ResGen or Visual Studio.
+    'To add or remove a member, edit your .ResX file then rerun ResGen
+    'with the /str option, or rebuild your VS project.
+    '''<summary>
+    '''  A strongly-typed resource class, for looking up localized strings, etc.
+    '''</summary>
+    <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"),  _
+     Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
+     Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(),  _
+     Global.Microsoft.VisualBasic.HideModuleNameAttribute()>  _
+    Friend Module Resources
+        
+        Private resourceMan As Global.System.Resources.ResourceManager
+        
+        Private resourceCulture As Global.System.Globalization.CultureInfo
+        
+        '''<summary>
+        '''  Returns the cached ResourceManager instance used by this class.
+        '''</summary>
+        <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>  _
+        Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
+            Get
+                If Object.ReferenceEquals(resourceMan, Nothing) Then
+                    Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("MapTests.Resources", GetType(Resources).Assembly)
+                    resourceMan = temp
+                End If
+                Return resourceMan
+            End Get
+        End Property
+        
+        '''<summary>
+        '''  Overrides the current thread's CurrentUICulture property for all
+        '''  resource lookups using this strongly typed resource class.
+        '''</summary>
+        <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>  _
+        Friend Property Culture() As Global.System.Globalization.CultureInfo
+            Get
+                Return resourceCulture
+            End Get
+            Set
+                resourceCulture = value
+            End Set
+        End Property
+    End Module
+End Namespace
diff --git a/MapTests/My Project/Resources.resx b/MapTests/My Project/Resources.resx
new file mode 100644
index 0000000000..af7dbebbac
--- /dev/null
+++ b/MapTests/My Project/Resources.resx	
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
\ No newline at end of file
diff --git a/MapTests/My Project/Settings.Designer.vb b/MapTests/My Project/Settings.Designer.vb
new file mode 100644
index 0000000000..9956019f29
--- /dev/null
+++ b/MapTests/My Project/Settings.Designer.vb	
@@ -0,0 +1,73 @@
+'------------------------------------------------------------------------------
+' <auto-generated>
+'     This code was generated by a tool.
+'     Runtime Version:4.0.30319.18444
+'
+'     Changes to this file may cause incorrect behavior and will be lost if
+'     the code is regenerated.
+' </auto-generated>
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+
+Namespace My
+    
+    <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(),  _
+     Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0"),  _
+     Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)>  _
+    Partial Friend NotInheritable Class MySettings
+        Inherits Global.System.Configuration.ApplicationSettingsBase
+        
+        Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
+        
+#Region "My.Settings Auto-Save Functionality"
+#If _MyType = "WindowsForms" Then
+    Private Shared addedHandler As Boolean
+
+    Private Shared addedHandlerLockObject As New Object
+
+    <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
+    Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
+        If My.Application.SaveMySettingsOnExit Then
+            My.Settings.Save()
+        End If
+    End Sub
+#End If
+#End Region
+        
+        Public Shared ReadOnly Property [Default]() As MySettings
+            Get
+                
+#If _MyType = "WindowsForms" Then
+               If Not addedHandler Then
+                    SyncLock addedHandlerLockObject
+                        If Not addedHandler Then
+                            AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
+                            addedHandler = True
+                        End If
+                    End SyncLock
+                End If
+#End If
+                Return defaultInstance
+            End Get
+        End Property
+    End Class
+End Namespace
+
+Namespace My
+    
+    <Global.Microsoft.VisualBasic.HideModuleNameAttribute(),  _
+     Global.System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
+     Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()>  _
+    Friend Module MySettingsProperty
+        
+        <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")>  _
+        Friend ReadOnly Property Settings() As Global.MapTests.My.MySettings
+            Get
+                Return Global.MapTests.My.MySettings.Default
+            End Get
+        End Property
+    End Module
+End Namespace
diff --git a/MapTests/My Project/Settings.settings b/MapTests/My Project/Settings.settings
new file mode 100644
index 0000000000..85b890b3c6
--- /dev/null
+++ b/MapTests/My Project/Settings.settings	
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>
diff --git a/VECTO/GUI/F_VECTO.vb b/VECTO/GUI/F_VECTO.vb
index f299d9a392..9c44772ab7 100644
--- a/VECTO/GUI/F_VECTO.vb
+++ b/VECTO/GUI/F_VECTO.vb
@@ -860,12 +860,13 @@ lbDlog:
 
         'Preset the DIALOG Details depending on the edit type.
         AuxDlog.ListItems.Clear()
-        Select AuxDlog.TbID.Text
+        Select Case AuxDlog.TbID.Text
 
             '**** ELECTRICS ****
             Case sKey.AUX.ElecSys.ToString()
              For Each item As VectoAuxiliaries.Electrics.ElectricalConsumer In ConsumerListES
-               AuxDlog.ListItems.Add(item.Name, item.Power)
+              ' AuxDlog.ListItems.Add(item.Name, item.Power)
+              'TODO: FIX THIS ABOVE
              Next
 
             AuxDlog.txtPulleyGearEfficiency.Text = PulleyGearEfficiencyES.ToString()
@@ -915,7 +916,8 @@ lbDlog:
             '**** ELECTRICS ****
             Case sKey.AUX.ElecSys.ToString()
              For Each item As KeyValuePair(Of String, Single) In AuxDlog.ListItems
-               ConsumerListES.Add(New VectoAuxiliaries.Electrics.ElectricalConsumer(item.Key, item.Value))
+             'TODO: FIX THIS
+              ' ConsumerListES.Add(New VectoAuxiliaries.Electrics.ElectricalConsumer(item.Key, item.Value))
              Next
 
             PulleyGearEfficiencyES = CType(AuxDlog.txtPulleyGearEfficiency.Text, Single)
diff --git a/VECTOAux/VectoAuxiliariesTests/TestFiles/testAlternatoMap.csv b/VECTOAux/VectoAuxiliariesTests/TestFiles/testAlternatorMap.csv
similarity index 100%
rename from VECTOAux/VectoAuxiliariesTests/TestFiles/testAlternatoMap.csv
rename to VECTOAux/VectoAuxiliariesTests/TestFiles/testAlternatorMap.csv
diff --git a/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj b/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj
index 95ad9c2593..ef12b2cf40 100644
--- a/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj
+++ b/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj
@@ -195,7 +195,7 @@
     <Content Include="TestFiles\TestHvacMap - MissingHeader.csv">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
-    <Content Include="TestFiles\testAlternatoMap.csv">
+    <Content Include="TestFiles\testAlternatorMap.csv">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
   </ItemGroup>
-- 
GitLab