From ed459dea2429ed09e8a7f22c0783327e2f95bc48 Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Thu, 16 Jun 2016 13:20:59 +0200 Subject: [PATCH] re-add Padd in fPaux (after merge with aaux code from ricardo) [+code formatting] --- VECTO/Input Files/cVECTO.vb | 1366 ++++++++--------- VECTO/MODcalc/cPower.vb | 8 +- .../UnitTests/M6Tests.vb | 223 ++- 3 files changed, 780 insertions(+), 817 deletions(-) diff --git a/VECTO/Input Files/cVECTO.vb b/VECTO/Input Files/cVECTO.vb index f4746dc0a5..266912af5d 100644 --- a/VECTO/Input Files/cVECTO.vb +++ b/VECTO/Input Files/cVECTO.vb @@ -12,868 +12,848 @@ Imports System.Collections.Generic Public Class cVECTO + Private Const FormatVersion As Short = 2 + Private FileVersion As Short - Private Const FormatVersion As Short = 2 - Private FileVersion As Short + 'AA-TB + 'STORES THE Type and version of the chosen or default Auxiliary Type ( Classic/Original or other ) + Public AuxiliaryAssembly As String + Public AuxiliaryVersion As String + Public AdvancedAuxiliaryFilePath As String - 'AA-TB - 'STORES THE Type and version of the chosen or default Auxiliary Type ( Classic/Original or other ) - public AuxiliaryAssembly As String - public AuxiliaryVersion As String - Public AdvancedAuxiliaryFilePath As String - - Private sFilePath As String + Private sFilePath As String - Private MyPath As String + Private MyPath As String - 'Input parameters - Private stPathVEH As cSubPath - Private stPathENG As cSubPath - Private stPathGBX As cSubPath + 'Input parameters + Private stPathVEH As cSubPath + Private stPathENG As cSubPath + Private stPathGBX As cSubPath - Private boStartStop As Boolean - Private siStStV As Single - Private siStStT As Single - Public StStDelay As Integer + Private boStartStop As Boolean + Private siStStV As Single + Private siStStT As Single + Public StStDelay As Integer - Private stDesMaxFile As cSubPath - Private laDesV As List(Of Single) - Private laDesMax As List(Of Single) - Private laDesMin As List(Of Single) - Private DesMaxDim As Integer + Private stDesMaxFile As cSubPath + Private laDesV As List(Of Single) + Private laDesMax As List(Of Single) + Private laDesMin As List(Of Single) + Private DesMaxDim As Integer - Public AuxPaths As Dictionary(Of String, cAuxEntry) - Public AuxRefs As Dictionary(Of String, cAux) 'Alle Nebenverbraucher die in der Veh-Datei UND im Zyklus definiert sind - Public AuxDef As Boolean 'True wenn ein oder mehrere Nebenverbraucher definiert sind - Public EStechs As List(Of String) + Public AuxPaths As Dictionary(Of String, cAuxEntry) + Public AuxRefs As Dictionary(Of String, cAux) _ + 'Alle Nebenverbraucher die in der Veh-Datei UND im Zyklus definiert sind + Public AuxDef As Boolean 'True wenn ein oder mehrere Nebenverbraucher definiert sind + Public EStechs As List(Of String) - Public CycleFiles As List(Of cSubPath) + Public CycleFiles As List(Of cSubPath) - Public EngOnly As Boolean + Public EngOnly As Boolean - Public a_lookahead As Single - Public vMin As Single - Public vMinLA As Single - Public LookAheadOn As Boolean - Public OverSpeedOn As Boolean - Public OverSpeed As Single - Public UnderSpeed As Single - Public EcoRollOn As Boolean + Public a_lookahead As Single + Public vMin As Single + Public vMinLA As Single + Public LookAheadOn As Boolean + Public OverSpeedOn As Boolean + Public OverSpeed As Single + Public UnderSpeed As Single + Public EcoRollOn As Boolean - Private MyFileList As List(Of String) + Private MyFileList As List(Of String) - Public SavedInDeclMode As Boolean + Public SavedInDeclMode As Boolean - Public Class cAuxEntry - Public Type As String - Public Path As cSubPath - Public TechStr As String = "" + Public Class cAuxEntry + Public Type As String + Public Path As cSubPath + Public TechStr As String = "" - Public Sub New() - Path = New cSubPath - End Sub + Public Sub New() + Path = New cSubPath + End Sub + End Class - End Class + Public Function CreateFileList() As Boolean + Dim Aux0 As cAuxEntry + Dim sb As cSubPath + Dim str As String - Public Function CreateFileList() As Boolean - Dim Aux0 As cAuxEntry - Dim sb As cSubPath - Dim str As String + MyFileList = New List(Of String) - MyFileList = New List(Of String) + '.vecto + MyFileList.Add(Me.sFilePath) - '.vecto - MyFileList.Add(Me.sFilePath) + 'Veh + If Not Me.EngOnly Then + MyFileList.Add(Me.PathVEH) - 'Veh - If Not Me.EngOnly Then - MyFileList.Add(Me.PathVEH) + If Not VEH.CreateFileList Then Return False + For Each str In VEH.FileList + MyFileList.Add(str) + Next + End If - If Not VEH.CreateFileList Then Return False - For Each str In VEH.FileList - MyFileList.Add(str) - Next - End If + 'Eng + MyFileList.Add(Me.PathENG) - 'Eng - MyFileList.Add(Me.PathENG) + If Not ENG.CreateFileList Then Return False + For Each str In ENG.FileList + MyFileList.Add(str) + Next + + If Not Me.EngOnly Then + + 'Gbx + MyFileList.Add(Me.PathGBX) + + If Not GBX.CreateFileList Then Return False + For Each str In GBX.FileList + MyFileList.Add(str) + Next + + 'Aux + If AuxDef And Not Cfg.DeclMode Then + For Each Aux0 In Me.AuxPaths.Values + MyFileList.Add(Aux0.Path.FullPath) + Next + End If + + '.vacc + MyFileList.Add(Me.stDesMaxFile.FullPath) + + End If + + 'Cycles + For Each sb In Me.CycleFiles + MyFileList.Add(sb.FullPath) + Next + + + Return True + End Function + + Public Sub New() + + MyPath = "" + sFilePath = "" + + stPathVEH = New cSubPath + stPathENG = New cSubPath + stPathGBX = New cSubPath + + stDesMaxFile = New cSubPath + + laDesV = New List(Of Single) + laDesMax = New List(Of Single) + laDesMin = New List(Of Single) + + AuxPaths = New Dictionary(Of String, cAuxEntry) + AuxRefs = New Dictionary(Of String, cAux) + AuxDef = False + EStechs = New List(Of String) + + CycleFiles = New List(Of cSubPath) + End Sub + + Public Function SaveFile() As Boolean + Dim AuxEntryKV As KeyValuePair(Of String, cAuxEntry) + 'Dim s As String + Dim sb As cSubPath + Dim JSON As New cJSON + Dim ls As List(Of Object) + Dim dic As Dictionary(Of String, Object) + Dim dic0 As Dictionary(Of String, Object) + + 'Header + dic = New Dictionary(Of String, Object) + dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") + dic.Add("Date", Now.ToString) + dic.Add("AppVersion", VECTOvers) + dic.Add("FileVersion", FormatVersion) + JSON.Content.Add("Header", dic) + + 'Body + dic0 = New Dictionary(Of String, Object) + + dic0.Add("SavedInDeclMode", Cfg.DeclMode) + SavedInDeclMode = Cfg.DeclMode + + 'Main Files + dic0.Add("VehicleFile", stPathVEH.PathOrDummy) + dic0.Add("EngineFile", stPathENG.PathOrDummy) + dic0.Add("GearboxFile", stPathGBX.PathOrDummy) + + 'Cycles + If CycleFiles.Count > 0 Then + ls = New List(Of Object) + For Each sb In CycleFiles + ls.Add(sb.PathOrDummy) + Next + dic0.Add("Cycles", ls) + End If + + 'AA-TB + 'ADVANCED AUXILIARIES + dic0.Add("AuxiliaryAssembly", AuxiliaryAssembly) + dic0.Add("AuxiliaryVersion", AuxiliaryVersion) + dic0.Add("AdvancedAuxiliaryFilePath", AdvancedAuxiliaryFilePath) + + 'Aux + If AuxPaths.Count > 0 Then + ls = New List(Of Object) + For Each AuxEntryKV In AuxPaths + dic = New Dictionary(Of String, Object) + dic.Add("ID", Trim(UCase(AuxEntryKV.Key))) + dic.Add("Type", AuxEntryKV.Value.Type) + dic.Add("Path", AuxEntryKV.Value.Path.PathOrDummy) + dic.Add("Technology", AuxEntryKV.Value.TechStr) + + If AuxEntryKV.Key = sKey.AUX.ElecSys Then + dic.Add("TechList", EStechs) + End If + + ls.Add(dic) + Next + dic0.Add("Aux", ls) + End If + + 'VACC + dic0.Add("VACC", stDesMaxFile.PathOrDummy) + + 'EngineOnlyMode + dic0.Add("EngineOnlyMode", EngOnly) + + 'Start Stop + dic = New Dictionary(Of String, Object) + dic.Add("Enabled", boStartStop) + dic.Add("MaxSpeed", siStStV) + dic.Add("MinTime", siStStT) + dic.Add("Delay", StStDelay) + dic0.Add("StartStop", dic) + + 'LAC + dic = New Dictionary(Of String, Object) + dic.Add("Enabled", LookAheadOn) + dic.Add("Dec", a_lookahead) + dic.Add("MinSpeed", vMinLA) + dic0.Add("LAC", dic) + + 'Overspeed / EcoRoll + dic = New Dictionary(Of String, Object) + If EcoRollOn Then + dic.Add("Mode", "EcoRoll") + ElseIf OverSpeedOn Then + dic.Add("Mode", "OverSpeed") + Else + dic.Add("Mode", "Off") + End If + dic.Add("MinSpeed", vMin) + dic.Add("OverSpeed", OverSpeed) + dic.Add("UnderSpeed", UnderSpeed) + dic0.Add("OverSpeedEcoRoll", dic) + + ' + + + JSON.Content.Add("Body", dic0) + + Return JSON.WriteFile(sFilePath) + End Function + + Public Function ReadFile() As Boolean + Dim AuxEntry As cAuxEntry + Dim AuxID As String + Dim MsgSrc As String + Dim SubPath As cSubPath + Dim JSON As New cJSON + Dim str As String + Dim dic As Object + + + MsgSrc = "Main/ReadInp/GEN" + + SetDefault() + + If Not JSON.ReadFile(sFilePath) Then Return False + + Try + + FileVersion = JSON.Content("Header")("FileVersion") + + If FileVersion > 1 Then + SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") + Else + SavedInDeclMode = Cfg.DeclMode + End If + + If Not JSON.Content("Body")("VehicleFile") Is Nothing Then _ + stPathVEH.Init(MyPath, JSON.Content("Body")("VehicleFile")) + + stPathENG.Init(MyPath, JSON.Content("Body")("EngineFile")) + + If Not JSON.Content("Body")("GearboxFile") Is Nothing Then _ + stPathGBX.Init(MyPath, JSON.Content("Body")("GearboxFile")) + + If Not JSON.Content("Body")("Cycles") Is Nothing Then + For Each str In JSON.Content("Body")("Cycles") + SubPath = New cSubPath + SubPath.Init(MyPath, str) + CycleFiles.Add(SubPath) + Next + End If - If Not ENG.CreateFileList Then Return False - For Each str In ENG.FileList - MyFileList.Add(str) - Next + 'AA-TB + 'ADVANCED AUXILIARIES + If Not JSON.Content("Body")("AuxiliaryAssembly") Is Nothing AndAlso + Not JSON.Content("Body")("AuxiliaryVersion") Is Nothing Then - If Not Me.EngOnly Then + AuxiliaryAssembly = JSON.Content("Body")("AuxiliaryAssembly").ToString() + AuxiliaryVersion = JSON.Content("Body")("AuxiliaryVersion").ToString() - 'Gbx - MyFileList.Add(Me.PathGBX) + End If + If Not JSON.Content("Body")("AdvancedAuxiliaryFilePath") Is Nothing Then + AdvancedAuxiliaryFilePath = JSON.Content("Body")("AdvancedAuxiliaryFilePath").ToString() + End If - If Not GBX.CreateFileList Then Return False - For Each str In GBX.FileList - MyFileList.Add(str) - Next - 'Aux - If AuxDef And Not Cfg.DeclMode Then - For Each Aux0 In Me.AuxPaths.Values - MyFileList.Add(Aux0.Path.FullPath) - Next - End If + If Not JSON.Content("Body")("Aux") Is Nothing Then + For Each dic In JSON.Content("Body")("Aux") - '.vacc - MyFileList.Add(Me.stDesMaxFile.FullPath) + AuxID = UCase(Trim(dic("ID").ToString)) - End If + If AuxPaths.ContainsKey(AuxID) Then + WorkerMsg(tMsgID.Err, "Multiple definitions of the same auxiliary type (" & AuxID & ")!", MsgSrc) + Return False + End If - 'Cycles - For Each sb In Me.CycleFiles - MyFileList.Add(sb.FullPath) - Next + AuxEntry = New cAuxEntry + AuxEntry.Type = dic("Type") + AuxEntry.Path.Init(MyPath, dic("Path")) - Return True - - End Function - - Public Sub New() - - MyPath = "" - sFilePath = "" - - stPathVEH = New cSubPath - stPathENG = New cSubPath - stPathGBX = New cSubPath - - stDesMaxFile = New cSubPath - - laDesV = New List(Of Single) - laDesMax = New List(Of Single) - laDesMin = New List(Of Single) - - AuxPaths = New Dictionary(Of String, cAuxEntry) - AuxRefs = New Dictionary(Of String, cAux) - AuxDef = False - EStechs = New List(Of String) - - CycleFiles = New List(Of cSubPath) - - End Sub - - Public Function SaveFile() As Boolean - Dim AuxEntryKV As KeyValuePair(Of String, cAuxEntry) - 'Dim s As String - Dim sb As cSubPath - Dim JSON As New cJSON - Dim ls As List(Of Object) - Dim dic As Dictionary(Of String, Object) - Dim dic0 As Dictionary(Of String, Object) - - 'Header - dic = New Dictionary(Of String, Object) - dic.Add("CreatedBy", Lic.LicString & " (" & Lic.GUID & ")") - dic.Add("Date", Now.ToString) - dic.Add("AppVersion", VECTOvers) - dic.Add("FileVersion", FormatVersion) - JSON.Content.Add("Header", dic) - - 'Body - dic0 = New Dictionary(Of String, Object) - - dic0.Add("SavedInDeclMode", Cfg.DeclMode) - SavedInDeclMode = Cfg.DeclMode + If Not dic("Technology") Is Nothing Then AuxEntry.TechStr = dic("Technology") - 'Main Files - dic0.Add("VehicleFile", stPathVEH.PathOrDummy) - dic0.Add("EngineFile", stPathENG.PathOrDummy) - dic0.Add("GearboxFile", stPathGBX.PathOrDummy) + AuxPaths.Add(AuxID, AuxEntry) - 'Cycles - If CycleFiles.Count > 0 Then - ls = New List(Of Object) - For Each sb In CycleFiles - ls.Add(sb.PathOrDummy) - Next - dic0.Add("Cycles", ls) - End If + AuxDef = True - 'AA-TB - 'ADVANCED AUXILIARIES - dic0.Add("AuxiliaryAssembly",AuxiliaryAssembly) - dic0.Add("AuxiliaryVersion",AuxiliaryVersion) - dic0.Add("AdvancedAuxiliaryFilePath",AdvancedAuxiliaryFilePath) + If AuxID = sKey.AUX.ElecSys Then + If Not dic("TechList") Is Nothing Then + For Each str In dic("TechList") + EStechs.Add(str) + Next + End If + End If - 'Aux - If AuxPaths.Count > 0 Then - ls = New List(Of Object) - For Each AuxEntryKV In AuxPaths - dic = New Dictionary(Of String, Object) - dic.Add("ID", Trim(UCase(AuxEntryKV.Key))) - dic.Add("Type", AuxEntryKV.Value.Type) - dic.Add("Path", AuxEntryKV.Value.Path.PathOrDummy) - dic.Add("Technology", AuxEntryKV.Value.TechStr) + Next + End If - If AuxEntryKV.Key = sKey.AUX.ElecSys Then - dic.Add("TechList", EStechs) - End If + If Not JSON.Content("Body")("VACC") Is Nothing Then stDesMaxFile.Init(MyPath, JSON.Content("Body")("VACC")) - ls.Add(dic) - Next - dic0.Add("Aux", ls) - End If + EngOnly = JSON.Content("Body")("EngineOnlyMode") - 'VACC - dic0.Add("VACC", stDesMaxFile.PathOrDummy) + If Not JSON.Content("Body")("StartStop") Is Nothing Then + dic = JSON.Content("Body")("StartStop") + boStartStop = dic("Enabled") + siStStV = dic("MaxSpeed") + siStStT = dic("MinTime") + StStDelay = dic("Delay") + Else + boStartStop = False + End If - 'EngineOnlyMode - dic0.Add("EngineOnlyMode", EngOnly) + If Not JSON.Content("Body")("LAC") Is Nothing Then + dic = JSON.Content("Body")("LAC") + LookAheadOn = dic("Enabled") + a_lookahead = dic("Dec") + vMinLA = dic("MinSpeed") + Else + LookAheadOn = False + End If - 'Start Stop - dic = New Dictionary(Of String, Object) - dic.Add("Enabled", boStartStop) - dic.Add("MaxSpeed", siStStV) - dic.Add("MinTime", siStStT) - dic.Add("Delay", StStDelay) - dic0.Add("StartStop", dic) + If Not JSON.Content("Body")("OverSpeedEcoRoll") Is Nothing Then - 'LAC - dic = New Dictionary(Of String, Object) - dic.Add("Enabled", LookAheadOn) - dic.Add("Dec", a_lookahead) - dic.Add("MinSpeed", vMinLA) - dic0.Add("LAC", dic) + dic = JSON.Content("Body")("OverSpeedEcoRoll") - 'Overspeed / EcoRoll - dic = New Dictionary(Of String, Object) - If EcoRollOn Then - dic.Add("Mode", "EcoRoll") - ElseIf OverSpeedOn Then - dic.Add("Mode", "OverSpeed") - Else - dic.Add("Mode", "Off") - End If - dic.Add("MinSpeed", vMin) - dic.Add("OverSpeed", OverSpeed) - dic.Add("UnderSpeed", UnderSpeed) - dic0.Add("OverSpeedEcoRoll", dic) + Select Case UCase(dic("Mode").ToString).Trim + Case "ECOROLL" + OverSpeedOn = False + EcoRollOn = True - ' + Case "OVERSPEED" + OverSpeedOn = True + EcoRollOn = False + Case "OFF" + OverSpeedOn = False + EcoRollOn = False - JSON.Content.Add("Body", dic0) + Case Else + WorkerMsg(tMsgID.Err, "Value '" & dic("Mode") & "' is not valid for OverSpeedEcoRoll/Mode!", MsgSrc) + Return False + End Select - Return JSON.WriteFile(sFilePath) + vMin = dic("MinSpeed") + OverSpeed = dic("OverSpeed") + If Not dic("UnderSpeed") Is Nothing Then UnderSpeed = dic("UnderSpeed") - End Function + Else + OverSpeedOn = False + EcoRollOn = False + End If - Public Function ReadFile() As Boolean - Dim AuxEntry As cAuxEntry - Dim AuxID As String - Dim MsgSrc As String - Dim SubPath As cSubPath - Dim JSON As New cJSON - Dim str As String - Dim dic As Object + Catch ex As Exception + WorkerMsg(tMsgID.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) + Return False + End Try - + Return True + End Function - MsgSrc = "Main/ReadInp/GEN" + Private Sub SetDefault() - SetDefault() + AuxiliaryAssembly = "CLASSIC" + AuxiliaryVersion = "CLASSIC" + AdvancedAuxiliaryFilePath = String.Empty - If Not JSON.ReadFile(sFilePath) Then Return False - Try + boStartStop = False + siStStV = 5 + siStStT = 5 + StStDelay = 0 + FileVersion = 0 - FileVersion = JSON.Content("Header")("FileVersion") + stPathVEH.Clear() + stPathENG.Clear() + CycleFiles.Clear() + stPathGBX.Clear() - If FileVersion > 1 Then - SavedInDeclMode = JSON.Content("Body")("SavedInDeclMode") - Else - SavedInDeclMode = Cfg.DeclMode - End If + stDesMaxFile.Clear() + laDesV.Clear() + laDesMax.Clear() + laDesMin.Clear() + DesMaxDim = -1 - If Not JSON.Content("Body")("VehicleFile") Is Nothing Then stPathVEH.Init(MyPath, JSON.Content("Body")("VehicleFile")) + AuxPaths.Clear() + AuxRefs.Clear() + AuxDef = False + EStechs.Clear() - stPathENG.Init(MyPath, JSON.Content("Body")("EngineFile")) + EngOnly = False - If Not JSON.Content("Body")("GearboxFile") Is Nothing Then stPathGBX.Init(MyPath, JSON.Content("Body")("GearboxFile")) + a_lookahead = 0 + vMin = 0 + LookAheadOn = True + OverSpeedOn = False + EcoRollOn = False + OverSpeed = 0 + UnderSpeed = 0 + vMinLA = 0 - If Not JSON.Content("Body")("Cycles") Is Nothing Then - For Each str In JSON.Content("Body")("Cycles") - SubPath = New cSubPath - SubPath.Init(MyPath, str) - CycleFiles.Add(SubPath) - Next - End If + SavedInDeclMode = False + End Sub - 'AA-TB - 'ADVANCED AUXILIARIES - If Not JSON.Content("Body")("AuxiliaryAssembly") is Nothing AndAlso - NOT JSON.Content("Body")("AuxiliaryVersion") is nothing + Public Function DeclInit() As Boolean - AuxiliaryAssembly = JSON.Content("Body")("AuxiliaryAssembly").ToString() - AuxiliaryVersion = JSON.Content("Body")("AuxiliaryVersion").ToString() + Dim cl As List(Of String) + Dim s As String + Dim SubPath As cSubPath + Dim MsgSrc As String - End If - If NOT JSON.Content("Body")("AdvancedAuxiliaryFilePath") is nothing then - AdvancedAuxiliaryFilePath = JSON.Content("Body")("AdvancedAuxiliaryFilePath").ToString() - end if + MsgSrc = "VECTO/DeclInit" + EngOnly = False + CycleFiles.Clear() - If Not JSON.Content("Body")("Aux") Is Nothing Then - For Each dic In JSON.Content("Body")("Aux") + cl = Declaration.SegRef.GetCycles - AuxID = UCase(Trim(dic("ID").ToString)) + For Each s In cl + SubPath = New cSubPath + SubPath.Init(MyPath, s) + CycleFiles.Add(SubPath) + Next - If AuxPaths.ContainsKey(AuxID) Then - WorkerMsg(tMsgID.Err, "Multiple definitions of the same auxiliary type (" & AuxID & ")!", MsgSrc) - Return False - End If + stDesMaxFile.Init(MyPath, Declaration.SegRef.VACCfile) - AuxEntry = New cAuxEntry + siStStV = cDeclaration.SSspeed + siStStT = cDeclaration.SStime + StStDelay = cDeclaration.SSdelay - AuxEntry.Type = dic("Type") - AuxEntry.Path.Init(MyPath, dic("Path")) + If Not EcoRollOn Then OverSpeedOn = True - If Not dic("Technology") Is Nothing Then AuxEntry.TechStr = dic("Technology") + OverSpeed = cDeclaration.Overspeed + UnderSpeed = cDeclaration.Underspeed + vMin = cDeclaration.ECvmin - AuxPaths.Add(AuxID, AuxEntry) + LookAheadOn = True + a_lookahead = cDeclaration.LACa + vMinLA = cDeclaration.LACvmin - AuxDef = True + 'No need to check Aux (AuxDef). Will be checked in cDeclaration.CalcInitLoad - If AuxID = sKey.AUX.ElecSys Then - If Not dic("TechList") Is Nothing Then - For Each str In dic("TechList") - EStechs.Add(str) - Next - End If - End If + Return True + End Function - Next - End If + 'This Sub reads those Input-files that do not have their own class, etc. + Public Function Init() As Boolean + Dim file As cFile_V3 + Dim line As String() - If Not JSON.Content("Body")("VACC") Is Nothing Then stDesMaxFile.Init(MyPath, JSON.Content("Body")("VACC")) + Dim MsgSrc As String - EngOnly = JSON.Content("Body")("EngineOnlyMode") + MsgSrc = "VECTO/Init" - If Not JSON.Content("Body")("StartStop") Is Nothing Then - dic = JSON.Content("Body")("StartStop") - boStartStop = dic("Enabled") - siStStV = dic("MaxSpeed") - siStStT = dic("MinTime") - StStDelay = dic("Delay") - Else - boStartStop = False - End If + If Not EngOnly Then - If Not JSON.Content("Body")("LAC") Is Nothing Then - dic = JSON.Content("Body")("LAC") - LookAheadOn = dic("Enabled") - a_lookahead = dic("Dec") - vMinLA = dic("MinSpeed") - Else - LookAheadOn = False - End If + file = New cFile_V3 - If Not JSON.Content("Body")("OverSpeedEcoRoll") Is Nothing Then + If Not file.OpenRead(stDesMaxFile.FullPath) Then + WorkerMsg(tMsgID.Err, "Can't read .vacc file (" & stDesMaxFile.FullPath & ")", MsgSrc) + Return False + End If - dic = JSON.Content("Body")("OverSpeedEcoRoll") + 'Skip Header + file.ReadLine() - Select Case UCase(dic("Mode").ToString).Trim - Case "ECOROLL" - OverSpeedOn = False - EcoRollOn = True + laDesV.Clear() + laDesMax.Clear() + laDesMin.Clear() + DesMaxDim = -1 + Try - Case "OVERSPEED" - OverSpeedOn = True - EcoRollOn = False + Do While Not file.EndOfFile - Case "OFF" - OverSpeedOn = False - EcoRollOn = False + DesMaxDim += 1 - Case Else - WorkerMsg(tMsgID.Err, "Value '" & dic("Mode") & "' is not valid for OverSpeedEcoRoll/Mode!", MsgSrc) - Return False - End Select + line = file.ReadLine - vMin = dic("MinSpeed") - OverSpeed = dic("OverSpeed") - If Not dic("UnderSpeed") Is Nothing Then UnderSpeed = dic("UnderSpeed") + laDesV.Add(CSng(line(0)) / 3.6) 'km/h => m/s !!!! + laDesMax.Add(CSng(line(1))) + laDesMin.Add(CSng(line(2))) - Else - OverSpeedOn = False - EcoRollOn = False - End If + Loop + Catch ex As Exception + file.Close() + WorkerMsg(tMsgID.Err, "Error in .vacc file. " & ex.Message & " (" & stDesMaxFile.FullPath & ")", MsgSrc, + stDesMaxFile.FullPath) + Return False + End Try + file.Close() - Catch ex As Exception - WorkerMsg(tMsgID.Err, "Failed to read VECTO file! " & ex.Message, MsgSrc) - Return False - End Try + End If - - Return True - - - End Function - - Private Sub SetDefault() - - AuxiliaryAssembly ="CLASSIC" - AuxiliaryVersion ="CLASSIC" - AdvancedAuxiliaryFilePath=String.Empty - - - boStartStop = False - siStStV = 5 - siStStT = 5 - StStDelay = 0 - FileVersion = 0 - - stPathVEH.Clear() - stPathENG.Clear() - CycleFiles.Clear() - stPathGBX.Clear() - - stDesMaxFile.Clear() - laDesV.Clear() - laDesMax.Clear() - laDesMin.Clear() - DesMaxDim = -1 - - AuxPaths.Clear() - AuxRefs.Clear() - AuxDef = False - EStechs.Clear() - - EngOnly = False - - a_lookahead = 0 - vMin = 0 - LookAheadOn = True - OverSpeedOn = False - EcoRollOn = False - OverSpeed = 0 - UnderSpeed = 0 - vMinLA = 0 - - SavedInDeclMode = False - - End Sub - - Public Function DeclInit() As Boolean - - Dim cl As List(Of String) - Dim s As String - Dim SubPath As cSubPath - Dim MsgSrc As String - - MsgSrc = "VECTO/DeclInit" - - EngOnly = False - - CycleFiles.Clear() - - cl = Declaration.SegRef.GetCycles - - For Each s In cl - SubPath = New cSubPath - SubPath.Init(MyPath, s) - CycleFiles.Add(SubPath) - Next - - stDesMaxFile.Init(MyPath, Declaration.SegRef.VACCfile) - - siStStV = cDeclaration.SSspeed - siStStT = cDeclaration.SStime - StStDelay = cDeclaration.SSdelay - - If Not EcoRollOn Then OverSpeedOn = True - - OverSpeed = cDeclaration.Overspeed - UnderSpeed = cDeclaration.Underspeed - vMin = cDeclaration.ECvmin - - LookAheadOn = True - a_lookahead = cDeclaration.LACa - vMinLA = cDeclaration.LACvmin - - 'No need to check Aux (AuxDef). Will be checked in cDeclaration.CalcInitLoad - - Return True - - End Function - - 'This Sub reads those Input-files that do not have their own class, etc. - Public Function Init() As Boolean - Dim file As cFile_V3 - Dim line As String() - - Dim MsgSrc As String - - MsgSrc = "VECTO/Init" - - If Not EngOnly Then - - file = New cFile_V3 - - If Not file.OpenRead(stDesMaxFile.FullPath) Then - WorkerMsg(tMsgID.Err, "Can't read .vacc file (" & stDesMaxFile.FullPath & ")", MsgSrc) - Return False - End If - - 'Skip Header - file.ReadLine() - - laDesV.Clear() - laDesMax.Clear() - laDesMin.Clear() - DesMaxDim = -1 - Try - - Do While Not file.EndOfFile - - DesMaxDim += 1 - - line = file.ReadLine - - laDesV.Add(CSng(line(0)) / 3.6) 'km/h => m/s !!!! - laDesMax.Add(CSng(line(1))) - laDesMin.Add(CSng(line(2))) - - Loop - - Catch ex As Exception - - file.Close() - WorkerMsg(tMsgID.Err, "Error in .vacc file. " & ex.Message & " (" & stDesMaxFile.FullPath & ")", MsgSrc, stDesMaxFile.FullPath) - Return False - - End Try - - file.Close() - - End If - - Return True - - End Function + Return True + End Function #Region "Aux" - Public Function AuxInit() As Boolean - - Dim Aux0 As cAux - Dim AuxPathKV As KeyValuePair(Of String, cAuxEntry) - Dim DRIauxcheck As New Dictionary(Of String, Boolean) - Dim AuxID As String + Public Function AuxInit() As Boolean - Dim MsgSrc As String + Dim Aux0 As cAux + Dim AuxPathKV As KeyValuePair(Of String, cAuxEntry) + Dim DRIauxcheck As New Dictionary(Of String, Boolean) + Dim AuxID As String - MsgSrc = "VEH/AuxInit" + Dim MsgSrc As String - AuxRefs = New Dictionary(Of String, cAux) + MsgSrc = "VEH/AuxInit" - If Cfg.DeclMode Then + AuxRefs = New Dictionary(Of String, cAux) - For Each AuxPathKV In AuxPaths - AuxRefs.Add(AuxPathKV.Key, Nothing) - Next + If Cfg.DeclMode Then - Return True + For Each AuxPathKV In AuxPaths + AuxRefs.Add(AuxPathKV.Key, Nothing) + Next - End If + Return True + End If - If DRI.AuxDef Xor AuxDef Then - If AuxDef Then - WorkerMsg(tMsgID.Err, "No auxiliary input defined in driving cycle!", MsgSrc) - Return False - Else - WorkerMsg(tMsgID.Warn, "No auxiliary defined in vehicle file! Psupply input will be ignored!", MsgSrc) - Return True - End If + If DRI.AuxDef Xor AuxDef Then - End If + If AuxDef Then + WorkerMsg(tMsgID.Err, "No auxiliary input defined in driving cycle!", MsgSrc) + Return False + Else + WorkerMsg(tMsgID.Warn, "No auxiliary defined in vehicle file! Psupply input will be ignored!", MsgSrc) + Return True + End If - If Not (DRI.AuxDef Or AuxDef) Then Return True + End If + If Not (DRI.AuxDef Or AuxDef) Then Return True - For Each AuxID In DRI.AuxComponents.Keys - DRIauxcheck.Add(AuxID, False) - Next - For Each AuxPathKV In AuxPaths + For Each AuxID In DRI.AuxComponents.Keys + DRIauxcheck.Add(AuxID, False) + Next - MsgSrc = "VEH/AuxInit/" & AuxPathKV.Key + For Each AuxPathKV In AuxPaths - If Not DRI.AuxComponents.ContainsKey(AuxPathKV.Key) Then - WorkerMsg(tMsgID.Err, "No Psupply input defined in driving cycle for auxiliary '" & AuxPathKV.Key & "'!", MsgSrc) - Return False - End If + MsgSrc = "VEH/AuxInit/" & AuxPathKV.Key - Aux0 = New cAux - Aux0.Filepath = AuxPathKV.Value.Path.FullPath + If Not DRI.AuxComponents.ContainsKey(AuxPathKV.Key) Then + WorkerMsg(tMsgID.Err, "No Psupply input defined in driving cycle for auxiliary '" & AuxPathKV.Key & "'!", MsgSrc) + Return False + End If - If Not Aux0.Readfile Then - 'Notificationin ReadFile() - Return False - End If + Aux0 = New cAux + Aux0.Filepath = AuxPathKV.Value.Path.FullPath - AuxRefs.Add(AuxPathKV.Key, Aux0) + If Not Aux0.Readfile Then + 'Notificationin ReadFile() + Return False + End If - DRIauxcheck(AuxPathKV.Key) = True + AuxRefs.Add(AuxPathKV.Key, Aux0) - Next + DRIauxcheck(AuxPathKV.Key) = True - MsgSrc = "VEH/AuxInit" + Next - For Each AuxID In DRI.AuxComponents.Keys - If Not DRIauxcheck(AuxID) Then WorkerMsg(tMsgID.Warn, "Auxiliary '" & AuxID & "' not found! Psupply input will be ignored!", MsgSrc) - Next + MsgSrc = "VEH/AuxInit" - Return True + For Each AuxID In DRI.AuxComponents.Keys + If Not DRIauxcheck(AuxID) Then _ + WorkerMsg(tMsgID.Warn, "Auxiliary '" & AuxID & "' not found! Psupply input will be ignored!", MsgSrc) + Next - End Function + Return True + End Function - Public Function Paux(ByVal AuxID As String, ByVal t As Integer, ByVal nU As Single) As Single - Dim Psupply As Single - Dim Px As Single - Dim Aux0 As cAux + Public Function Paux(ByVal AuxID As String, ByVal t As Integer, ByVal nU As Single) As Single + Dim Psupply As Single + Dim Px As Single + Dim Aux0 As cAux - Dim MsgSrc As String + Dim MsgSrc As String - MsgSrc = "VEH/Paux" + MsgSrc = "VEH/Paux" - If Cfg.DeclMode Then Return Declaration.AuxPower(AuxID) + If Cfg.DeclMode Then Return Declaration.AuxPower(AuxID) - If AuxDef Then + If AuxDef Then - Aux0 = AuxRefs(AuxID) + Aux0 = AuxRefs(AuxID) - Psupply = DRI.AuxComponents(AuxID)(t) + Psupply = DRI.AuxComponents(AuxID)(t) - If Psupply < 0 Then GoTo lbAuxError + If Psupply < 0 Then GoTo lbAuxError - Px = Aux0.Paux(nU, Psupply) + Px = Aux0.Paux(nU, Psupply) - If Px < 0 Then GoTo lbAuxError + If Px < 0 Then GoTo lbAuxError - Return Px + Return Px - Else + Else - Return 0 + Return 0 - End If + End If lbAuxError: - MODdata.ModErrors.AuxNegative = AuxID - Return 0 + MODdata.ModErrors.AuxNegative = AuxID + Return 0 + End Function + Public Function PauxSum(ByVal t As Integer, ByVal nU As Single) As Single + Dim sum As Single + Dim AuxID As String - End Function + Dim MsgSrc As String - Public Function PauxSum(ByVal t As Integer, ByVal nU As Single) As Single - Dim sum As Single - Dim AuxID As String + MsgSrc = "VEH/Paux" - Dim MsgSrc As String + If AuxDef Then - MsgSrc = "VEH/Paux" + sum = 0 - If AuxDef Then + For Each AuxID In AuxRefs.Keys - sum = 0 + sum += Paux(AuxID, t, nU) - For Each AuxID In AuxRefs.Keys + Next - sum += Paux(AuxID, t, nU) + Return sum - Next + Else - Return sum + Return 0 - Else - - Return 0 - - End If - - End Function + End If + End Function #End Region #Region "Properties" - Public ReadOnly Property FileList As List(Of String) - Get - Return MyFileList - End Get - End Property - - - Public Property FilePath() As String - Get - Return sFilePath - End Get - Set(ByVal value As String) - sFilePath = value - If sFilePath = "" Then - MyPath = "" - Else - MyPath = IO.Path.GetDirectoryName(sFilePath) & "\" - End If - End Set - End Property - - - Public Property PathVEH(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return stPathVEH.OriginalPath - Else - Return stPathVEH.FullPath - End If - End Get - Set(ByVal value As String) - stPathVEH.Init(MyPath, value) - End Set - End Property - - Public Property PathENG(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return stPathENG.OriginalPath - Else - Return stPathENG.FullPath - End If - End Get - Set(ByVal value As String) - stPathENG.Init(MyPath, value) - End Set - End Property - - Public Property PathGBX(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return stPathGBX.OriginalPath - Else - Return stPathGBX.FullPath - End If - End Get - Set(ByVal value As String) - stPathGBX.Init(MyPath, value) - End Set - End Property - - - Public Property StartStop() As Boolean - Get - Return boStartStop - End Get - Set(ByVal value As Boolean) - boStartStop = value - End Set - End Property - - Public Property StStV() As Single - Get - Return siStStV - End Get - Set(ByVal value As Single) - siStStV = value - End Set - End Property - - Public Property StStT() As Single - Get - Return siStStT - End Get - Set(ByVal value As Single) - siStStT = value - End Set - End Property - - Public Property DesMaxFile(Optional ByVal Original As Boolean = False) As String - Get - If Original Then - Return stDesMaxFile.OriginalPath - Else - Return stDesMaxFile.FullPath - End If - End Get - Set(ByVal value As String) - stDesMaxFile.Init(MyPath, value) - End Set - End Property + Public ReadOnly Property FileList As List(Of String) + Get + Return MyFileList + End Get + End Property + + + Public Property FilePath() As String + Get + Return sFilePath + End Get + Set(ByVal value As String) + sFilePath = value + If sFilePath = "" Then + MyPath = "" + Else + MyPath = IO.Path.GetDirectoryName(sFilePath) & "\" + End If + End Set + End Property + + + Public Property PathVEH(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return stPathVEH.OriginalPath + Else + Return stPathVEH.FullPath + End If + End Get + Set(ByVal value As String) + stPathVEH.Init(MyPath, value) + End Set + End Property + + Public Property PathENG(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return stPathENG.OriginalPath + Else + Return stPathENG.FullPath + End If + End Get + Set(ByVal value As String) + stPathENG.Init(MyPath, value) + End Set + End Property + + Public Property PathGBX(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return stPathGBX.OriginalPath + Else + Return stPathGBX.FullPath + End If + End Get + Set(ByVal value As String) + stPathGBX.Init(MyPath, value) + End Set + End Property + + + Public Property StartStop() As Boolean + Get + Return boStartStop + End Get + Set(ByVal value As Boolean) + boStartStop = value + End Set + End Property + + Public Property StStV() As Single + Get + Return siStStV + End Get + Set(ByVal value As Single) + siStStV = value + End Set + End Property + + Public Property StStT() As Single + Get + Return siStStT + End Get + Set(ByVal value As Single) + siStStT = value + End Set + End Property + + Public Property DesMaxFile(Optional ByVal Original As Boolean = False) As String + Get + If Original Then + Return stDesMaxFile.OriginalPath + Else + Return stDesMaxFile.FullPath + End If + End Get + Set(ByVal value As String) + stDesMaxFile.Init(MyPath, value) + End Set + End Property #End Region - Public Function aDesMax(ByVal v As Single) As Single - Dim i As Int32 + Public Function aDesMax(ByVal v As Single) As Single + Dim i As Int32 - 'Extrapolation for x < x(1) - If laDesV(0) >= v Then - If laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - i = 1 - GoTo lbInt - End If + 'Extrapolation for x < x(1) + If laDesV(0) >= v Then + If laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" + i = 1 + GoTo lbInt + End If - i = 0 - Do While laDesV(i) < v And i < DesMaxDim - i += 1 - Loop + i = 0 + Do While laDesV(i) < v And i < DesMaxDim + i += 1 + Loop - 'Extrapolation for x > x(imax) - If laDesV(i) < v Then - MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - End If + 'Extrapolation for x > x(imax) + If laDesV(i) < v Then + MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" + End If lbInt: - 'Interpolation - Return (v - laDesV(i - 1)) * (laDesMax(i) - laDesMax(i - 1)) / (laDesV(i) - laDesV(i - 1)) + laDesMax(i - 1) - - End Function - - Public Function aDesMin(ByVal v As Single) As Single - Dim i As Int32 - - 'Extrapolation for x < x(1) - If laDesV(0) >= v Then - If laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - i = 1 - GoTo lbInt - End If - - i = 0 - Do While laDesV(i) < v And i < DesMaxDim - i += 1 - Loop - - 'Extrapolation for x > x(imax) - If laDesV(i) < v Then - MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" - End If + 'Interpolation + Return (v - laDesV(i - 1)) * (laDesMax(i) - laDesMax(i - 1)) / (laDesV(i) - laDesV(i - 1)) + laDesMax(i - 1) + End Function + + Public Function aDesMin(ByVal v As Single) As Single + Dim i As Int32 + + 'Extrapolation for x < x(1) + If laDesV(0) >= v Then + If laDesV(0) > v Then MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" + i = 1 + GoTo lbInt + End If + + i = 0 + Do While laDesV(i) < v And i < DesMaxDim + i += 1 + Loop + + 'Extrapolation for x > x(imax) + If laDesV(i) < v Then + MODdata.ModErrors.DesMaxExtr = "v= " & v * 3.6 & "[km/h]" + End If lbInt: - 'Interpolation - Return (v - laDesV(i - 1)) * (laDesMin(i) - laDesMin(i - 1)) / (laDesV(i) - laDesV(i - 1)) + laDesMin(i - 1) - - End Function - - + 'Interpolation + Return (v - laDesV(i - 1)) * (laDesMin(i) - laDesMin(i - 1)) / (laDesV(i) - laDesV(i - 1)) + laDesMin(i - 1) + End Function End Class diff --git a/VECTO/MODcalc/cPower.vb b/VECTO/MODcalc/cPower.vb index 05038adeba..1e0fd56f4d 100644 --- a/VECTO/MODcalc/cPower.vb +++ b/VECTO/MODcalc/cPower.vb @@ -296,7 +296,7 @@ Public Class cPower 'Total aux power '[kW] - Paux = PreExistingAuxPower + fPaux(t, EngineSpeed) + Paux = fPaux(t, EngineSpeed) 'Internal Engine Power (Pclutch plus Aux plus Inertia) P = Pkup + Paux + PaMot @@ -1094,7 +1094,7 @@ lb_nOK: 'Total aux power '[kW] - Paux = PreExistingAuxPower + fPaux(jz, EngineSpeed) + Paux = fPaux(jz, EngineSpeed) '***************** ADVANCED AUXILIARIES END ******************************************************** 'ICE-inertia @@ -2735,7 +2735,7 @@ lb10: If VECTO_Global.VEC.AuxiliaryAssembly = "CLASSIC" Then - Return CSng(VEC.PauxSum(t, nU)) + Return CSng(MODdata.Vh.Padd(t) + VEC.PauxSum(t, nU)) Else @@ -2753,7 +2753,7 @@ lb10: mAAUX_Global.advancedAuxModel.Signals.Internal_Engine_Power = mAAUX_Global.Internal_Engine_Power 'Power coming out of Advanced Model is in Watts. - power = (advancedAuxModel.AuxiliaryPowerAtCrankWatts / 1000) + power = PreExistingAuxPower + (advancedAuxModel.AuxiliaryPowerAtCrankWatts / 1000) 'Glenn: Comment the previous line and uncomment the next line to include the classic auxilaries power togeher with the advanced auxiliary power. 'power = VEC.PauxSum(t, nU) + (advancedAuxModel.AuxiliaryPowerAtCrankWatts / 1000) diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M6Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M6Tests.vb index 832e3de2a6..846171d3ad 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M6Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M6Tests.vb @@ -7,126 +7,109 @@ Imports VectoAuxiliaries Imports Moq Namespace UnitTests - -<TestFixture()> -Public Class M6Test - -Private M1 As New M1_Mock(100, 200, 300, 50) -Private M2 As New M2_Mock(120, 130) -Private M3 As New M3_Mock(200, 5000) -Private M4 As New M4_Mock(100, 2, 200, 100, 100) -Private M5 As New M5_Mock(200, 50, 80) -Private Signals As New Signals() - -Private Function GetStandardInstanceM6() As IM6 - - M1 = New M1_Mock(100, 200, 300, 50) - M2 = New M2_Mock(120, 130) - M3 = New M3_Mock(200, 5000) - M4 = New M4_Mock(100, 2, 200, 100, 100) - M5 = New M5_Mock(200, 50, 80) - - Return New M6(M1,M2,M3,M4,M5,Signals) - -End Function - -Public Sub new () - -Signals.EngineMotoringPower=100 -Signals.EngineDrivelinePower=150 -Signals.PreExistingAuxPower=30 - - -End Sub - -<Test()> -Public Sub CreateNewM6Instance() - -Dim target As IM6 = GetStandardInstanceM6() - -Assert.IsNotNull( target) - -End Sub - - -'Test Cases Supplied by Mike Preston. - <Test()> _ - <TestCase(100, 100, 100, 100, 20, 20, 40, 100, 100, 100, 0.1F, -0.55F, False, 0, 0, 0, 20, 0, 100, 20, 200, 0)> _ - <TestCase(100, 100, 100, 100, 20, 20, 40, 100, 100, 100, 100, -550, True, 0, 0, 0, 20, 0, 100, 20, 200, 0)> _ - Public Sub MikesConditionsTest(M1_1 As Single, _ - M1_2 As Single, _ - M2_1 As Single, _ - M3_1 As Single, _ - M4_1 As Single, _ - M4_2 As Single, _ - M4_3 As Single, _ - M5_1 As Single, _ - M5_2 As Single, _ - AUX As Single, _ - EMP As Single, _ - EDP As Single, _ - SM As Boolean, _ - OUT1 As Single, _ - OUT2 As Single, _ - OUT3 As Single, _ - OUT4 As Single, _ - OUT5 As Single, _ - OUT6 As Single, _ - OUT7 As Single, _ - OUT8 As Single, _ - OUT9 As Single) - - - Dim M1 = New M1_Mock() - Dim M2 = New M2_Mock() - Dim M3 = New M3_Mock() - Dim M4 = New M4_Mock() - Dim M5 = New M5_Mock() - - Dim signals As New Signals() - - - M1._AveragePowerDemandAtCrankFromHVACMechanicalsWatts = M1_1 - M1._AveragePowerDemandAtCrankFromHVACElectricsWatts = M1_2 - M2._GetAveragePowerAtCrankFromElectrics = M2_1 - M3._GetAveragePowerDemandAtCrankFromPneumatics = M3_1 - M4._PowerCompressorOff = M4_1 - M4._PowerDifference = M4_2 - M4._PowerCompressorOn = M4_3 - M5._AlternatorsGenerationPowerAtCrankTractionOnWatts = M5_1 - M5._AlternatorsGenerationPowerAtCrankOverrunWatts = M5_2 - - - - signals.EngineMotoringPower = EMP - signals.PreExistingAuxPower = AUX - signals.EngineDrivelinePower = EDP - signals.SmartElectrics = SM - - - Dim target As New M6(M1, M2, M3, M4, M5, signals) - - Assert.AreEqual(OUT1, target.OverrunFlag) - Assert.AreEqual(OUT2, target.SmartElecAndPneumaticsCompressorFlag) - Assert.AreEqual(OUT3, target.SmartElecAndPneumaticAltPowerGenAtCrank) - Assert.AreEqual(OUT4, target.SmartElecAndPneumaticAirCompPowerGenAtCrank) - Assert.AreEqual(OUT5, target.SmartElecOnlyAltPowerGenAtCrank) - Assert.AreEqual(OUT6, target.AveragePowerDemandAtCrankFromPneumatics) - Assert.AreEqual(OUT7, target.SmartElecAndPneumaticAirCompPowerGenAtCrank) - Assert.AreEqual(OUT8, target.AvgPowerDemandAtCrankFromElectricsIncHVAC) - Assert.AreEqual(OUT9, target.SmartPneumaticsOnlyCompressorFlag) - - - - - End Sub - - -End Class - - - + <TestFixture()> + Public Class M6Test + Private M1 As New M1_Mock(100, 200, 300, 50) + Private M2 As New M2_Mock(120, 130) + Private M3 As New M3_Mock(200, 5000) + Private M4 As New M4_Mock(100, 2, 200, 100, 100) + Private M5 As New M5_Mock(200, 50, 80) + Private Signals As New Signals() + + Private Function GetStandardInstanceM6() As IM6 + + M1 = New M1_Mock(100, 200, 300, 50) + M2 = New M2_Mock(120, 130) + M3 = New M3_Mock(200, 5000) + M4 = New M4_Mock(100, 2, 200, 100, 100) + M5 = New M5_Mock(200, 50, 80) + + Return New M6(M1, M2, M3, M4, M5, Signals) + End Function + + Public Sub New() + + Signals.EngineMotoringPower = 100 + Signals.EngineDrivelinePower = 150 + Signals.PreExistingAuxPower = 30 + End Sub + + <Test()> + Public Sub CreateNewM6Instance() + + Dim target As IM6 = GetStandardInstanceM6() + + Assert.IsNotNull(target) + End Sub + + + 'Test Cases Supplied by Mike Preston. + <Test()> _ + <TestCase(100, 100, 100, 100, 20, 20, 40, 100, 100, 100, 0.1F, -0.55F, False, 0, 0, 0, 20, 0, 100, 20, 200, 0)> _ + <TestCase(100, 100, 100, 100, 20, 20, 40, 100, 100, 100, 100, -550, True, 0, 0, 0, 20, 0, 100, 20, 200, 0)> + Public Sub MikesConditionsTest(M1_1 As Single, + M1_2 As Single, + M2_1 As Single, + M3_1 As Single, + M4_1 As Single, + M4_2 As Single, + M4_3 As Single, + M5_1 As Single, + M5_2 As Single, + AUX As Single, + EMP As Single, + EDP As Single, + SM As Boolean, + OUT1 As Single, + OUT2 As Single, + OUT3 As Single, + OUT4 As Single, + OUT5 As Single, + OUT6 As Single, + OUT7 As Single, + OUT8 As Single, + OUT9 As Single) + + + Dim M1 = New M1_Mock() + Dim M2 = New M2_Mock() + Dim M3 = New M3_Mock() + Dim M4 = New M4_Mock() + Dim M5 = New M5_Mock() + + Dim signals As New Signals() + + + M1._AveragePowerDemandAtCrankFromHVACMechanicalsWatts = M1_1 + M1._AveragePowerDemandAtCrankFromHVACElectricsWatts = M1_2 + M2._GetAveragePowerAtCrankFromElectrics = M2_1 + M3._GetAveragePowerDemandAtCrankFromPneumatics = M3_1 + M4._PowerCompressorOff = M4_1 + M4._PowerDifference = M4_2 + M4._PowerCompressorOn = M4_3 + M5._AlternatorsGenerationPowerAtCrankTractionOnWatts = M5_1 + M5._AlternatorsGenerationPowerAtCrankOverrunWatts = M5_2 + + + signals.EngineMotoringPower = EMP + signals.PreExistingAuxPower = AUX + signals.EngineDrivelinePower = EDP + signals.SmartElectrics = SM + + + Dim target As New M6(M1, M2, M3, M4, M5, signals) + + Assert.AreEqual(OUT1, target.OverrunFlag) + Assert.AreEqual(OUT2, target.SmartElecAndPneumaticsCompressorFlag) + Assert.AreEqual(OUT3, target.SmartElecAndPneumaticAltPowerGenAtCrank) + Assert.AreEqual(OUT4, target.SmartElecAndPneumaticAirCompPowerGenAtCrank) + Assert.AreEqual(OUT5, target.SmartElecOnlyAltPowerGenAtCrank) + Assert.AreEqual(OUT6, target.AveragePowerDemandAtCrankFromPneumatics) + Assert.AreEqual(OUT7, target.SmartElecAndPneumaticAirCompPowerGenAtCrank) + Assert.AreEqual(OUT8, target.AvgPowerDemandAtCrankFromElectricsIncHVAC) + Assert.AreEqual(OUT9, target.SmartPneumaticsOnlyCompressorFlag) + End Sub + End Class End Namespace - -- GitLab