diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/cDelaunayMap.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/cDelaunayMap.vb deleted file mode 100644 index 7f0a94632c54af9cfc61a6c5c4542f38b3ce8cdb..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/cDelaunayMap.vb +++ /dev/null @@ -1,474 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - -Public Class cDelaunayMap - Public ptDim As Integer - - Public ptList As List(Of dPoint) - Private lDT As List(Of dTriangle) - Private planes As List(Of Double()) - - Public DualMode As Boolean - Private ptListXZ As List(Of dPoint) - Private planesXZ As List(Of Double()) - Private lDTXZ As List(Of dTriangle) - - Public ExtrapolError As Boolean - - - Public Sub New() - ptList = New List(Of dPoint) - ptListXZ = New List(Of dPoint) - DualMode = False - End Sub - - Public Sub AddPoints(ByVal X As Double, ByVal Y As Double, ByVal Z As Double) - ptList.Add(New dPoint(X, Y, Z)) - If DualMode Then ptListXZ.Add(New dPoint(X, Z, Y)) - End Sub - - Public Function Triangulate() As Boolean - Dim tr As dTriangle - Dim DT As dTriangulation - - ptDim = ptList.Count - 1 - - 'XY-triangulation - Try - DT = New dTriangulation - lDT = DT.Triangulate(ptList) - Catch ex As Exception - Return False - End Try - - planes = New List(Of Double()) - - For Each tr In lDT - planes.Add(GetPlane(tr)) - Next - - - '#If DEBUG Then - ' Dim i As Int16 - ' Debug.Print("#,x1,y1,z1,x2,y2,z2") - ' i = -1 - ' For Each tr In lDT - ' i += 1 - ' Debug.Print(i & "," & tr.P1.X & "," & tr.P1.Y & "," & tr.P1.Z & "," & tr.P2.X & "," & tr.P2.Y & "," & tr.P2.Z) - ' Debug.Print(i & "," & tr.P3.X & "," & tr.P3.Y & "," & tr.P3.Z & "," & tr.P2.X & "," & tr.P2.Y & "," & tr.P2.Z) - ' Debug.Print(i & "," & tr.P1.X & "," & tr.P1.Y & "," & tr.P1.Z & "," & tr.P3.X & "," & tr.P3.Y & "," & tr.P3.Z) - ' Next - '#End If - - - 'XZ-triangulation - If DualMode Then - - If ptDim <> ptListXZ.Count - 1 Then Return False - - Try - DT = New dTriangulation - lDTXZ = DT.Triangulate(ptListXZ) - Catch ex As Exception - Return False - End Try - - planesXZ = New List(Of Double()) - - For Each tr In lDTXZ - planesXZ.Add(GetPlane(tr)) - Next - - End If - - Return True - End Function - - 'XY => Z Interpolation - Public Function Intpol(ByVal x As Double, ByVal y As Double) As Double - Dim j As Integer - Dim l0 As Double() - Dim tr As dTriangle - - ExtrapolError = False - - 'Try exact solution for IsInside() - j = -1 - For Each tr In lDT - j += 1 - If IsInside(tr, x, y, True) Then - l0 = planes(j) - Return (l0(3) - x * l0(0) - y * l0(1)) / l0(2) - End If - Next - - 'Try approx. solution (fixes rounding errors when points lies exactly on an edge of a triangle) - j = -1 - For Each tr In lDT - j += 1 - If IsInside(tr, x, y, False) Then - l0 = planes(j) - Return (l0(3) - x * l0(0) - y * l0(1)) / l0(2) - End If - Next - - - 'ERROR: Extrapolation - ExtrapolError = True - - Return Nothing - End Function - - 'XZ => Y Interpolation - Public Function IntpolXZ(ByVal x As Double, ByVal z As Double) As Double - Dim j As Integer - Dim l0 As Double() - Dim tr As dTriangle - - ExtrapolError = False - - If DualMode Then - - j = -1 - - 'Try exact solution for IsInside() - For Each tr In lDTXZ - j += 1 - If IsInside(tr, x, z, True) Then - l0 = planesXZ(j) - Return (l0(3) - x * l0(0) - z * l0(1)) / l0(2) - End If - Next - - 'Try approx. solution (fixes rounding errors when points lies exactly on an edge of a triangle) - j = -1 - For Each tr In lDTXZ - j += 1 - If IsInside(tr, x, z, False) Then - l0 = planesXZ(j) - Return (l0(3) - x * l0(0) - z * l0(1)) / l0(2) - End If - Next - - 'ERROR: Extrapolation - ExtrapolError = True - Return Nothing - - Else - - 'ERROR: Extrapolation - ExtrapolError = True - Return Nothing - - End If - End Function - - Private Function GetPlane(ByRef tr As dTriangle) As Double() - Dim AB As dPoint - Dim AC As dPoint - Dim cross As dPoint - Dim l(3) As Double - Dim pt1 As dPoint - Dim pt2 As dPoint - Dim pt3 As dPoint - - pt1 = tr.P1 - pt2 = tr.P2 - pt3 = tr.P3 - - AB = New dPoint(pt2.X - pt1.X, pt2.Y - pt1.Y, pt2.Z - pt1.Z) - AC = New dPoint(pt3.X - pt1.X, pt3.Y - pt1.Y, pt3.Z - pt1.Z) - - cross = New dPoint(AB.Y * AC.Z - AB.Z * AC.Y, AB.Z * AC.X - AB.X * AC.Z, AB.X * AC.Y - AB.Y * AC.X) - - l(0) = cross.X - l(1) = cross.Y - l(2) = cross.Z - - l(3) = pt1.X * cross.X + pt1.Y * cross.Y + pt1.Z * cross.Z - - Return l - End Function - - Private Function IsInside(ByRef tr As dTriangle, ByVal xges As Double, ByVal yges As Double, ByVal Exact As Boolean) _ - As Boolean - Dim v0(1) As Double - Dim v1(1) As Double - Dim v2(1) As Double - Dim dot00 As Double - Dim dot01 As Double - Dim dot02 As Double - Dim dot11 As Double - Dim dot12 As Double - Dim invDenom As Double - Dim u As Double - Dim v As Double - Dim pt1 As dPoint - Dim pt2 As dPoint - Dim pt3 As dPoint - - pt1 = tr.P1 - pt2 = tr.P2 - pt3 = tr.P3 - - 'Quelle: http://www.blackpawn.com/texts/pointinpoly/default.html (Barycentric Technique) - - ' Compute vectors - v0(0) = pt3.X - pt1.X - v0(1) = pt3.Y - pt1.Y - - v1(0) = pt2.X - pt1.X - v1(1) = pt2.Y - pt1.Y - - v2(0) = xges - pt1.X - v2(1) = yges - pt1.Y - - ' Compute dot products - dot00 = v0(0) * v0(0) + v0(1) * v0(1) - dot01 = v0(0) * v1(0) + v0(1) * v1(1) - dot02 = v0(0) * v2(0) + v0(1) * v2(1) - dot11 = v1(0) * v1(0) + v1(1) * v1(1) - dot12 = v1(0) * v2(0) + v1(1) * v2(1) - - ' Compute barycentric coordinates - invDenom = 1 / (dot00 * dot11 - dot01 * dot01) - u = (dot11 * dot02 - dot01 * dot12) * invDenom - v = (dot00 * dot12 - dot01 * dot02) * invDenom - - 'Debug.Print(u & ", " & v & ", " & u + v) - - ' Check if point is in triangle - If Exact Then - Return (u >= 0) And (v >= 0) And (u + v <= 1) - Else - Return (u >= -0.001) And (v >= -0.001) And (u + v <= 1.001) - End If - End Function - - Public Class dPoint - Public X As Double - Public Y As Double - Public Z As Double - - Public Sub New(ByVal xd As Double, ByVal yd As Double, ByVal zd As Double) - X = xd - Y = yd - Z = zd - End Sub - - Public Shared Operator =(left As dPoint, right As dPoint) As Boolean - - 'If DirectCast(left, Object) = DirectCast(right, Object) Then - ' Return True - 'End If - - 'If (DirectCast(left, Object) Is Nothing) OrElse (DirectCast(right, Object) Is Nothing) Then - ' Return False - 'End If - - ' Just compare x and y here... - If left.X <> right.X Then - Return False - End If - - If left.Y <> right.Y Then - Return False - End If - - Return True - End Operator - - Public Shared Operator <>(left As dPoint, right As dPoint) As Boolean - Return Not (left = right) - End Operator - End Class - - Public Class dTriangle - Public P1 As dPoint - Public P2 As dPoint - Public P3 As dPoint - - Public Sub New(ByRef pp1 As dPoint, ByRef pp2 As dPoint, ByRef pp3 As dPoint) - P1 = pp1 - P2 = pp2 - P3 = pp3 - End Sub - - Public Function ContainsInCircumcircle(pt As dPoint) As Double - Dim ax As Double = Me.P1.X - pt.X - Dim ay As Double = Me.P1.Y - pt.Y - Dim bx As Double = Me.P2.X - pt.X - Dim by As Double = Me.P2.Y - pt.Y - Dim cx As Double = Me.P3.X - pt.X - Dim cy As Double = Me.P3.Y - pt.Y - Dim det_ab As Double = ax * by - bx * ay - Dim det_bc As Double = bx * cy - cx * by - Dim det_ca As Double = cx * ay - ax * cy - Dim a_squared As Double = ax * ax + ay * ay - Dim b_squared As Double = bx * bx + by * by - Dim c_squared As Double = cx * cx + cy * cy - - Return a_squared * det_bc + b_squared * det_ca + c_squared * det_ab - End Function - - Public Function SharesVertexWith(triangle As dTriangle) As Boolean - If Me.P1.X = triangle.P1.X AndAlso Me.P1.Y = triangle.P1.Y Then - Return True - End If - If Me.P1.X = triangle.P2.X AndAlso Me.P1.Y = triangle.P2.Y Then - Return True - End If - If Me.P1.X = triangle.P3.X AndAlso Me.P1.Y = triangle.P3.Y Then - Return True - End If - - If Me.P2.X = triangle.P1.X AndAlso Me.P2.Y = triangle.P1.Y Then - Return True - End If - If Me.P2.X = triangle.P2.X AndAlso Me.P2.Y = triangle.P2.Y Then - Return True - End If - If Me.P2.X = triangle.P3.X AndAlso Me.P2.Y = triangle.P3.Y Then - Return True - End If - - If Me.P3.X = triangle.P1.X AndAlso Me.P3.Y = triangle.P1.Y Then - Return True - End If - If Me.P3.X = triangle.P2.X AndAlso Me.P3.Y = triangle.P2.Y Then - Return True - End If - If Me.P3.X = triangle.P3.X AndAlso Me.P3.Y = triangle.P3.Y Then - Return True - End If - - Return False - End Function - End Class - - Public Class dEdge - Public StartPoint As dPoint - Public EndPoint As dPoint - - Public Sub New(ByRef p1 As dPoint, ByRef p2 As dPoint) - StartPoint = p1 - EndPoint = p2 - End Sub - - Public Shared Operator =(left As dEdge, right As dEdge) As Boolean - 'If DirectCast(left, Object) = DirectCast(right, Object) Then - ' Return True - 'End If - - 'If (DirectCast(left, Object) Is Nothing) Or (DirectCast(right, Object) Is Nothing) Then - ' Return False - 'End If - - Return _ - ((left.StartPoint = right.StartPoint AndAlso left.EndPoint = right.EndPoint) OrElse - (left.StartPoint = right.EndPoint AndAlso left.EndPoint = right.StartPoint)) - End Operator - - Public Shared Operator <>(left As dEdge, right As dEdge) As Boolean - Return Not (left = right) - End Operator - End Class - - Public Class dTriangulation - Public Function Triangulate(triangulationPoints As List(Of dPoint)) As List(Of dTriangle) - If triangulationPoints.Count < 3 Then - Throw New ArgumentException("Can not triangulate less than three vertices!") - End If - - ' The triangle list - Dim triangles As New List(Of dTriangle)() - - - ' The "supertriangle" which encompasses all triangulation points. - ' This triangle initializes the algorithm and will be removed later. - Dim superTriangle As dTriangle = Me.SuperTriangle(triangulationPoints) - triangles.Add(superTriangle) - - ' Include each point one at a time into the existing triangulation - For i As Integer = 0 To triangulationPoints.Count - 1 - ' Initialize the edge buffer. - Dim EdgeBuffer As New List(Of dEdge)() - - ' If the actual vertex lies inside the circumcircle, then the three edges of the - ' triangle are added to the edge buffer and the triangle is removed from list. - For j As Integer = triangles.Count - 1 To 0 Step -1 - Dim t As dTriangle = triangles(j) - If t.ContainsInCircumcircle(triangulationPoints(i)) > 0 Then - EdgeBuffer.Add(New dEdge(t.P1, t.P2)) - EdgeBuffer.Add(New dEdge(t.P2, t.P3)) - EdgeBuffer.Add(New dEdge(t.P3, t.P1)) - triangles.RemoveAt(j) - End If - Next - - ' Remove duplicate edges. This leaves the convex hull of the edges. - ' The edges in this convex hull are oriented counterclockwise! - For j As Integer = EdgeBuffer.Count - 2 To 0 Step -1 - For k As Integer = EdgeBuffer.Count - 1 To j + 1 Step -1 - If EdgeBuffer(j) = EdgeBuffer(k) Then - EdgeBuffer.RemoveAt(k) - EdgeBuffer.RemoveAt(j) - k -= 1 - Continue For - End If - Next - Next - - ' Generate new counterclockwise oriented triangles filling the "hole" in - ' the existing triangulation. These triangles all share the actual vertex. - For j As Integer = 0 To EdgeBuffer.Count - 1 - triangles.Add(New dTriangle(EdgeBuffer(j).StartPoint, EdgeBuffer(j).EndPoint, triangulationPoints(i))) - Next - Next - - ' We don't want the supertriangle in the triangulation, so - ' remove all triangles sharing a vertex with the supertriangle. - For i As Integer = triangles.Count - 1 To 0 Step -1 - If triangles(i).SharesVertexWith(superTriangle) Then - triangles.RemoveAt(i) - End If - Next - - ' Return the triangles - Return triangles - End Function - - - Private Function SuperTriangle(triangulationPoints As List(Of dPoint)) As dTriangle - Dim M As Double = triangulationPoints(0).X - - ' get the extremal x and y coordinates - For i As Integer = 1 To triangulationPoints.Count - 1 - Dim xAbs As Double = Math.Abs(triangulationPoints(i).X) - Dim yAbs As Double = Math.Abs(triangulationPoints(i).Y) - If xAbs > M Then - M = xAbs - End If - If yAbs > M Then - M = yAbs - End If - Next - - ' make a triangle - Dim sp1 As New dPoint(10 * M, 0, 0) - Dim sp2 As New dPoint(0, 10 * M, 0) - Dim sp3 As New dPoint(-10 * M, -10 * M, 0) - - Return New dTriangle(sp1, sp2, sp3) - End Function - End Class -End Class - diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/cFile V3.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/cFile V3.vb deleted file mode 100644 index 9c75cac2ce191764ed4369c14864a4e594a687f5..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/cFile V3.vb +++ /dev/null @@ -1,150 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. -Public Class cFile_V3 - Private TxtFldParser As Microsoft.VisualBasic.FileIO.TextFieldParser - Private StrWrter As System.IO.StreamWriter - Private Mode As FileMode - Private Path As String - Private Sepp As String - Private SkipCom As Boolean - Private StopE As Boolean - Private FileOpen As Boolean - Private PreLine As String() - Private FileEnd As Boolean - - 'File format - private FileFormat As System.Text.Encoding = System.Text.Encoding.UTF8 - - Public Sub New() - Me.Reset() - End Sub - - Private Sub Reset() - FileOpen = False - Mode = FileMode.Undefined - PreLine = Nothing - FileEnd = False - End Sub - - Public Function OpenRead(ByVal FileName As String, Optional ByVal Separator As String = ",", - Optional ByVal SkipComment As Boolean = True, Optional ByVal StopAtE As Boolean = False) As Boolean - Me.Reset() - StopE = StopAtE - Path = FileName - Sepp = Separator - SkipCom = SkipComment - If Not (Mode = FileMode.Undefined) Then Return False - If Not IO.File.Exists(Path) Then Return False - Mode = FileMode.Read - Try - TxtFldParser = New Microsoft.VisualBasic.FileIO.TextFieldParser(Path, System.Text.Encoding.Default) - FileOpen = True - Catch ex As Exception - Return False - End Try - TxtFldParser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited - TxtFldParser.Delimiters = New String() {Sepp} - - 'If TxtFldParser.EndOfData Then Return False - - Me.ReadLine() - Return True - End Function - - Public Function ReadLine() As String() - Dim line As String() - Dim line0 As String - - line = PreLine - - lb10: - If TxtFldParser.EndOfData Then - - FileEnd = True - - Else - - PreLine = TxtFldParser.ReadFields - line0 = UCase(Trim(PreLine(0))) - - If SkipCom Then - If Left(line0, 1) = "#" Then GoTo lb10 - End If - - If StopE Then FileEnd = (line0 = "E") - - End If - - Return line - End Function - - Public Sub Close() - Select Case Mode - Case FileMode.Read - If FileOpen Then TxtFldParser.Close() - TxtFldParser = Nothing - Case FileMode.Write - If FileOpen Then StrWrter.Close() - StrWrter = Nothing - End Select - Me.Reset() - End Sub - - Public ReadOnly Property EndOfFile() As Boolean - Get - Return FileEnd - End Get - End Property - - Public Function OpenWrite(ByVal FileName As String, Optional ByVal Separator As String = ",", - Optional ByVal AutoFlush As Boolean = False, Optional ByVal Append As Boolean = False) As Boolean - Me.Reset() - Path = FileName - Sepp = Separator - If Not (Mode = FileMode.Undefined) Then Return False - Mode = FileMode.Write - Try - StrWrter = My.Computer.FileSystem.OpenTextFileWriter(Path, Append, FileFormat) - FileOpen = True - Catch ex As Exception - Return False - End Try - StrWrter.AutoFlush = AutoFlush - Return True - End Function - - Public Sub WriteLine(ByVal ParamArray x() As Object) - Dim St As String - Dim StB As New System.Text.StringBuilder - Dim Skip As Boolean - Skip = True - For Each St In x - If Skip Then - StB.Append(St) - Skip = False - Else - StB.Append(Sepp & St) - End If - Next - StrWrter.WriteLine(StB.ToString) - StB = Nothing - End Sub - - Public Sub WriteLine(ByVal x As String) - StrWrter.WriteLine(x) - End Sub - - Private Enum FileMode - Undefined - Read - Write - End Enum -End Class diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/cMAP.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/cMAP.vb deleted file mode 100644 index fc315c0880a28d9a3d6a0cc07f4bb813b18ce4dd..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/cMAP.vb +++ /dev/null @@ -1,192 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. -Imports System.Globalization -Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.BusAuxiliaries.Interfaces - -Public Class cMAP - Implements IFuelConsumptionMap - - Private LnU As List(Of Single) - Private LTq As List(Of Single) - Private lFC As List(Of Single) - - Private sFilePath As String - Private iMapDim As Integer - - Private FuelMap As cDelaunayMap - - Private Sub ResetMe() - lFC = Nothing - LTq = Nothing - LnU = Nothing - iMapDim = -1 - FuelMap = New cDelaunayMap - End Sub - - Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean - Dim file As cFile_V3 - Dim line As String() - Dim nU As Single - Dim MsgSrc As String - - - MsgSrc = "Main/ReadInp/MAP" - - 'Reset - ResetMe() - - 'Stop if there's no file - If sFilePath = "" OrElse Not IO.File.Exists(sFilePath) Then - Return False - End If - - 'Open file - file = New cFile_V3 - If Not file.OpenRead(sFilePath) Then - file = Nothing - Return False - End If - - 'Skip Header - file.ReadLine() - - 'Initi Lists (before version check so ReadOldFormat works) - lFC = New System.Collections.Generic.List(Of Single) - LTq = New System.Collections.Generic.List(Of Single) - LnU = New System.Collections.Generic.List(Of Single) - - Try - Do While Not file.EndOfFile - - 'Line read - line = file.ReadLine - - 'Line counter up (was reset in ResetMe) - iMapDim += 1 - - 'Revolutions - nU = Single.Parse(line(0), CultureInfo.InvariantCulture) - - LnU.Add(nU) - - 'Power - LTq.Add(Single.Parse(line(1), CultureInfo.InvariantCulture)) - - 'FC - 'Check sign - If CSng(line(2)) < 0 Then - file.Close() - - Return False - End If - - lFC.Add(CSng(line(2))) - - - Loop - Catch ex As Exception - - - GoTo lbEr - - End Try - - 'Close file - file.Close() - - file = Nothing - - Return True - - - 'ERROR-label for clean Abort -lbEr: - file.Close() - file = Nothing - - Return False - End Function - - Public Function Triangulate() As Boolean - Dim i As Integer - - Dim MsgSrc As String - - MsgSrc = "MAP/Norm" - - 'FC Delauney - For i = 0 To iMapDim - FuelMap.AddPoints(LnU(i), LTq(i), lFC(i)) - Next - - Return FuelMap.Triangulate() - End Function - - - Public Function fFCdelaunay_Intp(ByVal nU As Single, ByVal Tq As Single) As Single - Dim val As Single - - val = CType(FuelMap.Intpol(nU, Tq), Single) - - If FuelMap.ExtrapolError Then - - Return -10000 - Else - Return val - End If - End Function - -#Region "Properties" - - Public Property FilePath() As String - Get - Return sFilePath - End Get - Set(ByVal value As String) - sFilePath = value - End Set - End Property - - Public ReadOnly Property MapDim As Integer - Get - Return iMapDim - End Get - End Property - - Public ReadOnly Property Tq As List(Of Single) - Get - Return LTq - End Get - End Property - - Public ReadOnly Property FC As List(Of Single) - Get - Return lFC - End Get - End Property - - Public ReadOnly Property nU As List(Of Single) - Get - Return LnU - End Get - End Property - -#End Region - - Public Function GetFuelConsumption(torque As NewtonMeter, angularVelocity As PerSecond) As KilogramPerSecond _ - Implements IFuelConsumptionMap.GetFuelConsumption - Return _ - (fFCdelaunay_Intp(CType(angularVelocity.AsRPM, Single), CType(torque.Value(), Single)) / 3600.0 / 1000.0).SI(Of KilogramPerSecond)() - End Function -End Class - - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb deleted file mode 100644 index 2c96a5af4588d4f4e20b4229f1039536ade585e8..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb +++ /dev/null @@ -1,318 +0,0 @@ -Option Strict On - -Imports DownstreamModules.Electrics - -Namespace Electrics - - - - 'Model based on CombinedALTS_V02_Editable.xlsx - Public Class Alternator - Implements IAlternator - - Private signals As ICombinedAlternatorSignals - - 'D6 - Public Property AlternatorName As String Implements IAlternator.AlternatorName - 'G6 - Public Property PulleyRatio As Double Implements IAlternator.PulleyRatio - 'C10-D15 - Public Property InputTable2000 As New List(Of AltUserInput) Implements IAlternator.InputTable2000 - 'F10-G15 - Public Property InputTable4000 As New List(Of AltUserInput) Implements IAlternator.InputTable4000 - 'I10-J15 - Public Property InputTable6000 As New List(Of AltUserInput) Implements IAlternator.InputTable6000 - 'M10-N15 - Public Property RangeTable As New List(Of Table4Row) Implements IAlternator.RangeTable - 'S9 - Public ReadOnly Property SpindleSpeed As Double Implements IAlternator.SpindleSpeed - Get - Return signals.CrankRPM * PulleyRatio - End Get - End Property - 'S10 - Public ReadOnly Property Efficiency As Double Implements IAlternator.Efficiency - - Get - 'First build RangeTable, table 4 - InitialiseRangeTable() - CalculateRangeTable() - - 'Calculate ( Interpolate ) Efficiency - Dim range As List(Of AltUserInput) = RangeTable.Select(Function(s) New AltUserInput(s.RPM, s.Efficiency)).ToList() - - Return Alternator.Iterpolate(range, Convert.ToSingle(SpindleSpeed)) - End Get - End Property - - - 'Constructors - Sub New() - End Sub - - 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 = inputs.First().AlternatorName - Me.PulleyRatio = inputs.First().PulleyRatio - - Dim values2k As Dictionary(Of Double, Double) = - inputs.Where(Function(x) x.RPM = 2000).Select(Function(x) New KeyValuePair(Of Double, Double)(x.Amps, x.Efficiency)) _ - .ToDictionary(Function(x) x.Key, Function(x) x.Value) - Dim values4k As Dictionary(Of Double, Double) = - inputs.Where(Function(x) x.RPM = 4000).Select(Function(x) New KeyValuePair(Of Double, Double)(x.Amps, x.Efficiency)) _ - .ToDictionary(Function(x) x.Key, Function(x) x.Value) - Dim values6k As Dictionary(Of Double, Double) = - inputs.Where(Function(x) x.RPM = 6000).Select(Function(x) New KeyValuePair(Of Double, Double)(x.Amps, x.Efficiency)) _ - .ToDictionary(Function(x) x.Key, Function(x) x.Value) - - - BuildInputTable(values2k, InputTable2000) - BuildInputTable(values4k, InputTable4000) - BuildInputTable(values6k, InputTable6000) - - - CreateRangeTable() - End Sub - - Public Shared Function Iterpolate(values As List(Of AltUserInput), x As Double) As Double - - Dim lowestX As Double = values.Min(Function(m) m.Amps) - Dim highestX As Double = values.Max(Function(m) m.Amps) - Dim preKey, postKey, preEff, postEff, EffSlope As Double - Dim deltaX, deltaEff As Double - - 'Out of range, returns efficiency for lowest - 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 - - 'On Bounds check - 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. - preKey = values.Last(Function(l) l.Amps < x).Amps - postKey = values.First(Function(l) l.Amps > x).Amps - preEff = values.First(Function(f) f.Amps = preKey).Eff - postEff = values.First(Function(f) f.Amps = postKey).Eff - - - deltaX = postKey - preKey - deltaEff = postEff - preEff - - 'slopes - EffSlope = deltaEff / deltaX - - - Dim retVal As Double = ((x - preKey) * EffSlope) + preEff - - Return retVal - End Function - - Private Sub CalculateRangeTable() - - 'M10=Row0-Rpm - N10=Row0-Eff - 'M11=Row1-Rpm - N11=Row1-Eff - 'M12=Row2-Rpm - N12=Row2-Eff - 2000 - 'M13=Row3-Rpm - N13=Row3-Eff - 4000 - 'M14=Row4-Rpm - N14=Row4-Eff - 6000 - 'M15=Row5-Rpm - N15=Row5-Eff - 'M16=Row6-Rpm - N16=Row6-Eff - - Dim N10, N11, N12, N13, N14, N15, N16 As Double - Dim M10, M11, M12, M13, M14, M15, M16 As Double - - 'EFFICIENCY - - '2000 - N12 = Alternator.Iterpolate(InputTable2000, signals.CurrentDemandAmps.Value()) - RangeTable(2).Efficiency = N12 - '4000 - N13 = Alternator.Iterpolate(InputTable4000, signals.CurrentDemandAmps.Value()) - RangeTable(3).Efficiency = N13 - '6000 - N14 = Alternator.Iterpolate(InputTable6000, signals.CurrentDemandAmps.Value()) - 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)) - 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)) - RangeTable(5).Efficiency = N15 - 'Row 6 - Efficiency - N16 = N15 - RangeTable(6).Efficiency = N16 - - 'RPM - - '2000 Row 2 - RPM - M12 = 2000 - RangeTable(2).RPM = M12 - - '4000 Row 3 - RPM - M13 = 4000 - RangeTable(3).RPM = M13 - - '6000 Row 4 - RPM - M14 = 6000 - RangeTable(4).RPM = M14 - - 'Row 1 - RPM - 'NOTE: Update to reflect CombineALternatorSchematicV02 20150429 - 'IF(M12=IF(N12>N13,M12-((M12-M13)/(N12-N13))*(N12-N11),M12-((M12-M13)/(N12-N13))*(N12-N11)), M12-0.01, IF(N12>N13,M12-((M12-M13)/(N12-N13))*(N12-N11),M12-((M12-M13)/(N12-N13))*(N12-N11))) - M11 = - Convert.ToSingle( - If _ - (N12 - N13 = 0, 0, - If _ - (M12 = If(N12 > N13, M12 - ((M12 - M13) / (N12 - N13)) * (N12 - N11), M12 - ((M12 - M13) / (N12 - N13)) * (N12 - N11)), - M12 - 0.01, - If(N12 > N13, M12 - ((M12 - M13) / (N12 - N13)) * (N12 - N11), M12 - ((M12 - M13) / (N12 - N13)) * (N12 - N11))))) - RangeTable(1).RPM = M11 - - 'Row 0 - RPM - 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))))) - RangeTable(5).RPM = M15 - - - 'Row 6 - RPM - M16 = If(M15 > 10000, M15 + 1, 10000) - RangeTable(6).RPM = M16 - End Sub - - Private Sub InitialiseRangeTable() - - RangeTable(0).RPM = 0 - RangeTable(0).Efficiency = 0 - RangeTable(1).RPM = 0 - RangeTable(0).Efficiency = 0 - RangeTable(2).RPM = 2000 - RangeTable(0).Efficiency = 0 - RangeTable(3).RPM = 4000 - RangeTable(0).Efficiency = 0 - RangeTable(4).RPM = 6000 - RangeTable(0).Efficiency = 0 - RangeTable(5).RPM = 0 - RangeTable(0).Efficiency = 0 - RangeTable(6).RPM = 0 - RangeTable(0).Efficiency = 0 - End Sub - - Private Sub CreateRangeTable() - - - RangeTable.Clear() - - RangeTable.Add(New Table4Row(0, 0)) - RangeTable.Add(New Table4Row(0, 0)) - RangeTable.Add(New Table4Row(0, 0)) - RangeTable.Add(New Table4Row(0, 0)) - RangeTable.Add(New Table4Row(0, 0)) - RangeTable.Add(New Table4Row(0, 0)) - RangeTable.Add(New Table4Row(0, 0)) - End Sub - - Public Sub BuildInputTable(inputs As Dictionary(Of Double, Double), targetTable As List(Of AltUserInput)) - - - Dim C11, C12, C13, C14, C15, D11, D12, D13, D14, D15 As Double - targetTable.Clear() - - 'Row0 - targetTable.Add(New AltUserInput(0, D14)) - - 'Row1 - targetTable.Add(New AltUserInput(inputs.OrderBy(Function(x) x.Key).First.Key, - inputs.OrderBy(Function(x) x.Key).First.Value)) - - 'Row2 - targetTable.Add(New AltUserInput(inputs.OrderBy(Function(x) x.Key).Skip(1).First.Key, - inputs.OrderBy(Function(x) x.Key).Skip(1).First.Value)) - - 'Row3 - targetTable.Add(New AltUserInput(inputs.OrderBy(Function(x) x.Key).Skip(2).First.Key, - inputs.OrderBy(Function(x) x.Key).Skip(2).First.Value)) - - 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)) - - - 'Row4 - Eff - targetTable.Add(New AltUserInput(0, D14)) - - - 'Row4 - Amps - ' Should probably refactor this into some sort of helper/extension method - Dim numarray As Double() = {D11, D12, D13} - Dim maxD11_D13 As Double = numarray.Max() - - '=IF(OR(D13=0,D13=D12),C13+1,IF(D12>D13,((((C13-C12)/(D12-D13))*D13)+C13),((((C13-C12)/(D12-D13))*(D13-D14))+C13))) - C14 = - 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 = C14 - - 'Row5 - C15 = If(C14 > 200, C14 + 1, 200) - D15 = D14 - targetTable.Add(New AltUserInput(C15, D15)) - - 'Row0 - targetTable(0).Eff = D11 - End Sub - - 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 - - Dim i As Integer = 1 - - 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 - - - Next - - Return True - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMap.vb b/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMap.vb deleted file mode 100644 index 71a09675fad9b223f65f0d85da15dbe990f0161e..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMap.vb +++ /dev/null @@ -1,342 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. -Imports System.Globalization -Imports System.IO -Imports System.Text -Imports DownstreamModules.Electrics -Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.BusAuxiliaries.Interfaces -Imports TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics - -Namespace Electrics - Public Class AlternatorMap - Implements IAlternatorMap - - Private ReadOnly filePath As String - - Private _map As New List(Of MapPoint) - Private _yRange As List(Of Double) - Private _xRange As List(Of Double) - Private _minX, _minY, _maxX, _maxY As Double - - 'Required Action Test or Interpolation Type - Public Function OnBoundaryYInterpolatedX(x As Double, y As Double) As Boolean - Return _yRange.Contains(y) AndAlso Not _xRange.Contains(x) - End Function - - Public Function OnBoundaryXInterpolatedY(x As Double, y As Double) As Boolean - Return Not _yRange.Contains(y) AndAlso _xRange.Contains(x) - End Function - - Public Function ONBoundaryXY(x As Double, y As Double) As Boolean - Return (From sector In _map Where sector.Y = y AndAlso sector.x = x).Count = 1 - End Function - - 'Determine Value Methods - Private Function GetOnBoundaryXY(x As Double, y As Double) As Double - Return (From sector In _map Where sector.Y = y AndAlso sector.x = x).First().v - End Function - - Private Function GetOnBoundaryYInterpolatedX(x As Double, y As Double) As Double - - Dim x0, x1, v0, v1, slope, dx As Double - - x0 = (From p In _xRange Order By p Where p < x).Last() - x1 = (From p In _xRange Order By p Where p > x).First() - dx = x1 - x0 - - v0 = GetOnBoundaryXY(x0, y) - v1 = GetOnBoundaryXY(x1, y) - - slope = (v1 - v0) / (x1 - x0) - - Return v0 + ((x - x0) * slope) - End Function - - Private Function GetOnBoundaryXInterpolatedY(x As Double, y As Double) As Double - - Dim y0, y1, v0, v1, dy, v, slope As Double - - y0 = (From p In _yRange Order By p Where p < y).Last() - y1 = (From p In _yRange Order By p Where p > y).First() - dy = y1 - y0 - - v0 = GetOnBoundaryXY(x, y0) - v1 = GetOnBoundaryXY(x, y1) - - slope = (v1 - v0) / (y1 - y0) - - v = v0 + ((y - y0) * slope) - - Return v - End Function - - Private Function GetBiLinearInterpolatedValue(x As Double, y As Double) As Double - - Dim q11, q12, q21, q22, x1, x2, y1, y2, r1, r2, p As Double - - y1 = (From mapSector As MapPoint In _map Where mapSector.Y < y).Last().Y - y2 = (From mapSector As MapPoint In _map Where mapSector.Y > y).First().Y - - x1 = (From mapSector As MapPoint In _map Where mapSector.x < x).Last().x - x2 = (From mapSector As MapPoint In _map Where mapSector.x > x).First().x - - q11 = GetOnBoundaryXY(x1, y1) - q12 = GetOnBoundaryXY(x1, y2) - - q21 = GetOnBoundaryXY(x2, y1) - q22 = GetOnBoundaryXY(x2, y2) - - r1 = ((x2 - x) / (x2 - x1)) * q11 + ((x - x1) / (x2 - x1)) * q21 - - r2 = ((x2 - x) / (x2 - x1)) * q12 + ((x - x1) / (x2 - x1)) * q22 - - - p = ((y2 - y) / (y2 - y1)) * r1 + ((y - y1) / (y2 - y1)) * r2 - - - Return p - End Function - - 'Utilities - Private Sub fillMapWithDefaults() - - - _map.Add(New MapPoint(10, 1500, 0.615)) - _map.Add(New MapPoint(27, 1500, 0.7)) - _map.Add(New MapPoint(53, 1500, 0.1947)) - _map.Add(New MapPoint(63, 1500, 0.0)) - _map.Add(New MapPoint(68, 1500, 0.0)) - _map.Add(New MapPoint(125, 1500, 0.0)) - _map.Add(New MapPoint(136, 1500, 0.0)) - _map.Add(New MapPoint(10, 2000, 0.62)) - _map.Add(New MapPoint(27, 2000, 0.7)) - _map.Add(New MapPoint(53, 2000, 0.3)) - _map.Add(New MapPoint(63, 2000, 0.1462)) - _map.Add(New MapPoint(68, 2000, 0.692)) - _map.Add(New MapPoint(125, 2000, 0.0)) - _map.Add(New MapPoint(136, 2000, 0.0)) - _map.Add(New MapPoint(10, 4000, 0.64)) - _map.Add(New MapPoint(27, 4000, 0.6721)) - _map.Add(New MapPoint(53, 4000, 0.7211)) - _map.Add(New MapPoint(63, 4000, 0.74)) - _map.Add(New MapPoint(68, 4000, 0.7352)) - _map.Add(New MapPoint(125, 4000, 0.68)) - _map.Add(New MapPoint(136, 4000, 0.6694)) - _map.Add(New MapPoint(10, 6000, 0.53)) - _map.Add(New MapPoint(27, 6000, 0.5798)) - _map.Add(New MapPoint(53, 6000, 0.656)) - _map.Add(New MapPoint(63, 6000, 0.6853)) - _map.Add(New MapPoint(68, 6000, 0.7)) - _map.Add(New MapPoint(125, 6000, 0.6329)) - _map.Add(New MapPoint(136, 6000, 0.62)) - _map.Add(New MapPoint(10, 7000, 0.475)) - _map.Add(New MapPoint(27, 7000, 0.5337)) - _map.Add(New MapPoint(53, 7000, 0.6235)) - _map.Add(New MapPoint(63, 7000, 0.658)) - _map.Add(New MapPoint(68, 7000, 0.6824)) - _map.Add(New MapPoint(125, 7000, 0.6094)) - _map.Add(New MapPoint(136, 7000, 0.5953)) - End Sub - - Private Sub getMapRanges() - - _yRange = (From coords As MapPoint In _map Order By coords.Y Select coords.Y Distinct).ToList() - _xRange = (From coords As MapPoint In _map Order By coords.x Select coords.x Distinct).ToList() - - _minX = _xRange.First - _maxX = _xRange.Last - _minY = _yRange.First - _maxY = _yRange.Last - End Sub - - 'Single entry point to determine Value on map - Public Function GetValue(x As Double, y As Double) As Double - - - If x < _minX OrElse x > _maxX OrElse y < _minY OrElse y > _maxY Then - - 'OnAuxiliaryEvent(String.Format("Alternator Map Limiting : RPM{0}, AMPS{1}",x,y),AdvancedAuxiliaryMessageType.Warning) - - - 'Limiting - If x < _minX Then x = _minX - If x > _maxX Then x = _maxX - If y < _minY Then y = _minY - If y > _maxY Then y = _maxY - - End If - - - 'Satisfies both data points - non interpolated value - If ONBoundaryXY(x, y) Then Return GetOnBoundaryXY(x, y) - - 'Satisfies only x or y - single interpolation value - If OnBoundaryXInterpolatedY(x, y) Then Return GetOnBoundaryXInterpolatedY(x, y) - If OnBoundaryYInterpolatedX(x, y) Then Return GetOnBoundaryYInterpolatedX(x, y) - - 'satisfies no data points - Bi-Linear interpolation - Return GetBiLinearInterpolatedValue(x, y) - End Function - - Public Function ReturnDefaultMapValueTests() As String - - Dim sb As StringBuilder = New StringBuilder() - Dim x, y As Single - - 'All Sector Values - sb.AppendLine("All Values From Map") - sb.AppendLine("-------------------") - For Each x In _xRange - - For Each y In _yRange - sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", x, y, GetValue(x, y))) - Next - - Next - - sb.AppendLine("") - sb.AppendLine("Four Corners with interpolated other") - sb.AppendLine("-------------------") - x = 1500 - y = 18.5 - sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", x, y, GetValue(x, y))) - x = 7000 - y = 96.5 - sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", x, y, GetValue(x, y))) - x = 1750 - y = 10 - sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", x, y, GetValue(x, y))) - x = 6500 - y = 10 - sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", x, y, GetValue(x, y))) - - sb.AppendLine("") - sb.AppendLine("Interpolated both") - sb.AppendLine("-------------------") - - Dim mx, my As Double - Dim x2, y2 As Integer - For x2 = 0 To _xRange.Count - 2 - - For y2 = 0 To _yRange.Count - 2 - - mx = _xRange(x2) + (_xRange(x2 + 1) - _xRange(x2)) / 2 - my = _yRange(y2) + (_yRange(y2 + 1) - _yRange(y2)) / 2 - - sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", mx, my, GetValue(mx, my))) - - - Next - - Next - - sb.AppendLine("") - sb.AppendLine("MIKE -> 40 & 1000") - sb.AppendLine("-------------------") - x = 1000 - y = 40 - sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", x, y, GetValue(x, y))) - - - Return sb.ToString() - End Function - - 'Constructors - Public Sub New(filepath As String) - - Me.filePath = filepath - - Initialise() - - getMapRanges() - End Sub - - Private Class MapPoint - Public Y As Double - Public x As Double - Public v As Double - - Public Sub New(y As Double, x As Double, v As Double) - - Me.Y = y - Me.x = x - Me.v = v - End Sub - End Class - - 'Get Alternator Efficiency - Public Function GetEfficiency(rpm As Double, amps As Ampere) As AlternatorMapValues _ - Implements IAlternatorMap.GetEfficiency - - Return New AlternatorMapValues(GetValue(rpm, amps.Value())) - End Function - - 'Initialises the map. - Public Function Initialise() As Boolean Implements IAlternatorMap.Initialise - 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 MapPoint) - Dim firstline As Boolean = True - - For Each line As String In lines - If Not firstline Then - - 'Advanced Alternator Source Check. - If line.Contains("[MODELSOURCE") Then Exit For - - 'split the line - Dim elements() As String = line.Split(New Char() {","c}, 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 newPoint As MapPoint = New MapPoint(Single.Parse(elements(0), CultureInfo.InvariantCulture), - Single.Parse(elements(1), CultureInfo.InvariantCulture), - Single.Parse(elements(2), CultureInfo.InvariantCulture)) - _map.Add(newPoint) - - 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 - - - 'Public Events - Public Event AuxiliaryEvent(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) _ - Implements IAuxiliaryEvent.AuxiliaryEvent - - Protected Sub OnAuxiliaryEvent(message As String, messageType As AdvancedAuxiliaryMessageType) - - RaiseEvent AuxiliaryEvent(Me, message, messageType) - End Sub - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb deleted file mode 100644 index 3e9126db2f00a01271de6015a9569ae650f615ad..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb +++ /dev/null @@ -1,435 +0,0 @@ -Option Strict On -Imports System.Text -Imports System.IO -Imports System.Globalization -Imports DownstreamModules.Electrics -Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.BusAuxiliaries.Interfaces -Imports TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics - - -Namespace Electrics - Public Class CombinedAlternator - Implements IAlternatorMap, ICombinedAlternator - - Private map As New List(Of ICombinedAlternatorMapRow) - Public Property Alternators As New List(Of IAlternator) Implements ICombinedAlternator.Alternators - Private OriginalAlternators As New List(Of IAlternator) - Private FilePath As String - Private altSignals As ICombinedAlternatorSignals - Private Signals As ISignals - Private AverageAlternatorsEfficiency As AlternatorMapValues - - 'Interface Implementation - Public Function GetEfficiency(ByVal CrankRPM As Double, ByVal Amps As Ampere) As AlternatorMapValues _ - Implements IAlternatorMap.GetEfficiency - - altSignals.CrankRPM = CrankRPM - altSignals.CurrentDemandAmps = (Amps.Value() / Alternators.Count).SI(Of Ampere)() - - Dim alternatorMapValues As AlternatorMapValues = Nothing - - If Signals Is Nothing OrElse Signals.RunningCalc Then - 'If running calc cycle get efficiency from interpolation function - alternatorMapValues = New AlternatorMapValues(Convert.ToSingle(Alternators.Average(Function(a) a.Efficiency) / 100)) - Else - 'If running Pre calc cycle get an average of inputs - alternatorMapValues = AverageAlternatorsEfficiency - End If - - If alternatorMapValues.Efficiency <= 0 Then - alternatorMapValues = New AlternatorMapValues(0.01) - End If - - Return alternatorMapValues - End Function - - Public Function Initialise() As Boolean Implements IAlternatorMap.Initialise - - 'From the map we construct this CombinedAlternator object and original CombinedAlternator Object - - Alternators.Clear() - OriginalAlternators.Clear() - - - For Each alt As IEnumerable(Of ICombinedAlternatorMapRow) In map.GroupBy(Function(g) g.AlternatorName) - - Dim altName As String = alt.First().AlternatorName - Dim pulleyRatio As Double = alt.First().PulleyRatio - - - Dim alternator As IAlternator = New Alternator(altSignals, alt.ToList()) - - Alternators.Add(alternator) - - - Next - - Return True - End Function - - 'Constructors - Public Sub New(filePath As String, Optional signals As ISignals = Nothing) - - Dim feedback As String = String.Empty - Me.Signals = signals - - If Not FilePathUtils.ValidateFilePath(filePath, ".aalt", feedback) Then - Throw New ArgumentException(String.Format("Combined Alternator requires a valid .AALT filename. : {0}", feedback)) - Else - Me.FilePath = filePath - End If - - - Me.altSignals = New CombinedAlternatorSignals() - - - 'IF file exists then read it otherwise create a default. - - If File.Exists(filePath) AndAlso InitialiseMap(filePath) Then - Initialise() - Else - 'Create Default Map - CreateDefaultMap() - Initialise() - End If - - ' Calculate alternators average which is used only in the pre-run - Dim efficiencySum As Double - Dim efficiencyAverage As Double - - For Each alt As IAlternator In Alternators - efficiencySum += alt.InputTable2000.ElementAt(1).Eff - efficiencySum += alt.InputTable2000.ElementAt(2).Eff - efficiencySum += alt.InputTable2000.ElementAt(3).Eff - - efficiencySum += alt.InputTable4000.ElementAt(1).Eff - efficiencySum += alt.InputTable4000.ElementAt(2).Eff - efficiencySum += alt.InputTable4000.ElementAt(3).Eff - - efficiencySum += alt.InputTable6000.ElementAt(1).Eff - efficiencySum += alt.InputTable6000.ElementAt(2).Eff - efficiencySum += alt.InputTable6000.ElementAt(3).Eff - Next - - efficiencyAverage = efficiencySum / (Alternators.Count * 9) - AverageAlternatorsEfficiency = New AlternatorMapValues(efficiencyAverage / 100) - End Sub - - 'Helpers - Private Sub CreateDefaultMap() - - map.Clear() - - map.Add(New CombinedAlternatorMapRow("Alt1", 2000, 10, 62, 3.6)) - map.Add(New CombinedAlternatorMapRow("Alt1", 2000, 27, 70, 3.6)) - map.Add(New CombinedAlternatorMapRow("Alt1", 2000, 53, 30, 3.6)) - - map.Add(New CombinedAlternatorMapRow("Alt1", 4000, 10, 64, 3.6)) - map.Add(New CombinedAlternatorMapRow("Alt1", 4000, 63, 74, 3.6)) - map.Add(New CombinedAlternatorMapRow("Alt1", 4000, 125, 68, 3.6)) - - map.Add(New CombinedAlternatorMapRow("Alt1", 6000, 10, 53, 3.6)) - map.Add(New CombinedAlternatorMapRow("Alt1", 6000, 68, 70, 3.6)) - map.Add(New CombinedAlternatorMapRow("Alt1", 6000, 136, 62, 3.6)) - - map.Add(New CombinedAlternatorMapRow("Alt2", 2000, 10, 62, 3)) - map.Add(New CombinedAlternatorMapRow("Alt2", 2000, 27, 70, 3)) - map.Add(New CombinedAlternatorMapRow("Alt2", 2000, 53, 30, 3)) - - map.Add(New CombinedAlternatorMapRow("Alt2", 4000, 10, 64, 3)) - map.Add(New CombinedAlternatorMapRow("Alt2", 4000, 63, 74, 3)) - map.Add(New CombinedAlternatorMapRow("Alt2", 4000, 125, 68, 3)) - - map.Add(New CombinedAlternatorMapRow("Alt2", 6000, 10, 53, 3)) - map.Add(New CombinedAlternatorMapRow("Alt2", 6000, 68, 70, 3)) - map.Add(New CombinedAlternatorMapRow("Alt2", 6000, 136, 62, 3)) - End Sub - - 'Grid Management - Private Function AddNewAlternator(list As List(Of ICombinedAlternatorMapRow), ByRef feeback As String) As Boolean - - Dim returnValue As Boolean = True - - Dim altName As String = list.First().AlternatorName - Dim pulleyRatio As Double = list.First().PulleyRatio - - 'Check alt does not already exist in list - If Alternators.Where(Function(w) w.AlternatorName = altName).Count > 0 Then - feeback = "This alternator already exists in in the list, operation not completed." - Return False - End If - - Dim alternator As IAlternator = New Alternator(altSignals, list.ToList()) - - Alternators.Add(alternator) - - - Return returnValue - End Function - - Public Function AddAlternator(rows As List(Of ICombinedAlternatorMapRow), ByRef feedback As String) As Boolean - - If Not AddNewAlternator(rows, feedback) Then - feedback = String.Format("Unable to add new alternator : {0}", feedback) - Return False - End If - - Return True - End Function - - Public Function DeleteAlternator(alternatorName As String, ByRef feedback As String, CountValidation As Boolean) _ - As Boolean - - 'Is this the last alternator, if so deny the user the right to remove it. - If CountValidation AndAlso Alternators.Count < 2 Then - feedback = "There must be at least one alternator remaining, operation aborted." - Return False - End If - - If Alternators.Where(Function(w) w.AlternatorName = alternatorName).Count = 0 Then - feedback = "This alternator does not exist" - Return False - End If - - Dim altToRemove As IAlternator = Alternators.First(Function(w) w.AlternatorName = alternatorName) - Dim numAlternators As Integer = Alternators.Count - - Alternators.Remove(altToRemove) - - If Alternators.Count = numAlternators - 1 Then - Return True - Else - feedback = String.Format("The alternator {0} could not be removed : {1}", alternatorName, feedback) - Return False - End If - End Function - 'Public Function UpdateAlternator( gridIndex As Integer, rows As List(Of ICombinedAlternatorMapRow), ByRef feedback As String) As Boolean - - ' Dim altName As String = rows.First.AlternatorName - ' Dim altToUpd As IAlternator = Alternators.First(Function(w) w.AlternatorName = altName) - - ' If Not DeleteAlternator(altName, feedback) Then - ' feedback = feedback - ' Return False - - ' End If - - ' 'Re.create alternator. - - ' Dim replacementAlt As New Alternator(altSignals, rows) - ' Alternators.Add(replacementAlt) - - ' Return True - - - 'End Function - - 'Persistance Functions - Public Function Save(aaltPath As String) As Boolean - - - Dim returnValue As Boolean = True - Dim sb As New StringBuilder() - Dim row As Integer = 0 - Dim amps As Double - Dim eff As Double - - 'write headers - sb.AppendLine("[AlternatorName],[RPM],[Amps],[Efficiency],[PulleyRatio]") - - 'write details - For Each alt As IAlternator In Alternators.OrderBy(Function(o) o.AlternatorName) - - - '2000 - IE Alt1,2000,10,50,3 - For row = 1 To 3 - amps = alt.InputTable2000(row).Amps - eff = alt.InputTable2000(row).Eff - sb.Append( - alt.AlternatorName + ",2000," + amps.ToString("0.000") + "," + eff.ToString("0.000") + "," + - alt.PulleyRatio.ToString("0.000")) - sb.AppendLine("") - Next - - '4000 - IE Alt1,2000,10,50,3 - For row = 1 To 3 - amps = alt.InputTable4000(row).Amps - eff = alt.InputTable4000(row).Eff - sb.Append( - alt.AlternatorName + ",4000," + amps.ToString("0.000") + "," + eff.ToString("0.000") + "," + - alt.PulleyRatio.ToString("0.000")) - sb.AppendLine("") - Next - - '6000 - IE Alt1,2000,10,50,3 - For row = 1 To 3 - amps = alt.InputTable6000(row).Amps - eff = alt.InputTable6000(row).Eff - sb.Append( - alt.AlternatorName + ",6000," + amps.ToString("0.000") + "," + eff.ToString("0.000") + "," + - alt.PulleyRatio.ToString("0.000")) - sb.AppendLine("") - Next - - - Next - - 'Add Model Source - sb.AppendLine("[MODELSOURCE]") - sb.Append(Me.ToString()) - - ' Write the stream cotnents to a new file named "AllTxtFiles.txt" - Using outfile As New StreamWriter(aaltPath) - outfile.Write(sb.ToString()) - End Using - - Return returnValue - End Function - - Private Function Load() As Boolean - - If Not InitialiseMap(FilePath) Then Return False - - - Return True - End Function - - 'Initialises the map, only valid when loadingUI for first time in edit mode or always in operational mode. - Private Function InitialiseMap(filePath As String) As Boolean - - Dim returnValue As Boolean = False - Dim elements As String() - - 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() < 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 - - 'Advanced Alternator Source Check. - If line.Contains("[MODELSOURCE") Then Exit For - - 'split the line - elements = line.Split(New Char() {","c}, 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 - - map.Add(New CombinedAlternatorMapRow(elements(0), Single.Parse(elements(1), CultureInfo.InvariantCulture), - Single.Parse(elements(2), CultureInfo.InvariantCulture), - Single.Parse(elements(3), CultureInfo.InvariantCulture), - Single.Parse(elements(4), CultureInfo.InvariantCulture))) - - 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 - - 'Can be used to send messages to Vecto. - Public Event AuxiliaryEvent(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) _ - Implements IAuxiliaryEvent.AuxiliaryEvent - - 'This is used to generate a diagnostics output which enables the user to - 'Determine if they beleive the resulting map is what is expected - 'Basically it is a check against the model/Spreadsheet - Public Overrides Function ToString() As String - - Dim sb As New StringBuilder() - Dim a1, a2, a3, e1, e2, e3 As String - - - For Each alt As Alternator In Alternators.OrderBy(Function(o) o.AlternatorName) - sb.AppendLine("") - sb.AppendFormat("** {0} ** , PulleyRatio {1}", alt.AlternatorName, alt.PulleyRatio) - sb.AppendLine("") - sb.AppendLine("******************************************************************") - sb.AppendLine("") - - Dim i As Integer = 1 - sb.AppendLine("Table 1 (2000)" + vbTab + "Table 2 (4000)" + vbTab + "Table 3 (6000)") - sb.AppendLine("Amps" + vbTab + "Eff" + vbTab + "Amps" + vbTab + "Eff" + vbTab + "Amps" + vbTab + "Eff" + vbTab) - sb.AppendLine("") - For i = 1 To 3 - - a1 = alt.InputTable2000(i).Amps.ToString("0") - e1 = alt.InputTable2000(i).Eff.ToString("0.000") - a2 = alt.InputTable4000(i).Amps.ToString("0") - e2 = alt.InputTable4000(i).Eff.ToString("0.000") - a3 = alt.InputTable6000(i).Amps.ToString("0") - e3 = alt.InputTable6000(i).Eff.ToString("0.000") - sb.AppendLine(a1 + vbTab + e1 + vbTab + a2 + vbTab + e2 + vbTab + a3 + vbTab + e3 + vbTab) - - Next - - - Next - - 'sb.AppendLine("") - 'sb.AppendLine("********* COMBINED EFFICIENCY VALUES **************") - 'sb.AppendLine("") - 'sb.AppendLine(vbTab + "RPM VALUES") - 'sb.AppendLine("AMPS" + vbTab + "500" + vbTab + "1500" + vbTab + "2500" + vbTab + "3500" + vbTab + "4500" + vbTab + "5500" + vbTab + "6500" + vbTab + "7500") - 'For a As Single = 1 To Alternators.Count * 50 - - ' sb.Append(a.ToString("0") + vbTab) - ' For Each r As Single In {500, 1500, 2500, 3500, 4500, 5500, 6500, 7500} - - ' Dim eff As Single = GetEfficiency(r, a).Efficiency - - ' sb.Append(eff.ToString("0.000") + vbTab) - - ' Next - ' sb.AppendLine("") - - 'Next - - - Return sb.ToString() - End Function - - - 'Equality - Public Function IsEqualTo(other As ICombinedAlternator) As Boolean Implements ICombinedAlternator.IsEqualTo - - 'Count Check. - If Me.Alternators.Count <> other.Alternators.Count Then Return False - - For Each alt As IAlternator In Me.Alternators - - 'Can we find the same alternatorName in other - If other.Alternators.Where(Function(f) f.AlternatorName = alt.AlternatorName).Count() <> 1 Then Return False - - 'get the alternator to compare and compare it. - If Not alt.IsEqualTo(other.Alternators.First(Function(f) f.AlternatorName = alt.AlternatorName)) Then Return False - - Next - - Return True - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorMapRow.vb b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorMapRow.vb deleted file mode 100644 index 1829dce3c5d39a28e85f8e077c92a359c6185572..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorMapRow.vb +++ /dev/null @@ -1,38 +0,0 @@ -Imports DownstreamModules.Electrics - -Namespace Electrics - 'This class is reflective of the stored entries for the combined alternator - 'And is used by the Combined Alternator Form and any related classes. - - Public Class CombinedAlternatorMapRow - Implements ICombinedAlternatorMapRow - - Public Property AlternatorName As String Implements ICombinedAlternatorMapRow.AlternatorName - Public Property RPM As Double Implements ICombinedAlternatorMapRow.RPM - Public Property Amps As Double Implements ICombinedAlternatorMapRow.Amps - Public Property Efficiency As Double Implements ICombinedAlternatorMapRow.Efficiency - Public Property PulleyRatio As Double Implements ICombinedAlternatorMapRow.PulleyRatio - - 'Constructors - 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("Alternator Efficiency must be between 0 and 100") - If PulleyRatio <= 0 Then Throw New ArgumentException("Alternator 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/CombinedAlternatorSignals.vb b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorSignals.vb deleted file mode 100644 index 71d64aa05ad7af43181ae5dde83e3a7f4fda8fc6..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorSignals.vb +++ /dev/null @@ -1,19 +0,0 @@ - -Imports DownstreamModules.Electrics -Imports TUGraz.VectoCommon.Utils - -Namespace Electrics - 'Used by the CombinedAlternator class and any other related classes. - Public Class CombinedAlternatorSignals - Implements ICombinedAlternatorSignals - - Public Property CrankRPM As Double Implements ICombinedAlternatorSignals.CrankRPM - - Public Property CurrentDemandAmps As Ampere Implements ICombinedAlternatorSignals.CurrentDemandAmps - - 'Number of alternators in the Combined Alternator - Public Property NumberOfAlternators As Integer Implements ICombinedAlternatorSignals.NumberOfAlternators - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumer.vb b/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumer.vb deleted file mode 100644 index 4b86f8c77b24bec1aafadec8658ba98980df9922..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumer.vb +++ /dev/null @@ -1,191 +0,0 @@ -Imports System.ComponentModel -Imports DownstreamModules.Electrics -Imports TUGraz.VectoCommon.Utils - -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - -Namespace Electrics - ''' <summary> - ''' Described a consumer of Alternator electrical power - ''' </summary> - ''' <remarks></remarks> - Public Class ElectricalConsumer - Implements IElectricalConsumer - - 'Fields - Private _BaseVehicle As Boolean - Private _Category As String - Private _ConsumerName As String - Private _NominalConsumptionAmps As Double - Private _NumberInActualVehicle As Integer - Private _PhaseIdle_TractionOn As Double - Private _PowerNetVoltage As Double - Private _Info As String - - 'Calculated - Private Property AvgConsumptionAmps As Double Implements IElectricalConsumer.AvgConsumptionAmps - - 'Properties - Public Property BaseVehicle As Boolean Implements IElectricalConsumer.BaseVehicle - Get - Return _BaseVehicle - End Get - Set(value As Boolean) - _BaseVehicle = value - NotifyPropertyChanged("BaseVehicle") - End Set - End Property - - Public Property Category As String Implements IElectricalConsumer.Category - Get - Return _Category - End Get - Set(value As String) - _Category = value - NotifyPropertyChanged("Category") - End Set - End Property - - Public Property ConsumerName As String Implements IElectricalConsumer.ConsumerName - Get - Return _ConsumerName - End Get - Set(value As String) - _ConsumerName = value - NotifyPropertyChanged("ConsumerName") - End Set - End Property - - Public Property NominalConsumptionAmps As Double Implements IElectricalConsumer.NominalConsumptionAmps - Get - Return _NominalConsumptionAmps - End Get - Set(value As Double) - _NominalConsumptionAmps = value - NotifyPropertyChanged("NominalConsumptionAmps") - End Set - End Property - - Public Property NumberInActualVehicle As Integer Implements IElectricalConsumer.NumberInActualVehicle - Get - Return _NumberInActualVehicle - End Get - Set(value As Integer) - _NumberInActualVehicle = value - NotifyPropertyChanged("NumberInActualVehicle") - End Set - End Property - - Public Property PhaseIdle_TractionOn As Double Implements IElectricalConsumer.PhaseIdle_TractionOn - Get - Return _PhaseIdle_TractionOn - End Get - Set(value As Double) - _PhaseIdle_TractionOn = value - NotifyPropertyChanged("PhaseIdle_TractionOn") - End Set - End Property - - Public Property PowerNetVoltage As Double Implements IElectricalConsumer.PowerNetVoltage - Get - Return _PowerNetVoltage - End Get - Set(value As Double) - _PowerNetVoltage = value - NotifyPropertyChanged("PowerNetVoltage") - End Set - End Property - - Public Property Info As String Implements IElectricalConsumer.Info - Get - Return _Info - End Get - Set(value As String) - _Info = value - NotifyPropertyChanged("Info") - End Set - End Property - - - 'Public class outputs - Public Function TotalAvgConumptionAmps(Optional PhaseIdle_TractionOnBasedOnCycle As Double = Nothing) As Ampere _ - Implements IElectricalConsumer.TotalAvgConumptionAmps - - If ConsumerName = "Doors per Door" Then - Return NominalConsumptionAmps.SI(Of Ampere)() * (NumberInActualVehicle * PhaseIdle_TractionOnBasedOnCycle) - Else - Return NominalConsumptionAmps.SI(Of Ampere)() * (NumberInActualVehicle * PhaseIdle_TractionOn) - End If - End Function - - Public Function TotalAvgConsumptionInWatts(Optional PhaseIdle_TractionOnBasedOnCycle As Double = 0.0) As Watt _ - Implements IElectricalConsumer.TotalAvgConsumptionInWatts - Return TotalAvgConumptionAmps(PhaseIdle_TractionOnBasedOnCycle) * PowerNetVoltage.SI(Of Volt)() - End Function - - 'Constructor - Public Sub New(BaseVehicle As Boolean, Category As String, ConsumerName As String, NominalConsumptionAmps As Double, - PhaseIdle_TractionOn As Double, PowerNetVoltage As Double, numberInVehicle As Integer, info As String) - - 'Illegal Value Check. - If Category.Trim.Length = 0 Then Throw New ArgumentException("Category Name cannot be empty") - If ConsumerName.Trim.Length = 0 Then Throw New ArgumentException("ConsumerName Name cannot be empty") - If _ - PhaseIdle_TractionOn < ElectricConstants.PhaseIdleTractionOnMin Or - PhaseIdle_TractionOn > ElectricConstants.PhaseIdleTractionMax Then _ - Throw New ArgumentException("PhaseIdle_TractionOn must have a value between 0 and 1") - If _ - NominalConsumptionAmps < ElectricConstants.NonminalConsumerConsumptionAmpsMin Or - NominalConsumptionAmps > ElectricConstants.NominalConsumptionAmpsMax Then _ - Throw New ArgumentException("NominalConsumptionAmps must have a value between 0 and 100") - If PowerNetVoltage < ElectricConstants.PowenetVoltageMin Or PowerNetVoltage > ElectricConstants.PowenetVoltageMax _ - Then Throw New ArgumentException("PowerNetVoltage must have a value between 6 and 48") - If numberInVehicle < 0 Then Throw New ArgumentException("Cannot have less than 0 consumers in the vehicle") - - 'Good, now assign. - Me.BaseVehicle = BaseVehicle - Me.Category = Category - Me.ConsumerName = ConsumerName - Me.NominalConsumptionAmps = NominalConsumptionAmps - Me.PhaseIdle_TractionOn = PhaseIdle_TractionOn - Me.PowerNetVoltage = PowerNetVoltage - Me.NumberInActualVehicle = numberInVehicle - Me.Info = info - End Sub - - 'Comparison Overrides - Public Overrides Function Equals(obj As Object) As Boolean - - If obj Is Nothing OrElse Not Me.GetType() Is obj.GetType() Then - Return False - End If - - Dim other As IElectricalConsumer = CType(obj, IElectricalConsumer) - - - Return Me.ConsumerName = other.ConsumerName - End Function - - <System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage> - Public Overrides Function GetHashCode() As Integer - Return 0 - End Function - - - Public Event PropertyChanged As PropertyChangedEventHandler _ - Implements INotifyPropertyChanged.PropertyChanged - - Private Sub NotifyPropertyChanged(p As String) - RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(p)) - End Sub - End Class -End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumerList.vb b/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumerList.vb deleted file mode 100644 index ffa571378f040612cf9d88672e245c7e01f3670d..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumerList.vb +++ /dev/null @@ -1,230 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - - -Imports DownstreamModules.Electrics -Imports TUGraz.VectoCommon.Utils - -Namespace Electrics - Public Class ElectricalConsumerList - Implements IElectricalConsumerList - - Private _items As New List(Of IElectricalConsumer) - Private _powernetVoltage As Double - Private _doorDutyCycleZeroToOne As Double - - - 'Constructor - Public Sub New(powernetVoltage As Double, doorDutyCycle_ZeroToOne As Double, - Optional createDefaultList As Boolean = False) - - _powernetVoltage = powernetVoltage - - If createDefaultList Then - - _items = GetDefaultConsumerList() - - End If - - - _doorDutyCycleZeroToOne = doorDutyCycle_ZeroToOne - End Sub - - 'Transfers the Info comments from a default set of consumables to a live set. - 'This way makes the comments not dependent on saved data. - Public Sub MergeInfoData() Implements IElectricalConsumerList.MergeInfoData - - If _items.Count <> GetDefaultConsumerList().Count Then Return - - Dim dflt As List(Of IElectricalConsumer) = GetDefaultConsumerList() - - For idx As Integer = 0 To _items.Count - 1 - - _items(idx).Info = dflt(idx).Info - - Next - End Sub - - 'Initialise default set of consumers - Public Function GetDefaultConsumerList() As List(Of IElectricalConsumer) - - 'This populates the default settings as per engineering spreadsheet. - 'Vehicle Basic Equipment' category can be added or remove by customers. - 'At some time in the future, this may be removed and replace with file based consumer lists. - - Dim items As New List(Of IElectricalConsumer) - - Dim c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20 As IElectricalConsumer - - c1 = CType(New ElectricalConsumer(False, "Doors", "Doors per Door", 3.0, 0.096339, - _powernetVoltage, 3, ""), - IElectricalConsumer) - c2 = CType(New ElectricalConsumer(True, "Veh Electronics &Engine", "Controllers,Valves etc", - 25.0, 1.0, - _powernetVoltage, 1, ""), - IElectricalConsumer) - c3 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Radio City", 2.0, 0.8, - _powernetVoltage, 1, ""), - IElectricalConsumer) - c4 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Radio Intercity", 5.0, - 0.8, _powernetVoltage, - 0, ""), - IElectricalConsumer) - c5 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Radio/Audio Tourism", - 9.0, 0.8, - _powernetVoltage, 0, ""), - IElectricalConsumer) - c6 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Fridge", 4.0, 0.5, - _powernetVoltage, 0, ""), - IElectricalConsumer) - c7 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Kitchen Standard", - 67.0, 0.05, _powernetVoltage, - 0, ""), - IElectricalConsumer) - c8 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", - "Interior lights City/ Intercity + Doorlights [Should be 1/m]", 1.0, 0.7, - _powernetVoltage, 12, - "1 Per metre length of bus"), - IElectricalConsumer) - c9 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", - "LED Interior lights ceiling city/Intercity + door [Should be 1/m]", 0.6, 0.7, - _powernetVoltage, 0, - "1 Per metre length of bus"), - IElectricalConsumer) - c10 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Interior lights Tourism + reading [1/m]", - 1.1, - 0.7, _powernetVoltage, 0, "1 Per metre length of bus"), - IElectricalConsumer) - c11 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", - "LED Interior lights ceiling Tourism + LED reading [Should be 1/m]", 0.66, 0.7, - _powernetVoltage, 0, - "1 Per metre length of bus"), - IElectricalConsumer) - c12 = CType(New ElectricalConsumer(False, "Customer Specific Equipment", "External Displays Font/Side/Rear", - 2.65017667844523, 1.0, _powernetVoltage, 4, ""), - IElectricalConsumer) - c13 = CType(New ElectricalConsumer(False, "Customer Specific Equipment", - "Internal display per unit ( front side rear)", 1.06007067137809, 1.0, - _powernetVoltage, 1, ""), - IElectricalConsumer) - c14 = CType(New ElectricalConsumer(False, "Customer Specific Equipment", - "CityBus Ref EBSF Table4 Devices ITS No Displays", 9.3, 1.0, _powernetVoltage, 1, - ""), - IElectricalConsumer) - c15 = CType(New ElectricalConsumer(False, "Lights", "Exterior Lights BULB", 7.4, 1.0, - _powernetVoltage, 1, ""), - IElectricalConsumer) - c16 = CType(New ElectricalConsumer(False, "Lights", "Day running lights LED bonus", - -0.723, 1.0, _powernetVoltage, - 1, ""), - IElectricalConsumer) - c17 = CType(New ElectricalConsumer(False, "Lights", "Antifog rear lights LED bonus", - -0.17, 1.0, _powernetVoltage, - 1, ""), - IElectricalConsumer) - c18 = CType(New ElectricalConsumer(False, "Lights", "Position lights LED bonus", -1.2, - 1.0, _powernetVoltage, 1, - ""), - IElectricalConsumer) - c19 = CType(New ElectricalConsumer(False, "Lights", "Direction lights LED bonus", -0.3, - 1.0, _powernetVoltage, 1, - ""), - IElectricalConsumer) - c20 = CType(New ElectricalConsumer(False, "Lights", "Brake Lights LED bonus", -1.2, 1.0, - _powernetVoltage, 1, ""), - IElectricalConsumer) - - items.Add(c1) - items.Add(c2) - items.Add(c3) - items.Add(c4) - items.Add(c5) - items.Add(c6) - items.Add(c7) - items.Add(c8) - items.Add(c9) - items.Add(c10) - items.Add(c11) - items.Add(c12) - items.Add(c13) - items.Add(c14) - items.Add(c15) - items.Add(c16) - items.Add(c17) - items.Add(c18) - items.Add(c19) - items.Add(c20) - - Return items - End Function - - - 'Interface implementation - Public Property DoorDutyCycleFraction As Double Implements IElectricalConsumerList.DoorDutyCycleFraction - - Get - Return _doorDutyCycleZeroToOne - End Get - Set(value As Double) - _doorDutyCycleZeroToOne = value - End Set - End Property - - Public ReadOnly Property Items As List(Of IElectricalConsumer) Implements IElectricalConsumerList.Items - Get - Return _items - End Get - End Property - - Public Sub AddConsumer(consumer As IElectricalConsumer) Implements IElectricalConsumerList.AddConsumer - - If Not _items.Contains(consumer) Then - _items.Add(consumer) - Else - - Throw New ArgumentException("Consumer Already Present in the list") - - End If - End Sub - - Public Sub RemoveConsumer(consumer As IElectricalConsumer) Implements IElectricalConsumerList.RemoveConsumer - - If _items.Contains(consumer) Then - - _items.Remove(consumer) - - Else - - Throw New ArgumentException("Consumer Not In List") - - End If - End Sub - - - Public Function GetTotalAverageDemandAmps(excludeOnBase As Boolean) As Ampere _ - Implements IElectricalConsumerList.GetTotalAverageDemandAmps - - Dim Amps As Ampere - - If excludeOnBase Then - Amps = - Aggregate item In Items Where item.BaseVehicle = False Into Sum(item.TotalAvgConumptionAmps(DoorDutyCycleFraction)) - Else - Amps = Aggregate item In Items Into Sum(item.TotalAvgConumptionAmps(DoorDutyCycleFraction)) - End If - - - Return Amps - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ElectricsUserInputsConfig.vb b/VECTOAux/VectoAuxiliaries/Electrics/ElectricsUserInputsConfig.vb deleted file mode 100644 index c45a3f5c494ac2abde778a1972fa19d35efc043c..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Electrics/ElectricsUserInputsConfig.vb +++ /dev/null @@ -1,56 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - -Imports DownstreamModules.Electrics -Imports TUGraz.VectoCore.BusAuxiliaries.Interfaces -Imports TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics - -Namespace Electrics - Public Class ElectricsUserInputsConfig - Implements IElectricsUserInputsConfig - - Public Property PowerNetVoltage As Double Implements IElectricsUserInputsConfig.PowerNetVoltage - Public Property AlternatorMap As String Implements IElectricsUserInputsConfig.AlternatorMap - Public Property AlternatorGearEfficiency As Double Implements IElectricsUserInputsConfig.AlternatorGearEfficiency - - Public Property ElectricalConsumers As IElectricalConsumerList _ - Implements IElectricsUserInputsConfig.ElectricalConsumers - - Public Property DoorActuationTimeSecond As Integer Implements IElectricsUserInputsConfig.DoorActuationTimeSecond - Public Property StoredEnergyEfficiency As Double Implements IElectricsUserInputsConfig.StoredEnergyEfficiency - - Public Property ResultCardIdle As IResultCard Implements IElectricsUserInputsConfig.ResultCardIdle - Public Property ResultCardTraction As IResultCard Implements IElectricsUserInputsConfig.ResultCardTraction - Public Property ResultCardOverrun As IResultCard Implements IElectricsUserInputsConfig.ResultCardOverrun - - Public Property SmartElectrical As Boolean Implements IElectricsUserInputsConfig.SmartElectrical - - Public Sub New(Optional setToDefaults As Boolean = False, Optional vectoInputs As VectoInputs = Nothing) - - If setToDefaults Then SetPropertiesToDefaults(vectoInputs) - End Sub - - Public Sub SetPropertiesToDefaults(vectoInputs As VectoInputs) - - DoorActuationTimeSecond = 4 - StoredEnergyEfficiency = 0.935 - AlternatorGearEfficiency = 0.92 - PowerNetVoltage = vectoInputs.PowerNetVoltage.Value() - ResultCardIdle = New ResultCard(New List(Of SmartResult)) - ResultCardOverrun = New ResultCard(New List(Of SmartResult)) - ResultCardTraction = New ResultCard(New List(Of SmartResult)) - SmartElectrical = False - AlternatorMap = String.Empty - End Sub - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ResultCard.vb b/VECTOAux/VectoAuxiliaries/Electrics/ResultCard.vb deleted file mode 100644 index ccb86a31f74591dfcbf3e013676ec6c3bc3aeb26..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Electrics/ResultCard.vb +++ /dev/null @@ -1,144 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - -Imports DownstreamModules.Electrics -Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.BusAuxiliaries.Interfaces.DownstreamModules.Electrics - -Namespace Electrics - Public Class ResultCard - Implements IResultCard - - Private _results As List(Of SmartResult) - - 'Constructor - Public Sub New(results As List(Of SmartResult)) - - If results Is Nothing Then Throw New ArgumentException("A list of smart results must be supplied.") - - _results = results - End Sub - - - 'Public class outputs - Public ReadOnly Property Results As List(Of SmartResult) Implements IResultCard.Results - Get - Return _results - End Get - End Property - - Public Function GetSmartCurrentResult(ByVal Amps As Ampere) As Ampere Implements IResultCard.GetSmartCurrentResult - - - If _results.Count < 2 Then Return 10.SI(Of Ampere)() - - Return GetOrInterpolate(Amps.Value()).SI(Of Ampere)() - End Function - - - 'Helpers - ''' <summary> - ''' Gets or interpolates value (A) - ''' </summary> - ''' <param name="amps"></param> - ''' <returns></returns> - ''' <remarks></remarks> - Private Function GetOrInterpolate(amps As Double) As Double - - Dim pre As Double - Dim post As Double - Dim dAmps As Double - Dim dSmartAmps As Double - Dim smartAmpsSlope As Double - Dim smartAmps As Double - Dim maxKey As Double - Dim minKey As Double - - maxKey = _results.Max.Amps - minKey = _results.Min.Amps - - Dim compareKey As SmartResult = New SmartResult(amps, 0) - - 'Is on boundary check - If _results.Contains(compareKey) Then _ - Return _results.OrderBy(Function(x) x.Amps).First(Function(x) x.Amps = compareKey.Amps).SmartAmps - - 'Is over map - Extrapolate - If amps > maxKey Then - - 'get the entries before and after the supplied key - pre = (From a In _results Order By a.Amps Where a.Amps < maxKey Select a).Last().Amps - post = maxKey - - 'get the delta values - dAmps = post - pre - dSmartAmps = (From da In _results Order By da.Amps Where da.Amps = post).First().SmartAmps - - (From da In _results Order By da.Amps Where da.Amps = pre).First().SmartAmps - - 'calculate the slopes - smartAmpsSlope = dSmartAmps / dAmps - - 'calculate the new values - smartAmps = ((amps - post) * smartAmpsSlope) + - (From da In _results Order By da.Amps Where da.Amps = post).First().SmartAmps - - Return smartAmps - - End If - - 'Is under map - Extrapolate - If amps < minKey Then - - 'get the entries before and after the supplied key - 'Post is the first entry and pre is the penultimate to first entry - post = minKey - pre = (From k In _results Order By k.Amps Where k.Amps > minKey Select k).First().Amps - - 'get the delta values - dAmps = post - pre - dSmartAmps = (From da In _results Order By da.Amps Where da.Amps = post).First().SmartAmps - - (From da In _results Order By da.Amps Where da.Amps = pre).First().SmartAmps - - 'calculate the slopes - smartAmpsSlope = dSmartAmps / dAmps - - 'calculate the new values - smartAmps = ((amps - post) * smartAmpsSlope) + - (From da In _results Order By da.Amps Where da.Amps = post).First().SmartAmps - - Return smartAmps - End If - - 'Is Inside map - Interpolate - - 'get the entries before and after the supplied rpm - pre = (From m In _results Order By m.Amps Where m.Amps < amps Select m).Last().Amps - post = (From m In _results Where m.Amps > amps Select m).First().Amps - - 'get the delta values for rpm and the map values - dAmps = post - pre - dSmartAmps = (From da In _results Order By da.Amps Where da.Amps = post).First().SmartAmps - - (From da In _results Order By da.Amps Where da.Amps = pre).First().SmartAmps - - 'calculate the slopes - smartAmpsSlope = dSmartAmps / dAmps - - 'calculate the new values - smartAmps = ((amps - post) * smartAmpsSlope) + - (From da In _results Order By da.Amps Where da.Amps = post).First().SmartAmps - - - Return smartAmps - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb b/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb deleted file mode 100644 index 53fd82da052c5fbe4bba9d69ddfdbbc2d4d33419..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb +++ /dev/null @@ -1,188 +0,0 @@ -Namespace Hvac - Public Class Bus - Implements IBus - - 'Private Property Backing - Private _id As Integer - Private _model As String - Private _floorType As String - Private _engineType As String - Private _lengthInMetres As Double - Private _widthInMetres As Double - Private _heightInMetres As Double - Private _registeredPassengers As Integer - Private _isDoubleDecker As Boolean - - Public ReadOnly Property Id As Integer Implements IBus.Id - Get - Return _id - End Get - End Property - - Public Property Model As String Implements IBus.Model - Get - Return _model - End Get - Set(value As String) - If Not ModelOK(value) Then Throw New ArgumentException("Model argument is invalid") - _model = value - End Set - End Property - - Public Property FloorType As String Implements IBus.FloorType - Get - Return _floorType - End Get - Set(value As String) - If Not FloorTypeOK(value) Then Throw New ArgumentException("Model argument is invalid") - _floorType = value - End Set - End Property - - Public Property EngineType As String Implements IBus.EngineType - Get - Return _engineType - End Get - Set(value As String) - If Not EngineOK(value) Then Throw New ArgumentException("EngineType argument is invalid") - _engineType = value - End Set - End Property - - Public Property LengthInMetres As Double Implements IBus.LengthInMetres - Get - Return _lengthInMetres - End Get - Set(value As Double) - If Not DimensionOK(value) Then Throw New ArgumentException("Invalid Length") - _lengthInMetres = value - End Set - End Property - - Public Property WidthInMetres As Double Implements IBus.WidthInMetres - Get - Return _widthInMetres - End Get - Set(value As Double) - If Not DimensionOK(value) Then Throw New ArgumentException("Invalid Width") - _widthInMetres = value - End Set - End Property - - Public Property HeightInMetres As Double Implements IBus.HeightInMetres - Get - Return _heightInMetres - End Get - Set(value As Double) - If Not DimensionOK(value) Then Throw New ArgumentException("Invalid Height") - _heightInMetres = value - End Set - End Property - - Public Property RegisteredPassengers As Integer Implements IBus.RegisteredPassengers - Get - Return _registeredPassengers - End Get - Set(value As Integer) - If Not PassengersOK(value) Then Throw New ArgumentException("Invalid Number Of Passengers") - _registeredPassengers = value - End Set - End Property - - Public Property IsDoubleDecker As Boolean Implements IBus.IsDoubleDecker - Get - Return _isDoubleDecker - End Get - Set(ByVal value As Boolean) - _isDoubleDecker = value - End Set - End Property - - 'Constructors - Public Sub New(_id As Integer, - _model As String, - _floorType As String, - _engineType As String, - _lengthInMetres As Double, - _widthInMetres As Double, - _heightInMetres As Double, - _registeredPassengers As Integer, - _doubleDecker As Boolean) - - - 'Validity checks. - If Not ModelOK(_model) Then Throw New ArgumentException("Model argument is invalid") - If Not FloorTypeOK(_floorType) Then Throw New ArgumentException("Model argument is invalid") - If Not EngineOK(_engineType) Then Throw New ArgumentException("EngineType argument is invalid") - If Not DimensionOK(_lengthInMetres) Then Throw New ArgumentException("Invalid Length") - If Not DimensionOK(_widthInMetres) Then Throw New ArgumentException("Invalid Width") - If Not DimensionOK(_heightInMetres) Then Throw New ArgumentException("Invalid Height") - If Not PassengersOK(_registeredPassengers) Then Throw New ArgumentException("Invalid Number Of Passengers") - - - 'Set Private Members - Me._id = _id - Me._model = _model - Me._floorType = _floorType - Me._engineType = _engineType - Me._lengthInMetres = _lengthInMetres - Me._widthInMetres = _widthInMetres - Me._heightInMetres = _heightInMetres - Me._registeredPassengers = _registeredPassengers - Me._isDoubleDecker = _doubleDecker - End Sub - - 'Construction Validators Helpers - Private Function ModelOK(ByVal model As String) As Boolean - - model = model.ToLower - - If model Is Nothing OrElse model.Trim.Length = 0 Then Return False - - Return True - End Function - - Private Function FloorTypeOK(ByVal floorType As String) As Boolean - - floorType = floorType.ToLower - - If floorType Is Nothing OrElse floorType.Trim.Length = 0 Then Return False - - If floorType <> "raised floor" AndAlso floorType <> "low floor" AndAlso floorType <> "semi low floor" Then _ - Return False - - Return True - End Function - - Private Function EngineOK(ByVal engine As String) As Boolean - - engine = engine.ToLower - - If engine Is Nothing OrElse engine.Trim.Length = 0 Then Return False - - If engine <> "diesel" AndAlso engine <> "gas" AndAlso engine <> "hybrid" Then Return False - - Return True - End Function - - Private Function DimensionOK(ByVal dimension As Double) As Boolean - - Return dimension > 0.5 - End Function - - Private Function PassengersOK(ByVal registeredPassengers As Integer) As Boolean - - Return registeredPassengers > 1 - End Function - - 'To String function - Public Overrides Function ToString() As String - - Return _ - String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", _model, _floorType, _engineType, _lengthInMetres, _widthInMetres, - _heightInMetres, _registeredPassengers, _isDoubleDecker) - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/BusDatabase.vb b/VECTOAux/VectoAuxiliaries/Hvac/BusDatabase.vb deleted file mode 100644 index 783b0ca0652bd25b10ff48fde17e06c6e06da2b3..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/BusDatabase.vb +++ /dev/null @@ -1,156 +0,0 @@ -Imports System.Globalization -Imports System.IO -Imports System.Text - -Namespace Hvac - Public Class BusDatabase - Implements IBusDatabase - - Private buses As New List(Of IBus) - Private selectListBuses As New List(Of IBus) - - Public Function AddBus(bus As IBus) As Boolean Implements IBusDatabase.AddBus - - Dim result As Boolean = True - - Try - buses.Add(bus) - Catch ex As Exception - result = False - End Try - - Return result - End Function - - Public Function GetBuses(busModel As String, Optional AsSelectList As Boolean = False) As List(Of IBus) _ - Implements IBusDatabase.GetBuses - - If AsSelectList Then - selectListBuses = New List(Of IBus) - selectListBuses = buses.Where(Function(v) v.Model = "" OrElse v.Model.ToLower.Contains(busModel.ToLower)).ToList() - selectListBuses.Insert(0, New Bus(0, "<Select>", "low floor", "gas", 1, 1, 1, 2, False)) - Return selectListBuses - - Else - - Return buses.Where(Function(v) v.Model = "" OrElse v.Model.ToLower.Contains(busModel.ToLower)).ToList() - - End If - End Function - - Public Function Initialise(filepath As String) As Boolean Implements IBusDatabase.Initialise - - Dim returnStatus As Boolean = True - - 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() < 2) Then - Return False - End If - - Dim firstline As Boolean = True - - Dim id As Integer = 1 - - For Each line As String In lines - If Not firstline Then - - 'split the line - Dim elements() As String = line.Split(New Char() {","c}, StringSplitOptions.RemoveEmptyEntries) - '7 or 8 entries per line required - If (elements.Length <> 7 AndAlso elements.Length <> 8) Then - Throw New ArgumentException("Incorrect number of values in csv file") - End If - - 'Bus - Try - Dim bus As New Bus(id, - elements(0), - elements(1), - elements(2), - Double.Parse(elements(3), CultureInfo.InvariantCulture), - Double.Parse(elements(4), CultureInfo.InvariantCulture), - Double.Parse(elements(5), CultureInfo.InvariantCulture), - Integer.Parse(elements(6), CultureInfo.InvariantCulture), - If(elements.Length = 8, Boolean.Parse(elements(7)), False)) - - buses.Add(bus) - - Catch ex As Exception - - 'Indicate problems - returnStatus = False - - End Try - - id = id + 1 - Else - firstline = False - End If - Next line - End Using - - Else - returnStatus = False - End If - - Dim uniqueBuses As Integer = (From b In buses Select New With {Key b.Model, b} Distinct).Count() - - If buses.Count <> uniqueBuses Then - returnStatus = False - End If - - Return returnStatus - End Function - - Public Function UpdateBus(id As Integer, bus As IBus) As Boolean Implements IBusDatabase.UpdateBus - - Dim result As Boolean = True - - Try - - Dim existingBus As IBus = buses.Single(Function(b) b.Id = id) - - existingBus.Model = bus.Model - existingBus.RegisteredPassengers = bus.RegisteredPassengers - existingBus.FloorType = bus.FloorType - existingBus.LengthInMetres = bus.LengthInMetres - existingBus.WidthInMetres = bus.WidthInMetres - existingBus.HeightInMetres = bus.HeightInMetres - existingBus.IsDoubleDecker = bus.IsDoubleDecker - - Catch ex As Exception - result = False - End Try - - Return result - End Function - - Public Function Save(filepath As String) As Boolean Implements IBusDatabase.Save - - Dim result As Boolean = True - Dim output As New StringBuilder - - Try - output.AppendLine("Bus Model,Type,engine Type,length in m,wide in m,height in m,registered passengers,double decker") - - For Each bus As IBus In buses - output.AppendLine(bus.ToString()) - Next - - File.WriteAllText(filepath, output.ToString()) - Catch ex As Exception - result = False - End Try - - Return result - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/BusEngineType.vb b/VECTOAux/VectoAuxiliaries/Hvac/BusEngineType.vb deleted file mode 100644 index 7c6d5f5c65d9c8f6a15bc284cc180c291d6b4dad..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/BusEngineType.vb +++ /dev/null @@ -1,10 +0,0 @@ -Namespace Hvac - Public Enum BusEngineType - - Diesal = 1 - Gas = 2 - Hybrid = 3 - End Enum -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb b/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb deleted file mode 100644 index ae83180688b957f0839fb2be8e3cae9fd82b4015..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb +++ /dev/null @@ -1,49 +0,0 @@ -Imports System.Windows.Forms -Imports System.Drawing - - -Public Class DeleteCell - Inherits DataGridViewButtonCell - - Public Property ToolTip As String = "Delete tech benefit line" - Private del As Image = TryCast(My.Resources.ResourceManager.GetObject("Delete"), Image) - - - Protected Overrides Sub Paint(graphics As Graphics, clipBounds As Rectangle, cellBounds As Rectangle, - rowIndex As Integer, elementState As DataGridViewElementStates, value As Object, formattedValue As Object, - errorText As String, cellStyle As DataGridViewCellStyle, advancedBorderStyle As DataGridViewAdvancedBorderStyle, - paintParts As DataGridViewPaintParts) - - advancedBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single - - Me.ToolTipText = ToolTip - - cellStyle.BackColor = Color.White - MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, - advancedBorderStyle, paintParts) - graphics.DrawImage(del, cellBounds) - End Sub -End Class - -Public Class DeleteAlternatorCell - Inherits DataGridViewButtonCell - - Public Property ToolTip As String = "Delete alternator" - Private del As Image = TryCast(My.Resources.ResourceManager.GetObject("Delete"), Image) - - - Protected Overrides Sub Paint(graphics As Graphics, clipBounds As Rectangle, cellBounds As Rectangle, - rowIndex As Integer, elementState As DataGridViewElementStates, value As Object, formattedValue As Object, - errorText As String, cellStyle As DataGridViewCellStyle, advancedBorderStyle As DataGridViewAdvancedBorderStyle, - paintParts As DataGridViewPaintParts) - - advancedBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single - - Me.ToolTipText = ToolTip - - cellStyle.BackColor = Color.White - MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, - advancedBorderStyle, paintParts) - graphics.DrawImage(del, cellBounds) - End Sub -End Class \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Hvac/DeleteColumn.vb b/VECTOAux/VectoAuxiliaries/Hvac/DeleteColumn.vb deleted file mode 100644 index d222b9838dd7dbf657a0dfd37e088e2f33694bc6..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/DeleteColumn.vb +++ /dev/null @@ -1,22 +0,0 @@ -Imports System.Windows.Forms - - -Public Class DeleteColumn - Inherits DataGridViewButtonColumn - - Public Sub new() - - MyBase.New() - Me.CellTemplate = New DeleteCell() - End Sub -End Class - -Public Class DeleteAlternatorColumn - Inherits DataGridViewButtonColumn - - Public Sub new() - - MyBase.New() - Me.CellTemplate = New DeleteAlternatorCell() - End Sub -End Class \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalCondition.vb b/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalCondition.vb deleted file mode 100644 index ade4f8acef632516316b9ef2af91cf3d797a5cdd..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalCondition.vb +++ /dev/null @@ -1,35 +0,0 @@ -Imports DownstreamModules.HVAC - -Namespace Hvac - Public Class EnvironmentalCondition - Implements IEnvironmentalCondition - - Private _temperature As Double - Private _solar As Double - Private _weight As Double - - Public Sub New(temperature As Double, solar As Double, weight As Double) - - _temperature = temperature - _solar = solar - _weight = weight - End Sub - - Public Function GetTemperature() As Double Implements IEnvironmentalCondition.GetTemperature - Return _temperature - End Function - - Public Function GetSolar() As Double Implements IEnvironmentalCondition.GetSolar - Return _solar - End Function - - Public Function GetWeight() As Double Implements IEnvironmentalCondition.GetWeighting - Return _weight - End Function - - Public Function GetNormalisedWeight(map As List(Of IEnvironmentalCondition)) As Double _ - Implements IEnvironmentalCondition.GetNormalisedWeighting - Return _weight/map.Sum(Function(w) w.GetWeighting()) - End Function - End Class -End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalConditionsMap.vb b/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalConditionsMap.vb deleted file mode 100644 index 26e5f7f0928e7c55b37515d2e6309973f6f1afd0..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalConditionsMap.vb +++ /dev/null @@ -1,81 +0,0 @@ -Imports System.Globalization -Imports System.IO -Imports DownstreamModules.HVAC - -Namespace Hvac - Public Class EnvironmentalConditionsMap - Implements IEnvironmentalConditionsMap - - Private filePath As String - Private vectoDirectory As String - - Private _map As New List(Of IEnvironmentalCondition) - - Public Sub New(filepath As String, vectoDirectory As String) - - Me.filePath = filepath - Me.vectoDirectory = vectoDirectory - - Initialise() - End Sub - - Public Function Initialise() As Boolean Implements IEnvironmentalConditionsMap.Initialise - - If (Not String.IsNullOrWhiteSpace(filePath)) Then - - filePath = FilePathUtils.ResolveFilePath(vectoDirectory, filePath) - - 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 1 entries to make it usable [dont forget the header row] - If (lines.Count() < 2) Then - Return False - End If - - 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() {","c}, StringSplitOptions.RemoveEmptyEntries) - - '3 entries per line required - If (elements.Length <> 4) Then - Return False - End If - - 'Add environment condition - Dim newCondition As EnvironmentalCondition = New EnvironmentalCondition( - Double.Parse(elements(1), CultureInfo.InvariantCulture), - Double.Parse(elements(2), CultureInfo.InvariantCulture), - Double.Parse(elements(3), CultureInfo.InvariantCulture)) - - _map.Add(newCondition) - - Else - firstline = False - End If - Next line - End Using - - Else - Return False - End If - End If - - Return True - End Function - - Public Function GetEnvironmentalConditions() As List(Of IEnvironmentalCondition) _ - Implements IEnvironmentalConditionsMap.GetEnvironmentalConditions - - Return _map - End Function - End Class -End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Hvac/HVACConstants.vb b/VECTOAux/VectoAuxiliaries/Hvac/HVACConstants.vb deleted file mode 100644 index 6d9abc638aee4dce394a5edb1bd72058e03462f0..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/HVACConstants.vb +++ /dev/null @@ -1,54 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. -Imports DownstreamModules.HVAC -Imports Newtonsoft.Json -Imports TUGraz.VectoCommon.Utils - -Namespace Hvac - Public Class HVACConstants - Implements IHVACConstants - - <JsonProperty("FuelDensity")> ReadOnly _fuelDensity As Double - <JsonProperty("DieselGCVJperGram")> ReadOnly _dieselGcvJperGram As Double = 44800 - - Public Sub New() - _fuelDensity = 835 '.SI(Of KilogramPerCubicMeter)() - End Sub - - Public Sub New(fuelDensitySingle As KilogramPerCubicMeter) - _fuelDensity = fuelDensitySingle.Value() - End Sub - - - <JsonIgnore> - Public ReadOnly Property DieselGCVJperGram As JoulePerKilogramm Implements IHVACConstants.DieselGCVJperGram - Get - Return _dieselGcvJperGram.SI(Unit.SI.Joule.Per.Gramm).Cast(Of JoulePerKilogramm)() - End Get - End Property - - <JsonIgnore()> - Public ReadOnly Property FuelDensity As KilogramPerCubicMeter Implements IHVACConstants.FuelDensity - Get - Return _fuelDensity.SI(Of KilogramPerCubicMeter)() - End Get - End Property - - <JsonIgnore()> - Public ReadOnly Property FuelDensityAsGramPerLiter As Double Implements IHVACConstants.FuelDensityAsGramPerLiter - Get - Return _fuelDensity * 1000 - End Get - End Property - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/HVACSteadyStateModel.vb b/VECTOAux/VectoAuxiliaries/Hvac/HVACSteadyStateModel.vb deleted file mode 100644 index 41ebd4fa8d59f54a878ab0bd5bb881957c1447ff..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/HVACSteadyStateModel.vb +++ /dev/null @@ -1,113 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - -Imports System.IO -Imports DownstreamModules.HVAC - -Namespace Hvac - Public Class HVACSteadyStateModel - Implements IHVACSteadyStateModel - - Public Property HVACElectricalLoadPowerWatts As Single Implements IHVACSteadyStateModel.HVACElectricalLoadPowerWatts - Public Property HVACFuellingLitresPerHour As Single Implements IHVACSteadyStateModel.HVACFuellingLitresPerHour - Public Property HVACMechanicalLoadPowerWatts As Single Implements IHVACSteadyStateModel.HVACMechanicalLoadPowerWatts - - 'Constructors - Public Sub New() - End Sub - - Public Sub New(elecPowerW As Single, mechPowerW As Single, fuellingLPH As Single) - - HVACElectricalLoadPowerWatts = elecPowerW - HVACFuellingLitresPerHour = mechPowerW - HVACMechanicalLoadPowerWatts = fuellingLPH - End Sub - - 'Implementation - Public Function SetValuesFromMap(ByVal filePath As String, byref message As String) As Boolean _ - Implements IHVACSteadyStateModel.SetValuesFromMap - - - Dim myData As String - Dim linesArray As String() - - - 'Check map file can be found. - Try - myData = System.IO.File.ReadAllText(filePath, System.Text.Encoding.UTF8) - Catch ex As FileNotFoundException - - message = "HVAC Steady State Model : The map file was not found" - Return false - End Try - - - linesArray = (From s As String In myData.Split(CType(vbLf, Char)) Select s.Trim).ToArray - - 'Check count is at least 2 rows - If linesArray.Count < 2 then - message = "HVAC Steady State Model : Insufficient Lines in this File" - Return False - End If - - 'validate headers - Dim headers As String() = linesArray(0).Split(","c) - If headers.Count <> 3 OrElse - headers(0).Trim <> "[Electrical Power (w)]" OrElse - headers(1).Trim <> "[Mechanical Power (w)]" OrElse - headers(2).Trim <> "[Fuelling (L/H)]" Then - message = "HVAC Steady State Model : Column headers in *.AHSM file being read are incompatable." - Return False - - End If - - 'validate values - Dim values As String() = linesArray(1).Split(","c) - If headers.Count <> 3 OrElse - NOT IsNumeric(values(0)) OrElse - NOT IsNumeric(values(1)) OrElse - Not IsNumeric(values(2)) - message = "Steady State Model : Unable to confirm numeric values in the *.AHSM file being read." - Return False - End If - - 'OK we have the values so lets set the properties - Dim out1, out2, out3 As single - out1 = HVACElectricalLoadPowerWatts - out2 = HVACMechanicalLoadPowerWatts - out3 = HVACFuellingLitresPerHour - try - - HVACElectricalLoadPowerWatts = Single.Parse(values(0)) - HVACMechanicalLoadPowerWatts = Single.Parse(values(1)) - HVACFuellingLitresPerHour = Single.Parse(values(2)) - - Catch ex As Exception - - 'Restore in the event of failure to fully assign - HVACElectricalLoadPowerWatts = out1 - HVACMechanicalLoadPowerWatts = out2 - HVACFuellingLitresPerHour = out3 - - 'Return result - message = - "Steady State Model : Unable to parse the values in the *.AHSM file being read no values were harmed in reading of this file." - Return False - - End Try - - - Return True - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/HVACUserInputsConfig.vb b/VECTOAux/VectoAuxiliaries/Hvac/HVACUserInputsConfig.vb deleted file mode 100644 index 651ec540f686705fd7bbaf4c8ccc36e1589ee47b..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/HVACUserInputsConfig.vb +++ /dev/null @@ -1,34 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - -Imports DownstreamModules.HVAC - -Namespace Hvac - Public Class HVACUserInputsConfig - Implements IHVACUserInputsConfig - - 'Constructor - Public Sub New(ssmFilePath As String, busDatabasePath As String, isDisabled As Boolean) - - Me.SSMFilePath = ssmFilePath - Me.BusDatabasePath = busDatabasePath - Me.SSMDisabled = isDisabled - End Sub - - Public Property SSMFilePath As String Implements IHVACUserInputsConfig.SSMFilePath - - Public Property BusDatabasePath As String Implements IHVACUserInputsConfig.BusDatabasePath - - Public Property SSMDisabled As Boolean Implements IHVACUserInputsConfig.SSMDisabled - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/IBus.vb b/VECTOAux/VectoAuxiliaries/Hvac/IBus.vb deleted file mode 100644 index d1f5b72190bbac39e51307a27f9487604657a888..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/IBus.vb +++ /dev/null @@ -1,17 +0,0 @@ - -Namespace Hvac - Public Interface IBus - ReadOnly Property Id As Integer - - Property Model As String - Property FloorType As String - Property EngineType As String - Property LengthInMetres As Double - Property WidthInMetres As Double - Property HeightInMetres As Double - Property RegisteredPassengers As Integer - Property IsDoubleDecker As Boolean - End Interface -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/IBusDatabase.vb b/VECTOAux/VectoAuxiliaries/Hvac/IBusDatabase.vb deleted file mode 100644 index afa479db3d88c75740c5340beed55f29cbfdf580..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/IBusDatabase.vb +++ /dev/null @@ -1,13 +0,0 @@ -Namespace Hvac - Public Interface IBusDatabase - Function AddBus(bus As IBus) As Boolean - - Function GetBuses(busModel As String, Optional AsSelectList As Boolean = False) As List(Of IBus) - - Function Initialise(busFileCSV As String) As Boolean - - Function UpdateBus(id As Integer, bus As IBus) As Boolean - - Function Save(filepath As String) As Boolean - End Interface -End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMCalculate.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMCalculate.vb deleted file mode 100644 index c039fab3195a548a736f3e2306078018a7bcf427..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMCalculate.vb +++ /dev/null @@ -1,794 +0,0 @@ -Imports System.Text -Imports DownstreamModules.HVAC - -Namespace Hvac - 'Modeling SSHVAC V07 - Public Class SSMCalculate - Implements ISSMCalculate - - Private ssmTOOL As ISSMTOOL - Private Property Run1 As ISSMRun Implements ISSMCalculate.Run1 - Private Property Run2 As ISSMRun Implements ISSMCalculate.Run2 - - 'Constructor - Sub New(ssmTool As ISSMTOOL) - - Me.ssmTOOL = ssmTool - Run1 = New SSMRun(Me.ssmTOOL, 1) - Run2 = New SSMRun(Me.ssmTOOL, 2) - End Sub - -#Region "Main Outputs" - - 'BASE RESULTS - Public ReadOnly Property ElectricalWBase As Double Implements ISSMCalculate.ElectricalWBase - Get - - Dim ElectricalWBaseWeightedAverage As Double - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim EC_EnviromentalTemperatureBefore As Double = gen.EC_EnviromentalTemperature - Dim EC_SolarBefore As Double = gen.EC_Solar - - 'If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. - 'Else if batch is enable calculate the ElectricalWBase for each input in the AENV file and then calculate the weighted average - If Not gen.EC_EnviromentalConditions_BatchEnabled Then - ElectricalWBaseWeightedAverage = CalculateElectricalWBase(gen, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1) - Else - For Each envCondition As IEnvironmentalCondition In gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions() - ElectricalWBaseWeightedAverage += CalculateElectricalWBase(gen, envCondition.GetTemperature(), - envCondition.GetSolar(), - envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())) - Next - gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore - gen.EC_Solar = EC_SolarBefore - End If - - Return ElectricalWBaseWeightedAverage - End Get - End Property - - Public ReadOnly Property MechanicalWBase As Double Implements ISSMCalculate.MechanicalWBase - Get - - Dim MechanicalWBaseWeightedAverage As Double - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim EC_EnviromentalTemperatureBefore As Double = gen.EC_EnviromentalTemperature - Dim EC_SolarBefore As Double = gen.EC_Solar - - 'If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. - 'Else if batch is enable calculate the MechanicalWBase for each input in the AENV file and then calculate the weighted average - If Not gen.EC_EnviromentalConditions_BatchEnabled Then - MechanicalWBaseWeightedAverage = CalculateMechanicalWBase(gen, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1) - Else - For Each envCondition As IEnvironmentalCondition In gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions() - MechanicalWBaseWeightedAverage += CalculateMechanicalWBase(gen, envCondition.GetTemperature(), - envCondition.GetSolar(), - envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())) - Next - gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore - gen.EC_Solar = EC_SolarBefore - End If - - Return MechanicalWBaseWeightedAverage - End Get - End Property - - Public ReadOnly Property FuelPerHBase As Double Implements ISSMCalculate.FuelPerHBase - Get - - Dim FuelLPerHBaseWeightedAverage As Double - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim EC_EnviromentalTemperatureBefore As Double = gen.EC_EnviromentalTemperature - Dim EC_SolarBefore As Double = gen.EC_Solar - - 'If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. - 'Else if batch is enable calculate the FuelLPerHBase for each input in the AENV file and then calculate the weighted average - If Not gen.EC_EnviromentalConditions_BatchEnabled Then - FuelLPerHBaseWeightedAverage = CalculateFuelLPerHBase(gen, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1) - Else - For Each envCondition As IEnvironmentalCondition In gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions() - FuelLPerHBaseWeightedAverage += CalculateFuelLPerHBase(gen, envCondition.GetTemperature(), envCondition.GetSolar(), - envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())) - Next - gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore - gen.EC_Solar = EC_SolarBefore - End If - - Return FuelLPerHBaseWeightedAverage - End Get - End Property - - 'ADJUSTED RESULTS - Public ReadOnly Property ElectricalWAdjusted As Double Implements ISSMCalculate.ElectricalWAdjusted - Get - Dim ElectricalWAdjustedAverage As Double - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim tl As ISSMTechList = ssmTOOL.TechList - Dim EC_EnviromentalTemperatureBefore As Double = gen.EC_EnviromentalTemperature - Dim EC_SolarBefore As Double = gen.EC_Solar - - 'If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. - 'Else if batch is enable calculate the ElectricalWAdjusted for each input in the AENV file and then calculate the weighted average - If Not gen.EC_EnviromentalConditions_BatchEnabled Then - ElectricalWAdjustedAverage = CalculateElectricalWAdjusted(gen, tl, gen.EC_EnviromentalTemperature, gen.EC_Solar, 1) - Else - For Each envCondition As IEnvironmentalCondition In gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions() - ElectricalWAdjustedAverage += CalculateElectricalWAdjusted(gen, tl, envCondition.GetTemperature(), - envCondition.GetSolar(), - envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())) - Next - gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore - gen.EC_Solar = EC_SolarBefore - End If - - Return ElectricalWAdjustedAverage - End Get - End Property - - Public ReadOnly Property MechanicalWBaseAdjusted As Double Implements ISSMCalculate.MechanicalWBaseAdjusted - Get - - Dim MechanicalWBaseAdjustedAverage As Double - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim tl As ISSMTechList = ssmTOOL.TechList - Dim EC_EnviromentalTemperatureBefore As Double = gen.EC_EnviromentalTemperature - Dim EC_SolarBefore As Double = gen.EC_Solar - - 'If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. - 'Else if batch is enable calculate the MechanicalWBaseAdjusted for each input in the AENV file and then calculate the weighted average - If Not gen.EC_EnviromentalConditions_BatchEnabled Then - MechanicalWBaseAdjustedAverage = CalculateMechanicalWBaseAdjusted(gen, tl, gen.EC_EnviromentalTemperature, - gen.EC_Solar, 1) - Else - For Each envCondition As IEnvironmentalCondition In gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions() - MechanicalWBaseAdjustedAverage += CalculateMechanicalWBaseAdjusted(gen, tl, envCondition.GetTemperature(), - envCondition.GetSolar(), - envCondition.GetNormalisedWeighting( - gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())) - Next - gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore - gen.EC_Solar = EC_SolarBefore - End If - - Return MechanicalWBaseAdjustedAverage - End Get - End Property - - Public ReadOnly Property FuelPerHBaseAdjusted As Double Implements ISSMCalculate.FuelPerHBaseAdjusted - Get - Dim FuelLPerHBaseAdjustedAverage As Double - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim tl As ISSMTechList = ssmTOOL.TechList - Dim EC_EnviromentalTemperatureBefore As Double = gen.EC_EnviromentalTemperature - Dim EC_SolarBefore As Double = gen.EC_Solar - - 'If batch mode is disabled use the EC_EnviromentalTemperature and EC_Solar variables. - 'Else if batch is enable calculate the FuelLPerHBaseAdjusted for each input in the AENV file and then calculate the weighted average - If Not gen.EC_EnviromentalConditions_BatchEnabled Then - FuelLPerHBaseAdjustedAverage = CalculateFuelLPerHBaseAdjusted(gen, tl, gen.EC_EnviromentalTemperature, gen.EC_Solar, - 1) - Else - For Each envCondition As IEnvironmentalCondition In gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions() - FuelLPerHBaseAdjustedAverage += CalculateFuelLPerHBaseAdjusted(gen, tl, envCondition.GetTemperature(), - envCondition.GetSolar(), - envCondition.GetNormalisedWeighting(gen.EC_EnvironmentalConditionsMap.GetEnvironmentalConditions())) - Next - gen.EC_EnviromentalTemperature = EC_EnviromentalTemperatureBefore - gen.EC_Solar = EC_SolarBefore - End If - - Return FuelLPerHBaseAdjustedAverage - End Get - End Property - - -#End Region - -#Region "Staging Calculations" - - 'Base Values - Public ReadOnly Property BaseHeatingW_Mechanical As Double Implements ISSMCalculate.BaseHeatingW_Mechanical - Get - Return Nothing - End Get - End Property - - Public ReadOnly Property BaseHeatingW_ElectricalCoolingHeating As Double _ - Implements ISSMCalculate.BaseHeatingW_ElectricalCoolingHeating - Get - Return Nothing - End Get - End Property - - Public ReadOnly Property BaseHeatingW_ElectricalVentilation As Double _ - Implements ISSMCalculate.BaseHeatingW_ElectricalVentilation - Get - '=IF(AND(M89<0,M90<0),IF(AND(C62="yes",C66="high"),C33,IF(AND(C62="yes",C66="low"),C34,0)),0) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - 'Dim C33 = gen.BC_HighVentPowerW - 'Dim C34 = gen.BC_LowVentPowerW - 'Dim C62 = gen.VEN_VentilationONDuringHeating - 'Dim C66 = gen.VEN_VentilationDuringHeating - 'Dim M89 = Me.Run1.TotalW - 'Dim M90 = Me.Run2.TotalW - - Dim res As Double - - res = If(Run1.TotalW < 0 AndAlso Run2.TotalW < 0, - If(gen.VEN_VentilationOnDuringHeating AndAlso gen.VEN_VentilationDuringHeating.ToLower() = "high", - gen.BC_HighVentPowerW, - If _ - (gen.VEN_VentilationOnDuringHeating AndAlso gen.VEN_VentilationDuringHeating.ToLower() = "low", - gen.BC_LowVentPowerW, 0)), 0) - - - Return res - End Get - End Property - - Public ReadOnly Property BaseHeatingW_FuelFiredHeating As Double _ - Implements ISSMCalculate.BaseHeatingW_FuelFiredHeating - - Get - '=IF(AND(M89<0,M90<0),VLOOKUP(MAX(M89:M90),M89:O90,3),0) - - 'Dim M89 = Me.Run1.TotalW - 'Dim M90 = Me.Run2.TotalW - 'VLOOKUP(MAX(M89:M90),M89:O90 => VLOOKUP ( lookupValue, tableArray, colIndex, rangeLookup ) - - 'If both Run TotalW values are >=0 then return FuelW from Run with largest TotalW value, else return 0 - If (Run1.TotalW < 0 AndAlso Run2.TotalW < 0) Then - - Return If(Run1.TotalW > Run2.TotalW, Run1.FuelW, Run2.FuelW) - - Else - - Return 0 - - End If - End Get - End Property - - Public ReadOnly Property BaseCoolingW_Mechanical As Double Implements ISSMCalculate.BaseCoolingW_Mechanical - Get - '=IF(C46<C28,0,IF(C53="electrical", 0, IF(AND(M89>0,M90>0),MIN(M89:M90),0))) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - 'Dim C46 = gen.EC_EnviromentalTemperature - 'Dim C28 = gen.BC_TemperatureCoolingTurnsOff - 'Dim C53 = gen.AC_CompressorTypeDerived - 'Dim M89 = Run1.TotalW - 'Dim M90 = Run2.TotalW - - Return _ - If _ - (gen.EC_EnviromentalTemperature < gen.BC_TemperatureCoolingTurnsOff, 0, - If _ - (gen.AC_CompressorTypeDerived.ToLower() = "electrical", 0, - If(Run1.TotalW > 0 AndAlso Run2.TotalW > 0, Math.Min(Run1.TotalW, Run2.TotalW), 0))) - End Get - End Property - - Public ReadOnly Property BaseCoolingW_ElectricalCoolingHeating As Double _ - Implements ISSMCalculate.BaseCoolingW_ElectricalCoolingHeating - Get - '=IF(C46<C28,0,IF(C53="electrical",IF(AND(M89>0,M90>0),MIN(M89:M90),0),0)) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - 'Dim C46 = gen.EC_EnviromentalTemperature - 'Dim C28 = gen.BC_TemperatureCoolingTurnsOff - 'Dim C53 = gen.AC_CompressorTypeDerived - 'Dim M89 = Run1.TotalW - 'Dim M90 = Run2.TotalW - - Return _ - If _ - (gen.EC_EnviromentalTemperature < gen.BC_TemperatureCoolingTurnsOff, 0, - If _ - (gen.AC_CompressorTypeDerived.ToLower() = "electrical", - If(Run1.TotalW > 0 AndAlso Run2.TotalW > 0, Math.Min(Run1.TotalW, Run2.TotalW), 0), 0)) - End Get - End Property - - Public ReadOnly Property BaseCoolingW_ElectricalVentilation As Double _ - Implements ISSMCalculate.BaseCoolingW_ElectricalVentilation - Get - '=IF(AND(C46>=C28,M89>0,M90>0),IF(AND(C64="yes",C67="high"),C33,IF(AND(C64="yes",C67="low"),C34,0)),0) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - 'Dim C46 = gen.EC_EnviromentalTemperature - 'Dim C28 = gen.BC_TemperatureCoolingTurnsOff - 'Dim M89 = Run1.TotalW - 'Dim M90 = Run2.TotalW - 'Dim C64 = gen.VEN_VentilationDuringAC - 'Dim C67 = gen.VEN_VentilationDuringCooling - 'Dim C33 = gen.BC_HighVentPowerW - 'Dim C34 = gen.BC_LowVentPowerW - - Return _ - If _ - ( - gen.EC_EnviromentalTemperature >= gen.BC_TemperatureCoolingTurnsOff AndAlso Run1.TotalW > 0 AndAlso - Run2.TotalW > 0, - If _ - (gen.VEN_VentilationDuringAC AndAlso gen.VEN_VentilationDuringCooling.ToLower() = "high", gen.BC_HighVentPowerW, - If _ - (gen.VEN_VentilationDuringAC AndAlso gen.VEN_VentilationDuringCooling.ToLower() = "low", gen.BC_LowVentPowerW, 0)) _ - , 0) - End Get - End Property - - Public ReadOnly Property BaseCoolingW_FuelFiredHeating As Double _ - Implements ISSMCalculate.BaseCoolingW_FuelFiredHeating - Get - Return 0 - End Get - End Property - - Public ReadOnly Property BaseVentilationW_Mechanical As Double Implements ISSMCalculate.BaseVentilationW_Mechanical - Get - Return Nothing - End Get - End Property - - Public ReadOnly Property BaseVentilationW_ElectricalCoolingHeating As Double _ - Implements ISSMCalculate.BaseVentilationW_ElectricalCoolingHeating - Get - Return Nothing - End Get - End Property - - Public ReadOnly Property BaseVentilationW_ElectricalVentilation As Double _ - Implements ISSMCalculate.BaseVentilationW_ElectricalVentilation - Get - '=IF(OR(AND(C46<C28,M89>0,M90>0),AND(M89>0,M90<0)),IF(AND(C63="yes",C65="high"),C33,IF(AND(C63="yes",C65="low"),C34,0)),0) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - 'Dim C46 = gen.EC_EnviromentalTemperature - 'Dim C28 = gen.BC_TemperatureCoolingTurnsOff - 'Dim M89 = Run1.TotalW - 'Dim M90 = Run2.TotalW - 'Dim C63 = gen.VEN_VentilationWhenBothHeatingAndACInactive - 'Dim C65 = gen.VEN_VentilationFlowSettingWhenHeatingAndACInactive - 'Dim C33 = gen.BC_HighVentPowerW - 'Dim C34 = gen.BC_LowVentPowerW - - Return _ - If _ - ( - (gen.EC_EnviromentalTemperature < gen.BC_TemperatureCoolingTurnsOff AndAlso Run1.TotalW > 0 AndAlso - Run2.TotalW > 0) OrElse (Run1.TotalW > 0 AndAlso Run2.TotalW < 0), - If _ - ( - gen.VEN_VentilationWhenBothHeatingAndACInactive AndAlso - gen.VEN_VentilationFlowSettingWhenHeatingAndACInactive.ToLower() = "high", gen.BC_HighVentPowerW, - If _ - ( - gen.VEN_VentilationWhenBothHeatingAndACInactive AndAlso - gen.VEN_VentilationFlowSettingWhenHeatingAndACInactive.ToLower() = "low", gen.BC_LowVentPowerW, 0)), 0) - End Get - End Property - - Public ReadOnly Property BaseVentilationW_FuelFiredHeating As Double _ - Implements ISSMCalculate.BaseVentilationW_FuelFiredHeating - Get - Return 0 - End Get - End Property - - 'Adjusted Values - Public ReadOnly Property TechListAdjustedHeatingW_Mechanical As Double _ - Implements ISSMCalculate.TechListAdjustedHeatingW_Mechanical - Get - Return Nothing - End Get - End Property - - Public ReadOnly Property TechListAdjustedHeatingW_ElectricalCoolingHeating As Double _ - Implements ISSMCalculate.TechListAdjustedHeatingW_ElectricalCoolingHeating - Get - Return Nothing - End Get - End Property - - Public ReadOnly Property TechListAdjustedHeatingW_ElectricalVentilation As Double _ - Implements ISSMCalculate.TechListAdjustedHeatingW_ElectricalVentilation - Get - '=IF('TECH LIST INPUT'!O92>0,MIN('TECH LIST INPUT'!O92,C43),MAX('TECH LIST INPUT'!O92,-C43)) - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim tl As ISSMTechList = ssmTOOL.TechList - - 'TECH LIST INPUT'!O92 - 'Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList - 'Dim TLO92 As Double = tl.VHValueVariation - - - Return _ - If _ - (tl.VHValueVariation > 0, Math.Min(tl.VHValueVariation, gen.BC_MaxPossibleBenefitFromTechnologyList), - Math.Max(tl.VHValueVariation, -gen.BC_MaxPossibleBenefitFromTechnologyList)) - End Get - End Property - - Public ReadOnly Property TechListAdjustedHeatingW_FuelFiredHeating As Double _ - Implements ISSMCalculate.TechListAdjustedHeatingW_FuelFiredHeating - Get - '=IF('TECH LIST INPUT'!N92>0,MIN('TECH LIST INPUT'!N92,C43),MAX('TECH LIST INPUT'!N92,-C43)) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim tl As ISSMTechList = ssmTOOL.TechList - - 'TECH LIST INPUT'!N92 - 'Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList - 'Dim TLN92 As Double = tl.HValueVariation - - - Return _ - If _ - (tl.HValueVariation > 0, Math.Min(tl.HValueVariation, gen.BC_MaxPossibleBenefitFromTechnologyList), - Math.Max(tl.HValueVariation, -gen.BC_MaxPossibleBenefitFromTechnologyList)) - End Get - End Property - - Public ReadOnly Property TechListAdjustedCoolingW_Mechanical As Double _ - Implements ISSMCalculate.TechListAdjustedCoolingW_Mechanical - Get - '=IF(IF(C53="mechanical",'TECH LIST INPUT'!R92,0)>0,MIN(IF(C53="mechanical",'TECH LIST INPUT'!R92,0),C43),MAX(IF(C53="mechanical",'TECH LIST INPUT'!R92,0),-C43)) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim tl As ISSMTechList = ssmTOOL.TechList - Dim result As Double - 'Dim TLR92 As Double = tl.CValueVariation 'TECH LIST INPUT'!R92 - 'Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList - 'Dim C53 As string = gen.AC_CompressorType - - result = If(If(gen.AC_CompressorType.ToLower() = "mechanical", tl.CValueVariation, 0) > 0, - Math.Min(If(gen.AC_CompressorType.ToLower() = "mechanical", tl.CValueVariation, 0), - gen.BC_MaxPossibleBenefitFromTechnologyList), - Math.Max(If(gen.AC_CompressorType.ToLower() = "mechanical", tl.CValueVariation, 0), - -gen.BC_MaxPossibleBenefitFromTechnologyList)) - - Return result - End Get - End Property - - Public ReadOnly Property TechListAdjustedCoolingW_ElectricalCoolingHeating As Double _ - Implements ISSMCalculate.TechListAdjustedCoolingW_ElectricalCoolingHeating - Get - '=IF(IF(C53="mechanical",0,'TECH LIST INPUT'!R92)>0,MIN(IF(C53="mechanical",0,'TECH LIST INPUT'!R92),C43),MAX(IF(C53="mechanical",0,'TECH LIST INPUT'!R92),-C43)) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim tl As ISSMTechList = ssmTOOL.TechList - Dim result As Double - - 'Dim TLR92 As Double = tl.CValueVariation 'TECH LIST INPUT'!R92 - 'Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList - 'Dim C53 As string = gen.AC_CompressorType - - result = If(If(gen.AC_CompressorType.ToLower() = "mechanical", 0, tl.CValueVariation) > 0, - Math.Min(If(gen.AC_CompressorType.ToLower() = "mechanical", 0, tl.CValueVariation), - gen.BC_MaxPossibleBenefitFromTechnologyList), - Math.Max(If(gen.AC_CompressorType.ToLower() = "mechanical", 0, tl.CValueVariation), - -gen.BC_MaxPossibleBenefitFromTechnologyList)) - - Return result - End Get - End Property - - Public ReadOnly Property TechListAdjustedCoolingW_ElectricalVentilation As Double _ - Implements ISSMCalculate.TechListAdjustedCoolingW_ElectricalVentilation - Get - '=IF('TECH LIST INPUT'!Q92>0,MIN('TECH LIST INPUT'!Q92,C43),MAX('TECH LIST INPUT'!Q92,-C43)) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim tl As ISSMTechList = ssmTOOL.TechList - - 'Dim TLQ92 As Double = tl.VCValueVariation'TECH LIST INPUT'!Q92 - 'Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList - - Return If(tl.VCValueVariation > 0, - Math.Min(tl.VCValueVariation, gen.BC_MaxPossibleBenefitFromTechnologyList), - Math.Max(tl.VCValueVariation, -gen.BC_MaxPossibleBenefitFromTechnologyList)) - End Get - End Property - - Public ReadOnly Property TechListAdjustedCoolingW_FuelFiredHeating As Double _ - Implements ISSMCalculate.TechListAdjustedCoolingW_FuelFiredHeating - Get - Return 0 - End Get - End Property - - Public ReadOnly Property TechListAdjustedVentilationW_Mechanical As Double _ - Implements ISSMCalculate.TechListAdjustedVentilationW_Mechanical - Get - Return Nothing - End Get - End Property - - Public ReadOnly Property TechListAdjustedVentilationW_ElectricalCoolingHeating As Double _ - Implements ISSMCalculate.TechListAdjustedVentilationW_ElectricalCoolingHeating - Get - Return Nothing - End Get - End Property - - Public ReadOnly Property TechListAdjustedVentilationW_ElectricalVentilation As Double _ - Implements ISSMCalculate.TechListAdjustedVentilationW_ElectricalVentilation - Get - '=IF('TECH LIST INPUT'!P92>0,MIN('TECH LIST INPUT'!P92,C43),MAX('TECH LIST INPUT'!P92,-C43)) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim tl As ISSMTechList = ssmTOOL.TechList - - 'Dim TLP92 As Double = tl.VVValueVariation 'TECH LIST INPUT'!P92 - 'Dim C43 As Double = gen.BC_MaxPossibleBenefitFromTechnologyList - - - Return _ - If _ - (tl.VVValueVariation > 0, Math.Min(tl.VVValueVariation, gen.BC_MaxPossibleBenefitFromTechnologyList), - Math.Max(tl.VVValueVariation, -gen.BC_MaxPossibleBenefitFromTechnologyList)) - End Get - End Property - - Public ReadOnly Property TechListAdjustedVentilationW_FuelFiredHeating As Double _ - Implements ISSMCalculate.TechListAdjustedVentilationW_FuelFiredHeating - Get - Return 0 - End Get - End Property - -#End Region - - 'Provides Diagnostic Information for the user which can be displayed on the form. - 'Based on the inputs generated, can be used to cross reference the Excel Model with the - 'Outputs generated here. - Public Overrides Function ToString() As String - - Dim sb As New StringBuilder() - - sb.AppendLine("") - sb.AppendLine("TechList Detail") - sb.AppendLine("***********************") - - Dim nameLength As Integer = 40 - Dim catLength As Integer = 15 - Dim unitLength As Integer = 15 - Dim firstValuePos As Integer = nameLength + catLength + unitLength + 2 - Dim cat As String - Dim name As String - Dim units As String - - sb.AppendLine(String.Format(Space(firstValuePos) + "H{0}VH{0}VV{0}VC{0}C{0}", vbtab)) - - - For Each line As ITechListBenefitLine In ssmTOOL.TechList.TechLines - - With line - - Dim extraNameSpaces, extraCatSpaces, extraUnitSpaces As Integer - - extraNameSpaces = nameLength - .BenefitName.Length - extraCatSpaces = catLength - .Category.Length - extraUnitSpaces = unitLength - .Units.Length - - cat = line.Category.Substring(0, Math.Min(line.Category.Length, catLength)) + - Space(If(extraCatSpaces < 0, 0, extraCatSpaces)).Replace(" ", ".") - name = line.BenefitName.Substring(0, Math.Min(line.BenefitName.Length, nameLength)) + - Space(If(extraNameSpaces < 0, 0, extraNameSpaces)).Replace(" ", ".") - units = line.Units.Substring(0, Math.Min(line.Units.Length, unitLength)) + - Space(If(extraUnitSpaces < 0, 0, extraUnitSpaces)).Replace(" ", ".") - - sb.AppendLine(String.Format(units + cat + name + " {0}{1}{0}{2}{0}{3}{0}{4}{0}{5}", vbTab, .H().ToString("0.000"), - .VH().ToString("0.000"), .VV().ToString("0.000"), .VC().ToString("0.000"), .C().ToString("0.000"))) - - End With - - Next - - sb.AppendLine("") - sb.AppendLine("TechList Totals") - sb.AppendLine("***********************") - - With ssmTOOL.TechList - - sb.AppendLine(vbTab + vbTab + "H" + vbTab + "VH" + vbTab + "VV" + vbTab + "VC" + vbTab + "C") - sb.AppendLine(String.Format("Base Var % {0}{1}{0}{2}{0}{3}{0}{4}{0}{5}", vbtab, .HValueVariation.ToString("0.000"), - .VHValueVariation.ToString("0.000"), .VVValueVariation.ToString("0.000"), .VCValueVariation.ToString("0.000"), - .CValueVariation.ToString("0.000"))) - sb.AppendLine(String.Format("Base Var KW {0}{1}{0}{2}{0}{3}{0}{4}{0}{5}", vbtab, - .HValueVariationKW.ToString("0.000"), .VHValueVariationKW.ToString("0.000"), - .VVValueVariationKW.ToString("0.000"), .VCValueVariationKW.ToString("0.000"), - .CValueVariationKW.ToString("0.000"))) - - End With - - - 'Runs - sb.AppendLine(Run1.ToString()) - sb.AppendLine(Run2.ToString()) - - 'Staging Calcs - sb.AppendLine("Staging Base Values") - sb.AppendLine("*******************") - sb.AppendLine( - vbTab + vbTab + vbTab + "Mechanical" + vbTab + "Elec Cool/Heat" + vbTab + "Elec Vent" + vbTab + "Fuel Fired Heating") - - sb.AppendLine(String.Format("Heating {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbtab, - BaseHeatingW_Mechanical.ToString("0.00"), BaseHeatingW_ElectricalCoolingHeating.ToString("0.00"), - BaseHeatingW_ElectricalVentilation.ToString("0.00"), BaseHeatingW_FuelFiredHeating.ToString("0.00"))) - sb.AppendLine(String.Format("Cooling {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbtab, - BaseCoolingW_Mechanical.ToString("0.00"), BaseCoolingW_ElectricalCoolingHeating.ToString("0.00"), - BaseCoolingW_ElectricalVentilation.ToString("0.00"), BaseCoolingW_FuelFiredHeating.ToString("0.00"))) - sb.AppendLine(String.Format("Ventilate {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbtab, - BaseVentilationW_Mechanical.ToString("0.00"), BaseVentilationW_ElectricalCoolingHeating.ToString("0.00"), - BaseVentilationW_ElectricalVentilation.ToString("0.00"), BaseVentilationW_FuelFiredHeating.ToString("0.00"))) - - sb.AppendLine("") - sb.AppendLine("Staging Adjusted Values") - sb.AppendLine("***********************") - - sb.AppendLine(String.Format("Heating {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbtab, - TechListAdjustedHeatingW_Mechanical.ToString("0.00"), - TechListAdjustedHeatingW_ElectricalCoolingHeating.ToString("0.00"), - TechListAdjustedHeatingW_ElectricalVentilation.ToString("0.00"), - TechListAdjustedHeatingW_FuelFiredHeating.ToString("0.00"))) - sb.AppendLine(String.Format("Cooling {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbtab, - TechListAdjustedCoolingW_Mechanical.ToString("0.00"), - TechListAdjustedCoolingW_ElectricalCoolingHeating.ToString("0.00"), - TechListAdjustedCoolingW_ElectricalVentilation.ToString("0.00"), - TechListAdjustedCoolingW_FuelFiredHeating.ToString("0.00"))) - sb.AppendLine(String.Format("Ventilate {0}{1}{0}{2}{0}{3}{0}{4}", vbTab + vbtab, - TechListAdjustedVentilationW_Mechanical.ToString("0.00"), - TechListAdjustedVentilationW_ElectricalCoolingHeating.ToString("0.00"), - TechListAdjustedVentilationW_ElectricalVentilation.ToString("0.00"), - TechListAdjustedVentilationW_FuelFiredHeating.ToString("0.00"))) - - - Return sb.ToString() - End Function - - Private Function CalculateElectricalWBase(genInputs As ISSMGenInputs, EnviromentalTemperature As Double, - Solar As Double, Weight As Double) As Double - - 'MIN(SUM(H94),C54*1000)/C59+SUM(I93:I95) - - genInputs.EC_EnviromentalTemperature = EnviromentalTemperature - genInputs.EC_Solar = Solar - - 'Dim H94 = BaseCoolingW_ElectricalCoolingHeating - 'Dim C54 = genInputs.AC_CompressorCapacitykW - 'Dim C59 = genInputs.AC_COP - 'Dim I93 = BaseHeatingW_ElectricalVentilation - 'Dim I94 = BaseCoolingW_ElectricalVentilation - 'Dim I95 = BaseVentilationW_ElectricalVentilation - - Dim ElectricalWBaseCurrentResult As Double = - Math.Min(BaseCoolingW_ElectricalCoolingHeating, genInputs.AC_CompressorCapacitykW * 1000) / genInputs.AC_COP + - BaseHeatingW_ElectricalVentilation + BaseCoolingW_ElectricalVentilation + BaseVentilationW_ElectricalVentilation - - Return ElectricalWBaseCurrentResult * Weight - End Function - - Private Function CalculateMechanicalWBase(genInputs As ISSMGenInputs, EnviromentalTemperature As Double, - Solar As Double, Weight As Double) As Double - - '=MIN(F94,C54*1000)/C59 - - genInputs.EC_EnviromentalTemperature = EnviromentalTemperature - genInputs.EC_Solar = Solar - - 'Dim F94 = BaseCoolingW_Mechanical - 'Dim C54 = genInputs.AC_CompressorCapacitykW - 'Dim C59 = genInputs.AC_COP - - Dim MechanicalWBaseCurrentResult As Double = - Math.Min(BaseCoolingW_Mechanical, genInputs.AC_CompressorCapacitykW * 1000) / genInputs.AC_COP - - Return MechanicalWBaseCurrentResult * Weight - End Function - - Private Function CalculateFuelLPerHBase(genInputs As ISSMGenInputs, EnviromentalTemperature As Double, Solar As Double, - Weight As Double) As Double - - '=(MIN(ABS(J93/1000),C71)/C37)*(1/(C39*C38)) - - genInputs.EC_EnviromentalTemperature = EnviromentalTemperature - genInputs.EC_Solar = Solar - - 'Dim J93 = BaseHeatingW_FuelFiredHeating - 'Dim C71 = genInputs.AH_FuelFiredHeaterkW - 'Dim C37 = genInputs.BC_AuxHeaterEfficiency - 'Dim C39 = ssmTOOL.HVACConstants.FuelDensity - 'Dim C38 = genInputs.BC_GCVDieselOrHeatingOil - - Dim FuelLPerHBaseCurrentResult As Double = - (Math.Min(Math.Abs(BaseHeatingW_FuelFiredHeating / 1000), genInputs.AH_FuelFiredHeaterkW) / - genInputs.BC_AuxHeaterEfficiency) * - (1 / (genInputs.BC_GCVDieselOrHeatingOil * ssmTOOL.HVACConstants.FuelDensityAsGramPerLiter)) - - Return FuelLPerHBaseCurrentResult * Weight - End Function - - Private Function CalculateElectricalWAdjusted(genInputs As ISSMGenInputs, tecList As ISSMTechList, - EnviromentalTemperature As Double, Solar As Double, Weight As Double) As Double - - '=(MIN((H94*(1-H100)),C54*1000)/C59)+(I93*(1-I99))+(I94*(1-I100))+(I95*(1-I101)) - - genInputs.EC_EnviromentalTemperature = EnviromentalTemperature - genInputs.EC_Solar = Solar - - Dim H94 As Double = BaseCoolingW_ElectricalCoolingHeating - Dim H100 As Double = TechListAdjustedCoolingW_ElectricalCoolingHeating - Dim C54 As Double = genInputs.AC_CompressorCapacitykW - Dim C59 As Double = genInputs.AC_COP - - Dim I93 As Double = BaseHeatingW_ElectricalVentilation - Dim I94 As Double = BaseCoolingW_ElectricalVentilation - Dim I95 As Double = BaseVentilationW_ElectricalVentilation - Dim I99 As Double = TechListAdjustedHeatingW_ElectricalVentilation - Dim I100 As Double = TechListAdjustedCoolingW_ElectricalVentilation - Dim I101 As Double = TechListAdjustedVentilationW_ElectricalVentilation - - Dim ElectricalWAdjusted As Double = (Math.Min((H94 * (1 - H100)), C54 * 1000) / C59) + (I93 * (1 - I99)) + (I94 * (1 - I100)) + - (I95 * (1 - I101)) - - Return ElectricalWAdjusted * Weight - End Function - - Private Function CalculateMechanicalWBaseAdjusted(genInputs As ISSMGenInputs, tecList As ISSMTechList, - EnviromentalTemperature As Double, Solar As Double, Weight As Double) As Double - - '=(MIN((F94*(1-F100)),C54*1000)/C59) - - genInputs.EC_EnviromentalTemperature = EnviromentalTemperature - genInputs.EC_Solar = Solar - - Dim F94 As Double = BaseCoolingW_Mechanical - Dim F100 As Double = TechListAdjustedCoolingW_Mechanical - Dim C54 As Double = genInputs.AC_CompressorCapacitykW - Dim C59 As Double = genInputs.AC_COP - - Dim MechanicalWBaseAdjusted As Double = (Math.Min((F94 * (1 - F100)), C54 * 1000) / C59) - - Return MechanicalWBaseAdjusted * Weight - End Function - - Private Function CalculateFuelLPerHBaseAdjusted(genInputs As ISSMGenInputs, tecList As ISSMTechList, - EnviromentalTemperature As Double, Solar As Double, Weight As Double) As Double - - '=MIN(ABS(IF(AND(M89<0,M90<0),VLOOKUP(MAX(M89:M90),M89:P90,4),0)/1000),C71)/C37*(1/(C39*C38)) - - genInputs.EC_EnviromentalTemperature = EnviromentalTemperature - genInputs.EC_Solar = Solar - - 'Dim M89 = Run1.TotalW - 'Dim M90 = genInputs.BC_GCVDieselOrHeatingOil - 'Dim C71 = genInputs.AH_FuelFiredHeaterkW - 'Dim C37 = genInputs.BC_AuxHeaterEfficiency - 'Dim C38 = genInputs.BC_GCVDieselOrHeatingOil - 'Dim C39 = ssmTOOL.HVACConstants.FuelDensity - - Dim result As Double = 0 - - If Run1.TotalW < 0 AndAlso Run2.TotalW < 0 Then - result = Math.Abs(If(Run1.TotalW > Run2.TotalW, Run1.TechListAmendedFuelW, Run2.TechListAmendedFuelW) / 1000) - End If - - Dim FuelLPerHBaseAdjusted As Double = Math.Min(result, genInputs.AH_FuelFiredHeaterkW) / - genInputs.BC_AuxHeaterEfficiency * - (1 / (genInputs.BC_GCVDieselOrHeatingOil * ssmTOOL.HVACConstants.FuelDensityAsGramPerLiter)) - - Return FuelLPerHBaseAdjusted * Weight - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMGenInputs.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMGenInputs.vb deleted file mode 100644 index 86495e15e42bbd9517523a25f2d7fa7daa58287f..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMGenInputs.vb +++ /dev/null @@ -1,437 +0,0 @@ -Imports DownstreamModules.HVAC - -Namespace Hvac - 'Used by SSMHVAC Class - Public Class SSMGenInputs - Implements ISSMGenInputs - - Private _EC_EnviromentalConditions_BatchFile As String - Private _EC_EnvironmentalConditionsMap As IEnvironmentalConditionsMap - Private _vectoDir As String - -#Region "Constructors" - - Sub New(Optional initialiseDefaults As Boolean = False, Optional vectoDir As String = "") - - _vectoDir = vectoDir - BP_BusModel = "" - BP_BusFloorType = "" - EC_EnviromentalConditions_BatchFile = "" - AC_CompressorType = "" - VEN_VentilationDuringCooling = "" - VEN_VentilationDuringHeating = "" - VEN_VentilationFlowSettingWhenHeatingAndACInactive = "" - If initialiseDefaults Then SetDefaults() - End Sub - -#End Region - -#Region "Bus Parameterisation" - - 'C4/D4 - Public Property BP_BusModel As String Implements ISSMGenInputs.BP_BusModel - - 'C5/D5 - Public Property BP_NumberOfPassengers As Double Implements ISSMGenInputs.BP_NumberOfPassengers - - 'C6/D6 - Public Property BP_BusFloorType As String Implements ISSMGenInputs.BP_BusFloorType - - 'D7/C7 - ( M/2 ) - Public ReadOnly Property BP_BusFloorSurfaceArea As Double Implements ISSMGenInputs.BP_BusFloorSurfaceArea - Get - - '=IF(AND(C6="low floor",C13<=2.55,C13>=2.5),(2.55*(C12-1.2)),((C12-1.2)*C13)) - If BP_BusFloorType = "low floor" AndAlso BP_BusWidth <= 2.55 AndAlso BP_BusWidth >= 2.5 Then - Return Math.Round((2.55 * (BP_BusLength - 1.2)), 6) - Else - Return Math.Round(((BP_BusLength - 1.2) * BP_BusWidth), 6) - End If - End Get - End Property - - 'D8/C8 - ( M/2 ) - Public ReadOnly Property BP_BusSurfaceAreaM2 As Double Implements ISSMGenInputs.BP_BusSurfaceAreaM2 - Get - '2 * (C12*C13 + C12*C14 + C13*C14) - Return 2 * ((BP_BusLength * BP_BusWidth) + (BP_BusLength * BP_BusHeight) + (BP_BusWidth * BP_BusHeight)) - End Get - End Property - - 'D9/C9 - ( M/2 ) - Public ReadOnly Property BP_BusWindowSurface As Double Implements ISSMGenInputs.BP_BusWindowSurface - Get - '=(C40*C12)+C41 - Return (BC_WindowAreaPerUnitBusLength * BP_BusLength) + BC_FrontRearWindowArea - End Get - End Property - - 'C10/D10 - Public Property BP_DoubleDecker As Boolean Implements ISSMGenInputs.BP_DoubleDecker - - 'D11/C11 - ( M/3 ) - Public ReadOnly Property BP_BusVolume As Double Implements ISSMGenInputs.BP_BusVolume - Get - '=(C12*C13*C14) - Return (BP_BusLength * BP_BusWidth * BP_BusHeight) - End Get - End Property - - 'D12/C12 - ( M ) - Public Property BP_BusLength As Double Implements ISSMGenInputs.BP_BusLength - - 'D13/C13 - ( M ) - Public Property BP_BusWidth As Double Implements ISSMGenInputs.BP_BusWidth - - 'D14/C14 - ( M ) - Public Property BP_BusHeight As Double Implements ISSMGenInputs.BP_BusHeight - -#End Region - -#Region "Boundary Conditions" - - 'C17 - Public Property BC_GFactor As Double Implements ISSMGenInputs.BC_GFactor - - 'C18 - Public ReadOnly Property BC_SolarClouding As Double Implements ISSMGenInputs.BC_SolarClouding - Get - '=IF(C46<17,0.65,0.8) - Return If(EC_EnviromentalTemperature < 17, 0.65, 0.8) - End Get - End Property - - 'C19 - ( W ) - Public ReadOnly Property BC_HeatPerPassengerIntoCabinW As Double _ - Implements ISSMGenInputs.BC_HeatPerPassengerIntoCabinW - Get - '=IF(C46<17,50,80) - Return If(EC_EnviromentalTemperature < 17, 50, 80) - End Get - End Property - - 'C20 - ( oC ) - Public Property BC_PassengerBoundaryTemperature As Double Implements ISSMGenInputs.BC_PassengerBoundaryTemperature - - 'C21 - ( Passenger/Metre Squared ) - Public ReadOnly Property BC_PassengerDensityLowFloor As Double Implements ISSMGenInputs.BC_PassengerDensityLowFloor - Get - '=IF($C$10="No",3,3.7) - Return If(BP_DoubleDecker, 3.7, 3) - End Get - End Property - - 'C22 - ( Passenger/Metre Squared ) - Public ReadOnly Property BC_PassengerDensitySemiLowFloor As Double _ - Implements ISSMGenInputs.BC_PassengerDensitySemiLowFloor - Get - '=IF($C$10="No",2.2,3) - Return If(BP_DoubleDecker, 3, 2.2) - End Get - End Property - - 'C23 - ( Passenger/Metre Squared ) - Public ReadOnly Property BC_PassengerDensityRaisedFloor As Double _ - Implements ISSMGenInputs.BC_PassengerDensityRaisedFloor - Get - '=IF($C$10="No",1.4,2) - Return If(BP_DoubleDecker, 2, 1.4) - End Get - End Property - - 'C24 - Public ReadOnly Property BC_CalculatedPassengerNumber As Double Implements ISSMGenInputs.BC_CalculatedPassengerNumber - Get - '=ROUND(IF($D$5<IF(D6="low floor",C21,IF(D6="semi low floor",C22,C23))*D7,$D$5,IF(D6="low floor",C21,IF(D6="semi low floor",C22,C23))*D7),0) - Dim tmp As Double = - If _ - (BP_BusFloorType = "low floor", BC_PassengerDensityLowFloor, - If(BP_BusFloorType = "semi low floor", BC_PassengerDensitySemiLowFloor, BC_PassengerDensityRaisedFloor)) * - BP_BusFloorSurfaceArea - Return Math.Round(If(BP_NumberOfPassengers < tmp, BP_NumberOfPassengers, tmp), 0) - End Get - End Property - - 'C25 - ( W/K/M3 ) - Public ReadOnly Property BC_UValues As Double Implements ISSMGenInputs.BC_UValues - Get - '=IF(D6="low floor",4,IF(D6="semi low floor",3.5,3)) - Return If(BP_BusFloorType = "low floor", 4, If(BP_BusFloorType = "semi low floor", 3.5, 3)) - End Get - End Property - - 'C26 - ( oC ) - Public Property BC_HeatingBoundaryTemperature As Double Implements ISSMGenInputs.BC_HeatingBoundaryTemperature - - 'C27 - ( oC ) - Public Property BC_CoolingBoundaryTemperature As Double Implements ISSMGenInputs.BC_CoolingBoundaryTemperature - - 'C28 - ( oC ) - Public ReadOnly Property BC_TemperatureCoolingTurnsOff As Double _ - Implements ISSMGenInputs.BC_TemperatureCoolingTurnsOff - Get - Return 17 - End Get - End Property - - 'C29 - ( L/H ) - Public Property BC_HighVentilation As Double Implements ISSMGenInputs.BC_HighVentilation - - 'C30 - ( L/H ) - Public Property BC_lowVentilation As Double Implements ISSMGenInputs.BC_lowVentilation - - 'C31 - ( M3/H ) - Public ReadOnly Property BC_High As Double Implements ISSMGenInputs.BC_High - Get - '=D11*C29 - Return BP_BusVolume * BC_HighVentilation - End Get - End Property - - 'C32 - ( M3/H ) - Public ReadOnly Property BC_Low As Double Implements ISSMGenInputs.BC_Low - Get - '=C30*D11 - Return BP_BusVolume * BC_lowVentilation - End Get - End Property - - 'C33 - ( W ) - Public ReadOnly Property BC_HighVentPowerW As Double Implements ISSMGenInputs.BC_HighVentPowerW - Get - '=C31*C35 - Return BC_High * BC_SpecificVentilationPower - End Get - End Property - - 'C34 - ( W ) - Public ReadOnly Property BC_LowVentPowerW As Double Implements ISSMGenInputs.BC_LowVentPowerW - Get - '=C32*C35 - Return BC_Low * BC_SpecificVentilationPower - End Get - End Property - - 'C35 - ( Wh/M3 ) - Public Property BC_SpecificVentilationPower As Double Implements ISSMGenInputs.BC_SpecificVentilationPower - - 'C37 - Public Property BC_AuxHeaterEfficiency As Double Implements ISSMGenInputs.BC_AuxHeaterEfficiency - - 'C38 - ( KW/HKG ) - Public Property BC_GCVDieselOrHeatingOil As Double Implements ISSMGenInputs.BC_GCVDieselOrHeatingOil - - 'C40 - ( M2/M ) - Public ReadOnly Property BC_WindowAreaPerUnitBusLength As Double _ - Implements ISSMGenInputs.BC_WindowAreaPerUnitBusLength - Get - '=IF($C$10="No",1.5,2.5) - Return If(BP_DoubleDecker, 2.5, 1.5) - End Get - End Property - - 'C41 - ( M/2 ) - Public ReadOnly Property BC_FrontRearWindowArea As Double Implements ISSMGenInputs.BC_FrontRearWindowArea - Get - '=IF($C$10="No",5,8) - Return If(BP_DoubleDecker, 8, 5) - End Get - End Property - - 'C42 - ( K ) - Public Property BC_MaxTemperatureDeltaForLowFloorBusses As Double _ - Implements ISSMGenInputs.BC_MaxTemperatureDeltaForLowFloorBusses - - 'C43 - ( Fraction ) - Public Property BC_MaxPossibleBenefitFromTechnologyList As Double _ - Implements ISSMGenInputs.BC_MaxPossibleBenefitFromTechnologyList - -#End Region - -#Region "Environmental Conditions" - - 'C46 - ( oC ) - Public Property EC_EnviromentalTemperature As Double Implements ISSMGenInputs.EC_EnviromentalTemperature - - 'C47 - ( W/M3 ) - Public Property EC_Solar As Double Implements ISSMGenInputs.EC_Solar - - '( EC_EnviromentalTemperature and EC_Solar) (Batch Mode) - Public ReadOnly Property EC_EnvironmentalConditionsMap As IEnvironmentalConditionsMap _ - Implements ISSMGenInputs.EC_EnvironmentalConditionsMap - Get - Return _EC_EnvironmentalConditionsMap - End Get - End Property - - Public Property EC_EnviromentalConditions_BatchFile As String _ - Implements ISSMGenInputs.EC_EnviromentalConditions_BatchFile - Get - Return _EC_EnviromentalConditions_BatchFile - End Get - Set(value As String) - _EC_EnvironmentalConditionsMap = New EnvironmentalConditionsMap(value, _vectoDir) - _EC_EnviromentalConditions_BatchFile = value - End Set - End Property - - Public Property EC_EnviromentalConditions_BatchEnabled As Boolean _ - Implements ISSMGenInputs.EC_EnviromentalConditions_BatchEnabled - -#End Region - -#Region "AC System" - - 'C53 - "Continous/2-stage/3-stage/4-stage - Public Property AC_CompressorType As String Implements ISSMGenInputs.AC_CompressorType - - 'mechanical/electrical - Public ReadOnly Property AC_CompressorTypeDerived As String Implements ISSMGenInputs.AC_CompressorTypeDerived - Get - Return If(AC_CompressorType = "Continuous", "Electrical", "Mechanical") - End Get - End Property - - 'C54 - ( KW ) - Public Property AC_CompressorCapacitykW As Double Implements ISSMGenInputs.AC_CompressorCapacitykW - - 'C59 - Public ReadOnly Property AC_COP As Double Implements ISSMGenInputs.AC_COP - Get - Dim cop As Double = 3.5R - - If (Not AC_CompressorType Is Nothing) Then - cop = If(AC_CompressorType.ToLower = "3-stage", cop * 1.02, cop) - cop = If(AC_CompressorType.ToLower = "4-stage", cop * 1.02, cop) - cop = - If(AC_CompressorType.ToLower = "continuous", If(BP_BusFloorType.ToLower = "low floor", cop * 1.04, cop * 1.06), cop) - End If - - Return Math.Round(cop, 2) - End Get - End Property - -#End Region - -#Region "Ventilation" - - 'C62 - Boolean Yes/No - Public Property VEN_VentilationOnDuringHeating As Boolean Implements ISSMGenInputs.VEN_VentilationOnDuringHeating - - 'C63 - Boolean Yes/No - Property VEN_VentilationWhenBothHeatingAndACInactive As Boolean _ - Implements ISSMGenInputs.VEN_VentilationWhenBothHeatingAndACInactive - - 'C64 - Boolean Yes/No - Public Property VEN_VentilationDuringAC As Boolean Implements ISSMGenInputs.VEN_VentilationDuringAC - - 'C65 - String high/low - Public Property VEN_VentilationFlowSettingWhenHeatingAndACInactive As String _ - Implements ISSMGenInputs.VEN_VentilationFlowSettingWhenHeatingAndACInactive - - 'C66 - String high/low - Property VEN_VentilationDuringHeating As String Implements ISSMGenInputs.VEN_VentilationDuringHeating - - 'C67 - String high/low - Property VEN_VentilationDuringCooling As String Implements ISSMGenInputs.VEN_VentilationDuringCooling - -#End Region - -#Region "AUX Heater" - - 'C70 - ( KW ) - Public Property AH_EngineWasteHeatkW As Double Implements ISSMGenInputs.AH_EngineWasteHeatkW - - 'C71 - ( KW ) - Public Property AH_FuelFiredHeaterkW As Double Implements ISSMGenInputs.AH_FuelFiredHeaterkW - - Public Property AH_FuelEnergyToHeatToCoolant As Double Implements ISSMGenInputs.AH_FuelEnergyToHeatToCoolant - - Public Property AH_CoolantHeatTransferredToAirCabinHeater As Double _ - Implements ISSMGenInputs.AH_CoolantHeatTransferredToAirCabinHeater - -#End Region - -#Region "Default Values" - - Private Sub SetDefaults() - - 'BUS Parameterisation - '******************** - BP_BusModel = "DummyBus" - BP_NumberOfPassengers = 47.0R - BP_BusFloorType = "raised floor" - BP_DoubleDecker = False - BP_BusLength = 10.655R - BP_BusWidth = 2.55R - BP_BusHeight = 2.275R - 'BP_BusFloorSurfaceArea : Calculated - 'BP_BusSurfaceAreaM2 : Calculated - 'BP_BusWindowSurface : Calculated - 'BP_BusVolume : Calculated - - 'BOUNDRY CONDITIONS - '****************** - - BC_GFactor = 0.95R - 'BC_SolarClouding As Double :Calculated - 'BC_HeatPerPassengerIntoCabinW :Calculated - BC_PassengerBoundaryTemperature = 12.0R - 'BC_PassengerDensityLowFloor :Calculated - 'BC_PassengerDensitySemiLowFloor :Calculated - 'BC_PassengerDensityRaisedFloor :Calculated - 'BC_CalculatedPassengerNumber :Calculated - 'BC_UValues :Calculated - BC_HeatingBoundaryTemperature = 18.0R - BC_CoolingBoundaryTemperature = 23.0R - 'BC_CoolingBoundaryTemperature : ReadOnly Static - BC_HighVentilation = 20.0R - BC_lowVentilation = 7.0R - 'BC_High :Calculated - 'BC_Low :Calculated - 'BC_HighVentPowerW :Calculated - 'BC_LowVentPowerW :Calculated - BC_SpecificVentilationPower = 0.56R - 'BC_COP :Calculated - BC_AuxHeaterEfficiency = 0.84R - BC_GCVDieselOrHeatingOil = 11.8R - 'BC_WindowAreaPerUnitBusLength :Calculated - 'BC_FrontRearWindowArea :Calculated - BC_MaxTemperatureDeltaForLowFloorBusses = 3.0R - BC_MaxPossibleBenefitFromTechnologyList = 0.5R - - 'Environmental Conditions - '************************ - EC_EnviromentalTemperature = 25.0R - EC_Solar = 400.0R - EC_EnviromentalConditions_BatchEnabled = True - EC_EnviromentalConditions_BatchFile = "DefaultClimatic.aenv" - - 'AC SYSTEM - '********* - AC_CompressorType = "2-stage" - AC_CompressorCapacitykW = 18.0R - - - 'VENTILATION - '*********** - VEN_VentilationOnDuringHeating = True - VEN_VentilationWhenBothHeatingAndACInactive = True - VEN_VentilationDuringAC = True - VEN_VentilationFlowSettingWhenHeatingAndACInactive = "high" - VEN_VentilationDuringHeating = "high" - VEN_VentilationDuringCooling = "high" - - - 'AUX HEATER - '********** - AH_FuelFiredHeaterkW = 30.0R - AH_FuelEnergyToHeatToCoolant = 0.2 - AH_CoolantHeatTransferredToAirCabinHeater = 0.75 - End Sub - -#End Region - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMRun.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMRun.vb deleted file mode 100644 index b9c414c6c2e1c79049b2210631d15e84811ce8d7..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMRun.vb +++ /dev/null @@ -1,218 +0,0 @@ -Imports System.Text -Imports DownstreamModules.HVAC - -Namespace Hvac - - 'Used By SSMHVAC Class - Public Class SSMRun - Implements ISSMRun - - - Private ssmTOOL As ISSMTOOL - private runNumber As Integer - - - Sub New(ssm As ISSMTOOL, runNumber As Integer) - - If runNumber <> 1 AndAlso runNumber <> 2 Then Throw New ArgumentException("Run number must be either 1 or 2") - - Me.runNumber = runNumber - ssmTOOL = ssm - - End Sub - - - Public ReadOnly Property HVACOperation As Double Implements ISSMRun.HVACOperation - Get - '=IF(C43>C25,3,IF(C43<C24,1,2)) - 'C43 = EC_Enviromental Temperature - 'C25 = BC_CoolingBoundary Temperature - 'C24 = BC_HeatingBoundaryTemperature - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - Return If(gen.EC_EnviromentalTemperature > gen.BC_CoolingBoundaryTemperature, 3, If(gen.EC_EnviromentalTemperature < gen.BC_HeatingBoundaryTemperature, 1, 2)) - - End Get - - End Property - Public ReadOnly Property TCalc As Double Implements ISSMRun.TCalc - Get - - 'C24 = BC_HeatingBoundaryTemperature - 'C25 = BC_CoolingBoundary Temperature - 'C6 = BP_BusFloorType - 'C43 = EC_Enviromental Temperature - 'C39 = BC_FontAndRearWindowArea - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim returnVal As Double - - If runNumber = 1 Then '=C24 - - returnVal = gen.BC_HeatingBoundaryTemperature - - Else '=IF(C6="low floor",IF((C43-C25)<C39,C25,C43-3),C25) - - returnVal = If(gen.BP_BusFloorType = "low floor", If((gen.EC_EnviromentalTemperature - gen.BC_CoolingBoundaryTemperature) < gen.BC_FrontRearWindowArea, gen.BC_CoolingBoundaryTemperature, gen.EC_EnviromentalTemperature - 3), gen.BC_CoolingBoundaryTemperature) - - End If - - - Return returnVal - - End Get - End Property - Public ReadOnly Property TemperatureDelta As Double Implements ISSMRun.TemperatureDelta - Get - '=C43-F79/F80 - 'C43 = EC_Enviromental Temperature - 'F79/80 = Me.TCalc - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Return gen.EC_EnviromentalTemperature - TCalc - - End Get - End Property - Public ReadOnly Property QWall As Double Implements ISSMRun.QWall - Get - '=I79*D8*C23 or '=I80*D8*C23 - 'Translated to - '=I79*C8*C23 or '=I80*C8*C23 - - 'C23 = BC_UValues - 'C8 = BP_BusSurfaceAreaM2 - 'I78/I80 = Me.TemperatureDelta - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - Return TemperatureDelta * gen.BP_BusSurfaceAreaM2 * gen.BC_UValues - - End Get - End Property - Public ReadOnly Property WattsPerPass As Double Implements ISSMRun.WattsPerPass - Get - - '=IF(D5="",C22,IF(E5="",IF(C22<D5,C22,D5),E5))*C17 - 'Translated to - '=IF(IF(C22<C5,C22,C5))*C17 - 'Simplified to - 'Max( C22,C5 ) - - 'C5 = BP_NumberOfPassengers - 'C22 = BC_Calculated Passenger Number - 'C17 = BC_Heat Per Passenger into cabin - - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - Return Math.Min(gen.BP_NumberOfPassengers, gen.BC_CalculatedPassengerNumber) * gen.BC_HeatPerPassengerIntoCabinW - - - End Get - End Property - Public ReadOnly Property Solar As Double Implements ISSMRun.Solar - Get - '=C44*D9*C15*C16*0.25 - 'Translated to - '=C44*C9*C15*C16*0.25 - - 'C44 = EC_Solar - 'C9 = BP_BusWindowSurfaceArea - 'C15 = BC_GFactor - 'C16 = BC_SolarClouding - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - - Return gen.EC_Solar * gen.BP_BusWindowSurface * gen.BC_GFactor * gen.BC_SolarClouding * 0.25 - - - End Get - End Property - Public ReadOnly Property TotalW As Double Implements ISSMRun.TotalW - Get - - '=SUM(J79:L79) or =SUM(J80:L80) - 'Tanslated to - '=Sum ( Me.Qwall ,Me.WattsPerPass,Me.Solar ) - - Return Me.QWall + Me.WattsPerPass + Me.Solar - - End Get - End Property - Public ReadOnly Property TotalKW As Double Implements ISSMRun.TotalKW - Get - '=M79 or =M80 / (1000) - - Return Me.TotalW / 1000 - - End Get - End Property - Public ReadOnly Property FuelW As Double Implements ISSMRun.FuelW - Get - '=IF(AND(N79<0,N79<(C60*-1)),N79-(C60*-1),0)*1000 - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - - 'Dim N79 as Double = TotalKW - 'Dim C60 As Double = gen.AH_EngineWasteHeatkW - - Return IF((TotalKW < 0 AndAlso TotalKW < (gen.AH_EngineWasteHeatkW * -1)), _ - TotalKW - (gen.AH_EngineWasteHeatkW * -1), _ - 0) _ - * 1000 - - End Get - End Property - Public ReadOnly Property TechListAmendedFuelW As Double Implements ISSMRun.TechListAmendedFuelW - Get - '=IF(IF(AND((N79*(1-$J$89))<0,(N79*(1-$J$89))<(C60*-1)),(N79*(1-$J$89))-(C60*-1),0)*1000<0,IF(AND((N79*(1-$J$89))<0,(N79*(1-$J$89))<(C60*-1)),(N79*(1-$J$89))-(C60*-1),0)*1000,0) - - Dim gen As ISSMGenInputs = ssmTOOL.GenInputs - Dim TLFFH As Double = ssmTOOL.Calculate.TechListAdjustedHeatingW_FuelFiredHeating - 'Dim C60 As Double = gen.AH_EngineWasteHeatkW - 'Dim N79 As Double = Me.TotalKW - - Return IF(IF(((TotalKW * (1 - TLFFH)) < 0 AndAlso (TotalKW * (1 - TLFFH)) < (gen.AH_EngineWasteHeatkW * -1)), _ - (TotalKW * (1 - TLFFH)) - (gen.AH_EngineWasteHeatkW * -1), 0) * 1000 < 0, _ - IF(((TotalKW * (1 - TLFFH)) < 0 AndAlso (TotalKW * (1 - TLFFH)) < (gen.AH_EngineWasteHeatkW * -1)), (TotalKW * (1 - TLFFH)) - (gen.AH_EngineWasteHeatkW * -1), 0) * 1000, 0) - - End Get - - End Property - - 'Provides Diagnostic Information - 'To be utilised by the User. - Public Overrides Function ToString() As String - - Dim sb As New StringBuilder() - - sb.AppendLine(String.Format("Run : {0}", runNumber)) - sb.AppendLine(String.Format("************************************")) - sb.AppendLine(String.Format("HVAC OP " + vbTab + ": {0}", HVACOperation)) - sb.AppendLine(String.Format("TCALC " + vbTab + ": {0}", TCalc)) - sb.AppendLine(String.Format("Tempurature D " + vbTab + ": {0}", TemperatureDelta)) - sb.AppendLine(String.Format("QWall " + vbTab + ": {0}", QWall)) - sb.AppendLine(String.Format("WattsPerPass " + vbTab + ": {0}", WattsPerPass)) - sb.AppendLine(String.Format("Solar " + vbTab + ": {0}", Solar)) - sb.AppendLine(String.Format("TotalW " + vbTab + ": {0}", TotalW)) - sb.AppendLine(String.Format("TotalKW " + vbTab + ": {0}", TotalKW)) - sb.AppendLine(String.Format("Fuel W " + vbTab + ": {0}", FuelW)) - sb.AppendLine(String.Format("Fuel Tech Adj " + vbTab + ": {0}", TechListAmendedFuelW)) - - - Return sb.ToString() - - - End Function - - End Class - - - -End Namespace - - - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb deleted file mode 100644 index 2d434cb578bf76d3bb1b9e786a3925ab698726e3..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb +++ /dev/null @@ -1,295 +0,0 @@ -Imports Omu.ValueInjecter -Imports Newtonsoft.Json -Imports System.IO -Imports System.Reflection -Imports System.Text -Imports DownstreamModules.HVAC - -Namespace Hvac - 'Used by frmHVACTool - 'Replaces Spreadsheet model which does the same calculation - 'Version of which appears on the form title. - Public Class SSMTOOL - Implements ISSMTOOL - - Private filePath As String - Public Property GenInputs As ISSMGenInputs Implements ISSMTOOL.GenInputs - Public Property TechList As ISSMTechList Implements ISSMTOOL.TechList - Public Property Calculate As ISSMCalculate Implements ISSMTOOL.Calculate - Public Property SSMDisabled As Boolean Implements ISSMTOOL.SSMDisabled - Public Property HVACConstants As IHVACConstants Implements ISSMTOOL.HVACConstants - - 'Repeat Warning Flags - Private CompressorCapacityInsufficientWarned As Boolean - Private FuelFiredHeaterInsufficientWarned As Boolean - - 'Base Values - Public ReadOnly Property ElectricalWBase As Double Implements ISSMTOOL.ElectricalWBase - Get - Return If(SSMDisabled, 0, Calculate.ElectricalWBase()) '.SI(Of Watt)() - End Get - End Property - - Public ReadOnly Property MechanicalWBase As Double Implements ISSMTOOL.MechanicalWBase - Get - Return If(SSMDisabled, 0, Calculate.MechanicalWBase) '.SI(Of Watt)() - End Get - End Property - - Public ReadOnly Property FuelPerHBase As Double Implements ISSMTOOL.FuelPerHBase - Get - Return If(SSMDisabled, 0, Calculate.FuelPerHBase()) '.SI(Of LiterPerHour)() - End Get - End Property - - 'Adjusted Values - Public ReadOnly Property ElectricalWAdjusted As Double Implements ISSMTOOL.ElectricalWAdjusted - Get - Return If(SSMDisabled, 0, Calculate.ElectricalWAdjusted()) '.SI(Of Watt)() - End Get - End Property - - Public ReadOnly Property MechanicalWBaseAdjusted As Double Implements ISSMTOOL.MechanicalWBaseAdjusted - Get - Dim mechAdjusted As Double = If(SSMDisabled, 0, Calculate.MechanicalWBaseAdjusted()) - - If _ - CompressorCapacityInsufficientWarned = False AndAlso - (mechAdjusted) / (1000 * GenInputs.AC_COP) > GenInputs.AC_CompressorCapacitykW Then - - OnMessage(Me, - "HVAC SSM :AC-Compressor Capacity unable to service cooling, run continues as if capacity was sufficient.", - AdvancedAuxiliaryMessageType.Warning) - CompressorCapacityInsufficientWarned = True - - End If - - - Return mechAdjusted ' .SI(Of Watt)() - End Get - End Property - - Public ReadOnly Property FuelPerHBaseAdjusted As Double Implements ISSMTOOL.FuelPerHBaseAdjusted - Get - Return If(SSMDisabled, 0, Calculate.FuelPerHBaseAdjusted()) ' .SI(Of LiterPerHour)() - End Get - End Property - - 'Constructors - Sub New(filePath As String, hvacConstants As HVACConstants, Optional isDisabled As Boolean = False, - Optional useTestValues As Boolean = False) - - Me.filePath = filePath - Me.SSMDisabled = isDisabled - Me.HVACConstants = hvacConstants - - GenInputs = New SSMGenInputs(useTestValues, fPATH(filePath)) - TechList = New SSMTechList(filePath, GenInputs, useTestValues) - - Calculate = New SSMCalculate(Me) - End Sub - - 'Clone values from another object of same type - Public Sub Clone(from As ISSMTOOL) Implements ISSMTOOL.Clone - - Dim feedback As String = String.Empty - - GenInputs.InjectFrom(DirectCast(from, SSMTOOL).GenInputs) - - TechList.Clear() - - For Each line As TechListBenefitLine In DirectCast(from, SSMTOOL).TechList.TechLines - - Dim newLine As New TechListBenefitLine(Me.GenInputs) - 'newLine.InjectFrom() - newLine.InjectFrom(line) - TechList.Add(newLine, feedback) - - Next - End Sub - - 'Persistance Functions - Public Function Save(filePath As String) As Boolean Implements ISSMTOOL.Save - - - Dim returnValue As Boolean = True - Dim settings As JsonSerializerSettings = New JsonSerializerSettings() - settings.TypeNameHandling = TypeNameHandling.Objects - - 'JSON METHOD - Try - - Dim output As String = JsonConvert.SerializeObject(Me, Formatting.Indented, settings) - - File.WriteAllText(filePath, output) - - Catch ex As Exception - - 'Nothing to do except return false. - returnValue = False - - End Try - - 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(filePath, HVACConstants) - - settings.TypeNameHandling = TypeNameHandling.Objects - - 'JSON METHOD - Try - - Dim output As String = File.ReadAllText(filePath) - - - tmpAux = JsonConvert.DeserializeObject(Of SSMTOOL)(output, settings) - - tmpAux.TechList.SetSSMGeneralInputs(tmpAux.GenInputs) - - For Each tll As TechListBenefitLine In tmpAux.TechList.TechLines - - tll.inputSheet = tmpAux.GenInputs - - Next - - - 'This is where we Assume values of loaded( Deserialized ) object. - Clone(tmpAux) - - Catch ex As Exception - - 'Nothing to do except return false. - - returnValue = False - End Try - - Return returnValue - End Function - - 'Comparison - Public Function IsEqualTo(source As ISSMTOOL) As Boolean Implements ISSMTOOL.IsEqualTo - - '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. - - Return compareGenUserInputs(source) AndAlso compareTechListBenefitLines(source) - End Function - - Private Function compareGenUserInputs(source As ISSMTOOL) As Boolean - - Dim src As SSMTOOL = DirectCast(source, SSMTOOL) - - Dim returnValue As Boolean = True - - Dim properties As PropertyInfo() = Me.GenInputs.GetType.GetProperties - - For Each prop As PropertyInfo In properties - - 'If Not prop.GetAccessors.IsReadOnly Then - If prop.CanWrite Then - If Not prop.GetValue(Me.GenInputs, Nothing).Equals(prop.GetValue(src.GenInputs, Nothing)) Then - returnValue = False - End If - - End If - - Next - - Return returnValue - End Function - - Private Function compareTechListBenefitLines(source As ISSMTOOL) As Boolean - - - 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 - - Dim testLine As ITechListBenefitLine = - src.TechList.TechLines.First(Function(w) w.BenefitName = tl.BenefitName AndAlso w.Category = tl.Category) - - If Not testLine.IsEqualTo(tl) Then - Return False - End If - - End If - - - Next - - 'All Looks OK - Return True - End Function - - 'Overrides - Public Overrides Function ToString() As String - - - Dim sb As New StringBuilder - - sb.AppendLine(Calculate.ToString()) - - - Return sb.ToString() - End Function - - 'Dynamicly Get Fuel having re-adjusted Engine Heat Waste, this was originally supposed to be Solid State. Late adjustment request 24/3/2015 - Public Function FuelPerHBaseAsjusted(AverageUseableEngineWasteHeatKW As Double) As Double _ - Implements ISSMTOOL.FuelPerHBaseAsjusted - - If SSMDisabled Then - Return 0 - End If - - 'Set Engine Waste Heat - GenInputs.AH_EngineWasteHeatkW = AverageUseableEngineWasteHeatKW - Dim fba As Double = FuelPerHBaseAdjusted - - 'Dim FuelFiredWarning As Boolean = fba * GenInputs.BC_AuxHeaterEfficiency * HVACConstants.FuelDensity * GenInputs.BC_GCVDieselOrHeatingOil * 1000 > (AverageUseableEngineWasteHeatKW + GenInputs.AH_FuelFiredHeaterkW) - - 'If Not FuelFiredHeaterInsufficientWarned AndAlso FuelFiredWarning Then - - ' FuelFiredHeaterInsufficientWarned = True - - ' OnMessage(Me, " HVAC SSM : Fuel fired heater insufficient for heating requirements, run continues assuming it was sufficient.", AdvancedAuxiliaryMessageType.Warning) - - 'End If - - Return fba - End Function - - 'Events - Public Event Message(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) _ - Implements ISSMTOOL.Message - - 'Raise Message Event. - Private Sub OnMessage(sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) - - - If Not message Is Nothing Then - - RaiseEvent Message(Me, message, messageType) - - End If - End Sub - End Class -End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMTechList.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMTechList.vb deleted file mode 100644 index 2c2e1c824453b46eec6af442c359df1b49a1715b..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMTechList.vb +++ /dev/null @@ -1,531 +0,0 @@ -Imports System.Globalization -Imports System.IO -Imports DownstreamModules.HVAC -Imports TUGraz.VectoCommon.Utils - -Namespace Hvac - 'Used By SSMTOOL Class. - Public Class SSMTechList - Implements ISSMTechList - - 'Private Fields - Private filePath As String - Private _ssmInputs As ISSMGenInputs - Private _dirty As Boolean - - Public Property TechLines As List(Of ITechListBenefitLine) Implements ISSMTechList.TechLines - - 'Constructors - Public Sub New(filepath As String, genInputs As ISSMGenInputs, Optional initialiseDefaults As Boolean = False) - - Me.TechLines = New List(Of ITechListBenefitLine) - - Me.filePath = filepath - - Me._ssmInputs = genInputs - - If initialiseDefaults Then SetDefaults() - End Sub - - - Public Sub SetSSMGeneralInputs(genInputs As ISSMGenInputs) Implements ISSMTechList.SetSSMGeneralInputs - - _ssmInputs = genInputs - End Sub - - 'Initialisation Methods - Public Function Initialise(filePath As String) As Boolean Implements ISSMTechList.Initialise - - Me.filePath = filePath - - Return Initialise() - End Function - - Public Function Initialise() As Boolean Implements ISSMTechList.Initialise - - - Dim returnStatus As Boolean = True - - 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() < 1) Then - Return False - End If - - 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() {","c}, StringSplitOptions.RemoveEmptyEntries) - '3 entries per line required - If (elements.Length <> 17) Then - Throw New ArgumentException("Incorrect number of values in csv file") - End If - 'add values to map - - ' 00. Category, - ' 01. BenefitName, - ' 02. Units, - ' 03. LowH, - ' 04. LowV, - ' 05. LowC, - ' 06. SemiLowH, - ' 07. SemiLowV, - ' 08. SemiLowC, - ' 09. RaisedH, - ' 10. RaisedV, - ' 11. RaisedC, - ' 12. OnVehicle, - ' 13. LineType, - ' 14. AvtiveVH, - ' 15. ActiveVV, - ' 16. ActiveVC - - - 'Bus - Try - - - Dim tbline As New TechListBenefitLine(_ssmInputs, - elements(2), - elements(0), - elements(1), - Double.Parse(elements(3), CultureInfo.InvariantCulture), - Double.Parse(elements(4), CultureInfo.InvariantCulture), - Double.Parse(elements(5), CultureInfo.InvariantCulture), - Double.Parse(elements(6), CultureInfo.InvariantCulture), - Double.Parse(elements(7), CultureInfo.InvariantCulture), - Double.Parse(elements(8), CultureInfo.InvariantCulture), - Double.Parse(elements(9), CultureInfo.InvariantCulture), - Double.Parse(elements(10), CultureInfo.InvariantCulture), - Double.Parse(elements(11), CultureInfo.InvariantCulture), - Boolean.Parse(elements(12)), - elements(13).ParseEnum(Of TechLineType)(), - Boolean.Parse(elements(14)), - Boolean.Parse(elements(15)), - Boolean.Parse(elements(16))) - - TechLines.Add(tbline) - - Catch ex As Exception - - 'Indicate problems - returnStatus = False - - End Try - - - Else - firstline = False - End If - Next line - End Using - - Else - returnStatus = False - End If - - Return returnStatus - End Function - - 'Public Properties - Outputs Of Class - Public ReadOnly Property CValueVariation As Double Implements ISSMTechList.CValueVariation - Get - Dim a As Double - - a = TechLines.Where(Function(x) x.Units.ToLower = "fraction").Sum(Function(s) s.C()) - - Return a - End Get - End Property - - Public ReadOnly Property CValueVariationKW As Double Implements ISSMTechList.CValueVariationKW - Get - - Dim a As Double - - a = TechLines.Where(Function(x) x.Units.ToLower = "kw").Sum(Function(s) s.C()) - - Return a - End Get - End Property - - Public ReadOnly Property HValueVariation As Double Implements ISSMTechList.HValueVariation - Get - - 'Dim a,b As double - Return TechLines.Where(Function(x) x.Units = "fraction").Sum(Function(s) s.H()) - ' a = - ' b = HValueVariationKW - ' Return a-b - End Get - End Property - - Public ReadOnly Property HValueVariationKW As Double Implements ISSMTechList.HValueVariationKW - Get - Return TechLines.Where(Function(x) x.Units.ToLower = "kw").Sum(Function(s) s.H()) - End Get - End Property - - Public ReadOnly Property VCValueVariation As Double Implements ISSMTechList.VCValueVariation - Get - Return TechLines.Where(Function(x) x.Units.ToLower = "fraction").Sum(Function(s) s.VC()) '- VCValueVariationKW - End Get - End Property - - Public ReadOnly Property VCValueVariationKW As Double Implements ISSMTechList.VCValueVariationKW - Get - Return TechLines.Where(Function(x) x.Units.ToLower = "kw").Sum(Function(s) s.VC()) - End Get - End Property - - Public ReadOnly Property VHValueVariation As Double Implements ISSMTechList.VHValueVariation - Get - 'Dim a,b As double - - Return TechLines.Where(Function(x) x.Units.ToLower = "fraction").Sum(Function(s) s.VH()) - 'a=TechLines.Where( Function(x) x.Units="fraction").Sum( Function(s) s.VH) - 'b=VHValueVariationKW - ' Return a-b - End Get - End Property - - Public ReadOnly Property VHValueVariationKW As Double Implements ISSMTechList.VHValueVariationKW - Get - Return TechLines.Where(Function(x) x.Units.ToLower = "kw").Sum(Function(s) s.VH()) - End Get - End Property - - Public ReadOnly Property VVValueVariation As Double Implements ISSMTechList.VVValueVariation - Get - Return TechLines.Where(Function(x) x.Units.ToLower = "fraction").Sum(Function(s) s.VV()) - End Get - End Property - - Public ReadOnly Property VVValueVariationKW As Double Implements ISSMTechList.VVValueVariationKW - Get - Return TechLines.Where(Function(x) x.Units.ToLower = "kw").Sum(Function(s) s.VV()) ' - VVValueVariationKW - End Get - End Property - - 'Member Management - Public Function Add(item As ITechListBenefitLine, ByRef feedback As String) As Boolean Implements ISSMTechList.Add - - Dim initialCount As Integer = TechLines.Count - - If TechLines.Where(Function(w) w.Category = item.Category AndAlso w.BenefitName = item.BenefitName).Count() > 0 Then - 'Failure - feedback = "Item already exists." - Return False - End If - - - Try - - TechLines.Add(item) - - If TechLines.Count = initialCount + 1 Then - - 'Success - feedback = "OK" - _dirty = True - Return True - - Else - - 'Failure - feedback = "The system was unable to add the new tech benefit list item." - Return False - - End If - - Catch ex As Exception - - feedback = "The system threw an exception and was unable to add the new tech benefit list item." - Return False - - End Try - End Function - - Public Sub Clear() Implements ISSMTechList.Clear - - If TechLines.Count > 0 Then _dirty = True - - TechLines.Clear() - End Sub - - Public Function Delete(item As ITechListBenefitLine, ByRef feedback As String) As Boolean _ - Implements ISSMTechList.Delete - - Dim currentCount As Integer = TechLines.Count - - If (TechLines.Where(Function(c) c.Category = item.Category AndAlso c.BenefitName = item.BenefitName).Count = 1) Then - - Try - TechLines.RemoveAt( - TechLines.FindIndex(Function(c) c.Category = item.Category AndAlso c.BenefitName = item.BenefitName)) - - If TechLines.Count = currentCount - 1 Then - 'This succeeded - _dirty = True - Return True - Else - 'No Exception, but this failed for some reason. - feedback = "The system was unable to remove the item from the list." - Return False - - End If - - Catch ex As Exception - - feedback = "An exception occured, the removal failed." - Return False - - End Try - - - Else - - feedback = "the item was not found in the list." - Return False - - End If - End Function - - Public Function Modify(originalItem As ITechListBenefitLine, newItem As ITechListBenefitLine, ByRef feedback As String) _ - As Boolean Implements ISSMTechList.Modify - - Dim fi As ITechListBenefitLine = - TechLines.Find(Function(f) (f.Category = originalItem.Category) AndAlso f.BenefitName = originalItem.BenefitName) - Dim originalUnits As String = fi.Units - - If (Not fi Is Nothing) Then - - Try - - fi.CloneFrom(newItem) - - 'The lines below are to assist in testing. The KW units are being excluded, but for benchmarking against the spreadsheet model - 'Two KW entries are left in. There is no provision for adding KW units in so we check if the original entry was KW and - 'force it back to KW if it was already so. There shoud be no need to remove this as newly created lists will not match this - 'Phenomenon. - If (originalUnits.ToLower = "kw") Then - fi.Units = originalUnits - newItem.Units = originalUnits - End If - - If newItem Is fi Then - 'This succeeded - _dirty = True - Return True - Else - 'No Exception, but this failed for some reason. - feedback = "The system was unable to remove the item from the list." - Return False - - End If - - Catch ex As Exception - - feedback = "An exception occured, the update failed." - Return False - - End Try - - - Else - - feedback = "the item was not found so cannot be modified." - Return False - - End If - End Function - -#Region "Default Values" - - Private Sub SetDefaults() - - Dim techLine1 As ITechListBenefitLine = New TechListBenefitLine(_ssmInputs) - With techLine1 - .Category = "Cooling" - .BenefitName = "Separate air distribution ducts" - .LowFloorH = 0 - .LowFloorC = 0.04 - .LowFloorV = 0.04 - .SemiLowFloorH = 0 - .SemiLowFloorC = 0.04 - .SemiLowFloorV = 0.04 - .RaisedFloorH = 0 - .RaisedFloorC = 0.04 - .RaisedFloorV = 0.04 - .ActiveVH = False - .ActiveVV = False - .ActiveVC = True - .OnVehicle = False - .Units = "fraction" - End With - - Dim techLine2 As ITechListBenefitLine = New TechListBenefitLine(_ssmInputs) - With techLine2 - .Category = "Heating" - .BenefitName = "Adjustable auxiliary heater" - .LowFloorH = 0.02 - .LowFloorC = 0 - .LowFloorV = 0.02 - .SemiLowFloorH = 0.02 - .SemiLowFloorC = 0 - .SemiLowFloorV = 0.02 - .RaisedFloorH = 0.02 - .RaisedFloorC = 0 - .RaisedFloorV = 0.02 - .ActiveVH = True - .ActiveVV = False - .ActiveVC = False - .OnVehicle = False - .Units = "fraction" - End With - - Dim techLine3 As ITechListBenefitLine = New TechListBenefitLine(_ssmInputs) - With techLine3 - .Category = "Heating" - .BenefitName = "Adjustable coolant thermostat" - .LowFloorH = 0.02 - .LowFloorC = 0 - .LowFloorV = 0.02 - .SemiLowFloorH = 0.02 - .SemiLowFloorC = 0 - .SemiLowFloorV = 0.02 - .RaisedFloorH = 0.02 - .RaisedFloorC = 0 - .RaisedFloorV = 0.02 - .ActiveVH = True - .ActiveVV = False - .ActiveVC = False - .OnVehicle = False - .Units = "fraction" - End With - - Dim techLine4 As ITechListBenefitLine = New TechListBenefitLine(_ssmInputs) - With techLine4 - .Category = "Heating" - .BenefitName = "Engine waste gas heat exchanger" - .LowFloorH = 0.04 - .LowFloorC = 0 - .LowFloorV = 0.04 - .SemiLowFloorH = 0 - .SemiLowFloorC = 0 - .SemiLowFloorV = 0 - .RaisedFloorH = 0 - .RaisedFloorC = 0 - .RaisedFloorV = 0 - .ActiveVH = True - .ActiveVV = False - .ActiveVC = False - .OnVehicle = False - .Units = "fraction" - End With - - Dim techLine5 As ITechListBenefitLine = New TechListBenefitLine(_ssmInputs) - With techLine5 - .Category = "Heating" - .BenefitName = "Heat pump systems" - .LowFloorH = 0.06 - .LowFloorC = 0 - .LowFloorV = 0.06 - .SemiLowFloorH = 0.04 - .SemiLowFloorC = 0 - .SemiLowFloorV = 0.04 - .RaisedFloorH = 0.04 - .RaisedFloorC = 0 - .RaisedFloorV = 0.04 - .ActiveVH = True - .ActiveVV = False - .ActiveVC = False - .OnVehicle = False - .Units = "fraction" - End With - - Dim techLine6 As ITechListBenefitLine = New TechListBenefitLine(_ssmInputs) - With techLine6 - .Category = "Insulation" - .BenefitName = "Double-glazing" - .LowFloorH = 0.04 - .LowFloorC = 0.04 - .LowFloorV = 0.04 - .SemiLowFloorH = 0.04 - .SemiLowFloorC = 0.04 - .SemiLowFloorV = 0.04 - .RaisedFloorH = 0.04 - .RaisedFloorC = 0.04 - .RaisedFloorV = 0.04 - .ActiveVH = True - .ActiveVV = True - .ActiveVC = True - .OnVehicle = False - .Units = "fraction" - End With - - Dim techLine7 As ITechListBenefitLine = New TechListBenefitLine(_ssmInputs) - With techLine7 - .Category = "Insulation" - .BenefitName = "Tinted windows" - .LowFloorH = 0 - .LowFloorC = 0 - .LowFloorV = 0 - .SemiLowFloorH = 0 - .SemiLowFloorC = 0 - .SemiLowFloorV = 0 - .RaisedFloorH = 0 - .RaisedFloorC = 0 - .RaisedFloorV = 0 - .ActiveVH = False - .ActiveVV = False - .ActiveVC = False - .OnVehicle = False - .Units = "fraction" - End With - - Dim techLine8 As ITechListBenefitLine = New TechListBenefitLine(_ssmInputs) - With techLine8 - .Category = "Ventilation" - .BenefitName = "Fan control strategy (serial/parallel)" - .LowFloorH = 0.02 - .LowFloorC = 0.02 - .LowFloorV = 0.02 - .SemiLowFloorH = 0.02 - .SemiLowFloorC = 0.02 - .SemiLowFloorV = 0.02 - .RaisedFloorH = 0.02 - .RaisedFloorC = 0.02 - .RaisedFloorV = 0.02 - .ActiveVH = True - .ActiveVV = True - .ActiveVC = True - .OnVehicle = False - .Units = "fraction" - .LineType = TechLineType.HVCActiveSelection - End With - - Dim feedback As String = String.Empty - Add(techLine1, feedback) - Add(techLine2, feedback) - Add(techLine3, feedback) - Add(techLine4, feedback) - Add(techLine5, feedback) - Add(techLine6, feedback) - Add(techLine7, feedback) - Add(techLine8, feedback) - End Sub - -#End Region - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/TechListBenefitLine.vb b/VECTOAux/VectoAuxiliaries/Hvac/TechListBenefitLine.vb deleted file mode 100644 index 9fda90d03d53b1f2dc48197599441889089e3c63..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Hvac/TechListBenefitLine.vb +++ /dev/null @@ -1,308 +0,0 @@ - -Imports DownstreamModules.HVAC - -Namespace Hvac - - - Public Enum PowerType - - Mechanical - Electrical - End Enum - - 'Used by SSMTOOL Class, refer to original spreadsheet model - 'Or PDF Model Document which articulates the same spreadsheet functionality - 'But within the context of the Vecto interpretation of the same. - Public Class TechListBenefitLine - Implements ITechListBenefitLine - - Private _h, _vh, _vv, _vc, _c As Single - Public inputSheet As ISSMGenInputs - - Public Property Units As String Implements ITechListBenefitLine.Units - Public Property Category As String Implements ITechListBenefitLine.Category - Public Property BenefitName As String Implements ITechListBenefitLine.BenefitName - Public Property LowFloorH As New Double Implements ITechListBenefitLine.LowFloorH - Public Property LowFloorV As New Double Implements ITechListBenefitLine.LowFloorV - Public Property LowFloorC As New Double Implements ITechListBenefitLine.LowFloorC - - Public Property SemiLowFloorH As New Double Implements ITechListBenefitLine.SemiLowFloorH - Public Property SemiLowFloorV As New Double Implements ITechListBenefitLine.SemiLowFloorV - Public Property SemiLowFloorC As New Double Implements ITechListBenefitLine.SemiLowFloorC - - Public Property RaisedFloorH As New Double Implements ITechListBenefitLine.RaisedFloorH - Public Property RaisedFloorV As New Double Implements ITechListBenefitLine.RaisedFloorV - Public Property RaisedFloorC As New Double Implements ITechListBenefitLine.RaisedFloorC - - Public Property OnVehicle As Boolean Implements ITechListBenefitLine.OnVehicle - Public Property ActiveVH As Boolean Implements ITechListBenefitLine.ActiveVH - Public Property ActiveVV As Boolean Implements ITechListBenefitLine.ActiveVV - Public Property ActiveVC As Boolean Implements ITechListBenefitLine.ActiveVC - Public Property LineType As TechLineType Implements ITechListBenefitLine.LineType - - Public ReadOnly Property H As Double Implements ITechListBenefitLine.H - Get - - Dim returnValue As Double = 0 - - '=IF($M49=0,0,IF(AND($M49=1,'INPUT & RESULTS SHEET'!$D$6="low floor"),'TECH LIST INPUT'!D49, IF(AND($M49=1,'INPUT & RESULTS SHEET'!$D$6="semi low floor"),'TECH LIST INPUT'!G49,'TECH LIST INPUT'!J49))) - If Not OnVehicle Then Return returnValue - - Select Case inputSheet.BP_BusFloorType - Case "low floor" - returnValue = LowFloorH - Case "semi low floor" - returnValue = SemiLowFloorH - Case "raised floor" - returnValue = RaisedFloorH - End Select - - Return returnValue - End Get - End Property - - Public ReadOnly Property VH As Double Implements ITechListBenefitLine.VH - Get - - Dim floorValue As Double = 0 - - If Not OnVehicle Then Return floorValue - - 'Get floor value - Select Case inputSheet.BP_BusFloorType - Case "low floor" - floorValue = LowFloorV - Case "semi low floor" - floorValue = SemiLowFloorV - Case "raised floor" - floorValue = RaisedFloorV - End Select - - - 'Active - If ActiveVH Then ' TechLineType.HVCActiveSelection AndAlso - Return floorValue - Else - Return 0 - End If - End Get - End Property - - Public ReadOnly Property VV As Double Implements ITechListBenefitLine.VV - Get - - Dim floorValue As Double = 0 - - If Not OnVehicle Then Return floorValue - - 'Get floor value - Select Case inputSheet.BP_BusFloorType - Case "low floor" - floorValue = LowFloorV - Case "semi low floor" - floorValue = SemiLowFloorV - Case "raised floor" - floorValue = RaisedFloorV - End Select - - - 'Active - If ActiveVV Then ' TechLineType.HVCActiveSelection AndAlso - Return floorValue - Else - Return 0 - End If - End Get - End Property - - Public ReadOnly Property VC As Double Implements ITechListBenefitLine.VC - Get - - Dim floorValue As Double = 0 - - If Not OnVehicle Then Return floorValue - - 'Get floor value - Select Case inputSheet.BP_BusFloorType - Case "low floor" - floorValue = LowFloorV - Case "semi low floor" - floorValue = SemiLowFloorV - Case "raised floor" - floorValue = RaisedFloorV - End Select - - - 'Active - If ActiveVC Then ' TechLineType.HVCActiveSelection AndAlso - Return floorValue - Else - Return 0 - End If - End Get - End Property - - Public ReadOnly Property C As Double Implements ITechListBenefitLine.C - Get - - Dim returnValue As Double = 0 - - - If Not OnVehicle Then Return returnValue - - Select Case inputSheet.BP_BusFloorType - Case "low floor" - returnValue = LowFloorC - Case "semi low floor" - returnValue = SemiLowFloorC - Case "raised floor" - returnValue = RaisedFloorC - End Select - - Return returnValue - End Get - End Property - - Sub New() - End Sub - - Sub New(geninputs As ISSMGenInputs) - - Me.inputSheet = geninputs - End Sub - - Sub New(geninputs As ISSMGenInputs, - units As String, - category As String, - benefitName As String, - lowFloorH As Double, - lowFloorV As Double, - lowFloorC As Double, - semiLowFloorH As Double, - semiLowFloorV As Double, - semiLowFloorC As Double, - raisedFloorH As Double, - raisedFloorV As Double, - raisedFloorC As Double, - onVehicle As Boolean, - lineType As TechLineType, - activeVH As Boolean, - activeVV As Boolean, - activeVC As Boolean - ) - - Me.inputSheet = geninputs - Me.Units = Units - Me.category = category - Me.benefitName = benefitName - Me.lowFloorH = lowFloorH - Me.lowFloorV = lowFloorV - Me.lowFloorC = lowFloorC - Me.semiLowFloorH = semiLowFloorH - Me.semiLowFloorV = semiLowFloorV - Me.semiLowFloorC = semiLowFloorC - Me.raisedFloorH = raisedFloorH - Me.raisedFloorV = raisedFloorV - Me.raisedFloorC = raisedFloorC - Me.OnVehicle = onVehicle - Me.lineType = lineType - Me.ActiveVH = activeVH - Me.ActiveVV = activeVV - Me.ActiveVC = activeVC - End Sub - - 'Operator Overloads - Public Shared Operator =(ByVal op1 As TechListBenefitLine, ByVal op2 As TechListBenefitLine) As Boolean - - If (op1.Category = op2.Category AndAlso - op1.BenefitName = op2.BenefitName AndAlso - op1.ActiveVC = op2.ActiveVC AndAlso - op1.ActiveVH = op2.ActiveVH AndAlso - op1.ActiveVV = op2.ActiveVV AndAlso - op1.LineType = op2.LineType AndAlso - op1.LowFloorC = op2.LowFloorC AndAlso - op1.LowFloorV = op2.LowFloorV AndAlso - op1.LowFloorH = op2.LowFloorH AndAlso - op1.SemiLowFloorC = op2.SemiLowFloorC AndAlso - op1.SemiLowFloorH = op2.SemiLowFloorH AndAlso - op1.SemiLowFloorV = op2.SemiLowFloorV AndAlso - op1.RaisedFloorC = op2.RaisedFloorC AndAlso - op1.RaisedFloorH = op2.RaisedFloorH AndAlso - op1.RaisedFloorV = op2.RaisedFloorV AndAlso - op1.OnVehicle = op2.OnVehicle AndAlso - op1.Units = op2.Units) Then - - Return True - - Else - - Return False - - End If - End Operator - - Public Shared Operator <>(ByVal op1 As TechListBenefitLine, ByVal op2 As TechListBenefitLine) As Boolean - - If (op1.Category <> op2.Category OrElse - op1.BenefitName <> op2.BenefitName OrElse - op1.ActiveVC <> op2.ActiveVC OrElse - op1.ActiveVH <> op2.ActiveVH OrElse - op1.ActiveVV <> op2.ActiveVV OrElse - op1.LineType <> op2.LineType OrElse - op1.LowFloorC <> op2.LowFloorC OrElse - op1.LowFloorV <> op2.LowFloorV OrElse - op1.LowFloorH <> op2.LowFloorH OrElse - op1.SemiLowFloorC <> op2.SemiLowFloorC OrElse - op1.SemiLowFloorH <> op2.SemiLowFloorH OrElse - op1.SemiLowFloorV <> op2.SemiLowFloorV OrElse - op1.RaisedFloorC <> op2.RaisedFloorC OrElse - op1.RaisedFloorH <> op2.RaisedFloorH OrElse - op1.RaisedFloorV <> op2.RaisedFloorV OrElse - op1.OnVehicle <> op2.OnVehicle OrElse - op1.Units <> op2.Units) Then - - Return True - - Else - - Return False - - End If - End Operator - - Public Sub CloneFrom(source As ITechListBenefitLine) Implements ITechListBenefitLine.CloneFrom - - - Me.Units = source.Units - Me.Category = source.Category - Me.BenefitName = source.BenefitName - Me.LowFloorH = source.LowFloorH - Me.LowFloorV = source.LowFloorV - Me.LowFloorC = source.LowFloorC - - Me.SemiLowFloorH = source.SemiLowFloorH - Me.SemiLowFloorV = source.SemiLowFloorV - Me.SemiLowFloorC = source.SemiLowFloorC - - Me.RaisedFloorH = source.RaisedFloorH - Me.RaisedFloorV = source.RaisedFloorV - Me.RaisedFloorC = source.RaisedFloorC - - Me.OnVehicle = source.OnVehicle - Me.ActiveVH = source.ActiveVH - Me.ActiveVV = source.ActiveVV - Me.ActiveVC = source.ActiveVC - Me.LineType = source.LineType - End Sub - - Public Function IsEqualTo(source As ITechListBenefitLine) As Boolean Implements ITechListBenefitLine.IsEqualTo - Dim mySource As TechListBenefitLine = CType(source, TechListBenefitLine) - If mySource Is Nothing Then - Return False - End If - Return Me = mySource - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/CompressorMap.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/CompressorMap.vb deleted file mode 100644 index efb1a494cce30b5e1486d7d0706d91d87c9b03d5..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/CompressorMap.vb +++ /dev/null @@ -1,262 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - -Imports System.Globalization -Imports System.IO -Imports Pneumatics -Imports TUGraz.VectoCommon.Utils -Imports TUGraz.VectoCore.BusAuxiliaries.Interfaces - -Namespace Pneumatics - ''' <summary> - ''' Compressor Flow Rate and Power Map - ''' </summary> - ''' <remarks></remarks> - Public Class CompressorMap - Implements ICompressorMap, - IAuxiliaryEvent - - Private ReadOnly filePath As String - Private _averagePowerDemandPerCompressorUnitFlowRateLitresperSec As Double - Private _MapBoundariesExceeded As Boolean - - ''' <summary> - ''' Dictionary of values keyed by the rpm valaues in the csv file - ''' Values are held as a tuple as follows - ''' Item1 = flow rate - ''' Item2 - power [compressor on] - ''' Item3 - power [compressor off] - ''' </summary> - ''' <remarks></remarks> - Private map As Dictionary(Of Integer, CompressorMapValues) - - 'Returns the AveragePowerDemand per unit flow rate in seconds. - Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Double _ - Implements ICompressorMap.GetAveragePowerDemandPerCompressorUnitFlowRate - - Return _averagePowerDemandPerCompressorUnitFlowRateLitresperSec - End Function - - - ''' <summary> - ''' Creates a new instance of the CompressorMap class - ''' </summary> - ''' <param name="path">full path to csv data file</param> - ''' <remarks></remarks> - Public Sub New(ByVal path As String) - filePath = path - End Sub - - ''' <summary> - ''' Initilaises the map from the supplied csv data - ''' </summary> - ''' <remarks></remarks> - Public Function Initialise() As Boolean Implements ICompressorMap.Initialise - - If File.Exists(filePath) Then - Using sr As StreamReader = New StreamReader(filePath) - 'get array of lines from 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.Length < 3 Then Throw New ArgumentException("Insufficient rows in csv to build a usable map") - - map = New Dictionary(Of Integer, CompressorMapValues)() - 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() {","c}, StringSplitOptions.RemoveEmptyEntries) - '4 entries per line required - If (elements.Length <> 4) Then Throw New ArgumentException("Incorrect number of values in csv file") - 'add values to map - Try - map.Add(Integer.Parse(elements(0)), - New CompressorMapValues(Double.Parse(elements(1), CultureInfo.InvariantCulture).SI(Of NormLiterPerSecond), - Double.Parse(elements(2), CultureInfo.InvariantCulture).SI(Of Watt), - Double.Parse(elements(3), CultureInfo.InvariantCulture).SI(Of Watt))) - Catch fe As FormatException - Throw New InvalidCastException(String.Format("Compresor Map: line '{0}", line), fe) - End Try - Else - firstline = False - End If - Next - End Using - - '********************************************************************* - 'Calculate the Average Power Demand Per Compressor Unit FlowRate / per second. - Dim powerDividedByFlowRateSum As Double = 0 - For Each speed As KeyValuePair(Of Integer, CompressorMapValues) In map - powerDividedByFlowRateSum += (speed.Value.PowerCompressorOn - speed.Value.PowerCompressorOff).Value() / - speed.Value.FlowRate.Value() - Next - - 'Map in Litres Per Minute, so * 60 to get per second, calculated only once at initialisation. - _averagePowerDemandPerCompressorUnitFlowRateLitresperSec = (powerDividedByFlowRateSum / map.Count) * 60 - '********************************************************************** - - Else - Throw New ArgumentException("supplied input file does not exist") - End If - - 'If we get here then all should be well and we can return a True value of success. - Return True - End Function - - ''' <summary> - ''' Returns compressor flow rate at the given rotation speed - ''' </summary> - ''' <param name="rpm">compressor rotation speed</param> - ''' <returns></returns> - ''' <remarks>Single</remarks> - Public Function GetFlowRate(ByVal rpm As Double) As NormLiterPerSecond Implements ICompressorMap.GetFlowRate - Dim val As CompressorMapValues = InterpolatedTuple(rpm) - Return val.FlowRate - End Function - - ''' <summary> - ''' Returns mechanical power at rpm when compressor is on - ''' </summary> - ''' <param name="rpm">compressor rotation speed</param> - ''' <returns></returns> - ''' <remarks>Single</remarks> - Public Function GetPowerCompressorOn(ByVal rpm As Double) As Watt Implements ICompressorMap.GetPowerCompressorOn - Dim val As CompressorMapValues = InterpolatedTuple(rpm) - Return val.PowerCompressorOn - End Function - - ''' <summary> - ''' Returns mechanical power at rpm when compressor is off - ''' </summary> - ''' <param name="rpm">compressor rotation speed</param> - ''' <returns></returns> - ''' <remarks>Single</remarks> - Public Function GetPowerCompressorOff(ByVal rpm As Double) As Watt Implements ICompressorMap.GetPowerCompressorOff - Dim val As CompressorMapValues = InterpolatedTuple(rpm) - Return val.PowerCompressorOff - End Function - - ''' <summary> - ''' Returns an instance of CompressorMapValues containing the values at a key, or interpolated values - ''' </summary> - ''' <returns>CompressorMapValues</returns> - ''' <remarks>Throws exception if rpm are outside map</remarks> - Private Function InterpolatedTuple(ByVal rpm As Double) As CompressorMapValues - '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 - If Not _MapBoundariesExceeded Then - OnMessage(Me, - String.Format("Compresser : limited RPM of '{2}' to extent of map - map range is {0} to {1}", min, max, rpm), - AdvancedAuxiliaryMessageType.Warning) - _MapBoundariesExceeded = True - End If - - 'Limiting as agreed. - If rpm > max Then rpm = max - If rpm < min Then rpm = min - - End If - - 'If supplied rpm is a key, we can just return the appropriate tuple - Dim intRpm As Integer = CType(rpm, Integer) - If rpm.IsEqual(intRpm) AndAlso map.ContainsKey(intRpm) Then - Return map(intRpm) - End If - - 'Not a key value, interpolate - 'get the entries before and after the supplied rpm - Dim pre As KeyValuePair(Of Integer, CompressorMapValues) = (From m In map Where m.Key < rpm Select m).Last() - Dim post As KeyValuePair(Of Integer, CompressorMapValues) = (From m In map Where m.Key > rpm Select m).First() - - 'get the delta values for rpm and the map values - Dim dRpm As Double = post.Key - pre.Key - Dim dFlowRate As NormLiterPerSecond = post.Value.FlowRate - pre.Value.FlowRate - Dim dPowerOn As Watt = post.Value.PowerCompressorOn - pre.Value.PowerCompressorOn - Dim dPowerOff As Watt = post.Value.PowerCompressorOff - pre.Value.PowerCompressorOff - - 'calculate the slopes - Dim flowSlope As Double = dFlowRate.Value() / dRpm - Dim powerOnSlope As Double = dPowerOn.Value() / dRpm - Dim powerOffSlope As Double = dPowerOff.Value() / dRpm - - 'calculate the new values - Dim flowRate As NormLiterPerSecond = (((rpm - pre.Key) * flowSlope).SI(Of NormLiterPerSecond)() + pre.Value.FlowRate) - Dim powerCompressorOn As Watt = (((rpm - pre.Key) * powerOnSlope).SI(Of Watt)() + pre.Value.PowerCompressorOn) - Dim powerCompressorOff As Watt = (((rpm - pre.Key) * powerOffSlope).SI(Of Watt)() + pre.Value.PowerCompressorOff) - - 'Build and return a new CompressorMapValues instance - Return New CompressorMapValues(flowRate, powerCompressorOn, powerCompressorOff) - End Function - - ''' <summary> - ''' Encapsulates compressor map values - ''' Flow Rate - ''' Power - Compressor On - ''' Power - Compressor Off - ''' </summary> - ''' <remarks></remarks> - ''' - - Private Structure CompressorMapValues - ''' <summary> - ''' Compressor flowrate - ''' </summary> - ''' <remarks></remarks> - Public ReadOnly FlowRate As NormLiterPerSecond - - ''' <summary> - ''' Power, compressor on - ''' </summary> - ''' <remarks></remarks> - Public ReadOnly PowerCompressorOn As Watt - - ''' <summary> - ''' Power compressor off - ''' </summary> - ''' <remarks></remarks> - Public ReadOnly PowerCompressorOff As Watt - - ''' <summary> - ''' Creates a new instance of CompressorMapValues - ''' </summary> - ''' <param name="flowRate">flow rate</param> - ''' <param name="powerCompressorOn">power - compressor on</param> - ''' <param name="powerCompressorOff">power - compressor off</param> - ''' <remarks></remarks> - Public Sub New(ByVal flowRate As NormLiterPerSecond, ByVal powerCompressorOn As Watt, - ByVal powerCompressorOff As Watt) - Me.FlowRate = flowRate - Me.PowerCompressorOn = powerCompressorOn - Me.PowerCompressorOff = powerCompressorOff - End Sub - End Structure - - - Public Event Message(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) _ - Implements IAuxiliaryEvent.AuxiliaryEvent - - Private Sub OnMessage(sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) - - - If Not message Is Nothing Then - - RaiseEvent Message(Me, message, messageType) - - End If - End Sub - End Class -End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticActuationsMap.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticActuationsMap.vb deleted file mode 100644 index 2d15d9a9727bb6f15909d9eb2561781d662cde9a..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticActuationsMap.vb +++ /dev/null @@ -1,102 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - -Imports System.Globalization -Imports System.IO -Imports Pneumatics - -Namespace Pneumatics - Public Class PneumaticActuationsMAP - Implements IPneumaticActuationsMAP - - Private map As Dictionary(Of ActuationsKey, Integer) - Private filePath As String - - - Public Function GetNumActuations(key As ActuationsKey) As Integer Implements IPneumaticActuationsMAP.GetNumActuations - - If map Is Nothing OrElse Not map.ContainsKey(key) Then - Throw _ - New ArgumentException(String.Format("Pneumatic Actuations map does not contain the key '{0}'.", - key.CycleName & ":" & key.ConsumerName)) - End If - - Return map(key) - End Function - - - Public Sub New(filePath As String) - - Me.filePath = filePath - - If filePath.Trim.Length = 0 Then _ - Throw New ArgumentException("A filename for the Pneumatic Actuations Map has not been supplied") - - Initialise() - End Sub - - Public Function Initialise() As Boolean Implements IPneumaticActuationsMAP.Initialise - - Dim newKey As ActuationsKey - Dim numActuations As Integer - - If File.Exists(filePath) Then - Using sr As StreamReader = New StreamReader(filePath) - 'get array of lines from 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.Length < 3 Then _ - Throw _ - New ArgumentException("Pneumatic Actuations Map does not have sufficient rows in file to build a usable map") - - map = New Dictionary(Of ActuationsKey, Integer)() - 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() {","c}, StringSplitOptions.RemoveEmptyEntries) - '3 entries per line required - If (elements.Length <> 3) Then _ - Throw New ArgumentException("Pneumatic Actuations Map has Incorrect number of values in file") - - 'add values to map - - - If Not Integer.TryParse(elements(2), numActuations) Then - Throw New ArgumentException("Pneumatic Actuations Map Contains Non Integer values in actuations column") - End If - - 'Should throw exception if ConsumerName or CycleName are empty. - newKey = New ActuationsKey(elements(0).ToString(), elements(1).ToString()) - - map.Add(newKey, Integer.Parse(elements(2), CultureInfo.InvariantCulture)) - - Else - firstline = False - End If - Next - End Using - - - Else - Throw New ArgumentException(String.Format(" Pneumatic Acutations map '{0}' supplied does not exist", filePath)) - End If - - 'If we get here then all should be well and we can return a True value of success. - Return True - End Function - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticUserInputsConfig.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticUserInputsConfig.vb deleted file mode 100644 index e5722d574978ab979e5053e24587dedb15b08526..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticUserInputsConfig.vb +++ /dev/null @@ -1,60 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. -Imports Pneumatics - -Namespace Pneumatics - Public Class PneumaticUserInputsConfig - Implements IPneumaticUserInputsConfig - - Public Property CompressorMap As String Implements IPneumaticUserInputsConfig.CompressorMap - Public Property CompressorGearRatio As Double Implements IPneumaticUserInputsConfig.CompressorGearRatio - Public Property CompressorGearEfficiency As Double Implements IPneumaticUserInputsConfig.CompressorGearEfficiency - - 'pnmeumatic or electric - Public Property AdBlueDosing As String Implements IPneumaticUserInputsConfig.AdBlueDosing - - 'mechanical or electrical - Public Property AirSuspensionControl As String Implements IPneumaticUserInputsConfig.AirSuspensionControl - - 'pneumatic or electric - Public Property Doors As String Implements IPneumaticUserInputsConfig.Doors - Public Property KneelingHeightMillimeters As Double Implements IPneumaticUserInputsConfig.KneelingHeightMillimeters - - 'PneumaticActuationsMap - Public Property ActuationsMap As String Implements IPneumaticUserInputsConfig.ActuationsMap - - Public Property RetarderBrake As Boolean Implements IPneumaticUserInputsConfig.RetarderBrake - Public Property SmartAirCompression As Boolean Implements IPneumaticUserInputsConfig.SmartAirCompression - Public Property SmartRegeneration As Boolean Implements IPneumaticUserInputsConfig.SmartRegeneration - - Public Sub New(Optional setToDefaults As Boolean = False) - - If setToDefaults Then SetPropertiesToDefaults() - End Sub - - Public Sub SetPropertiesToDefaults() - - CompressorMap = String.Empty - CompressorGearRatio = 1.0 - CompressorGearEfficiency = 0.97 - AdBlueDosing = "Pneumatic" - AirSuspensionControl = "Mechanically" - Doors = "Pneumatic" - KneelingHeightMillimeters = 70 - ActuationsMap = Nothing - RetarderBrake = True - SmartAirCompression = False - SmartRegeneration = False - End Sub - End Class -End Namespace - - diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticsAuxilliariesConfig.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticsAuxilliariesConfig.vb deleted file mode 100644 index 43353ff6fbd9de0cfe598f64d834bfd2bd8614ef..0000000000000000000000000000000000000000 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticsAuxilliariesConfig.vb +++ /dev/null @@ -1,71 +0,0 @@ -' Copyright 2017 European Union. -' Licensed under the EUPL (the 'Licence'); -' -' * You may not use this work except in compliance with the Licence. -' * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl -' * Unless required by applicable law or agreed to in writing, -' software distributed under the Licence is distributed on an "AS IS" basis, -' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -' -' See the LICENSE.txt for the specific language governing permissions and limitations. - -Namespace Pneumatics - Public Class PneumaticsAuxilliariesConfig - Implements IPneumaticsAuxilliariesConfig - - Public Property AdBlueNIperMinute As Double Implements IPneumaticsAuxilliariesConfig.AdBlueNIperMinute - - Public Property AirControlledSuspensionNIperMinute As Double _ - Implements IPneumaticsAuxilliariesConfig.AirControlledSuspensionNIperMinute - - Public Property BrakingNoRetarderNIperKG As Double Implements IPneumaticsAuxilliariesConfig.BrakingNoRetarderNIperKG - - Public Property BrakingWithRetarderNIperKG As Double _ - Implements IPneumaticsAuxilliariesConfig.BrakingWithRetarderNIperKG - - Public Property BreakingPerKneelingNIperKGinMM As Double _ - Implements IPneumaticsAuxilliariesConfig.BreakingPerKneelingNIperKGinMM - - Public Property DeadVolBlowOutsPerLitresperHour As Double _ - Implements IPneumaticsAuxilliariesConfig.DeadVolBlowOutsPerLitresperHour - - Public Property DeadVolumeLitres As Double Implements IPneumaticsAuxilliariesConfig.DeadVolumeLitres - - Public Property NonSmartRegenFractionTotalAirDemand As Double _ - Implements IPneumaticsAuxilliariesConfig.NonSmartRegenFractionTotalAirDemand - - Public Property OverrunUtilisationForCompressionFraction As Double _ - Implements IPneumaticsAuxilliariesConfig.OverrunUtilisationForCompressionFraction - - Public Property PerDoorOpeningNI As Double Implements IPneumaticsAuxilliariesConfig.PerDoorOpeningNI - - Public Property PerStopBrakeActuationNIperKG As Double _ - Implements IPneumaticsAuxilliariesConfig.PerStopBrakeActuationNIperKG - - Public Property SmartRegenFractionTotalAirDemand As Double _ - Implements IPneumaticsAuxilliariesConfig.SmartRegenFractionTotalAirDemand - - - Public Sub New(Optional setToDefaults As Boolean = False) - - If setToDefaults Then SetDefaults() - End Sub - - Public Sub SetDefaults() - AdBlueNIperMinute = 21.25 - AirControlledSuspensionNIperMinute = 15 - BrakingNoRetarderNIperKG = 0.00081 - BrakingWithRetarderNIperKG = 0.0006 - BreakingPerKneelingNIperKGinMM = 0.000066 - DeadVolBlowOutsPerLitresperHour = 24 - DeadVolumeLitres = 30 - NonSmartRegenFractionTotalAirDemand = 0.26 - OverrunUtilisationForCompressionFraction = 0.97 - PerDoorOpeningNI = 12.7 - PerStopBrakeActuationNIperKG = 0.00064 - SmartRegenFractionTotalAirDemand = 0.12 - End Sub - End Class -End Namespace - -