Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 09e5b18b authored by Dana Nurse's avatar Dana Nurse Committed by Kostis ANAGNOSTOPOULOS
Browse files

Another change to Combined Alternators Schematic

Update to Row4 Amps calculation

git-tfs-id: [http://tfs00.element.root.com:8080/tfs/TFSCollection]$/VECTO;C1910
parent 58c3fa57
Branches
Tags
No related merge requests found
......@@ -9,7 +9,7 @@ Public Class Table4Row
Public RPM As Single
Public Efficiency As Single
Public Sub new ( rpm As single, eff As single)
Public Sub New(rpm As Single, eff As Single)
Me.rpm = rpm
Me.Efficiency = eff
......@@ -53,7 +53,7 @@ Public Class Alternator
'Calculate ( Interpolate ) Efficiency
Dim range as List(Of AltUserInput) = RangeTable.Select( Function(s) New AltUserInput(s.RPM,s.Efficiency)).ToList()
Dim range As List(Of AltUserInput) = RangeTable.Select(Function(s) New AltUserInput(s.RPM, s.Efficiency)).ToList()
Dim v As Single = Alternator.Iterpolate(range, Convert.ToSingle(SpindleSpeed))
......@@ -72,21 +72,21 @@ Public Class Alternator
'Constructors
Sub new()
Sub New()
End Sub
Sub new( isignals As ICombinedAlternatorSignals, inputs as List(Of ICombinedAlternatorMapRow))
Sub New(isignals As ICombinedAlternatorSignals, inputs As List(Of ICombinedAlternatorMapRow))
If isignals is Nothing then Throw New ArgumentException("Alternator - ISignals supplied is nothing")
If isignals Is Nothing Then Throw New ArgumentException("Alternator - ISignals supplied is nothing")
signals = isignals
Me.AlternatorName = inputs.First().AlternatorName
Me.PulleyRatio = inputs.First().PulleyRatio
Dim values2k As Dictionary(Of single,single) = inputs.where( function(x) x.RPM=2000).Select( function(x) new KeyValuePair(of single,single)(x.Amps,x.Efficiency)).ToDictionary( Function(x) x.Key, Function(x) x.Value)
Dim values4k As Dictionary(Of single,single) = inputs.where( function(x) x.RPM=4000).Select( function(x) new KeyValuePair(of single,single)(x.Amps,x.Efficiency)).ToDictionary( Function(x) x.Key, Function(x) x.Value)
Dim values6k As Dictionary(Of single,single) = inputs.where( function(x) x.RPM=6000).Select( function(x) new KeyValuePair(of single,single)(x.Amps,x.Efficiency)).ToDictionary( Function(x) x.Key, Function(x) x.Value)
Dim values2k As Dictionary(Of Single, Single) = inputs.where(Function(x) x.RPM = 2000).Select(Function(x) New KeyValuePair(Of Single, Single)(x.Amps, x.Efficiency)).ToDictionary(Function(x) x.Key, Function(x) x.Value)
Dim values4k As Dictionary(Of Single, Single) = inputs.where(Function(x) x.RPM = 4000).Select(Function(x) New KeyValuePair(Of Single, Single)(x.Amps, x.Efficiency)).ToDictionary(Function(x) x.Key, Function(x) x.Value)
Dim values6k As Dictionary(Of Single, Single) = inputs.where(Function(x) x.RPM = 6000).Select(Function(x) New KeyValuePair(Of Single, Single)(x.Amps, x.Efficiency)).ToDictionary(Function(x) x.Key, Function(x) x.Value)
BuildInputTable(values2k, InputTable2000)
......@@ -101,21 +101,21 @@ Public Class Alternator
End Sub
Public shared Function Iterpolate( values As List(Of AltUserInput), x As single) As Single
Public Shared Function Iterpolate(values As List(Of AltUserInput), x As Single) As Single
Dim lowestX As single = values.Min( Function(m) m.Amps)
Dim lowestX As Single = values.Min(Function(m) m.Amps)
Dim highestX As Single = values.Max(Function(m) m.Amps)
Dim preKey, postKey ,preEff,postEff, EffSlope As single
Dim deltaX , deltaEff As single
Dim preKey, postKey, preEff, postEff, EffSlope As Single
Dim deltaX, deltaEff As Single
'Out of range, returns efficiency for lowest
If x< lowestX then Return values.First( Function(f) f.Amps= lowestX).Eff
If x < lowestX Then Return values.First(Function(f) f.Amps = lowestX).Eff
'Out of range, efficiency for highest
If x> highestX then Return values.First( Function(f) f.Amps= highestX).Eff
If x > highestX Then Return values.First(Function(f) f.Amps = highestX).Eff
'On Bounds check
If values.Where( Function(w) w.Amps=x).Count=1 then Return values.First( Function(w) w.Amps=x).Eff
If values.Where(Function(w) w.Amps = x).Count = 1 Then Return values.First(Function(w) w.Amps = x).Eff
'OK, we need to interpolate.
......@@ -150,8 +150,8 @@ Public Class Alternator
'M15=Row5-Rpm - N15=Row5-Eff
'M16=Row6-Rpm - N16=Row6-Eff
Dim N10,N11,N12,N13,N14,N15,N16 As single
Dim M10,M11,M12,M13,M14,M15,M16 As single
Dim N10, N11, N12, N13, N14, N15, N16 As Single
Dim M10, M11, M12, M13, M14, M15, M16 As Single
'EFFICIENCY
......@@ -166,14 +166,14 @@ Public Class Alternator
RangeTable(4).Efficiency = N14
'Row0 & Row1 Efficiency =IF(N13>N12,0,MAX(N12:N14)) - Example Alt 1 N13=
N11=IF(N13>N12,0,Math.Max(Math.MAX(N12,N13),N14))
N11 = If(N13 > N12, 0, Math.Max(Math.MAX(N12, N13), N14))
RangeTable(1).Efficiency = N11
N10 = N11
RangeTable(0).Efficiency = N10
'Row 5 Efficiency
N15 =IF(N13>N14,0,Math.Max(Math.MAX(N12,N13),N14))
N15 = If(N13 > N14, 0, Math.Max(Math.MAX(N12, N13), N14))
RangeTable(5).Efficiency = N15
'Row 6 - Efficiency
N16 = N15
......@@ -200,22 +200,22 @@ Public Class Alternator
RangeTable(1).RPM = M11
'Row 0 - RPM
M10 = IF(M11<1500,M11-1,1500)
M10 = If(M11 < 1500, M11 - 1, 1500)
RangeTable(0).RPM = M10
'Row 5 - RPM
M15 = Convert.ToSingle(IF(M14=IF((N14=0 OrElse N14=N13),M14+1,IF(N13>N14,((((M14-M13)/(N13-N14))*N14)+M14),((((M14-M13)/(N13-N14))*(N14-N15))+M14))),M14+0.01,IF((N14=0 OrElse N14=N13),M14+1,IF(N13>N14,((((M14-M13)/(N13-N14))*N14)+M14),((((M14-M13)/(N13-N14))*(N14-N15))+M14)))))
M15 = Convert.ToSingle(If(M14 = If((N14 = 0 OrElse N14 = N13), M14 + 1, If(N13 > N14, ((((M14 - M13) / (N13 - N14)) * N14) + M14), ((((M14 - M13) / (N13 - N14)) * (N14 - N15)) + M14))), M14 + 0.01, If((N14 = 0 OrElse N14 = N13), M14 + 1, If(N13 > N14, ((((M14 - M13) / (N13 - N14)) * N14) + M14), ((((M14 - M13) / (N13 - N14)) * (N14 - N15)) + M14)))))
RangeTable(5).RPM = M15
'Row 6 - RPM
M16 = IF(M15>10000,M15+1,10000)
M16 = If(M15 > 10000, M15 + 1, 10000)
RangeTable(6).RPM = M16
End Sub
Private sub InitialiseRangeTable()
Private Sub InitialiseRangeTable()
RangeTable(0).RPM = 0 : RangeTable(0).Efficiency = 0
RangeTable(1).RPM = 0 : RangeTable(0).Efficiency = 0
......@@ -244,11 +244,11 @@ Public Class Alternator
End Sub
public Sub BuildInputTable( inputs As Dictionary(of Single, single), targetTable As List (Of AltUserInput ))
Public Sub BuildInputTable(inputs As Dictionary(Of Single, Single), targetTable As List(Of AltUserInput))
Dim C11,C12,C13,C14,D11,D12,D13,D14 As single
Dim tmpAmp As single
Dim C11, C12, C13, C14, D11, D12, D13, D14 As Single
Dim tmpAmp As Single
targetTable.Clear()
......@@ -266,19 +266,23 @@ Public Class Alternator
C11 = targetTable(1).Amps : C12 = targetTable(2).Amps : C13 = targetTable(3).Amps
D11 = targetTable(1).Eff : D12 = targetTable(2).Eff : D13 = targetTable(3).Eff
D14= IF(D12>D13,0, Math.Max(Math.MAX(D11,D12),D13))
D14 = If(D12 > D13, 0, Math.Max(Math.MAX(D11, D12), D13))
'Row4 - Eff
targetTable.Add( new AltUserInput( 0 ,D14 ))
targetTable.Add(New AltUserInput(0, D14))
'Row4 - Amps
tmpAmp =IF((D13=0 OrElse D13=D12),C13+1,IF(D12>D13,((((C13-C12)/(D12-D13))*D13)+C13),((((C13-C12)/(D12-D13))*(D13-D14))+C13)))
' Should probably refactor this into some sort of helper/extension method
Dim numarray As Single() = {D11, D12, D13}
Dim maxD11_D13 As Single = numarray.Max()
tmpAmp = If((D13 = 0 OrElse D13 = D12 OrElse D13 = maxD11_D13), C13 + 1, If(D12 > D13, ((((C13 - C12) / (D12 - D13)) * D13) + C13), ((((C13 - C12) / (D12 - D13)) * (D13 - D14)) + C13)))
targetTable(4).Amps = tmpAmp
'Row5
tmpAmp =IF(C14>200,C14+1,200)
tmpAmp = If(C14 > 200, C14 + 1, 200)
targetTable.Add(New AltUserInput(tmpAmp, D14))
'Row0
......@@ -291,16 +295,16 @@ Public Class Alternator
Public Function IsEqualTo(other As IAlternator) As Boolean Implements IAlternator.IsEqualTo
If Me.AlternatorName <> other.AlternatorName then Return False
If Me.PulleyRatio <> other.PulleyRatio then Return false
If Me.AlternatorName <> other.AlternatorName Then Return False
If Me.PulleyRatio <> other.PulleyRatio Then Return False
Dim i As Integer = 1
For i= 1 to 3
For i = 1 To 3
If Me.InputTable2000(i).Eff <> other.InputTable2000(i).Eff then Return False
If Me.InputTable4000(i).Eff <> other.InputTable4000(i).Eff then Return False
If Me.InputTable6000(i).Eff <> other.InputTable6000(i).Eff then Return False
If Me.InputTable2000(i).Eff <> other.InputTable2000(i).Eff Then Return False
If Me.InputTable4000(i).Eff <> other.InputTable4000(i).Eff Then Return False
If Me.InputTable6000(i).Eff <> other.InputTable6000(i).Eff Then Return False
Next
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment