diff --git a/VECTO/GUI/F_MAINForm.vb b/VECTO/GUI/F_MAINForm.vb index 4f6f97ade0983662be03e559d397a291d0ac56bb..c4a66edf50ed884d3098e9df1bec8458d9ae7a46 100644 --- a/VECTO/GUI/F_MAINForm.vb +++ b/VECTO/GUI/F_MAINForm.vb @@ -1615,8 +1615,8 @@ lbFound: mode = ExecutionMode.Declaration Else mode = ExecutionMode.Engineering - Physics.FuelDensity = New SI(Cfg.FuelDens).Kilo.Gramm.Per.Cubic.Dezi.Meter - Physics.AirDensity = New SI(Cfg.AirDensity).Kilo.Gramm.Per.Cubic.Meter + Physics.FuelDensity = New SI(Cfg.FuelDens).Kilo.Gramm.Per.Cubic.Dezi.Meter.Cast(Of KilogramPerCubicMeter)() + Physics.AirDensity = New SI(Cfg.AirDensity).Kilo.Gramm.Per.Cubic.Meter.Cast(Of KilogramPerCubicMeter)() Physics.CO2PerFuelWeight = Cfg.CO2perFC End If @@ -1651,10 +1651,15 @@ lbFound: 'print detected cycles For Each cycle As JobContainer.CycleTypeDescription In jobContainer.GetCycleTypes() - sender.ReportProgress(0, New With {.Target = "ListBox", .Message = String.Format("Detected Cycle {0}: {1}", cycle.Name, cycle.CycleType)}) + sender.ReportProgress(0, + New With {.Target = "ListBox", .Message = String.Format("Detected Cycle {0}: {1}", cycle.Name, cycle.CycleType)}) Next - sender.ReportProgress(0, New With {.Target = "ListBox", .Message = String.Format("Starting Simulation ({0} Jobs, {1} Runs)", JobFileList.Count, jobContainer.GetProgress().Count)}) + sender.ReportProgress(0, + New _ + With {.Target = "ListBox", + .Message = + String.Format("Starting Simulation ({0} Jobs, {1} Runs)", JobFileList.Count, jobContainer.GetProgress().Count)}) jobContainer.Execute(True) @@ -1672,15 +1677,21 @@ lbFound: Dim duration As Double = (DateTime.Now() - start).TotalSeconds sender.ReportProgress(Int((sumProgress * 100.0) / progress.Count), New With {.Target = "Status", - .Message = String.Format("Duration: {0:0}s, Current Progress: {1:P} ({2})", duration, sumProgress / progress.Count, String.Join(", ", progress.Select(Function(pair) String.Format("{0,4:P}", pair.Value.Progress))))}) + .Message = + String.Format("Duration: {0:0}s, Current Progress: {1:P} ({2})", duration, sumProgress / progress.Count, + String.Join(", ", progress.Select(Function(pair) String.Format("{0,4:P}", pair.Value.Progress))))}) - Dim justFinished As Dictionary(Of Integer, JobContainer.ProgressEntry) = progress.Where(Function(proc) proc.Value.Done AndAlso Not finishedRuns.Contains(proc.Key)).ToDictionary(Function(pair) pair.Key, Function(pair) pair.Value) + Dim justFinished As Dictionary(Of Integer, JobContainer.ProgressEntry) = + progress.Where(Function(proc) proc.Value.Done AndAlso Not finishedRuns.Contains(proc.Key)).ToDictionary( + Function(pair) pair.Key, Function(pair) pair.Value) PrintRuns(justFinished, fileWriters) finishedRuns.AddRange(justFinished.Select(Function(pair) pair.Key)) Thread.Sleep(100) End While - Dim remainingRuns As Dictionary(Of Integer, JobContainer.ProgressEntry) = jobContainer.GetProgress().Where(Function(proc) proc.Value.Done AndAlso Not finishedRuns.Contains(proc.Key)).ToDictionary(Function(pair) pair.Key, Function(pair) pair.Value) + Dim remainingRuns As Dictionary(Of Integer, JobContainer.ProgressEntry) = + jobContainer.GetProgress().Where(Function(proc) proc.Value.Done AndAlso Not finishedRuns.Contains(proc.Key)). + ToDictionary(Function(pair) pair.Key, Function(pair) pair.Value) PrintRuns(remainingRuns, fileWriters) finishedRuns.Clear() @@ -1688,10 +1699,11 @@ lbFound: For Each progressEntry As KeyValuePair(Of Integer, JobContainer.ProgressEntry) In jobContainer.GetProgress() sender.ReportProgress(100, New With {.Target = "ListBox", - .Message = String.Format("{0,-60} {1,8:P} {2,10:F2}s - {3}", - String.Format("{0} {1} {2}", progressEntry.Value.RunName, progressEntry.Value.CycleName, progressEntry.Value.RunSuffix), - progressEntry.Value.Progress, progressEntry.Value.ExecTime / 1000.0, - IIf(progressEntry.Value.Success, "Success", "Aborted"))}) + .Message = String.Format("{0,-60} {1,8:P} {2,10:F2}s - {3}", + String.Format("{0} {1} {2}", progressEntry.Value.RunName, progressEntry.Value.CycleName, + progressEntry.Value.RunSuffix), + progressEntry.Value.Progress, progressEntry.Value.ExecTime / 1000.0, + IIf(progressEntry.Value.Success, "Success", "Aborted"))}) If (Not progressEntry.Value.Success) Then sender.ReportProgress(100, New With {.Target = "ListBox", .Message = progressEntry.Value.Error.Message}) End If @@ -1701,33 +1713,51 @@ lbFound: For Each job As String In JobFileList Dim report As String = New FileOutputWriter(job).PDFReportName If File.Exists(report) Then - sender.ReportProgress(100, New With {.Target = "ListBox", .Message = String.Format("PDF-Report for '{0}' written to {1}", Path.GetFileName(job), report), .Link = report}) + sender.ReportProgress(100, + New _ + With {.Target = "ListBox", + .Message = String.Format("PDF-Report for '{0}' written to {1}", Path.GetFileName(job), report), .Link = report + }) End If Next If File.Exists(sumFileWriter.SumFileName) Then sender.ReportProgress(100, New With {.Target = "ListBox", - .Message = String.Format("Sum File written to {0}", sumFileWriter.SumFileName), - .Link = sumFileWriter.SumFileName}) + .Message = String.Format("Sum File written to {0}", sumFileWriter.SumFileName), + .Link = sumFileWriter.SumFileName}) End If - sender.ReportProgress(100, New With {.Target = "ListBox", .Message = String.Format("Simulation Finished in {0:0}s", (DateTime.Now() - start).TotalSeconds)}) + sender.ReportProgress(100, + New _ + With {.Target = "ListBox", + .Message = String.Format("Simulation Finished in {0:0}s", (DateTime.Now() - start).TotalSeconds)}) End Sub - Private Shared Sub PrintRuns(progress As Dictionary(Of Integer, JobContainer.ProgressEntry), fileWriters As Dictionary(Of Integer, FileOutputWriter)) + Private Shared Sub PrintRuns(progress As Dictionary(Of Integer, JobContainer.ProgressEntry), + fileWriters As Dictionary(Of Integer, FileOutputWriter)) For Each p As KeyValuePair(Of Integer, JobContainer.ProgressEntry) In progress Dim modFilename As String = fileWriters(p.Key).GetModDataFileName(p.Value.RunName, p.Value.CycleName, p.Value.RunSuffix + IIf(Cfg.Mod1Hz, "_1Hz", "")) + p.Value.RunSuffix) Dim runName As String = String.Format("{0} {1} {2}", p.Value.RunName, p.Value.CycleName, p.Value.RunSuffix) If Not p.Value.Error Is Nothing Then - VECTOworkerV3.ReportProgress(0, New With {.Target = "ListBoxError", .Message = String.Format("Finished Run {0} with ERROR: {1}", runName, p.Value.Error.Message), .Link = modFilename}) + VECTOworkerV3.ReportProgress(0, + New _ + With {.Target = "ListBoxError", + .Message = String.Format("Finished Run {0} with ERROR: {1}", runName, p.Value.Error.Message), + .Link = modFilename}) Else - VECTOworkerV3.ReportProgress(0, New With {.Target = "ListBox", .Message = String.Format("Finished Run {0} successfully.", runName)}) + VECTOworkerV3.ReportProgress(0, + New With {.Target = "ListBox", .Message = String.Format("Finished Run {0} successfully.", runName)}) End If If (File.Exists(modFilename)) Then - VECTOworkerV3.ReportProgress(0, New With {.Target = "ListBox", .Message = String.Format("Run {0}: Modal Results written to {1}", runName, modFilename), .Link = modFilename}) + VECTOworkerV3.ReportProgress(0, + New _ + With {.Target = "ListBox", + .Message = String.Format("Run {0}: Modal Results written to {1}", runName, modFilename), .Link = modFilename + }) End If Next End Sub diff --git a/VECTO/Input Files/cMAP.vb b/VECTO/Input Files/cMAP.vb index 3883d1b451c3c5de3f3aea88afb6e4af78e13fa2..306c02c1df8ec90fec347d52180db66b9d2f5dd5 100644 --- a/VECTO/Input Files/cMAP.vb +++ b/VECTO/Input Files/cMAP.vb @@ -9,6 +9,8 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.Configuration Imports VectoAuxiliaries Public Class cMAP @@ -187,9 +189,11 @@ lbEr: #End Region - Public Function GetFuelConsumption(torque As Double, angularVelocity As Double) As Double _ + Public Function GetFuelConsumption(torque As NewtonMeter, angularVelocity As PerSecond) As KilogramPerSecond _ Implements IFuelConsumptionMap.GetFuelConsumption - Return fFCdelaunay_Intp(angularVelocity, torque) + 'MQ: TODO: check units! + Return _ + (fFCdelaunay_Intp(angularVelocity.Value() / Constants.RPMToRad, torque.Value()) / 3600 / 1000).SI(Of KilogramPerSecond)() End Function End Class diff --git a/VECTO/MODcalc/cPower.vb b/VECTO/MODcalc/cPower.vb index 05038adebaeccba0977e7981cf9257b383c69862..e1c8e498a03a705b8493da6a960fc407eeea5d17 100644 --- a/VECTO/MODcalc/cPower.vb +++ b/VECTO/MODcalc/cPower.vb @@ -9,6 +9,7 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports TUGraz.VectoCommon.Utils Public Class cPower Private ClutchNorm As Single 'Normalized clutch speed @@ -1555,35 +1556,40 @@ lb_nOK: End If mAAUX_Global.EngineDrivelineTorque = nPeToM(nU, P) - (((Paux) * 1000) / (EngineSpeed / 9.55)) - mAAUX_Global.advancedAuxModel.Signals.EngineDrivelineTorque = mAAUX_Global.EngineDrivelineTorque + mAAUX_Global.advancedAuxModel.Signals.EngineDrivelineTorque = + mAAUX_Global.EngineDrivelineTorque.SI(Of NewtonMeter)() - advancedAuxModel.CycleStep(1, message) + advancedAuxModel.CycleStep(1.SI(Of Second), message) Try 'Add Mod Data - ModData.AA_NonSmartAlternatorsEfficiency.Add(advancedAuxModel.AA_NonSmartAlternatorsEfficiency) - ModData.AA_SmartIdleCurrent_Amps.Add(advancedAuxModel.AA_SmartIdleCurrent_Amps) - ModData.AA_SmartIdleAlternatorsEfficiency.Add(advancedAuxModel.AA_SmartIdleAlternatorsEfficiency) - ModData.AA_SmartTractionCurrent_Amps.Add(advancedAuxModel.AA_SmartTractionCurrent_Amps) - ModData.AA_SmartTractionAlternatorEfficiency.Add(advancedAuxModel.AA_SmartTractionAlternatorEfficiency) - ModData.AA_SmartOverrunCurrent_Amps.Add(advancedAuxModel.AA_SmartOverrunCurrent_Amps) - ModData.AA_SmartOverrunAlternatorEfficiency.Add(advancedAuxModel.AA_SmartOverrunAlternatorEfficiency) - ModData.AA_CompressorFlowRate_LitrePerSec.Add(advancedAuxModel.AA_CompressorFlowRate_LitrePerSec) - ModData.AA_OverrunFlag.Add(advancedAuxModel.AA_OverrunFlag) - ModData.AA_EngineIdleFlag.Add(advancedAuxModel.AA_EngineIdleFlag) - ModData.AA_CompressorFlag.Add(advancedAuxModel.AA_CompressorFlag) - ModData.AA_TotalCycleFC_Grams.Add(advancedAuxModel.AA_TotalCycleFC_Grams) - ModData.AA_TotalCycleFC_Litres.Add(advancedAuxModel.AA_TotalCycleFC_Litres) - - MODdata.AA_AveragePowerDemandCrankHVACMechanicals.Add(advancedAuxModel.AA_AveragePowerDemandCrankHVACMechanicals) - MODdata.AA_AveragePowerDemandCrankHVACElectricals.Add(advancedAuxModel.AA_AveragePowerDemandCrankHVACElectricals) - MODdata.AA_AveragePowerDemandCrankElectrics.Add(advancedAuxModel.AA_AveragePowerDemandCrankElectrics) - MODdata.AA_AveragePowerDemandCrankPneumatics.Add(advancedAuxModel.AA_AveragePowerDemandCrankPneumatics) - MODdata.AA_TotalCycleFuelConsumptionCompressorOff.Add(advancedAuxModel.AA_TotalCycleFuelConsumptionCompressorOff) - MODdata.AA_TotalCycleFuelConsumptionCompressorOn.Add(advancedAuxModel.AA_TotalCycleFuelConsumptionCompressorOn) + MODdata.AA_NonSmartAlternatorsEfficiency.Add(advancedAuxModel.AA_NonSmartAlternatorsEfficiency()) + MODdata.AA_SmartIdleCurrent_Amps.Add(advancedAuxModel.AA_SmartIdleCurrent_Amps().Value()) + MODdata.AA_SmartIdleAlternatorsEfficiency.Add(advancedAuxModel.AA_SmartIdleAlternatorsEfficiency()) + MODdata.AA_SmartTractionCurrent_Amps.Add(advancedAuxModel.AA_SmartTractionCurrent_Amps().Value()) + MODdata.AA_SmartTractionAlternatorEfficiency.Add(advancedAuxModel.AA_SmartTractionAlternatorEfficiency()) + MODdata.AA_SmartOverrunCurrent_Amps.Add(advancedAuxModel.AA_SmartOverrunCurrent_Amps().Value()) + MODdata.AA_SmartOverrunAlternatorEfficiency.Add(advancedAuxModel.AA_SmartOverrunAlternatorEfficiency()) + MODdata.AA_CompressorFlowRate_LitrePerSec.Add(advancedAuxModel.AA_CompressorFlowRate_LitrePerSec().Value()) + MODdata.AA_OverrunFlag.Add(advancedAuxModel.AA_OverrunFlag()) + MODdata.AA_EngineIdleFlag.Add(advancedAuxModel.AA_EngineIdleFlag) + MODdata.AA_CompressorFlag.Add(advancedAuxModel.AA_CompressorFlag()) + MODdata.AA_TotalCycleFC_Grams.Add(advancedAuxModel.AA_TotalCycleFC_Grams().Value()) + MODdata.AA_TotalCycleFC_Litres.Add(advancedAuxModel.AA_TotalCycleFC_Litres().Value()) + + MODdata.AA_AveragePowerDemandCrankHVACMechanicals.Add( + advancedAuxModel.AA_AveragePowerDemandCrankHVACMechanicals().Value()) + MODdata.AA_AveragePowerDemandCrankHVACElectricals.Add( + advancedAuxModel.AA_AveragePowerDemandCrankHVACElectricals().Value()) + MODdata.AA_AveragePowerDemandCrankElectrics.Add(advancedAuxModel.AA_AveragePowerDemandCrankElectrics().Value()) + MODdata.AA_AveragePowerDemandCrankPneumatics.Add(advancedAuxModel.AA_AveragePowerDemandCrankPneumatics().Value()) + MODdata.AA_TotalCycleFuelConsumptionCompressorOff.Add( + advancedAuxModel.AA_TotalCycleFuelConsumptionCompressorOff().Value()) + MODdata.AA_TotalCycleFuelConsumptionCompressorOn.Add( + advancedAuxModel.AA_TotalCycleFuelConsumptionCompressorOn().Value()) 'TODO:DIAGNOSTICS - REMOVE WHEN TESTED @@ -2742,18 +2748,19 @@ lb10: Try mAAUX_Global.advancedAuxModel.Signals.ClutchEngaged = mAAUX_Global.ClutchEngaged - mAAUX_Global.advancedAuxModel.Signals.EngineDrivelinePower = mAAUX_Global.EngineDrivelinePower - mAAUX_Global.advancedAuxModel.Signals.EngineDrivelineTorque = mAAUX_Global.EngineDrivelineTorque - mAAUX_Global.advancedAuxModel.Signals.EngineMotoringPower = mAAUX_Global.EngineMotoringPower - mAAUX_Global.advancedAuxModel.Signals.EngineSpeed = mAAUX_Global.EngineSpeed - mAAUX_Global.advancedAuxModel.Signals.PreExistingAuxPower = mAAUX_Global.PreExistingAuxPower + mAAUX_Global.advancedAuxModel.Signals.EngineDrivelinePower = (mAAUX_Global.EngineDrivelinePower * 1000).SI(Of Watt)() + mAAUX_Global.advancedAuxModel.Signals.EngineDrivelineTorque = + mAAUX_Global.EngineDrivelineTorque.SI(Of NewtonMeter)() + mAAUX_Global.advancedAuxModel.Signals.EngineMotoringPower = (mAAUX_Global.EngineMotoringPower * 1000).SI(Of Watt)() + mAAUX_Global.advancedAuxModel.Signals.EngineSpeed = mAAUX_Global.EngineSpeed.RPMtoRad() + mAAUX_Global.advancedAuxModel.Signals.PreExistingAuxPower = (mAAUX_Global.PreExistingAuxPower * 1000).SI(Of Watt)() mAAUX_Global.advancedAuxModel.Signals.Idle = mAAUX_Global.Idle mAAUX_Global.advancedAuxModel.Signals.InNeutral = mAAUX_Global.InNeutral mAAUX_Global.advancedAuxModel.Signals.RunningCalc = mAAUX_Global.RunningCalc - mAAUX_Global.advancedAuxModel.Signals.Internal_Engine_Power = mAAUX_Global.Internal_Engine_Power + mAAUX_Global.advancedAuxModel.Signals.InternalEnginePower = (mAAUX_Global.Internal_Engine_Power * 1000).SI(Of Watt)() 'Power coming out of Advanced Model is in Watts. - power = (advancedAuxModel.AuxiliaryPowerAtCrankWatts / 1000) + power = (advancedAuxModel.AuxiliaryPowerAtCrankWatts().Value() / 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/VECTO/mAAUX_Global.vb b/VECTO/mAAUX_Global.vb index 1eb3e26e569b7043e27eff5c55ea4c974d61b591..e671561c10542a6fdca33581e63d21ffa8a9c81c 100644 --- a/VECTO/mAAUX_Global.vb +++ b/VECTO/mAAUX_Global.vb @@ -1,6 +1,7 @@ Imports System.Collections.Generic Imports VectoAuxiliaries Imports System.IO +Imports TUGraz.VectoCommon.Utils Module mAAUX_Global Public ClutchEngaged As Boolean @@ -60,13 +61,13 @@ Module mAAUX_Global 'Set Statics advancedAuxModel.VectoInputs.Cycle = DetermineCycleNameFromCurrentFile() - advancedAuxModel.VectoInputs.VehicleWeightKG = VEH.Mass + advancedAuxModel.VectoInputs.VehicleWeightKG = VEH.Mass.SI(Of Kilogram)() advancedAuxModel.VectoInputs.FuelMap = fuelMap 'ENG.FuelMapFullPath - advancedAuxModel.VectoInputs.FuelDensity = Cfg.FuelDens + advancedAuxModel.VectoInputs.FuelDensity = CType(Cfg.FuelDens * 1000, Double).SI(Of KilogramPerCubicMeter)() 'Set Signals advancedAuxModel.Signals.TotalCycleTimeSeconds = CycleTimeInSeconds - advancedAuxModel.Signals.EngineIdleSpeed = ENG.Nidle + advancedAuxModel.Signals.EngineIdleSpeed = ENG.Nidle.RPMtoRad() advancedAuxModel.RunStart(aauxFile, VEC.FilePath) diff --git a/VECTOAux/VectoAuxiliaries/AdvancedAuxiliaries.vb b/VECTOAux/VectoAuxiliaries/AdvancedAuxiliaries.vb index fed02ad3081b0de7bf8c96aa2087a7b6192546b2..d7c2bc0f999f09385b584e7b55e4acac3b5593f5 100644 --- a/VECTOAux/VectoAuxiliaries/AdvancedAuxiliaries.vb +++ b/VECTOAux/VectoAuxiliaries/AdvancedAuxiliaries.vb @@ -15,6 +15,7 @@ Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Imports VectoAuxiliaries.DownstreamModules Imports System.Windows.Forms +Imports TUGraz.VectoCommon.Utils ''' <summary> @@ -61,7 +62,7 @@ Public Class AdvancedAuxiliaries 'Event Handler top level bubble. Public Sub VectoEventHandler(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) _ - Handles CompressorMap.AuxiliaryEvent, AlternatorMap.AuxiliaryEvent, SSMTOOL.Message, ssmToolModule14.Message + Handles compressorMap.AuxiliaryEvent, alternatorMap.AuxiliaryEvent, ssmTool.Message, ssmToolModule14.Message If Signals.AuxiliaryEventReportingLevel <= messageType Then @@ -137,31 +138,31 @@ Public Class AdvancedAuxiliaries M0 = New M0_NonSmart_AlternatorsSetEfficiency(auxConfig.ElectricalUserInputsConfig.ElectricalConsumers, alternatorMap, - auxConfig.ElectricalUserInputsConfig.PowerNetVoltage, + auxConfig.ElectricalUserInputsConfig.PowerNetVoltage.SI(Of Volt), Signals, ssmTool) - M05 = New M0_5_SmartAlternatorSetEfficiency(M0, - auxConfig.ElectricalUserInputsConfig.ElectricalConsumers, - alternatorMap, - auxConfig.ElectricalUserInputsConfig.ResultCardIdle, - auxConfig.ElectricalUserInputsConfig.ResultCardTraction, - auxConfig.ElectricalUserInputsConfig.ResultCardOverrun, Signals) - + Dim M05tmp As M0_5_SmartAlternatorSetEfficiency = New M0_5_SmartAlternatorSetEfficiency(M0, + auxConfig.ElectricalUserInputsConfig.ElectricalConsumers, + alternatorMap, + auxConfig.ElectricalUserInputsConfig.ResultCardIdle, + auxConfig.ElectricalUserInputsConfig.ResultCardTraction, + auxConfig.ElectricalUserInputsConfig.ResultCardOverrun, Signals) + M05 = M05tmp M1 = New M1_AverageHVACLoadDemand(M0, auxConfig.ElectricalUserInputsConfig.AlternatorGearEfficiency, auxConfig.PneumaticUserInputsConfig.CompressorGearEfficiency, - auxConfig.ElectricalUserInputsConfig.PowerNetVoltage, + auxConfig.ElectricalUserInputsConfig.PowerNetVoltage.SI(Of Volt), Signals, - ssmTOOL) + ssmTool) M2 = New M2_AverageElectricalLoadDemand(auxConfig.ElectricalUserInputsConfig.ElectricalConsumers, M0, auxConfig.ElectricalUserInputsConfig.AlternatorGearEfficiency, - auxConfig.ElectricalUserInputsConfig.PowerNetVoltage, Signals) + auxConfig.ElectricalUserInputsConfig.PowerNetVoltage.SI(Of Volt), Signals) M3 = New M3_AveragePneumaticLoadDemand(auxConfig.PneumaticUserInputsConfig, @@ -174,7 +175,7 @@ Public Class AdvancedAuxiliaries M4 = New M4_AirCompressor(compressorMap, auxConfig.PneumaticUserInputsConfig.CompressorGearRatio, auxConfig.PneumaticUserInputsConfig.CompressorGearEfficiency, Signals) - M5 = New M5__SmartAlternatorSetGeneration(M05, auxConfig.ElectricalUserInputsConfig.PowerNetVoltage, + M5 = New M5__SmartAlternatorSetGeneration(M05tmp, auxConfig.ElectricalUserInputsConfig.PowerNetVoltage.SI(Of Volt), auxConfig.ElectricalUserInputsConfig.AlternatorGearEfficiency) M6 = New M6(M1, M2, M3, M4, M5, Signals) M7 = New M7(M5, M6, Signals) @@ -227,7 +228,7 @@ Public Class AdvancedAuxiliaries Return True End Function - Public Function CycleStep(seconds As Double, ByRef message As String) As Boolean _ + Public Function CycleStep(seconds As Second, ByRef message As String) As Boolean _ Implements VectoAuxiliaries.IAdvancedAuxiliaries.CycleStep Try @@ -235,7 +236,7 @@ Public Class AdvancedAuxiliaries M10.CycleStep(seconds) M11.CycleStep(seconds) - Signals.CurrentCycleTimeInSeconds += seconds + Signals.CurrentCycleTimeInSeconds += seconds.Value() Catch ex As Exception MessageBox.Show("Exception: " + ex.Message + " Stack Trace: " + ex.StackTrace) Return False @@ -271,30 +272,22 @@ Public Class AdvancedAuxiliaries Throw New NotImplementedException End Function - Public ReadOnly Property TotalFuelGRAMS As Single Implements VectoAuxiliaries.IAdvancedAuxiliaries.TotalFuelGRAMS + Public ReadOnly Property TotalFuelGRAMS As Kilogram Implements VectoAuxiliaries.IAdvancedAuxiliaries.TotalFuelGRAMS Get If Not M13 Is Nothing Then - Return M14.TotalCycleFCGrams - Else - - Return 0 - + Return 0.SI(Of Kilogram)() End If End Get End Property - Public ReadOnly Property TotalFuelLITRES As Single Implements VectoAuxiliaries.IAdvancedAuxiliaries.TotalFuelLITRES + Public ReadOnly Property TotalFuelLITRES As Liter Implements VectoAuxiliaries.IAdvancedAuxiliaries.TotalFuelLITRES Get If Not M14 Is Nothing Then - Return M14.TotalCycleFCLitres - Else - - Return 0 - + Return 0.SI(Of Liter)() End If End Get End Property @@ -343,62 +336,62 @@ Public Class AdvancedAuxiliaries 'Diagnostics outputs for testing purposes in Vecto. 'Eventually this can be removed or rendered non effective to reduce calculation load on the model. - Public ReadOnly Property AA_NonSmartAlternatorsEfficiency As Single? _ + Public ReadOnly Property AA_NonSmartAlternatorsEfficiency As Double _ Implements IAdvancedAuxiliaries.AA_NonSmartAlternatorsEfficiency Get Return M0.AlternatorsEfficiency End Get End Property - Public ReadOnly Property AA_SmartIdleCurrent_Amps As Single? Implements IAdvancedAuxiliaries.AA_SmartIdleCurrent_Amps + Public ReadOnly Property AA_SmartIdleCurrent_Amps As Ampere Implements IAdvancedAuxiliaries.AA_SmartIdleCurrent_Amps Get Return M05.SmartIdleCurrent End Get End Property - Public ReadOnly Property AA_SmartIdleAlternatorsEfficiency As Single? _ + Public ReadOnly Property AA_SmartIdleAlternatorsEfficiency As Double _ Implements IAdvancedAuxiliaries.AA_SmartIdleAlternatorsEfficiency Get Return M05.AlternatorsEfficiencyIdleResultCard End Get End Property - Public ReadOnly Property AA_SmartTractionCurrent_Amps As Single? _ + Public ReadOnly Property AA_SmartTractionCurrent_Amps As Ampere _ Implements IAdvancedAuxiliaries.AA_SmartTractionCurrent_Amps Get Return M05.SmartTractionCurrent End Get End Property - Public ReadOnly Property AA_SmartTractionAlternatorEfficiency As Single? _ + Public ReadOnly Property AA_SmartTractionAlternatorEfficiency As Double _ Implements IAdvancedAuxiliaries.AA_SmartTractionAlternatorEfficiency Get Return M05.AlternatorsEfficiencyTractionOnResultCard End Get End Property - Public ReadOnly Property AA_SmartOverrunCurrent_Amps As Single? _ + Public ReadOnly Property AA_SmartOverrunCurrent_Amps As Ampere _ Implements IAdvancedAuxiliaries.AA_SmartOverrunCurrent_Amps Get Return M05.SmartOverrunCurrent End Get End Property - Public ReadOnly Property AA_SmartOverrunAlternatorEfficiency As Single? _ + Public ReadOnly Property AA_SmartOverrunAlternatorEfficiency As Double _ Implements IAdvancedAuxiliaries.AA_SmartOverrunAlternatorEfficiency Get Return M05.AlternatorsEfficiencyOverrunResultCard End Get End Property - Public ReadOnly Property AA_CompressorFlowRate_LitrePerSec As Single? _ + Public ReadOnly Property AA_CompressorFlowRate_LitrePerSec As NormLiterPerSecond _ Implements IAdvancedAuxiliaries.AA_CompressorFlowRate_LitrePerSec Get Return M4.GetFlowRate End Get End Property - Public ReadOnly Property AA_OverrunFlag As Integer? Implements IAdvancedAuxiliaries.AA_OverrunFlag + Public ReadOnly Property AA_OverrunFlag As Boolean Implements IAdvancedAuxiliaries.AA_OverrunFlag Get Return M6.OverrunFlag End Get @@ -409,71 +402,71 @@ Public Class AdvancedAuxiliaries Return _ If _ - (signals.EngineSpeed <= _signals.EngineIdleSpeed AndAlso (Not signals.ClutchEngaged OrElse signals.InNeutral), 1, 0) + (Signals.EngineSpeed <= _Signals.EngineIdleSpeed AndAlso (Not Signals.ClutchEngaged OrElse Signals.InNeutral), 1, 0) End Get End Property - Public ReadOnly Property AA_CompressorFlag As Integer? Implements IAdvancedAuxiliaries.AA_CompressorFlag + Public ReadOnly Property AA_CompressorFlag As Boolean Implements IAdvancedAuxiliaries.AA_CompressorFlag Get Return M8.CompressorFlag End Get End Property - Public ReadOnly Property AA_TotalCycleFC_Grams As Single? Implements IAdvancedAuxiliaries.AA_TotalCycleFC_Grams + Public ReadOnly Property AA_TotalCycleFC_Grams As Kilogram Implements IAdvancedAuxiliaries.AA_TotalCycleFC_Grams Get Return M14.TotalCycleFCGrams End Get End Property - Public ReadOnly Property AA_TotalCycleFC_Litres As Single? Implements IAdvancedAuxiliaries.AA_TotalCycleFC_Litres + Public ReadOnly Property AA_TotalCycleFC_Litres As Liter Implements IAdvancedAuxiliaries.AA_TotalCycleFC_Litres Get Return M14.TotalCycleFCLitres End Get End Property - Public ReadOnly Property AuxiliaryPowerAtCrankWatts As Single _ + Public ReadOnly Property AuxiliaryPowerAtCrankWatts As Watt _ Implements IAdvancedAuxiliaries.AuxiliaryPowerAtCrankWatts Get Return M8.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries End Get End Property - Public ReadOnly Property AA_AveragePowerDemandCrankHVACMechanicals As Single? _ + Public ReadOnly Property AA_AveragePowerDemandCrankHVACMechanicals As Watt _ Implements IAdvancedAuxiliaries.AA_AveragePowerDemandCrankHVACMechanicals Get Return M1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts() End Get End Property - Public ReadOnly Property AA_AveragePowerDemandCrankHVACElectricals As Single? _ + Public ReadOnly Property AA_AveragePowerDemandCrankHVACElectricals As Watt _ Implements IAdvancedAuxiliaries.AA_AveragePowerDemandCrankHVACElectricals Get Return M1.AveragePowerDemandAtCrankFromHVACElectricsWatts() End Get End Property - Public ReadOnly Property AA_AveragePowerDemandCrankElectrics As Single? _ + Public ReadOnly Property AA_AveragePowerDemandCrankElectrics As Watt _ Implements IAdvancedAuxiliaries.AA_AveragePowerDemandCrankElectrics Get Return M2.GetAveragePowerAtCrankFromElectrics() End Get End Property - Public ReadOnly Property AA_AveragePowerDemandCrankPneumatics As Single? _ + Public ReadOnly Property AA_AveragePowerDemandCrankPneumatics As Watt _ Implements IAdvancedAuxiliaries.AA_AveragePowerDemandCrankPneumatics Get Return M3.GetAveragePowerDemandAtCrankFromPneumatics() End Get End Property - Public ReadOnly Property AA_TotalCycleFuelConsumptionCompressorOff As Single? _ + Public ReadOnly Property AA_TotalCycleFuelConsumptionCompressorOff As Kilogram _ Implements IAdvancedAuxiliaries.AA_TotalCycleFuelConsumptionCompressorOff Get Return M9.TotalCycleFuelConsumptionCompressorOffContinuously End Get End Property - Public ReadOnly Property AA_TotalCycleFuelConsumptionCompressorOn As Single? _ + Public ReadOnly Property AA_TotalCycleFuelConsumptionCompressorOn As Kilogram _ Implements IAdvancedAuxiliaries.AA_TotalCycleFuelConsumptionCompressorOn Get Return M9.TotalCycleFuelConsumptionCompressorOnContinuously @@ -484,57 +477,57 @@ Public Class AdvancedAuxiliaries 'TODO:REMOVE WHEN TESTING IS COMPLETE 'PURE DIAGNOSTICS SHOULD ONLY BE USED IN MOD FOR ENGINEERING TESTS - Public ReadOnly Property AA_D_M10_INTERP1 As Single Implements IAdvancedAuxiliaries.AA_D_M12_INTERP1 + Public ReadOnly Property AA_D_M12_INTERP1 As Kilogram Implements IAdvancedAuxiliaries.AA_D_M12_INTERP1 Get - Return M12.INTRP1 + Return M12.INTRP1() End Get End Property - Public ReadOnly Property AA_D_M10_INTERP2 As Single Implements IAdvancedAuxiliaries.AA_D_M12_INTERP2 + Public ReadOnly Property AA_D_M12_INTERP2 As Kilogram Implements IAdvancedAuxiliaries.AA_D_M12_INTERP2 Get - Return M12.INTRP2 + Return M12.INTRP2() End Get End Property - Public ReadOnly Property AA_D_M12_P1X As Single Implements IAdvancedAuxiliaries.AA_D_M12_P1X + Public ReadOnly Property AA_D_M12_P1X As Joule Implements IAdvancedAuxiliaries.AA_D_M12_P1X Get - Return M12.P1X + Return M12.P1X() End Get End Property - Public ReadOnly Property AA_D_M12_P1Y As Single Implements IAdvancedAuxiliaries.AA_D_M12_P1Y + Public ReadOnly Property AA_D_M12_P1Y As Kilogram Implements IAdvancedAuxiliaries.AA_D_M12_P1Y Get - Return M12.P1Y + Return M12.P1Y() End Get End Property - Public ReadOnly Property AA_D_M12_P2X As Single Implements IAdvancedAuxiliaries.AA_D_M12_P2X + Public ReadOnly Property AA_D_M12_P2X As Joule Implements IAdvancedAuxiliaries.AA_D_M12_P2X Get - Return M12.P2X + Return M12.P2X() End Get End Property - Public ReadOnly Property AA_D_M12_P2Y As Single Implements IAdvancedAuxiliaries.AA_D_M12_P2Y + Public ReadOnly Property AA_D_M12_P2Y As Kilogram Implements IAdvancedAuxiliaries.AA_D_M12_P2Y Get - Return M12.P2Y + Return M12.P2Y() End Get End Property - Public ReadOnly Property AA_D_M12_P3X As Single Implements IAdvancedAuxiliaries.AA_D_M12_P3X + Public ReadOnly Property AA_D_M12_P3X As Joule Implements IAdvancedAuxiliaries.AA_D_M12_P3X Get - Return M12.P3X + Return M12.P3X() End Get End Property - Public ReadOnly Property AA_D_M12_P3Y As Single Implements IAdvancedAuxiliaries.AA_D_M12_P3Y + Public ReadOnly Property AA_D_M12_P3Y As Kilogram Implements IAdvancedAuxiliaries.AA_D_M12_P3Y Get - Return M12.P3Y + Return M12.P3Y() End Get End Property - Public ReadOnly Property AA_D_M12_XTAIN As Single Implements IAdvancedAuxiliaries.AA_D_M12_XTAIN + Public ReadOnly Property AA_D_M12_XTAIN As Joule Implements IAdvancedAuxiliaries.AA_D_M12_XTAIN Get - Return M12.XTAIN + Return M12.XTAIN() End Get End Property End Class diff --git a/VECTOAux/VectoAuxiliaries/AuxiliaryConfig.vb b/VECTOAux/VectoAuxiliaries/AuxiliaryConfig.vb index 46a06976dad9d7e9a086429ea9f3815a0ce03b4d..3f95ec9bf666ca24d28037ec069e532b0c76b704 100644 --- a/VECTOAux/VectoAuxiliaries/AuxiliaryConfig.vb +++ b/VECTOAux/VectoAuxiliaries/AuxiliaryConfig.vb @@ -16,6 +16,7 @@ Imports System.IO Imports VectoAuxiliaries.DownstreamModules Imports System.Windows.Forms Imports Newtonsoft.Json +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries <Serializable()> @@ -40,6 +41,7 @@ Public Class AuxiliaryConfig Public Property HvacUserInputsConfig As IHVACUserInputsConfig Implements IAuxiliaryConfig.HvacUserInputsConfig 'Vecto Signals + <JsonIgnore> Public Property Signals As ISignals 'Constructors @@ -53,7 +55,8 @@ Public Class AuxiliaryConfig 'Special Condition If auxConfigFile = "EMPTY" Then ElectricalUserInputsConfig = New ElectricsUserInputsConfig() With {.PowerNetVoltage = 28.3} - ElectricalUserInputsConfig.ElectricalConsumers = New ElectricalConsumerList(28.3, 0.096, False) + ElectricalUserInputsConfig.ElectricalConsumers = New ElectricalConsumerList(28.3, 0.096, + False) ElectricalUserInputsConfig.ResultCardIdle = New ResultCard(New List(Of SmartResult)) ElectricalUserInputsConfig.ResultCardOverrun = New ResultCard(New List(Of SmartResult)) ElectricalUserInputsConfig.ResultCardTraction = New ResultCard(New List(Of SmartResult)) @@ -64,9 +67,9 @@ Public Class AuxiliaryConfig End If - If auxConfigFile Is Nothing OrElse auxConfigFile.Trim().Length = 0 OrElse Not FILE.Exists(auxConfigFile) Then + If auxConfigFile Is Nothing OrElse auxConfigFile.Trim().Length = 0 OrElse Not File.Exists(auxConfigFile) Then - setdefaults() + setDefaults() Else @@ -82,15 +85,17 @@ Public Class AuxiliaryConfig 'Set Default Values Private Sub setDefaults() - VectoInputs = New VectoInputs With {.Cycle = "Urban", .VehicleWeightKG = 16500, .PowerNetVoltage = 28.3} - Signals = New Signals With {.EngineSpeed = 2000, .TotalCycleTimeSeconds = 3114, .ClutchEngaged = False} + Dim tmp As VectoInputs = New VectoInputs _ + With {.Cycle = "Urban", .VehicleWeightKG = 16500.SI(Of Kilogram)(), .PowerNetVoltage = 28.3.SI(Of Volt)()} + VectoInputs = tmp + Signals = New Signals With {.EngineSpeed = 2000.RPMtoRad(), .TotalCycleTimeSeconds = 3114, .ClutchEngaged = False} 'Pneumatics set deault values PneumaticUserInputsConfig = New PneumaticUserInputsConfig(True) PneumaticAuxillariesConfig = New PneumaticsAuxilliariesConfig(True) 'Electrical set deault values - ElectricalUserInputsConfig = New ElectricsUserInputsConfig(True, VectoInputs) + ElectricalUserInputsConfig = New ElectricsUserInputsConfig(True, tmp) ElectricalUserInputsConfig.ElectricalConsumers = New ElectricalConsumerList(28.3, 0.096, True) 'HVAC set deault values diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM10.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM10.vb index 7a5412912d6da4ea723164677a858e9785deb3cb..33375e64882a43e66712723ce171d6fc484a56ec 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM10.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM10.vb @@ -9,6 +9,7 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac @@ -17,23 +18,23 @@ Imports VectoAuxiliaries.DownstreamModules Namespace DownstreamModules Public Interface IM10 'AverageLoadsFuelConsumptionInterpolatedForPneumatics - ReadOnly Property AverageLoadsFuelConsumptionInterpolatedForPneumatics As Single + ReadOnly Property AverageLoadsFuelConsumptionInterpolatedForPneumatics As Kilogram 'Interpolated FC between points 2-3-1 Representing smart Pneumatics = Fuel consumption with smart Pneumatics and average electrical power demand - ReadOnly Property FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand As Single + ReadOnly Property FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand As Kilogram - Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0) + Sub CycleStep(stepTimeInSeconds As Second) 'Added for diagnostic inspection purposes only, does not materially affect the class function. - ReadOnly Property P1X As Single - ReadOnly Property P1Y As Single - ReadOnly Property P2X As Single - ReadOnly Property P2Y As Single - ReadOnly Property P3X As Single - ReadOnly Property P3Y As Single - ReadOnly Property XTAIN As Single - ReadOnly Property INTRP1 As Single - ReadOnly Property INTRP2 As Single + ReadOnly Property P1X As NormLiter + ReadOnly Property P1Y As Kilogram + ReadOnly Property P2X As NormLiter + ReadOnly Property P2Y As Kilogram + ReadOnly Property P3X As NormLiter + ReadOnly Property P3Y As Kilogram + ReadOnly Property XTAIN As NormLiter + ReadOnly Property INTRP1 As Kilogram + ReadOnly Property INTRP2 As Kilogram End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM11.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM11.vb index e47c61ab1c180eef4187563ea751c077a7409c0b..af031dbca530f1b6ea72a382ee346fa636a45783 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM11.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM11.vb @@ -9,6 +9,7 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac @@ -21,7 +22,7 @@ Namespace DownstreamModules ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly As Single + ReadOnly Property SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly As Joule ''' <summary> ''' Smart Electrical Total Cycle Eletrical EnergyGenerated (J) @@ -29,7 +30,7 @@ Namespace DownstreamModules ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property SmartElectricalTotalCycleEletricalEnergyGenerated As Single + ReadOnly Property SmartElectricalTotalCycleEletricalEnergyGenerated As Joule ''' <summary> ''' Total Cycle Electrical Demand (J) @@ -37,7 +38,7 @@ Namespace DownstreamModules ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property TotalCycleElectricalDemand As Single + ReadOnly Property TotalCycleElectricalDemand As Joule ''' <summary> ''' Total Cycle Fuel Consumption: Smart Electrical Load (g) @@ -45,7 +46,7 @@ Namespace DownstreamModules ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property TotalCycleFuelConsumptionSmartElectricalLoad As Single + ReadOnly Property TotalCycleFuelConsumptionSmartElectricalLoad As Kilogram ''' <summary> ''' Total Cycle Fuel Consumption: Zero Electrical Load (g) @@ -53,7 +54,7 @@ Namespace DownstreamModules ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property TotalCycleFuelConsumptionZeroElectricalLoad As Single + ReadOnly Property TotalCycleFuelConsumptionZeroElectricalLoad As Kilogram ''' <summary> ''' Stop Start Sensitive: Total Cycle Electrical Demand (J) @@ -61,7 +62,7 @@ Namespace DownstreamModules ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property StopStartSensitiveTotalCycleElectricalDemand As Single + ReadOnly Property StopStartSensitiveTotalCycleElectricalDemand As Joule ''' <summary> ''' Total Cycle Fuel Consuption : Average Loads (g) @@ -69,7 +70,7 @@ Namespace DownstreamModules ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property TotalCycleFuelConsuptionAverageLoads As Single + ReadOnly Property TotalCycleFuelConsuptionAverageLoads As Kilogram ''' <summary> ''' Clears aggregated values ( Sets them to zero ). @@ -82,7 +83,7 @@ Namespace DownstreamModules ''' </summary> ''' <param name="stepTimeInSeconds">Single : Mutiplies the values to be aggregated by number of seconds</param> ''' <remarks></remarks> - Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0) + Sub CycleStep(stepTimeInSeconds As Second) End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM12.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM12.vb index 6f8fdd15fb488c18ba8a806de8b1f2f359c7da1d..4f8a681b71efdce16e20d2a763dda7a29fdb91ea 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM12.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM12.vb @@ -8,50 +8,46 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace DownstreamModules - - Public Interface IM12 - - ''' <summary> - ''' Fuel consumption with smart Electrics and Average Pneumatic Power Demand - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand As Single - - ''' <summary> - ''' Base Fuel Consumption With Average Auxiliary Loads - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property BaseFuelConsumptionWithTrueAuxiliaryLoads As Single - ''' <summary> - ''' Stop Start Correction - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property StopStartCorrection As Single - - - 'Diagnostic Signals Only For Testing - No Material interference with operation of class. - ReadOnly Property P1X As Single - ReadOnly Property P1Y As Single - ReadOnly Property P2X As Single - ReadOnly Property P2Y As Single - ReadOnly Property P3X As Single - ReadOnly Property P3Y As Single - ReadOnly Property XTAIN As Single - ReadOnly Property INTRP1 As Single - ReadOnly Property INTRP2 As Single - - - End Interface - - + Public Interface IM12 + ''' <summary> + ''' Fuel consumption with smart Electrics and Average Pneumatic Power Demand + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand As Kilogram + + ''' <summary> + ''' Base Fuel Consumption With Average Auxiliary Loads + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property BaseFuelConsumptionWithTrueAuxiliaryLoads As Kilogram + + ''' <summary> + ''' Stop Start Correction + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property StopStartCorrection As Double + + + 'Diagnostic Signals Only For Testing - No Material interference with operation of class. + ReadOnly Property P1X As Joule + ReadOnly Property P1Y As Kilogram + ReadOnly Property P2X As Joule + ReadOnly Property P2Y As Kilogram + ReadOnly Property P3X As Joule + ReadOnly Property P3Y As Kilogram + ReadOnly Property XTAIN As Joule + ReadOnly Property INTRP1 As Kilogram + ReadOnly Property INTRP2 As Kilogram + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM13.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM13.vb index 33cb7bfa44b61b9f1be766bf38ec315bb4a8dd28..04531c6a0bc7945747c45c4bf145a57a659bc6c0 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM13.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM13.vb @@ -10,26 +10,21 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules - - Public Interface IM13 - - ''' <summary> - ''' Total Cycle Fuel Consumption Grams - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks>WHTC and Start Stop Adjusted</remarks> - ReadOnly Property WHTCTotalCycleFuelConsumptionGrams As Single - - - End Interface - - + Public Interface IM13 + ''' <summary> + ''' Total Cycle Fuel Consumption Grams + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks>WHTC and Start Stop Adjusted</remarks> + ReadOnly Property WHTCTotalCycleFuelConsumptionGrams As Kilogram + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM14.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM14.vb index db521cbf7f6622f2fd8ce904fe409e65ab3f3ac6..cd9537fc048ef1a08bd19f28bf3176f61cacedf2 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM14.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM14.vb @@ -1,18 +1,13 @@  +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules + Public Interface IM14 + ReadOnly Property TotalCycleFCGrams As Kilogram -Public Interface IM14 - - Readonly property TotalCycleFCGrams as single - - ReadOnly Property TotalCycleFCLitres As single - - - -End Interface - + ReadOnly Property TotalCycleFCLitres As Liter + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM6.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM6.vb index 2e79d9db8912dd789a5d9d983c4d80f2901631cc..0d688248cd3baf413f725ef49bd1f700d20bef1a 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM6.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM6.vb @@ -8,87 +8,82 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace DownstreamModules + Public Interface IM6 + ''' <summary> + ''' OverrunFlag + ''' </summary> + ''' <value></value> + ''' <returns>0 = Not in overrun, 1 = In Overrun</returns> + ''' <remarks></remarks> + ReadOnly Property OverrunFlag As Boolean - Public Interface IM6 + ''' <summary> + ''' Smart Elec And Pneumatics Compressor Flag + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartElecAndPneumaticsCompressorFlag As Boolean + ''' <summary> + ''' Smart Elec And Pneumatic: Alternator Power Gen At Crank (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartElecAndPneumaticAltPowerGenAtCrank As Watt - ''' <summary> - ''' OverrunFlag - ''' </summary> - ''' <value></value> - ''' <returns>0 = Not in overrun, 1 = In Overrun</returns> - ''' <remarks></remarks> - Readonly Property OverrunFlag As Integer - - ''' <summary> - ''' Smart Elec And Pneumatics Compressor Flag - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly Property SmartElecAndPneumaticsCompressorFlag As Integer - - ''' <summary> - ''' Smart Elec And Pneumatic: Alternator Power Gen At Crank (W) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property SmartElecAndPneumaticAltPowerGenAtCrank As Single - - ''' <summary> - ''' Smart Elec And Pneumatic: Air Compressor Power Gen At Crank (W) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property SmartElecAndPneumaticAirCompPowerGenAtCrank As Single - - ''' <summary> - ''' Smart Electrics Only : Alternator Power Gen At Crank (W) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property SmartElecOnlyAltPowerGenAtCrank As Single - - ''' <summary> -''' Average Power Demand At Crank From Pneumatics (W) -''' </summary> -''' <value></value> -''' <returns></returns> -''' <remarks></remarks> - ReadOnly Property AveragePowerDemandAtCrankFromPneumatics As Single - - ''' <summary> - ''' Smart Pneumatic Only Air Comp Power Gen At Crank (W) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property SmartPneumaticOnlyAirCompPowerGenAtCrank As Single - - ''' <summary> - ''' Avgerage Power Demand At Crank From Electrics Including HVAC electrics (W) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property AvgPowerDemandAtCrankFromElectricsIncHVAC As Single - - ''' <summary> - ''' Smart Pneumatics Only CompressorFlag - ''' </summary> - ''' <value></value> - ''' <returns>Less than Zero = No, Greater then Zero = Yes </returns> - ''' <remarks></remarks> - ReadOnly Property SmartPneumaticsOnlyCompressorFlag As Integer + ''' <summary> + ''' Smart Elec And Pneumatic: Air Compressor Power Gen At Crank (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartElecAndPneumaticAirCompPowerGenAtCrank As Watt - -End Interface + ''' <summary> + ''' Smart Electrics Only : Alternator Power Gen At Crank (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartElecOnlyAltPowerGenAtCrank As Watt + ''' <summary> + ''' Average Power Demand At Crank From Pneumatics (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property AveragePowerDemandAtCrankFromPneumatics As Watt + + ''' <summary> + ''' Smart Pneumatic Only Air Comp Power Gen At Crank (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartPneumaticOnlyAirCompPowerGenAtCrank As Watt + + ''' <summary> + ''' Avgerage Power Demand At Crank From Electrics Including HVAC electrics (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property AvgPowerDemandAtCrankFromElectricsIncHVAC As Watt + + ''' <summary> + ''' Smart Pneumatics Only CompressorFlag + ''' </summary> + ''' <value></value> + ''' <returns>Less than Zero = No, Greater then Zero = Yes </returns> + ''' <remarks></remarks> + ReadOnly Property SmartPneumaticsOnlyCompressorFlag As Boolean + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM7.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM7.vb index bc4535f78f923f44ab8375e4810c0ef3df9150ba..cbc4a99f9f4d95065580b1ef4991b69b4f4c61fa 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM7.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM7.vb @@ -9,48 +9,45 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules - - Public Interface IM7 - - ''' <summary> - ''' Smart Electrical And Pneumatic Aux: Alternator Power Gen At Crank (W) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Single - - ''' <summary> - ''' Smart Electrical And Pneumatic Aux : Air Compressor Power Gen At Crank (W) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Single - - ''' <summary> - ''' Smart Electrical Only Aux : Alternator Power Gen At Crank (W) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly property SmartElectricalOnlyAuxAltPowerGenAtCrank as single - - ''' <summary> - ''' Smart Pneumatic Only Aux : Air Comppressor Power Gen At Crank (W) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Single - - End Interface - + Public Interface IM7 + ''' <summary> + ''' Smart Electrical And Pneumatic Aux: Alternator Power Gen At Crank (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Watt + + ''' <summary> + ''' Smart Electrical And Pneumatic Aux : Air Compressor Power Gen At Crank (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Watt + + ''' <summary> + ''' Smart Electrical Only Aux : Alternator Power Gen At Crank (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartElectricalOnlyAuxAltPowerGenAtCrank As Watt + + ''' <summary> + ''' Smart Pneumatic Only Aux : Air Comppressor Power Gen At Crank (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Watt + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM8.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM8.vb index 857a0e0536840317a6ce3e7b06019e95c77ec5d6..971f8c6b069bfa2ec72fcdb9e58611e173047cc1 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM8.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM8.vb @@ -10,44 +10,38 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules - -Public Interface IM8 - - + Public Interface IM8 'OUT1 -''' <summary> -''' Aux Power At Crank From Electrical HVAC And Pneumatics Ancilaries (W) -''' </summary> -''' <value></value> -''' <returns></returns> -''' <remarks></remarks> -ReadOnly Property AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries As Single + ''' <summary> + ''' Aux Power At Crank From Electrical HVAC And Pneumatics Ancilaries (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries As Watt 'OUT2 -''' <summary> -''' Smart Electrical Alternator Power Gen At Crank (W) -''' </summary> -''' <value></value> -''' <returns></returns> -''' <remarks></remarks> -ReadOnly Property SmartElectricalAlternatorPowerGenAtCrank As Single + ''' <summary> + ''' Smart Electrical Alternator Power Gen At Crank (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartElectricalAlternatorPowerGenAtCrank As Watt 'OUT3 -''' <summary> -''' Compressor Flag -''' </summary> -''' <value></value> -''' <returns></returns> -''' <remarks></remarks> -ReadOnly Property CompressorFlag As Integer - - -End Interface - - + ''' <summary> + ''' Compressor Flag + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property CompressorFlag As Boolean + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM9.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM9.vb index 857e724fa80cb3c5784b6a037abf87ac8feb0623..a3477464b0458b9576aec1ff46d7c3f912755e2d 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/IM9.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/IM9.vb @@ -9,69 +9,60 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules - - Public Interface IM9 -Inherits IAuxiliaryEvent - - - ''' <summary> - ''' Clears aggregated values ( Sets them to zero ) - ''' </summary> - ''' <remarks></remarks> - Sub ClearAggregates() - - ''' <summary> - ''' Increments all aggregated outputs - ''' </summary> - ''' <param name="stepTimeInSeconds">Single : Mutiplies the values to be aggregated by number of seconds</param> - ''' <remarks></remarks> - Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0) - - ''' <summary> - ''' Litres Of Air: Compressor On Continually (L) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks>Start/Stop Sensitive</remarks> - ReadOnly Property LitresOfAirCompressorOnContinually As Single - - ''' <summary> - ''' Litres Of Air Compressor On Only In Overrun (L) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property LitresOfAirCompressorOnOnlyInOverrun As Single - - ''' <summary> - ''' Total Cycle Fuel Consumption Compressor *On* Continuously (G) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly property TotalCycleFuelConsumptionCompressorOnContinuously As single - - ''' <summary> - ''' Total Cycle Fuel Consumption Compressor *OFF* Continuously (G) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly property TotalCycleFuelConsumptionCompressorOffContinuously As single - - -End Interface - + Public Interface IM9 + Inherits IAuxiliaryEvent + + ''' <summary> + ''' Clears aggregated values ( Sets them to zero ) + ''' </summary> + ''' <remarks></remarks> + Sub ClearAggregates() + + ''' <summary> + ''' Increments all aggregated outputs + ''' </summary> + ''' <param name="stepTimeInSeconds">Single : Mutiplies the values to be aggregated by number of seconds</param> + ''' <remarks></remarks> + Sub CycleStep(stepTimeInSeconds As Second) + + ''' <summary> + ''' Litres Of Air: Compressor On Continually (L) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks>Start/Stop Sensitive</remarks> + ReadOnly Property LitresOfAirCompressorOnContinually As NormLiter + + ''' <summary> + ''' Litres Of Air Compressor On Only In Overrun (L) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property LitresOfAirCompressorOnOnlyInOverrun As NormLiter + + ''' <summary> + ''' Total Cycle Fuel Consumption Compressor *On* Continuously (G) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property TotalCycleFuelConsumptionCompressorOnContinuously As Kilogram + + ''' <summary> + ''' Total Cycle Fuel Consumption Compressor *OFF* Continuously (G) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property TotalCycleFuelConsumptionCompressorOffContinuously As Kilogram + End Interface End Namespace - - - - - diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M10.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M10.vb index 3f31e78b83e19118619adaaba8af83fdd753f9ce..1eb3be4564cbd8e64dbd2a6d47e03784f6623c49 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M10.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M10.vb @@ -9,6 +9,8 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac @@ -19,60 +21,68 @@ Namespace DownstreamModules Implements IM10 'Aggregators - Private _AverageAirConsumedLitre As Double + Private _AverageAirConsumedLitre As NormLiter 'Diagnostics - Private x1, y1, x2, y2, x3, y3, xTA, interp1, interp2 As Single - - Public ReadOnly Property P1X As Single Implements IM10.P1X + Private x1 As NormLiter + Private y1 As Kilogram + Private x2 As NormLiter + Private y2 As Kilogram + Private x3 As NormLiter + Private y3 As Kilogram + Private xTA As NormLiter + Private interp1 As Kilogram + Private interp2 As Kilogram + + Public ReadOnly Property P1X As NormLiter Implements IM10.P1X Get Return x1 End Get End Property - Public ReadOnly Property P1Y As Single Implements IM10.P1Y + Public ReadOnly Property P1Y As Kilogram Implements IM10.P1Y Get Return y1 End Get End Property - Public ReadOnly Property P2X As Single Implements IM10.P2X + Public ReadOnly Property P2X As NormLiter Implements IM10.P2X Get Return x2 End Get End Property - Public ReadOnly Property P2Y As Single Implements IM10.P2Y + Public ReadOnly Property P2Y As Kilogram Implements IM10.P2Y Get Return y2 End Get End Property - Public ReadOnly Property P3X As Single Implements IM10.P3X + Public ReadOnly Property P3X As NormLiter Implements IM10.P3X Get Return x3 End Get End Property - Public ReadOnly Property P3Y As Single Implements IM10.P3Y + Public ReadOnly Property P3Y As Kilogram Implements IM10.P3Y Get Return y3 End Get End Property - Public ReadOnly Property XTAIN As Single Implements IM10.XTAIN + Public ReadOnly Property XTAIN As NormLiter Implements IM10.XTAIN Get Return xTA End Get End Property - Public ReadOnly Property INTRP1 As Single Implements IM10.INTRP1 + Public ReadOnly Property INTRP1 As Kilogram Implements IM10.INTRP1 Get Return interp1 End Get End Property - Public ReadOnly Property INTRP2 As Single Implements IM10.INTRP2 + Public ReadOnly Property INTRP2 As Kilogram Implements IM10.INTRP2 Get Return interp2 End Get @@ -95,14 +105,14 @@ Namespace DownstreamModules SmartPneumtaics End Enum - Private Function Interpolate(interpType As InterpolationType) As Single + Private Function Interpolate(interpType As InterpolationType) As Kilogram - Dim returnValue As Single + Dim returnValue As Kilogram = 0.SI(Of Kilogram)() ' Dim x1,y1,x2,y2,x3,y3, xTA As Single x1 = m9.LitresOfAirCompressorOnContinually y1 = m9.TotalCycleFuelConsumptionCompressorOnContinuously - x2 = 0 + x2 = 0.SI(Of NormLiter)() y2 = m9.TotalCycleFuelConsumptionCompressorOffContinuously x3 = m9.LitresOfAirCompressorOnOnlyInOverrun y3 = m9.TotalCycleFuelConsumptionCompressorOffContinuously @@ -115,15 +125,15 @@ Namespace DownstreamModules 'Non-Smart Pneumatics ( OUT 1 ) Case InterpolationType.NonSmartPneumtaics - returnValue = y2 + (((y1 - y2) * xTA) / x1) + 'returnValue = (y2 + (((y1 - y2) * xTA) / x1)) + returnValue = VectoMath.Interpolate(x1, x2, y1, y2, xTA) interp1 = returnValue 'Smart Pneumatics ( OUT 2 ) Case InterpolationType.SmartPneumtaics - returnValue = y3 + (((y1 - y3) / (x1 - x3)) * (xTA - x3)) + 'returnValue = (y3 + (((y1 - y3) / (x1 - x3)) * (xTA - x3))) + returnValue = VectoMath.Interpolate(x1, x3, y1, y3, xTA) interp2 = returnValue - - End Select @@ -134,23 +144,23 @@ Namespace DownstreamModules #Region "Public Properties" - Public ReadOnly Property AverageLoadsFuelConsumptionInterpolatedForPneumatics As Single _ + Public ReadOnly Property AverageLoadsFuelConsumptionInterpolatedForPneumatics As Kilogram _ Implements IM10.AverageLoadsFuelConsumptionInterpolatedForPneumatics Get 'SCHM 3_02 - Dim intrp1 As Single = Interpolate(InterpolationType.NonSmartPneumtaics) + Dim intrp1 As Kilogram = Interpolate(InterpolationType.NonSmartPneumtaics) 'intrp1 = If(Not Single.IsNaN(intrp1), intrp1, 0) Return intrp1 End Get End Property - Public ReadOnly Property FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand As Single _ + Public ReadOnly Property FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand As Kilogram _ Implements IM10.FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand Get 'SCHM 3_02 - Dim intrp2 As Single = Interpolate(InterpolationType.SmartPneumtaics) + Dim intrp2 As Kilogram = Interpolate(InterpolationType.SmartPneumtaics) 'intrp2 = If(Not Single.IsNaN(intrp2), intrp2, 0) Return intrp2 End Get @@ -165,14 +175,17 @@ Namespace DownstreamModules Me.m3 = m3 Me.m9 = m9 Me.signals = signals + _AverageAirConsumedLitre = 0.SI(Of NormLiter)() End Sub #End Region - Public Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0) Implements IM10.CycleStep + Public Sub CycleStep(stepTimeInSeconds As Second) Implements IM10.CycleStep _AverageAirConsumedLitre += - If(Single.IsNaN(m3.AverageAirConsumedPerSecondLitre), 0, m3.AverageAirConsumedPerSecondLitre * stepTimeInSeconds) + If _ + (Double.IsNaN(m3.AverageAirConsumedPerSecondLitre.Value()), 0.SI(Of NormLiter), + m3.AverageAirConsumedPerSecondLitre * stepTimeInSeconds) End Sub End Class End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M11.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M11.vb index 8c500f704b3423831f08b4d2d4ca3ab1821e0a77..c14e8c4462fb30c9d6de2e3268a588f5b535e585 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M11.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M11.vb @@ -9,6 +9,7 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac @@ -21,13 +22,13 @@ Namespace DownstreamModules #Region "Private Aggregates" 'Private Aggregations - Private AG1 As Double - Private AG2 As Double - Private AG3 As Double - Private AG4 As Double - Private AG5 As Double - Private AG6 As Double - Private AG7 As Double + Private AG1 As Joule + Private AG2 As Joule + Private AG3 As Joule + Private AG4 As Kilogram + Private AG5 As Kilogram + Private AG6 As Joule + Private AG7 As Kilogram #End Region @@ -42,187 +43,193 @@ Namespace DownstreamModules #End Region + 'Staging Calculations - Private Function Sum0(ByVal rpm As Single) As Single + Private Function Sum0(ByVal rpm As PerSecond) As PerSecond - If rpm < 1 Then rpm = 1 + If rpm < 1 Then rpm = 1.RPMtoRad() - Return rpm / RPM_to_RadiansPerSecond + Return rpm ' / RPM_to_RadiansPerSecond End Function - Private ReadOnly Property Sum1 As Single + Private ReadOnly Property Sum1 As Watt Get - Return m6.OverrunFlag * m8.SmartElectricalAlternatorPowerGenAtCrank + Return If(M6.OverrunFlag, M8.SmartElectricalAlternatorPowerGenAtCrank, SIBase(Of Watt).Create(0.0)) + 'Return M6.OverrunFlag*M8.SmartElectricalAlternatorPowerGenAtCrank End Get End Property - Private ReadOnly Property Sum2 As Single + Private ReadOnly Property Sum2 As Watt Get - Return m3.GetAveragePowerDemandAtCrankFromPneumatics + m1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts + Return M3.GetAveragePowerDemandAtCrankFromPneumatics + M1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts End Get End Property - Private ReadOnly Property Sum3 As Single + Private ReadOnly Property Sum3 As NewtonMeter Get - Return m8.SmartElectricalAlternatorPowerGenAtCrank / Sum0(signals.EngineSpeed) + Return M8.SmartElectricalAlternatorPowerGenAtCrank / Sum0(signals.EngineSpeed) End Get End Property - Private ReadOnly Property Sum4 As Single + Private ReadOnly Property Sum4 As NewtonMeter Get Return Sum2 / Sum0(signals.EngineSpeed) End Get End Property - Private ReadOnly Property Sum5 As Single + Private ReadOnly Property Sum5 As NewtonMeter Get Return Sum4 + Sum9 End Get End Property - Private ReadOnly Property Sum6 As Single + Private ReadOnly Property Sum6 As NewtonMeter Get Return Sum3 + Sum5 End Get End Property - Private ReadOnly Property Sum7 As Single + Private ReadOnly Property Sum7 As KilogramPerSecond Get 'SCM 3_02 - Dim intrp1 As Single = fmap.GetFuelConsumption(sum6, signals.EngineSpeed) - intrp1 = If(Not Single.IsNaN(intrp1) AndAlso intrp1 > 0, intrp1, 0) + Dim intrp1 As KilogramPerSecond = fmap.GetFuelConsumption(Sum6, signals.EngineSpeed) + intrp1 = If(Not Double.IsNaN(intrp1.Value()) AndAlso intrp1 > 0, intrp1, 0.SI(Of KilogramPerSecond)) Return intrp1 End Get End Property - Private ReadOnly Property Sum8 As Single + Private ReadOnly Property Sum8 As KilogramPerSecond Get 'SCHM 3_2 - Dim intrp2 As Single = fmap.GetFuelConsumption(Sum5, signals.EngineSpeed) - intrp2 = If(Not Single.IsNaN(intrp2) AndAlso intrp2 > 0, intrp2, 0) + Dim intrp2 As KilogramPerSecond = fmap.GetFuelConsumption(Sum5, signals.EngineSpeed) + intrp2 = If(Not Double.IsNaN(intrp2.Value()) AndAlso intrp2 > 0, intrp2, 0.SI(Of KilogramPerSecond)) Return intrp2 End Get End Property - Private ReadOnly Property Sum9 As Single + Private ReadOnly Property Sum9 As NewtonMeter Get - Return signals.EngineDrivelineTorque + ((signals.PreExistingAuxPower * 1000) / Sum0(signals.EngineSpeed)) + Return _ + signals.EngineDrivelineTorque + + (signals.PreExistingAuxPower / Sum0(signals.EngineSpeed)) End Get End Property - Private ReadOnly Property Sum10 As Single + Private ReadOnly Property Sum10 As NewtonMeter Get Return M6.AvgPowerDemandAtCrankFromElectricsIncHVAC / Sum0(signals.EngineSpeed) End Get End Property - Private ReadOnly Property Sum11 As Single + Private ReadOnly Property Sum11 As NewtonMeter Get Return Sum5 + Sum10 End Get End Property - Private ReadOnly Property Sum12 As Single + Private ReadOnly Property Sum12 As KilogramPerSecond Get 'SCHM 3_2 - Dim intrp3 As Single = fmap.GetFuelConsumption(Sum11, signals.EngineSpeed) - intrp3 = If(Not Single.IsNaN(intrp3) AndAlso intrp3 > 0, intrp3, 0) + Dim intrp3 As KilogramPerSecond = fmap.GetFuelConsumption(Sum11, signals.EngineSpeed) + intrp3 = If(Not Double.IsNaN(intrp3.Value()) AndAlso intrp3 > 0, intrp3, 0.SI(Of KilogramPerSecond)) Return intrp3 End Get End Property 'OUT1 - Public ReadOnly Property SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly As Single _ + Public ReadOnly Property SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly As Joule _ Implements IM11.SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly Get Return AG1 End Get End Property 'OUT2 - Public ReadOnly Property SmartElectricalTotalCycleEletricalEnergyGenerated As Single _ + Public ReadOnly Property SmartElectricalTotalCycleEletricalEnergyGenerated As Joule _ Implements IM11.SmartElectricalTotalCycleEletricalEnergyGenerated Get Return AG2 End Get End Property 'OUT3 - Public ReadOnly Property TotalCycleElectricalDemand As Single Implements IM11.TotalCycleElectricalDemand + Public ReadOnly Property TotalCycleElectricalDemand As Joule Implements IM11.TotalCycleElectricalDemand Get Return AG3 End Get End Property 'OUT4 - Public ReadOnly Property TotalCycleFuelConsumptionSmartElectricalLoad As Single _ + Public ReadOnly Property TotalCycleFuelConsumptionSmartElectricalLoad As Kilogram _ Implements IM11.TotalCycleFuelConsumptionSmartElectricalLoad Get Return AG4 End Get End Property 'OUT5 - Public ReadOnly Property TotalCycleFuelConsumptionZeroElectricalLoad As Single _ + Public ReadOnly Property TotalCycleFuelConsumptionZeroElectricalLoad As Kilogram _ Implements IM11.TotalCycleFuelConsumptionZeroElectricalLoad Get Return AG5 End Get End Property 'OUT6 - Public ReadOnly Property StopStartSensitiveTotalCycleElectricalDemand As Single _ + Public ReadOnly Property StopStartSensitiveTotalCycleElectricalDemand As Joule _ Implements IM11.StopStartSensitiveTotalCycleElectricalDemand Get Return AG6 End Get End Property 'OUT7 - Public ReadOnly Property TotalCycleFuelConsuptionAverageLoads As Single _ + Public ReadOnly Property TotalCycleFuelConsuptionAverageLoads As Kilogram _ Implements IM11.TotalCycleFuelConsuptionAverageLoads Get Return AG7 End Get End Property - Private ReadOnly Property SW1 As Single + Private ReadOnly Property SW1 As Boolean Get - Return If(signals.EngineStopped, 0, 1) + Return Not signals.EngineStopped End Get End Property 'Clear at the beginning of cycle Sub ClearAggregates() Implements IM11.ClearAggregates - AG1 = 0 - AG2 = 0 - AG3 = 0 - AG4 = 0 - AG5 = 0 - AG6 = 0 - AG7 = 0 + AG1 = 0.SI(Of Joule)() + AG2 = 0.SI(Of Joule)() + AG3 = 0.SI(Of Joule)() + AG4 = 0.SI(Of Kilogram)() + AG5 = 0.SI(Of Kilogram)() + AG6 = 0.SI(Of Joule)() + AG7 = 0.SI(Of Kilogram)() End Sub 'Add to Aggregates dependent on cycle step time. - Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0) Implements IM11.CycleStep + Sub CycleStep(stepTimeInSeconds As Second) Implements IM11.CycleStep 'S/S Insensitive - AG3 += (stepTimeInSeconds * M6.AvgPowerDemandAtCrankFromElectricsIncHVAC) + AG3 += (M6.AvgPowerDemandAtCrankFromElectricsIncHVAC * stepTimeInSeconds) If signals.EngineStopped Then Return 'S/S Sensitive - AG1 += (stepTimeInSeconds * Sum1 * SW1) - AG2 += (stepTimeInSeconds * M8.SmartElectricalAlternatorPowerGenAtCrank * SW1) + If (SW1) Then + AG1 += (Sum1 * stepTimeInSeconds) + AG2 += (M8.SmartElectricalAlternatorPowerGenAtCrank * stepTimeInSeconds) - AG6 += (stepTimeInSeconds * M6.AvgPowerDemandAtCrankFromElectricsIncHVAC * SW1) + AG6 += (M6.AvgPowerDemandAtCrankFromElectricsIncHVAC * stepTimeInSeconds) - 'These need to be divided by 3600 as the Fuel Map output is in Grams/Second. - AG4 += (stepTimeInSeconds * Sum7 / 3600 * SW1) - AG5 += (stepTimeInSeconds * Sum8 / 3600 * SW1) - AG7 += (stepTimeInSeconds * Sum12 / 3600 * SW1) + 'MQ: No longer needed - already per Second 'These need to be divided by 3600 as the Fuel Map output is in Grams/Second. + AG4 += (Sum7 * stepTimeInSeconds) '/ 3600 + AG5 += (Sum8 * stepTimeInSeconds) ' / 3600 + AG7 += (Sum12 * stepTimeInSeconds) '/ 3600 + End If End Sub 'Constructor @@ -235,6 +242,7 @@ Namespace DownstreamModules Me.M8 = m8 Me.fmap = fmap Me.signals = signals + ClearAggregates() End Sub End Class End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M12.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M12.vb index f0aa1f2212a2ce6a19543e09065a1bff4200d961..1ff23254f1ceb0e90e1d561aa1bee926274344ce 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M12.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M12.vb @@ -9,174 +9,191 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules + Public Class M12 + Implements IM12 - Public Class M12 - Implements IM12 + Private Class Point + Public X As Joule + Public Y As Kilogram + End Class + Private M11 As IM11 + Private M10 As IM10 + Private Signals As ISignals + Private _P1X As Joule + Private _P1Y As Kilogram + Private _P2X As Joule + Private _P2Y As Kilogram + Private _P3X As Joule + Private _P3Y As Kilogram + Private _XT As Joule + Private _INTERP1 As Kilogram + Private _INTERP2 As Kilogram - Private Class Point - - Public X As Single - Public Y As Single - - End Class - - Private M11 As IM11 - Private M10 As IM10 - Private Signals As ISignals - Private _P1X, _P1Y, _P2X, _P2Y, _P3X, _P3Y, _XT, _INTERP1, _INTERP2 As Single - - Private Sub setPoints() - - _P1X = 0 - _P1Y = M11.TotalCycleFuelConsumptionZeroElectricalLoad - _P2X = M11.SmartElectricalTotalCycleEletricalEnergyGenerated - _P2Y = M11.TotalCycleFuelConsumptionSmartElectricalLoad - _P3X = M11.StopStartSensitiveTotalCycleElectricalDemand - _P3Y = M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics - _XT = M11.TotalCycleElectricalDemand - - - - - End Sub - - 'Interpolation - Private Function Sum1() As Single - - Dim P1 As Point = New Point With {.X = 0, .Y = M11.TotalCycleFuelConsumptionZeroElectricalLoad} - Dim P2 As Point = New Point With {.X = M11.SmartElectricalTotalCycleEletricalEnergyGenerated * Signals.StoredEnergyEfficiency, .Y = M11.TotalCycleFuelConsumptionSmartElectricalLoad} - - Dim IP5x As Single = M11.TotalCycleElectricalDemand - Dim IP5y As Single = 0 - - Dim TanTeta As Single = (P2.Y - P1.Y) / (P2.X - P1.X) - - IP5y = P1.Y + (TanTeta * IP5x) - - _INTERP1 = IP5Y - - setPoints() - - Return If(Single.IsNaN(IP5Y), 0, IP5y) - - End Function - Private Function Sum2() As Single - - Dim P1 As Point = New Point With {.X = 0, .Y = M11.TotalCycleFuelConsumptionZeroElectricalLoad} - Dim P3 As Point = New Point With {.X = M11.StopStartSensitiveTotalCycleElectricalDemand, .Y = M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics} - - Dim IP5x As Single = M11.TotalCycleElectricalDemand - Dim IP5y As Single = 0 - - Dim TanTeta As Single = (P3.Y - P1.Y) / (P3.X - P1.X) - - IP5y = P1.Y + (TanTeta * IP5x) - - _INTERP2 = IP5y - - Return If(Single.IsNaN(IP5Y), 0, IP5y) - - End Function - - 'Constructor - Public Sub New(m10 As IM10, m11 As IM11, signals As ISignals) - - Me.M10 = m10 - Me.M11 = m11 - Me.Signals = signals - - End Sub - - 'Main Class Outputs - Public ReadOnly Property FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand As Single Implements IM12.FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand - Get - - 'SCHM 3_2 - Dim interp1 As Single = Sum1 - - interp1 = If(Not Single.IsNaN(interp1) AndAlso M11.StopStartSensitiveTotalCycleElectricalDemand > 0, interp1, M11.TotalCycleFuelConsumptionZeroElectricalLoad) - Return interp1 - - End Get - - End Property - Public ReadOnly Property BaseFuelConsumptionWithTrueAuxiliaryLoads As Single Implements IM12.BaseFuelConsumptionWithTrueAuxiliaryLoads - Get - - 'SCM 3_02 - Dim interp2 As Single = Sum2() - - interp2 = If(Not Single.IsNaN(interp2) AndAlso M11.StopStartSensitiveTotalCycleElectricalDemand > 0, interp2, M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics) - Return interp2 - - End Get - End Property - Public ReadOnly Property StopStartCorrection As Single Implements IM12.StopStartCorrection - Get - - Dim _stopStartCorrection As Single = BaseFuelConsumptionWithTrueAuxiliaryLoads / If(M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics > 0, M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics, 1) - - Return If(_stopStartCorrection > 0, _stopStartCorrection, 1) - - End Get - End Property - - 'Diagnostics Signal Exposure only. Does not materially affect class operation. - Public ReadOnly Property INTRP1 As Single Implements IM12.INTRP1 - Get - Return _INTERP1 - End Get - End Property - Public ReadOnly Property INTRP2 As Single Implements IM12.INTRP2 - Get - Return _INTERP2 - End Get - End Property - Public ReadOnly Property P1X As Single Implements IM12.P1X - Get - Return _P1X - End Get - End Property - Public ReadOnly Property P1Y As Single Implements IM12.P1Y - Get - Return _p1Y - End Get - End Property - Public ReadOnly Property P2X As Single Implements IM12.P2X - Get - Return _P2X - End Get - End Property - Public ReadOnly Property P2Y As Single Implements IM12.P2Y - Get - Return _P2Y - End Get - End Property - Public ReadOnly Property P3X As Single Implements IM12.P3X - Get - Return _P3X - End Get - End Property - Public ReadOnly Property P3Y As Single Implements IM12.P3Y - Get - Return _P3Y - End Get - End Property - Public ReadOnly Property XTAIN As Single Implements IM12.XTAIN - Get - Return _XT - End Get - End Property - - End Class + Private Sub setPoints() + _P1X = 0.SI(Of Joule)() + _P1Y = M11.TotalCycleFuelConsumptionZeroElectricalLoad + _P2X = M11.SmartElectricalTotalCycleEletricalEnergyGenerated + _P2Y = M11.TotalCycleFuelConsumptionSmartElectricalLoad + _P3X = M11.StopStartSensitiveTotalCycleElectricalDemand + _P3Y = M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics + _XT = M11.TotalCycleElectricalDemand + End Sub + + 'Interpolation + Private Function Sum1() As Kilogram + + Dim P1 As Point = New Point With {.X = 0.SI(Of Joule)(), .Y = M11.TotalCycleFuelConsumptionZeroElectricalLoad} + Dim P2 As Point = New Point _ + With {.X = M11.SmartElectricalTotalCycleEletricalEnergyGenerated * Signals.StoredEnergyEfficiency, + .Y = M11.TotalCycleFuelConsumptionSmartElectricalLoad} + + Dim IP5x As Joule = M11.TotalCycleElectricalDemand + Dim IP5y As Kilogram + + Dim TanTeta As SI = (P2.Y - P1.Y) / (P2.X - P1.X) + + IP5y = P1.Y + (TanTeta * IP5x) + + _INTERP1 = IP5y + + setPoints() + + Return If(Double.IsNaN(IP5y.Value()), 0.SI(Of Kilogram), IP5y) + End Function + + Private Function Sum2() As Kilogram + + Dim P1 As Point = New Point With {.X = 0.SI(Of Joule)(), .Y = M11.TotalCycleFuelConsumptionZeroElectricalLoad} + Dim P3 As Point = New Point _ + With {.X = M11.StopStartSensitiveTotalCycleElectricalDemand, + .Y = M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics} + + Dim IP5x As Joule = M11.TotalCycleElectricalDemand + Dim IP5y As Kilogram + + Dim TanTeta As Double = (P3.Y - P1.Y).Value() / (P3.X - P1.X).Value() + + IP5y = P1.Y + (TanTeta * IP5x.Value()).SI(Of Kilogram)() + + _INTERP2 = IP5y + + Return If(Double.IsNaN(IP5y.Value()), 0.SI(Of Kilogram), IP5y) + End Function + + 'Constructor + Public Sub New(m10 As IM10, m11 As IM11, signals As ISignals) + + Me.M10 = m10 + Me.M11 = m11 + Me.Signals = signals + End Sub + + 'Main Class Outputs + Public ReadOnly Property FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand As Kilogram _ + Implements IM12.FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand + Get + + 'SCHM 3_2 + Dim interp1 As Kilogram = Sum1() + + interp1 = + If _ + (Not Double.IsNaN(interp1.Value()) AndAlso M11.StopStartSensitiveTotalCycleElectricalDemand > 0, interp1, + M11.TotalCycleFuelConsumptionZeroElectricalLoad) + Return interp1 + End Get + End Property + + Public ReadOnly Property BaseFuelConsumptionWithTrueAuxiliaryLoads As Kilogram _ + Implements IM12.BaseFuelConsumptionWithTrueAuxiliaryLoads + Get + + 'SCM 3_02 + Dim interp2 As Kilogram = Sum2() + + interp2 = + If _ + (Not Double.IsNaN(interp2.Value()) AndAlso M11.StopStartSensitiveTotalCycleElectricalDemand > 0, interp2, + M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics) + Return interp2 + End Get + End Property + + Public ReadOnly Property StopStartCorrection As Double Implements IM12.StopStartCorrection + Get + + Dim _stopStartCorrection As Scalar = BaseFuelConsumptionWithTrueAuxiliaryLoads() / + If _ + (M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics > 0, + M10.AverageLoadsFuelConsumptionInterpolatedForPneumatics, 1.SI(Of Kilogram)) + + Return If(_stopStartCorrection > 0, _stopStartCorrection.Value(), 1) + End Get + End Property + + 'Diagnostics Signal Exposure only. Does not materially affect class operation. + Public ReadOnly Property INTRP1 As Kilogram Implements IM12.INTRP1 + Get + Return _INTERP1 + End Get + End Property + + Public ReadOnly Property INTRP2 As Kilogram Implements IM12.INTRP2 + Get + Return _INTERP2 + End Get + End Property + + Public ReadOnly Property P1X As Joule Implements IM12.P1X + Get + Return _P1X + End Get + End Property + + Public ReadOnly Property P1Y As Kilogram Implements IM12.P1Y + Get + Return _P1Y + End Get + End Property + + Public ReadOnly Property P2X As Joule Implements IM12.P2X + Get + Return _P2X + End Get + End Property + + Public ReadOnly Property P2Y As Kilogram Implements IM12.P2Y + Get + Return _P2Y + End Get + End Property + + Public ReadOnly Property P3X As Joule Implements IM12.P3X + Get + Return _P3X + End Get + End Property + + Public ReadOnly Property P3Y As Kilogram Implements IM12.P3Y + Get + Return _P3Y + End Get + End Property + + Public ReadOnly Property XTAIN As Joule Implements IM12.XTAIN + Get + Return _XT + End Get + End Property + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M13.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M13.vb index cfd161a5e151e6e86c1425ef571105f03838dcf8..357c5c0b395a648543643c72c37c318c11f6d7f1 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M13.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M13.vb @@ -9,111 +9,118 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules - - Public Class M13 - Implements IM13 - - Private m10 As IM10 - Private m11 As IM11 - Private m12 As IM12 - Private signals As ISignals - - 'Internal Staging Calculations - - Private ReadOnly Property Sum1 As Single - Get - Return m11.TotalCycleFuelConsuptionAverageLoads * m12.StopStartCorrection - End Get - End Property - Private ReadOnly Property Sum2 As Single - Get - Return m10.AverageLoadsFuelConsumptionInterpolatedForPneumatics * m12.StopStartCorrection - End Get - End Property - Private ReadOnly Property Sum3 As Single - Get - Return m10.FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand * m12.StopStartCorrection - End Get - End Property - Private ReadOnly Property Sum4 As Single - Get - Return -m12.FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand + Sum1 - End Get - End Property - Private ReadOnly Property Sum5 As Single - Get - Return Sum2 - Sum3 - End Get - End Property - Private ReadOnly Property Sum6 As Single - Get - Return m12.BaseFuelConsumptionWithTrueAuxiliaryLoads - Sum4 - End Get - End Property - Private ReadOnly Property Sum7 As Single - Get - Return m12.BaseFuelConsumptionWithTrueAuxiliaryLoads - Sum5 - End Get - End Property - Private ReadOnly Property Sum8 As Single - Get - Return -Sum4 + Sum7 - End Get - End Property - Private ReadOnly Property Sum9 As Single - Get - Return SW4 * SW3 - End Get - End Property - - 'Internal Staging Switches - Private ReadOnly Property SW1 As Single - Get - Return If(signals.SmartPneumatics, Sum8, Sum6) - End Get - End Property - Private ReadOnly Property SW2 As Single - Get - Return If(signals.SmartPneumatics, Sum3, m12.BaseFuelConsumptionWithTrueAuxiliaryLoads) - End Get - End Property - Private ReadOnly Property SW3 As Single - Get - Return If(signals.SmartElectrics, SW1, SW2) - End Get - End Property - Private ReadOnly Property SW4 As Single - Get - Return If(signals.DeclarationMode, signals.WHTC, 1) - End Get - End Property - - 'Constructor - Public Sub New(m10 As IM10, m11 As IM11, m12 As IM12, signals As ISignals) - - Me.m10 = m10 - Me.m11 = m11 - Me.m12 = m12 - Me.signals = signals - - End Sub - - 'Public class outputs - Public ReadOnly Property WHTCTotalCycleFuelConsumptionGrams As Single Implements IM13.WHTCTotalCycleFuelConsumptionGrams - Get - Return Sum9 - End Get - End Property - - - End Class - + Public Class M13 + Implements IM13 + + Private m10 As IM10 + Private m11 As IM11 + Private m12 As IM12 + Private signals As ISignals + + 'Internal Staging Calculations + + Private ReadOnly Property Sum1 As Kilogram + Get + Return m11.TotalCycleFuelConsuptionAverageLoads * m12.StopStartCorrection + End Get + End Property + + Private ReadOnly Property Sum2 As Kilogram + Get + Return m10.AverageLoadsFuelConsumptionInterpolatedForPneumatics * m12.StopStartCorrection + End Get + End Property + + Private ReadOnly Property Sum3 As Kilogram + Get + Return m10.FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand * m12.StopStartCorrection + End Get + End Property + + Private ReadOnly Property Sum4 As Kilogram + Get + Return -m12.FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand() + Sum1 + End Get + End Property + + Private ReadOnly Property Sum5 As Kilogram + Get + Return Sum2 - Sum3 + End Get + End Property + + Private ReadOnly Property Sum6 As Kilogram + Get + Return m12.BaseFuelConsumptionWithTrueAuxiliaryLoads() - Sum4 + End Get + End Property + + Private ReadOnly Property Sum7 As Kilogram + Get + Return m12.BaseFuelConsumptionWithTrueAuxiliaryLoads() - Sum5 + End Get + End Property + + Private ReadOnly Property Sum8 As Kilogram + Get + Return -Sum4 + Sum7 + End Get + End Property + + Private ReadOnly Property Sum9 As Kilogram + Get + Return SW4 * SW3 + End Get + End Property + + 'Internal Staging Switches + Private ReadOnly Property SW1 As Kilogram + Get + Return If(signals.SmartPneumatics, Sum8, Sum6) + End Get + End Property + + Private ReadOnly Property SW2 As Kilogram + Get + Return If(signals.SmartPneumatics, Sum3, m12.BaseFuelConsumptionWithTrueAuxiliaryLoads()) + End Get + End Property + + Private ReadOnly Property SW3 As Kilogram + Get + Return If(signals.SmartElectrics, SW1, SW2) + End Get + End Property + + Private ReadOnly Property SW4 As Double + Get + Return If(signals.DeclarationMode, signals.WHTC, 1) + End Get + End Property + + 'Constructor + Public Sub New(m10 As IM10, m11 As IM11, m12 As IM12, signals As ISignals) + + Me.m10 = m10 + Me.m11 = m11 + Me.m12 = m12 + Me.signals = signals + End Sub + + 'Public class outputs + Public ReadOnly Property WHTCTotalCycleFuelConsumptionGrams As Kilogram _ + Implements IM13.WHTCTotalCycleFuelConsumptionGrams + Get + Return Sum9 + End Get + End Property + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M14.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M14.vb index e808e7d0a6b46dee36a52bca1538d7bc1c53f60a..bef1c552445c5c3c3c25a216929587d4cb0caca6 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M14.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M14.vb @@ -1,92 +1,94 @@ -Imports VectoAuxiliaries.Electrics +Imports TUGraz.VectoCommon.Utils +Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules - -Public Class M14 - Implements IM14 - - - Private m13 As IM13 - Private signals As ISignals - Private constants As IHVACConstants - Private ssm As ISSMTOOL - - - Public Sub New(m13 As IM13, hvacSSM As ISSMTOOL, constants As IHVACConstants, signals As ISignals) - - If m13 Is Nothing Then Throw New ArgumentException("M14, No M13 Supplied in arguments") - If hvacSSM Is Nothing Then Throw New ArgumentException("M14, No SSMTOOL constants Supplied in arguments") - If constants Is Nothing Then Throw New ArgumentException("M14, No signals Supplied in arguments") - If signals Is Nothing Then Throw New ArgumentException("M14, No signals constants Supplied in arguments") - - - Me.m13 = m13 - Me.signals = signals - Me.constants = constants - Me.ssm = hvacSSM - - End Sub - - 'Staging Calculations - Private ReadOnly Property S1 As Single - Get - Return m13.WHTCTotalCycleFuelConsumptionGrams * constants.DieselGCVJperGram - End Get - End Property - Private ReadOnly Property S2 As Single - Get - Return ssm.GenInputs.AH_FuelEnergyToHeatToCoolant * S1 - End Get - End Property - Private ReadOnly Property S3 As Single - Get - Return S2 * ssm.GenInputs.AH_CoolantHeatTransferredToAirCabinHeater - End Get - End Property - Private ReadOnly Property S4 As Single - Get - Return (S3 / signals.CurrentCycleTimeInSeconds) / 1000 - End Get - End Property - Private ReadOnly Property S5 As Single - Get - Return signals.CurrentCycleTimeInSeconds / 3600 - End Get - End Property - Private ReadOnly Property S6 As Single - Get - Return S5 * ssm.FuelPerHBaseAsjusted(S4) * (constants.FuelDensity * 1000) - End Get - End Property - Private ReadOnly Property S7 As Single - Get - Return m13.WHTCTotalCycleFuelConsumptionGrams + s6 - End Get - End Property - - Private ReadOnly Property S8 As Single - Get - Return S7 / (constants.FuelDensity * 1000) - End Get - End Property - Public ReadOnly Property TotalCycleFCGrams As Single Implements IM14.TotalCycleFCGrams - Get - Return S7 - End Get - End Property - - Public ReadOnly Property TotalCycleFCLitres As Single Implements IM14.TotalCycleFCLitres - Get - Return S8 - End Get - End Property - - - -End Class - - - + Public Class M14 + Implements IM14 + + Private m13 As IM13 + Private signals As ISignals + Private constants As IHVACConstants + Private ssm As ISSMTOOL + + + Public Sub New(m13 As IM13, hvacSSM As ISSMTOOL, constants As IHVACConstants, signals As ISignals) + + If m13 Is Nothing Then Throw New ArgumentException("M14, No M13 Supplied in arguments") + If hvacSSM Is Nothing Then Throw New ArgumentException("M14, No SSMTOOL constants Supplied in arguments") + If constants Is Nothing Then Throw New ArgumentException("M14, No signals Supplied in arguments") + If signals Is Nothing Then Throw New ArgumentException("M14, No signals constants Supplied in arguments") + + + Me.m13 = m13 + Me.signals = signals + Me.constants = constants + Me.ssm = hvacSSM + End Sub + + 'Staging Calculations + Private ReadOnly Property S1 As Joule + Get + Return m13.WHTCTotalCycleFuelConsumptionGrams * constants.DieselGCVJperGram + End Get + End Property + + Private ReadOnly Property S2 As Joule + Get + Return ssm.GenInputs.AH_FuelEnergyToHeatToCoolant * S1 + End Get + End Property + + Private ReadOnly Property S3 As Joule + Get + Return S2 * ssm.GenInputs.AH_CoolantHeatTransferredToAirCabinHeater + End Get + End Property + + Private ReadOnly Property S4 As Watt 'kW + Get + Return (S3 / signals.CurrentCycleTimeInSeconds.SI(Of Second)()) + End Get + End Property + + Private ReadOnly Property S5 As Second ' hour + Get + Return signals.CurrentCycleTimeInSeconds.SI(Of Second)() ' / 3600 + End Get + End Property + + Private ReadOnly Property S6 As Kilogram + Get + 'Return (S5.Value() * ssm.FuelPerHBaseAsjusted(S4.Value() / 1000) / 3600 * (constants.FuelDensity)).SI(Of Kilogram)() + Return _ + (S5 * ssm.FuelPerHBaseAsjusted(S4.Value() / 1000).SI().Liter.Per.Hour).Cast(Of Liter)() * constants.FuelDensity + End Get + End Property + + Private ReadOnly Property S7 As Kilogram + Get + Return m13.WHTCTotalCycleFuelConsumptionGrams + S6 + End Get + End Property + + Private ReadOnly Property S8 As Liter + Get + Return (S7 / (constants.FuelDensity)) + End Get + End Property + + Public ReadOnly Property TotalCycleFCGrams As Kilogram Implements IM14.TotalCycleFCGrams + Get + Return S7 + End Get + End Property + + Public ReadOnly Property TotalCycleFCLitres As Liter Implements IM14.TotalCycleFCLitres + Get + Return S8 + End Get + End Property + End Class End Namespace + diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M6.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M6.vb index 28fcb4eea7ad088c305ef95dea8350ff1dde5446..0748fc3fa57d993b4a163bdfc99860083fc98c41 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M6.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M6.vb @@ -9,264 +9,283 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules - - Public Class M6 - Implements IM6 + Public Class M6 + Implements IM6 #Region "Private Field - Constructor requirements" - Private _m1 As IM1_AverageHVACLoadDemand - Private _m2 As IM2_AverageElectricalLoadDemand - Private _m3 As IM3_AveragePneumaticLoadDemand - Private _m4 As IM4_AirCompressor - Private _m5 As IM5_SmartAlternatorSetGeneration - Private _signals As ISignals -#End Region - 'OUT1 - Public ReadOnly Property OverrunFlag As Integer Implements IM6.OverrunFlag - - Get - Return VC0 - End Get - End Property - 'OUT2 - Public ReadOnly Property SmartElecAndPneumaticsCompressorFlag As Integer Implements IM6.SmartElecAndPneumaticsCompressorFlag - Get - Return VC2 - End Get - End Property - 'OUT3 - Public ReadOnly Property SmartElecAndPneumaticAltPowerGenAtCrank As Single Implements IM6.SmartElecAndPneumaticAltPowerGenAtCrank - Get - 'Multiply * 1 @ Engineering Request - Return Max1 * -1 - End Get - End Property - 'OUT4 - Public ReadOnly Property SmartElecAndPneumaticAirCompPowerGenAtCrank As Single Implements IM6.SmartElecAndPneumaticAirCompPowerGenAtCrank - Get - Return Sum16 - End Get - End Property - 'OUT5 - Public ReadOnly Property SmartElecOnlyAltPowerGenAtCrank As Single Implements IM6.SmartElecOnlyAltPowerGenAtCrank - Get - 'Multiply * -1 @ Engineering request. - Return Max2 * -1 - End Get - End Property - 'OUT6 - Public ReadOnly Property AveragePowerDemandAtCrankFromPneumatics As Single Implements IM6.AveragePowerDemandAtCrankFromPneumatics - Get - Return _m3.GetAveragePowerDemandAtCrankFromPneumatics - End Get - End Property - 'OUT7 - Public ReadOnly Property SmartPneumaticOnlyAirCompPowerGenAtCrank As Single Implements IM6.SmartPneumaticOnlyAirCompPowerGenAtCrank - Get - Return Sum19 - End Get - End Property - 'OUT8 - Public ReadOnly Property AvgPowerDemandAtCrankFromElectricsIncHVAC As Single Implements IM6.AvgPowerDemandAtCrankFromElectricsIncHVAC - Get - - Return Sum1 - - End Get - - End Property - 'OUT9 - Public ReadOnly Property SmartPneumaticsOnlyCompressorFlag As Integer Implements IM6.SmartPneumaticsOnlyCompressorFlag - Get - Return VC4 - End Get - End Property - - 'Internal Staging Calculations - 'switches - Private ReadOnly Property SW1 As Single - Get - - Return If(_signals.SmartElectrics, _m5.AlternatorsGenerationPowerAtCrankTractionOnWatts, Sum1) - - End Get - End Property - - 'Max of Sum5 vs Sum10 - Public ReadOnly Property Max1 As Single - Get - Return If(Sum5 > Sum10, Sum5, Sum10) - End Get - End Property - 'Max of Sum10 vs Sum7 - Public ReadOnly Property Max2 As Single - Get - Return If(Sum7 > Sum10, Sum7, Sum10) - End Get - End Property - - 'Value Choices - Public ReadOnly Property VC0 As Single - Get - Return If(Sum3 <= 0, 1, 0) - End Get - End Property - Public ReadOnly Property VC1 As Single - Get - Return If(Sum12 > 0, 1, 0) - End Get - End Property - Public ReadOnly Property VC2 As Single - Get - Return If(Sum12 < 0 OrElse Sum12 = 0, 1, 0) - End Get - End Property - Public ReadOnly Property VC3 As Single - Get - Return If(Sum13 > 0, 1, 0) - End Get - End Property - Public ReadOnly Property VC4 As Single - Get - Return If(Sum13 < 0 OrElse Sum13 = 0, 1, 0) - End Get - End Property - - 'Sums - Public ReadOnly Property Sum1 As Single - Get - Return _m1.AveragePowerDemandAtCrankFromHVACElectricsWatts() + _m2.GetAveragePowerAtCrankFromElectrics() - End Get - End Property - Public ReadOnly Property Sum2 As Single - Get - - Dim returnValue As Single = _m1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts + SW1 + _m3.GetAveragePowerDemandAtCrankFromPneumatics - - Return returnValue - - End Get - End Property - Public ReadOnly Property Sum3 As Single - Get - - Return (_signals.EngineMotoringPower * 1000) + _ - (_signals.Internal_Engine_Power * 1000) + _ - Sum2 - - End Get - End Property - Public ReadOnly Property Sum4 As Single - Get - - Return Sum3 - SW1 - _m3.GetAveragePowerDemandAtCrankFromPneumatics + _m4.GetPowerCompressorOff - - End Get - End Property - Public ReadOnly Property Sum5 As Single - Get - Return OverrunFlag * Sum4 - End Get - End Property - Public ReadOnly Property Sum6 As Single - Get - Return Sum4 - _m4.GetPowerCompressorOff + _m3.GetAveragePowerDemandAtCrankFromPneumatics - End Get - End Property - Public ReadOnly Property Sum7 As Single - Get - Return VC0 * Sum6 - End Get - End Property - Public ReadOnly Property Sum8 As Single - Get - Return Sum4 + SW1 - End Get - End Property - Public ReadOnly Property Sum9 As Single - Get - Return VC0 * Sum8 - End Get - End Property - Public ReadOnly Property Sum10 As Single - Get - Return -1 * _m5.AlternatorsGenerationPowerAtCrankOverrunWatts - End Get - End Property - Public ReadOnly Property Sum11 As Single - Get - Return Sum5 - Max1 - End Get - End Property - Public ReadOnly Property Sum12 As Single - Get - Return _m4.GetPowerDifference + Sum11 - End Get - End Property - Public ReadOnly Property Sum13 As Single - Get - Return Sum9 + _m4.GetPowerDifference - End Get - End Property - Public ReadOnly Property Sum14 As Single - Get - Return VC1 * _m4.GetPowerCompressorOff - End Get - End Property - Public ReadOnly Property Sum15 As Single - Get - Return VC2 * (_m4.GetPowerCompressorOn * _signals.PneumaticOverrunUtilisation) - End Get - End Property - Public ReadOnly Property Sum16 As Single - Get - Return Sum14 + Sum15 - End Get - End Property - Public ReadOnly Property Sum17 As Single - Get - Return _m4.GetPowerCompressorOff * VC3 - End Get - End Property - Public ReadOnly Property Sum18 As Single - Get - Return VC4 * (_m4.GetPowerCompressorOn * _signals.PneumaticOverrunUtilisation) - End Get - End Property - Public ReadOnly Property Sum19 As Single - Get - Return Sum17 + Sum18 - End Get - End Property - - - 'Constructor - Public Sub New(m1 As IM1_AverageHVACLoadDemand, - m2 As IM2_AverageElectricalLoadDemand, - m3 As IM3_AveragePneumaticLoadDemand, - m4 As IM4_AirCompressor, - m5 As IM5_SmartAlternatorSetGeneration, - signals As ISignals) - - _m1 = m1 - _m2 = m2 - _m3 = m3 - _m4 = m4 - _m5 = m5 - _signals = signals - - End Sub - - - End Class + Private _m1 As IM1_AverageHVACLoadDemand + Private _m2 As IM2_AverageElectricalLoadDemand + Private _m3 As IM3_AveragePneumaticLoadDemand + Private _m4 As IM4_AirCompressor + Private _m5 As IM5_SmartAlternatorSetGeneration + Private _signals As ISignals -End Namespace +#End Region + 'OUT1 + Public ReadOnly Property OverrunFlag As Boolean Implements IM6.OverrunFlag + + Get + Return VC0 + End Get + End Property + 'OUT2 + Public ReadOnly Property SmartElecAndPneumaticsCompressorFlag As Boolean _ + Implements IM6.SmartElecAndPneumaticsCompressorFlag + Get + Return VC2 + End Get + End Property + 'OUT3 + Public ReadOnly Property SmartElecAndPneumaticAltPowerGenAtCrank As Watt _ + Implements IM6.SmartElecAndPneumaticAltPowerGenAtCrank + Get + 'Multiply * 1 @ Engineering Request + Return Max1 * -1 + End Get + End Property + 'OUT4 + Public ReadOnly Property SmartElecAndPneumaticAirCompPowerGenAtCrank As Watt _ + Implements IM6.SmartElecAndPneumaticAirCompPowerGenAtCrank + Get + Return Sum16 + End Get + End Property + 'OUT5 + Public ReadOnly Property SmartElecOnlyAltPowerGenAtCrank As Watt Implements IM6.SmartElecOnlyAltPowerGenAtCrank + Get + 'Multiply * -1 @ Engineering request. + Return Max2 * -1 + End Get + End Property + 'OUT6 + Public ReadOnly Property AveragePowerDemandAtCrankFromPneumatics As Watt _ + Implements IM6.AveragePowerDemandAtCrankFromPneumatics + Get + Return _m3.GetAveragePowerDemandAtCrankFromPneumatics + End Get + End Property + 'OUT7 + Public ReadOnly Property SmartPneumaticOnlyAirCompPowerGenAtCrank As Watt _ + Implements IM6.SmartPneumaticOnlyAirCompPowerGenAtCrank + Get + Return Sum19 + End Get + End Property + 'OUT8 + Public ReadOnly Property AvgPowerDemandAtCrankFromElectricsIncHVAC As Watt _ + Implements IM6.AvgPowerDemandAtCrankFromElectricsIncHVAC + Get + + Return Sum1 + End Get + End Property + 'OUT9 + Public ReadOnly Property SmartPneumaticsOnlyCompressorFlag As Boolean Implements IM6.SmartPneumaticsOnlyCompressorFlag + Get + Return VC4 + End Get + End Property + + 'Internal Staging Calculations + 'switches + Private ReadOnly Property SW1 As Watt + Get + + Return If(_signals.SmartElectrics, _m5.AlternatorsGenerationPowerAtCrankTractionOnWatts, Sum1) + End Get + End Property + + 'Max of Sum5 vs Sum10 + Public ReadOnly Property Max1 As Watt + Get + Return If(Sum5 > Sum10, Sum5, Sum10) + End Get + End Property + 'Max of Sum10 vs Sum7 + Public ReadOnly Property Max2 As Watt + Get + Return If(Sum7 > Sum10, Sum7, Sum10) + End Get + End Property + + 'Value Choices + Public ReadOnly Property VC0 As Boolean + Get + Return Sum3 <= 0 + End Get + End Property + + Public ReadOnly Property VC1 As Boolean + Get + Return Sum12 > 0 + End Get + End Property + + Public ReadOnly Property VC2 As Boolean + Get + Return Sum12 < 0 OrElse Sum12.IsEqual(0) + End Get + End Property + + Public ReadOnly Property VC3 As Boolean + Get + Return Sum13 > 0 + End Get + End Property + + Public ReadOnly Property VC4 As Boolean + Get + Return Sum13 < 0 OrElse Sum13.IsEqual(0) + End Get + End Property + + 'Sums + Public ReadOnly Property Sum1 As Watt + Get + Return _m1.AveragePowerDemandAtCrankFromHVACElectricsWatts() + _m2.GetAveragePowerAtCrankFromElectrics() + End Get + End Property + + Public ReadOnly Property Sum2 As Watt + Get + + Dim returnValue As Watt = _m1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts + SW1 + + _m3.GetAveragePowerDemandAtCrankFromPneumatics + + Return returnValue + End Get + End Property + + Public ReadOnly Property Sum3 As Watt + Get + Return (_signals.EngineMotoringPower) + + (_signals.InternalEnginePower) + + Sum2 + End Get + End Property + + Public ReadOnly Property Sum4 As Watt + Get + + Return Sum3 - SW1 - _m3.GetAveragePowerDemandAtCrankFromPneumatics + _m4.GetPowerCompressorOff + End Get + End Property + + Public ReadOnly Property Sum5 As Watt + Get + Return If(OverrunFlag, Sum4, 0.SI(Of Watt)) + End Get + End Property + + Public ReadOnly Property Sum6 As Watt + Get + Return Sum4 - _m4.GetPowerCompressorOff + _m3.GetAveragePowerDemandAtCrankFromPneumatics + End Get + End Property + + Public ReadOnly Property Sum7 As Watt + Get + Return If(VC0, Sum6, 0.SI(Of Watt)) + End Get + End Property + + Public ReadOnly Property Sum8 As Watt + Get + Return Sum4 + SW1 + End Get + End Property + + Public ReadOnly Property Sum9 As Watt + Get + Return If(VC0, Sum8, 0.SI(Of Watt)) + End Get + End Property + + Public ReadOnly Property Sum10 As Watt + Get + Return _m5.AlternatorsGenerationPowerAtCrankOverrunWatts * -1.0 + End Get + End Property + + Public ReadOnly Property Sum11 As Watt + Get + Return Sum5 - Max1 + End Get + End Property + + Public ReadOnly Property Sum12 As Watt + Get + Return _m4.GetPowerDifference + Sum11 + End Get + End Property + + Public ReadOnly Property Sum13 As Watt + Get + Return Sum9 + _m4.GetPowerDifference + End Get + End Property + + Public ReadOnly Property Sum14 As Watt + Get + Return If(VC1, _m4.GetPowerCompressorOff, 0.SI(Of Watt)) + End Get + End Property + + Public ReadOnly Property Sum15 As Watt + Get + Return If(VC2, (_m4.GetPowerCompressorOn * _signals.PneumaticOverrunUtilisation), 0.SI(Of Watt)) + End Get + End Property + + Public ReadOnly Property Sum16 As Watt + Get + Return Sum14 + Sum15 + End Get + End Property + + Public ReadOnly Property Sum17 As Watt + Get + Return If(VC3, _m4.GetPowerCompressorOff, 0.SI(Of Watt)) + End Get + End Property + + Public ReadOnly Property Sum18 As Watt + Get + Return If(VC4, (_m4.GetPowerCompressorOn * _signals.PneumaticOverrunUtilisation), 0.SI(Of Watt)) + End Get + End Property + + Public ReadOnly Property Sum19 As Watt + Get + Return Sum17 + Sum18 + End Get + End Property + + + 'Constructor + Public Sub New(m1 As IM1_AverageHVACLoadDemand, + m2 As IM2_AverageElectricalLoadDemand, + m3 As IM3_AveragePneumaticLoadDemand, + m4 As IM4_AirCompressor, + m5 As IM5_SmartAlternatorSetGeneration, + signals As ISignals) + + _m1 = m1 + _m2 = m2 + _m3 = m3 + _m4 = m4 + _m5 = m5 + _signals = signals + End Sub + End Class +End Namespace diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M7.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M7.vb index a36fbe8b288dc987827e242cc52c4c87a7619ef2..f3bc2ceb5cefff4aabee6fb4831b036e5574a2e6 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M7.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M7.vb @@ -9,95 +9,101 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace DownstreamModules - -Public Class M7 - implements IM7 - - Private _m5 As IM5_SmartAlternatorSetGeneration - Private _m6 As IM6 - Private _signals As ISignals - - 'Boolean Conditions - Private Readonly Property C1 As Boolean - Get - Return If(_m6.OverrunFlag=1,True,False) Andalso _signals.ClutchEngaged Andalso _signals.InNeutral=false - End Get - End Property - - 'Internal Switched Outputs - Private Readonly Property SW1 As Single - Get - - Dim idle As Boolean = _signals.EngineSpeed <=_signals.EngineIdleSpeed ANDAlso ( NOT _signals.ClutchEngaged OrElse _signals.InNeutral) - - Return If ( idle, _m5.AlternatorsGenerationPowerAtCrankIdleWatts, _m5.AlternatorsGenerationPowerAtCrankTractionOnWatts) - - End Get - End Property - Private Readonly Property SW2 As Single - Get - Return If( C1, _m6.SmartElecAndPneumaticAltPowerGenAtCrank, SW1) - End Get - End Property - Private Readonly Property SW3 As Single - Get - Return If( C1,_m6.SmartElecAndPneumaticAirCompPowerGenAtCrank,_m6.AveragePowerDemandAtCrankFromPneumatics) - End Get - End Property - Private Readonly Property SW4 As Single - Get - Return If( C1,_m6.SmartElecOnlyAltPowerGenAtCrank,SW1) - End Get - End Property - Private Readonly Property SW5 As Single - Get - Return If( C1, _m6.SmartPneumaticOnlyAirCompPowerGenAtCrank,_m6.AveragePowerDemandAtCrankFromPneumatics) - End Get - End Property - - 'Public readonly properties ( Outputs ) - Public ReadOnly Property SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Single Implements IM7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank - Get - Return SW2 - End Get - End Property - Public ReadOnly Property SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Single Implements IM7.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank - Get - Return SW3 - End Get - End Property - Public ReadOnly Property SmartElectricalOnlyAuxAltPowerGenAtCrank As Single Implements IM7.SmartElectricalOnlyAuxAltPowerGenAtCrank - Get - Return SW4 - End Get - End Property - Public ReadOnly Property SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Single Implements IM7.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank - Get - Return SW5 - End Get - End Property - - 'Constructor - Public sub new ( m5 as IM5_SmartAlternatorSetGeneration, _ - m6 As IM6, _ - signals As ISignals) - - _m5 = m5 - _m6 = m6 - _signals = signals - - End Sub - - -End Class - - + Public Class M7 + Implements IM7 + + Private _m5 As IM5_SmartAlternatorSetGeneration + Private _m6 As IM6 + Private _signals As ISignals + + 'Boolean Conditions + Private ReadOnly Property C1 As Boolean + Get + Return _m6.OverrunFlag AndAlso _signals.ClutchEngaged AndAlso _signals.InNeutral = False + End Get + End Property + + 'Internal Switched Outputs + Private ReadOnly Property SW1 As Watt + Get + + Dim idle As Boolean = _signals.EngineSpeed <= _signals.EngineIdleSpeed AndAlso + (Not _signals.ClutchEngaged OrElse _signals.InNeutral) + + Return _ + If(idle, _m5.AlternatorsGenerationPowerAtCrankIdleWatts, _m5.AlternatorsGenerationPowerAtCrankTractionOnWatts) + End Get + End Property + + Private ReadOnly Property SW2 As Watt + Get + Return If(C1, _m6.SmartElecAndPneumaticAltPowerGenAtCrank, SW1) + End Get + End Property + + Private ReadOnly Property SW3 As Watt + Get + Return If(C1, _m6.SmartElecAndPneumaticAirCompPowerGenAtCrank, _m6.AveragePowerDemandAtCrankFromPneumatics) + End Get + End Property + + Private ReadOnly Property SW4 As Watt + Get + Return If(C1, _m6.SmartElecOnlyAltPowerGenAtCrank, SW1) + End Get + End Property + + Private ReadOnly Property SW5 As Watt + Get + Return If(C1, _m6.SmartPneumaticOnlyAirCompPowerGenAtCrank, _m6.AveragePowerDemandAtCrankFromPneumatics) + End Get + End Property + + 'Public readonly properties ( Outputs ) + Public ReadOnly Property SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Watt _ + Implements IM7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank + Get + Return SW2 + End Get + End Property + + Public ReadOnly Property SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Watt _ + Implements IM7.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank + Get + Return SW3 + End Get + End Property + + Public ReadOnly Property SmartElectricalOnlyAuxAltPowerGenAtCrank As Watt _ + Implements IM7.SmartElectricalOnlyAuxAltPowerGenAtCrank + Get + Return SW4 + End Get + End Property + + Public ReadOnly Property SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Watt _ + Implements IM7.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank + Get + Return SW5 + End Get + End Property + + 'Constructor + Public Sub New(m5 As IM5_SmartAlternatorSetGeneration, + m6 As IM6, + signals As ISignals) + + _m5 = m5 + _m6 = m6 + _signals = signals + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M8.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M8.vb index 20019383d0a50cd3c8e5fc65a17ab1e2dd1bbdcc..fc2af644d96b61acaf92b198f0001f180bb1e655 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M8.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M8.vb @@ -10,6 +10,7 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac @@ -30,100 +31,100 @@ Namespace DownstreamModules #Region "Internal Sums and Switches" 'Internal Staged Sums and Switches - Private ReadOnly Property Sum1 As Single + Private ReadOnly Property Sum1 As Watt Get Return _ - _m7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank + _m7.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank + _m7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank() + _m7.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank() End Get End Property - Private ReadOnly Property Sum2 As Single + Private ReadOnly Property Sum2 As Watt Get - Return _m7.SmartElectricalOnlyAuxAltPowerGenAtCrank + _m6.AveragePowerDemandAtCrankFromPneumatics + Return _m7.SmartElectricalOnlyAuxAltPowerGenAtCrank() + _m6.AveragePowerDemandAtCrankFromPneumatics End Get End Property - Private ReadOnly Property Sum3 As Single + Private ReadOnly Property Sum3 As Watt Get Return _m7.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank + _m6.AvgPowerDemandAtCrankFromElectricsIncHVAC End Get End Property - Private ReadOnly Property Sum4 As Single + Private ReadOnly Property Sum4 As Watt Get Return _m6.AvgPowerDemandAtCrankFromElectricsIncHVAC + _m6.AveragePowerDemandAtCrankFromPneumatics End Get End Property - Private ReadOnly Property Sum5 As Single + Private ReadOnly Property Sum5 As Watt Get Return _m1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts + SW5 End Get End Property - Private ReadOnly Property Sum6 As Single + Private ReadOnly Property Sum6 As Watt Get - Return Sum5 * SW6 + Return If(SW6, Sum5, SIBase(Of Watt).Create(0)) End Get End Property - Private ReadOnly Property SW1 As Single + Private ReadOnly Property SW1 As Watt Get Return If(_signals.SmartPneumatics, Sum1, Sum2) End Get End Property - Private ReadOnly Property SW2 As Single + Private ReadOnly Property SW2 As Watt Get Return If(_signals.SmartPneumatics, Sum3, Sum4) End Get End Property - Private ReadOnly Property SW3 As Single + Private ReadOnly Property SW3 As Watt Get Return _ If _ - (_signals.SmartPneumatics, _m7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank, - _m7.SmartElectricalOnlyAuxAltPowerGenAtCrank) + (_signals.SmartPneumatics, _m7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank(), + _m7.SmartElectricalOnlyAuxAltPowerGenAtCrank()) End Get End Property - Private ReadOnly Property SW4 As Integer + Private ReadOnly Property SW4 As Boolean Get Return If(_signals.SmartElectrics, _m6.SmartElecAndPneumaticsCompressorFlag, _m6.SmartPneumaticsOnlyCompressorFlag) End Get End Property - Private ReadOnly Property SW5 As Single + Private ReadOnly Property SW5 As Watt Get Return If(_signals.SmartElectrics, SW1, SW2) End Get End Property - Private ReadOnly Property SW6 As Single + Private ReadOnly Property SW6 As Boolean Get - Return If(_signals.EngineStopped, 0, 1) + Return Not _signals.EngineStopped End Get End Property #End Region 'OUT1 - Public ReadOnly Property AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries As Single _ + Public ReadOnly Property AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries As Watt _ Implements IM8.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries Get Return Sum6 End Get End Property 'OUT2 - Public ReadOnly Property SmartElectricalAlternatorPowerGenAtCrank As Single _ + Public ReadOnly Property SmartElectricalAlternatorPowerGenAtCrank As Watt _ Implements IM8.SmartElectricalAlternatorPowerGenAtCrank Get Return SW3 End Get End Property 'OUT3 - Public ReadOnly Property CompressorFlag As Integer Implements IM8.CompressorFlag + Public ReadOnly Property CompressorFlag As Boolean Implements IM8.CompressorFlag Get Return SW4 End Get diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/M9.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/M9.vb index 55b3b5d1672b571e7a77ada2e36103d185b1f03a..bb5c089ad316ae83ed041b4bcad9c4578c56ae73 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/M9.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/M9.vb @@ -9,6 +9,7 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac @@ -21,13 +22,13 @@ Namespace DownstreamModules #Region "Aggregates" 'AG1 - Private _LitresOfAirCompressorOnContinuallyAggregate As Double + Private _LitresOfAirCompressorOnContinuallyAggregate As NormLiter 'AG2 - Private _LitresOfAirCompressorOnOnlyInOverrunAggregate As Double + Private _LitresOfAirCompressorOnOnlyInOverrunAggregate As NormLiter 'AG3 - Private _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate As Double + Private _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate As Kilogram 'AG4 - Private _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate As Double + Private _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate As Kilogram #End Region @@ -46,28 +47,28 @@ Namespace DownstreamModules #Region "Class Outputs" 'OUT 1 - Public ReadOnly Property LitresOfAirCompressorOnContinually As Single _ + Public ReadOnly Property LitresOfAirCompressorOnContinually As NormLiter _ Implements IM9.LitresOfAirCompressorOnContinually Get Return _LitresOfAirCompressorOnContinuallyAggregate End Get End Property 'OUT 2 - Public ReadOnly Property LitresOfAirCompressorOnOnlyInOverrun As Single _ + Public ReadOnly Property LitresOfAirCompressorOnOnlyInOverrun As NormLiter _ Implements IM9.LitresOfAirCompressorOnOnlyInOverrun Get Return _LitresOfAirCompressorOnOnlyInOverrunAggregate End Get End Property 'OUT 3 - Public ReadOnly Property TotalCycleFuelConsumptionCompressorOffContinuously As Single _ + Public ReadOnly Property TotalCycleFuelConsumptionCompressorOffContinuously As Kilogram _ Implements IM9.TotalCycleFuelConsumptionCompressorOffContinuously Get Return _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate End Get End Property 'OUT 4 - Public ReadOnly Property TotalCycleFuelConsumptionCompressorOnContinuously As Single _ + Public ReadOnly Property TotalCycleFuelConsumptionCompressorOnContinuously As Kilogram _ Implements IM9.TotalCycleFuelConsumptionCompressorOnContinuously Get Return _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate @@ -77,136 +78,139 @@ Namespace DownstreamModules #End Region 'Staging Calculations - Private Function S0(ByVal rpm As Single) As Single + Private Function S0(ByVal rpm As PerSecond) As PerSecond - If rpm < 1 Then rpm = 1 + If rpm < 1 Then rpm = 1.RPMtoRad() - Return rpm / RPM_TO_RADS_PER_SECOND + Return rpm ' / RPM_TO_RADS_PER_SECOND End Function - Private ReadOnly Property S1 As Single + Private ReadOnly Property S1 As Watt Get Return M6.AvgPowerDemandAtCrankFromElectricsIncHVAC + M1.AveragePowerDemandAtCrankFromHVACMechanicalsWatts End Get End Property - Private ReadOnly Property S2 As Single + Private ReadOnly Property S2 As NewtonMeter Get - If S0(Signals.EngineSpeed) = 0 Then _ + If S0(Signals.EngineSpeed).IsEqual(0) Then _ Throw New DivideByZeroException("Engine speed is zero and cannot be used as a divisor.") Return M4.GetPowerCompressorOn / S0(Signals.EngineSpeed) End Get End Property - Private ReadOnly Property S3 As Single + Private ReadOnly Property S3 As NewtonMeter Get - If S0(Signals.EngineSpeed) = 0 Then _ + If S0(Signals.EngineSpeed).IsEqual(0) Then _ Throw New DivideByZeroException("Engine speed is zero and cannot be used as a divisor.") Return M4.GetPowerCompressorOff / S0(Signals.EngineSpeed) End Get End Property - Private ReadOnly Property S4 As Single + Private ReadOnly Property S4 As NewtonMeter Get - If S0(Signals.EngineSpeed) = 0 Then _ + If S0(Signals.EngineSpeed).IsEqual(0) Then _ Throw New DivideByZeroException("Engine speed is zero and cannot be used as a divisor.") Return S1 / S0(Signals.EngineSpeed) End Get End Property - Private ReadOnly Property S5 As Single + Private ReadOnly Property S5 As NewtonMeter Get Return S2 + S14 End Get End Property - Private ReadOnly Property S6 As Single + Private ReadOnly Property S6 As NewtonMeter Get Return S14 + S3 End Get End Property - Private ReadOnly Property S7 As Single + Private ReadOnly Property S7 As NewtonMeter Get Return S4 + S5 End Get End Property - Private ReadOnly Property S8 As Single + Private ReadOnly Property S8 As NewtonMeter Get Return S4 + S6 End Get End Property - Private ReadOnly Property S9 As Single + Private ReadOnly Property S9 As NormLiterPerSecond Get - Return M4.GetFlowRate * M6.OverrunFlag * M8.CompressorFlag + Return If(M6.OverrunFlag AndAlso M8.CompressorFlag, M4.GetFlowRate, SIBase(Of NormLiterPerSecond).Create(0)) End Get End Property - Private ReadOnly Property S10 As Single + Private ReadOnly Property S10 As NormLiterPerSecond Get Return S13 * PSAC.OverrunUtilisationForCompressionFraction End Get End Property - Private ReadOnly Property S11 As Single + Private ReadOnly Property S11 As KilogramPerSecond Get 'SCHM 3_02 - Dim int1 As Single = FMAP.GetFuelConsumption(S7, Signals.EngineSpeed) - int1 = If(int1 > 0 AndAlso Not Single.IsNaN(int1), int1, 0) + Dim int1 As KilogramPerSecond = FMAP.GetFuelConsumption(S7, Signals.EngineSpeed) + int1 = If(int1 > 0 AndAlso Not Double.IsNaN(int1.Value()), int1, 0.SI(Of KilogramPerSecond)) - Return int1 / 3600 + Return int1 End Get End Property - Private ReadOnly Property S12 As Single + Private ReadOnly Property S12 As KilogramPerSecond Get 'SCHM 3_02 - Dim int2 As Single = FMAP.GetFuelConsumption(S8, Signals.EngineSpeed) - int2 = If(int2 > 0 AndAlso Not Single.IsNaN(int2), int2, 0) + Dim int2 As KilogramPerSecond = FMAP.GetFuelConsumption(S8, Signals.EngineSpeed) + int2 = If(int2 > 0 AndAlso Not Double.IsNaN(int2.Value()), int2, 0.SI(Of KilogramPerSecond)) - Return int2 / 3600 + Return int2 End Get End Property - Private ReadOnly Property S13 As Single + Private ReadOnly Property S13 As NormLiterPerSecond Get - Return If(Signals.ClutchEngaged AndAlso Not (Signals.InNeutral), S9, 0) + Return If(Signals.ClutchEngaged AndAlso Not (Signals.InNeutral), S9, SIBase(Of NormLiterPerSecond).Create(0)) End Get End Property - Private ReadOnly Property S14 As Single + Private ReadOnly Property S14 As NewtonMeter Get - - Return Signals.EngineDrivelineTorque + ((Signals.PreExistingAuxPower * 1000) / S0(Signals.EngineSpeed)) + Return _ + Signals.EngineDrivelineTorque + + Signals.PreExistingAuxPower / S0(Signals.EngineSpeed) End Get End Property - Private ReadOnly Property SW1 As Integer + Private ReadOnly Property SW1 As Boolean Get - Return If(Signals.EngineStopped, 0, 1) + Return Not Signals.EngineStopped End Get End Property 'Utility Methods Public Sub ClearAggregates() Implements IM9.ClearAggregates - _LitresOfAirCompressorOnContinuallyAggregate = 0 - _LitresOfAirCompressorOnOnlyInOverrunAggregate = 0 - _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate = 0 - _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate = 0 + _LitresOfAirCompressorOnContinuallyAggregate = SIBase(Of NormLiter).Create(0) + _LitresOfAirCompressorOnOnlyInOverrunAggregate = SIBase(Of NormLiter).Create(0) + _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate = SIBase(Of Kilogram).Create(0) + _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate = SIBase(Of Kilogram).Create(0) End Sub - Public Sub CycleStep(Optional stepTimeInSeconds As Double = 0.0) Implements IM9.CycleStep + Public Sub CycleStep(stepTimeInSeconds As Second) Implements IM9.CycleStep If Signals.EngineStopped Then Return - _LitresOfAirCompressorOnContinuallyAggregate += stepTimeInSeconds * M4.GetFlowRate * SW1 - _LitresOfAirCompressorOnOnlyInOverrunAggregate += stepTimeInSeconds * S10 * SW1 - _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate += stepTimeInSeconds * S11 * SW1 - _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate += stepTimeInSeconds * S12 * SW1 + If (SW1) Then + _LitresOfAirCompressorOnContinuallyAggregate += M4.GetFlowRate * stepTimeInSeconds + _LitresOfAirCompressorOnOnlyInOverrunAggregate += S10 * stepTimeInSeconds + _TotalCycleFuelConsumptionCompressorOnContinuouslyAggregate += S11 * stepTimeInSeconds + _TotalCycleFuelConsumptionCompressorOffContinuouslyAggregate += S12 * stepTimeInSeconds + End If End Sub 'Constructor @@ -219,6 +223,8 @@ Namespace DownstreamModules Me.FMAP = fmap Me.PSAC = psac Me.Signals = signals + + ClearAggregates() End Sub 'Auxiliary Event diff --git a/VECTOAux/VectoAuxiliaries/DownstreamModules/cDelaunayMap.vb b/VECTOAux/VectoAuxiliaries/DownstreamModules/cDelaunayMap.vb index f008ca872f66982cf9ac3ec018e3ab9c109467a0..e5ac0614fbd243cae5346b64e45dd62efd5f75db 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/cDelaunayMap.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/cDelaunayMap.vb @@ -11,484 +11,465 @@ Imports System.Collections.Generic Public Class cDelaunayMap + Public ptDim As Integer - 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 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 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 ExtrapolError As Boolean + Public Function Triangulate() As Boolean + Dim tr As dTriangle + Dim DT As dTriangulation + ptDim = ptList.Count - 1 - 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 - + '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 index a924548d1fa912e32b4b93e27dd63ed9c6e7de9e..f1bdd41f6fb4c0165211cfe1d9353d9f81f25359 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/cFile V3.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/cFile V3.vb @@ -9,142 +9,142 @@ ' ' 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 - + 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 index 4267c9b8596d269a2e7205a86dd9d04d8aa6d422..c1ebf4fe23d4d5f186545206f12575a7e1d22e45 100644 --- a/VECTOAux/VectoAuxiliaries/DownstreamModules/cMAP.vb +++ b/VECTOAux/VectoAuxiliaries/DownstreamModules/cMAP.vb @@ -9,6 +9,8 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Collections.Generic +Imports System.Globalization +Imports TUGraz.VectoCommon.Utils Public Class cMAP Implements IFuelConsumptionMap @@ -33,7 +35,7 @@ Public Class cMAP Public Function ReadFile(Optional ByVal ShowMsg As Boolean = True) As Boolean Dim file As cFile_V3 Dim line As String() - Dim nU As Double + Dim nU As Single Dim MsgSrc As String @@ -74,12 +76,12 @@ Public Class cMAP iMapDim += 1 'Revolutions - nU = CDbl(line(0)) + nU = Single.Parse(line(0), CultureInfo.InvariantCulture) LnU.Add(nU) 'Power - LTq.Add(line(1)) + LTq.Add(Single.Parse(line(1), CultureInfo.InvariantCulture)) 'FC 'Check sign @@ -135,7 +137,7 @@ lbEr: Public Function fFCdelaunay_Intp(ByVal nU As Single, ByVal Tq As Single) As Single Dim val As Single - val = FuelMap.Intpol(nU, Tq) + val = CType(FuelMap.Intpol(nU, Tq), Single) If FuelMap.ExtrapolError Then 'TODO:WORKERMESSAGE WorkerMsg(tMsgID.Err, "Cannot extrapolate FC map! n= " & nU.ToString("0.0") & " [1/min], Me= " & Tq.ToString("0.0") & " [Nm]", "MAP/FC_Intp") @@ -182,9 +184,10 @@ lbEr: #End Region - Public Function GetFuelConsumption(torque As Double, angularVelocity As Double) As Double _ + Public Function GetFuelConsumption(torque As NewtonMeter, angularVelocity As PerSecond) As KilogramPerSecond _ Implements IFuelConsumptionMap.GetFuelConsumption - Return fFCdelaunay_Intp(angularVelocity, torque) + 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/AltUserInput.vb b/VECTOAux/VectoAuxiliaries/Electrics/AltUserInput.vb index 947d0e98c0c71ff86b28ebf1165ee6d90bafc65c..18c79741954b5c2d2b1b0bda7ee30bf73d94df8a 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/AltUserInput.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/AltUserInput.vb @@ -2,33 +2,26 @@ Namespace Electrics - 'Used by the Combined Alternator Form/Classes to accept user input for the combined alternators efficiency 'At different Current Demands - Public class AltUserInput - - Public Amps As Single - Public Eff As Single - - 'Constructor - Sub new( amps As Single , eff As single) - - Me.Amps=amps - Me.Eff = eff - - End Sub - - 'Equality - Public Function IsEqual( other As AltUserInput, Optional rounding As Integer=7) As Boolean - - Return Math.round(Me.Amps,rounding)= Math.Round(other.Amps,rounding) AndAlso _ - Math.Round(Me.Eff,rounding) = Math.Round(other.eff,rounding) - - End Function - - - End class + Public class AltUserInput + Public Amps As Double + Public Eff As Double + + 'Constructor + Sub New(amps As Double, eff As Double) + + Me.Amps = amps + Me.Eff = eff + End Sub + + 'Equality + Public Function IsEqual(other As AltUserInput, Optional rounding As Integer = 7) As Boolean + Return Math.round(Me.Amps, rounding) = Math.Round(other.Amps, rounding) AndAlso + Math.Round(Me.Eff, rounding) = Math.Round(other.eff, rounding) + End Function + End class End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb index 234e0e568b9d8988577f0b7ff30ebf9f18d1a9cd..179102eca47e75efb4950d735ef31202da8e56c5 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/Alternator.vb @@ -1,310 +1,326 @@ Option Strict On +Imports TUGraz.VectoCommon.Utils Namespace Electrics + Public Class Table4Row + Public RPM As Double + Public Efficiency As Double + Public Sub New(rpm As Double, eff As Double) - Public Class Table4Row + Me.RPM = rpm + Me.Efficiency = eff + End Sub + End Class - Public RPM As Single - Public Efficiency As Single + 'Model based on CombinedALTS_V02_Editable.xlsx + Public Class Alternator + Implements IAlternator - Public Sub New(rpm As Single, eff As Single) + Private signals As ICombinedAlternatorSignals - Me.rpm = rpm - Me.Efficiency = eff + 'D6 + Public Property AlternatorName As String Implements IAlternator.AlternatorName + 'G6 + Public Property PulleyRatio As Single 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 - End Sub + Get + 'First build RangeTable, table 4 + InitialiseRangeTable() + CalculateRangeTable() - End Class + 'Calculate ( Interpolate ) Efficiency + Dim range As List(Of AltUserInput) = RangeTable.Select(Function(s) New AltUserInput(s.RPM, s.Efficiency)).ToList() - 'Model based on CombinedALTS_V02_Editable.xlsx - Public Class Alternator - Implements IAlternator + Return Alternator.Iterpolate(range, Convert.ToSingle(SpindleSpeed)) + End Get + End Property - Private signals As ICombinedAlternatorSignals - 'D6 - Public Property AlternatorName As String Implements IAlternator.AlternatorName - 'G6 - Public Property PulleyRatio As Single 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 + 'Constructors + Sub New() + End Sub - Get - 'First build RangeTable, table 4 - InitialiseRangeTable() - CalculateRangeTable() + Sub New(isignals As ICombinedAlternatorSignals, inputs As List(Of ICombinedAlternatorMapRow)) - '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)) + If isignals Is Nothing Then Throw New ArgumentException("Alternator - ISignals supplied is nothing") + signals = isignals - End Get + Me.AlternatorName = inputs.First().AlternatorName + Me.PulleyRatio = inputs.First().PulleyRatio - End Property + 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) - 'Constructors - Sub New() + BuildInputTable(values2k, InputTable2000) + BuildInputTable(values4k, InputTable4000) + BuildInputTable(values6k, InputTable6000) - End Sub - Sub New(isignals As ICombinedAlternatorSignals, inputs As List(Of ICombinedAlternatorMapRow)) + CreateRangeTable() + End Sub + Public Shared Function Iterpolate(values As List(Of AltUserInput), x As Double) As Double - If isignals Is Nothing Then Throw New ArgumentException("Alternator - ISignals supplied is nothing") - signals = isignals + 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 - Me.AlternatorName = inputs.First().AlternatorName - Me.PulleyRatio = inputs.First().PulleyRatio + '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 - Dim values2k As Dictionary(Of Single, Single) = inputs.where(Function(x) x.RPM = 2000).Select(Function(x) New KeyValuePair(Of Single, Single)(x.Amps, x.Efficiency)).ToDictionary(Function(x) x.Key, Function(x) x.Value) - Dim values4k As Dictionary(Of Single, Single) = inputs.where(Function(x) x.RPM = 4000).Select(Function(x) New KeyValuePair(Of Single, Single)(x.Amps, x.Efficiency)).ToDictionary(Function(x) x.Key, Function(x) x.Value) - Dim values6k As Dictionary(Of Single, Single) = inputs.where(Function(x) x.RPM = 6000).Select(Function(x) New KeyValuePair(Of Single, Single)(x.Amps, x.Efficiency)).ToDictionary(Function(x) x.Key, Function(x) x.Value) + '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 - BuildInputTable(values2k, InputTable2000) - BuildInputTable(values4k, InputTable4000) - BuildInputTable(values6k, InputTable6000) + '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 - CreateRangeTable() + '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)) - End Sub - Public Shared Function Iterpolate(values As List(Of AltUserInput), x As Single) As Single + 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)) - Dim lowestX As Single = values.Min(Function(m) m.Amps) - Dim highestX As Single = values.Max(Function(m) m.Amps) - Dim preKey, postKey, preEff, postEff, EffSlope As Single - Dim deltaX, deltaEff As Single - 'Out of range, returns efficiency for lowest - If x < lowestX Then Return values.First(Function(f) f.Amps = lowestX).Eff + '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() - 'Out of range, efficiency for highest - If x > highestX Then Return values.First(Function(f) f.Amps = highestX).Eff + '=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 - 'On Bounds check - If values.Where(Function(w) w.Amps = x).Count = 1 Then Return values.First(Function(w) w.Amps = x).Eff + 'Row5 + C15 = If(C14 > 200, C14 + 1, 200) + D15 = D14 + targetTable.Add(New AltUserInput(C15, D15)) + 'Row0 + targetTable(0).Eff = D11 + End Sub - '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 + 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 - deltaX = postKey - preKey - deltaEff = postEff - preEff + Dim i As Integer = 1 - 'slopes - effSlope = deltaEff / deltaX + 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 - Dim retVal As Single = ((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 Single - Dim M10, M11, M12, M13, M14, M15, M16 As Single - - 'EFFICIENCY - - '2000 - N12 = Alternator.Iterpolate(InputTable2000, signals.CurrentDemandAmps) - RangeTable(2).Efficiency = N12 - '4000 - N13 = Alternator.Iterpolate(InputTable4000, signals.CurrentDemandAmps) - RangeTable(3).Efficiency = N13 - '6000 - N14 = Alternator.Iterpolate(InputTable6000, signals.CurrentDemandAmps) - 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 Single, Single), targetTable As List(Of AltUserInput)) - - - Dim C11, C12, C13, C14, C15, D11, D12, D13, D14, D15 As Single - 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 Single() = {D11, D12, D13} - Dim maxD11_D13 As Single = 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 + Next + Return True + End Function + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMap.vb b/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMap.vb index ba25a7c75018fd9c6d31da3d050748205622ad62..9b13d9c499a1b0349cbfd5792b93369feebf51bc 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMap.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMap.vb @@ -11,342 +11,329 @@ Imports System.Globalization Imports System.IO Imports System.Text +Imports TUGraz.VectoCommon.Utils Namespace Electrics + Public Class AlternatorMap + Implements IAlternatorMap -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 - Private ReadOnly filePath As String + '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 - Private _map As New List(Of MapPoint) - Private _yRange As List(Of Single) - Private _xRange As List(Of Single) - Private _minX, _minY, _maxX, _maxY As Single + Public Function OnBoundaryXInterpolatedY(x As Double, y As Double) As Boolean + Return Not _yRange.Contains(y) AndAlso _xRange.Contains(x) + End Function - 'Required Action Test or Interpolation Type - Public Function OnBoundaryYInterpolatedX(x As Single, y As Single) As Boolean - Return _yRange.Contains(y) AndAlso Not _xRange.Contains(x) - End Function - Public Function OnBoundaryXInterpolatedY(x As Single, y As Single) As Boolean - Return Not _yRange.Contains(y) AndAlso _xRange.Contains(x) - End Function - Public Function ONBoundaryXY(x As Single, y As Single) As Boolean - Return (From sector In _map Where sector.Y = y AndAlso sector.x = x).Count = 1 - 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 Single, y As Single) As Single - Return (From sector In _map Where sector.Y = y AndAlso sector.x = x).First().v - End Function - Private Function GetOnBoundaryYInterpolatedX(x As Single, y As Single) As Single + '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 - Dim x0, x1, v0, v1, slope, dx As Single + Private Function GetOnBoundaryYInterpolatedX(x As Double, y As Double) 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 + Dim x0, x1, v0, v1, slope, dx As Double - v0 = GetOnBoundaryXY(x0, y) - v1 = GetOnBoundaryXY(x1, y) + 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 - slope = (v1 - v0) / (x1 - x0) + v0 = GetOnBoundaryXY(x0, y) + v1 = GetOnBoundaryXY(x1, y) - Return v0 + ((x - x0) * slope) + slope = (v1 - v0) / (x1 - x0) - End Function - Private Function GetOnBoundaryXInterpolatedY(x As Single, y As Single) As Single + Return v0 + ((x - x0) * slope) + End Function - Dim y0, y1, v0, v1, dy, v, slope As Single + Private Function GetOnBoundaryXInterpolatedY(x As Double, y As Double) 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 + Dim y0, y1, v0, v1, dy, v, slope As Double - v0 = GetOnBoundaryXY(x, y0) - v1 = GetOnBoundaryXY(x, y1) + 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 - slope = (v1 - v0) / (y1 - y0) + v0 = GetOnBoundaryXY(x, y0) + v1 = GetOnBoundaryXY(x, y1) - v = v0 + ((y - y0) * slope) + slope = (v1 - v0) / (y1 - y0) - Return v + v = v0 + ((y - y0) * slope) - End Function - Private Function GetBiLinearInterpolatedValue(x As Single, y As Single) As Single + Return v + End Function - Dim q11, q12, q21, q22, x1, x2, y1, y2, r1, r2, p As Single + Private Function GetBiLinearInterpolatedValue(x As Double, y As Double) 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 + Dim q11, q12, q21, q22, x1, x2, y1, y2, r1, r2, p As Double - 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 + 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 - q11 = GetOnBoundaryXY(x1, y1) - q12 = GetOnBoundaryXY(x1, y2) + 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 - q21 = GetOnBoundaryXY(x2, y1) - q22 = GetOnBoundaryXY(x2, y2) + q11 = GetOnBoundaryXY(x1, y1) + q12 = GetOnBoundaryXY(x1, y2) - r1 = ((x2 - x) / (x2 - x1)) * q11 + ((x - x1) / (x2 - x1)) * q21 + q21 = GetOnBoundaryXY(x2, y1) + q22 = GetOnBoundaryXY(x2, y2) - r2 = ((x2 - x) / (x2 - x1)) * q12 + ((x - x1) / (x2 - x1)) * q22 + 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 + p = ((y2 - y) / (y2 - y1)) * r1 + ((y - y1) / (y2 - y1)) * r2 - Return p - End Function + Return p + End Function - 'Utilities - Private Sub fillMapWithDefaults() + '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 - _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)) + 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 - 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() + If x < _minX OrElse x > _maxX OrElse y < _minY OrElse y > _maxY Then - _minX = _xRange.First - _maxX = _xRange.Last - _minY = _yRange.First - _maxY = _yRange.Last + 'OnAuxiliaryEvent(String.Format("Alternator Map Limiting : RPM{0}, AMPS{1}",x,y),AdvancedAuxiliaryMessageType.Warning) - End Sub + '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 - 'Single entry point to determine Value on map - Public Function GetValue(x As Single, y As Single) As Single + End If - If x < _minX OrElse x > _maxX OrElse y < _minY OrElse y > _maxY then + 'Satisfies both data points - non interpolated value + If ONBoundaryXY(x, y) Then Return GetOnBoundaryXY(x, y) - 'OnAuxiliaryEvent(String.Format("Alternator Map Limiting : RPM{0}, AMPS{1}",x,y),AdvancedAuxiliaryMessageType.Warning) + '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 - '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 + Public Function ReturnDefaultMapValueTests() As String - End If + 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 - 'Satisfies both data points - non interpolated value - If ONBoundaryXY(x, y) Then Return GetOnBoundaryXY(x, y) + For Each y In _yRange + sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", x, y, GetValue(x, y))) + Next - '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) + Next - 'satisfies no data points - Bi-Linear interpolation - Return GetBiLinearInterpolatedValue(x, y) + 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 - End Function - Public Function ReturnDefaultMapValueTests() As String + For y2 = 0 To _yRange.Count - 2 - Dim sb As StringBuilder = New StringBuilder() - Dim x, y As Single + mx = _xRange(x2) + (_xRange(x2 + 1) - _xRange(x2)) / 2 + my = _yRange(y2) + (_yRange(y2 + 1) - _yRange(y2)) / 2 - 'All Sector Values - sb.AppendLine("All Values From Map") - sb.AppendLine("-------------------") - For Each x In _xRange + sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", mx, my, GetValue(mx, my))) - For Each y In _yRange - sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", x, y, GetValue(x, y))) - Next - 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))) + Next - sb.AppendLine("") - sb.AppendLine("Interpolated both") - sb.AppendLine("-------------------") + 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))) - Dim mx, my As Single - For x = 0 To _xRange.Count - 2 - For y = 0 To _yRange.Count - 2 + Return sb.ToString() + End Function - mx = _xRange(x) + (_xRange(x + 1) - _xRange(x)) / 2 - my = _yRange(y) + (_yRange(y + 1) - _yRange(y)) / 2 + 'Constructors + Public Sub New(filepath As String) - sb.AppendLine(String.Format("X:{0}, Y:{1}, V:{2}", mx, my, GetValue(mx, my))) + Me.filePath = filepath + Initialise() - Next + getMapRanges() + End Sub - Next + Private Class MapPoint + Public Y As Double + Public x As Double + Public v As Double - 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))) + 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 - Return sb.ToString() + '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) - End Function + '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 - 'Constructors - Public Sub New(filepath As String) + _map = New List(Of MapPoint) + Dim firstline As Boolean = True - Me.filePath = filepath + For Each line As String In lines + If Not firstline Then - Initialise() + 'Advanced Alternator Source Check. + If line.Contains("[MODELSOURCE") Then Exit For - getMapRanges() + '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 - End Sub - - Private Class MapPoint - - Public Y As Single - Public x As Single - Public v As Single - - Public Sub New(y As Single, x As Single, v As Single) - - Me.Y = y - Me.x = x - Me.v = v - - End Sub - - End Class - - 'Get Alternator Efficiency - Public Function GetEfficiency(rpm As single, amps As single) As AlternatorMapValues Implements IAlternatorMap.GetEfficiency - - Return New AlternatorMapValues( GetValue(rpm,amps)) - - 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() {","}, 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 + '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 - - + 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/AlternatorMapValues.vb b/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMapValues.vb index 7c2b6ea0a9abd212673968fa8b591ed77ecc3158..fecaa48ca0e90a0fed30b95447af5146bb0bb925 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMapValues.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/AlternatorMapValues.vb @@ -11,18 +11,13 @@ Namespace Electrics - - 'Originally was going to hold more than one value type. - Public Structure AlternatorMapValues - - Public ReadOnly Efficiency As Single - - Public Sub New(ByVal efficiency As Single) - Me.Efficiency = efficiency - End Sub - - End Structure - - + 'Originally was going to hold more than one value type. + Public Structure AlternatorMapValues + Public ReadOnly Efficiency As Double + + Public Sub New(ByVal efficiency As Double) + Me.Efficiency = efficiency + End Sub + End Structure End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb index d40afbd73a3aac36a9a3a54940200199408457f7..410d5f8dfc7abdc0550f183a614280d2860829c7 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternator.vb @@ -11,432 +11,431 @@ Imports DocumentFormat.OpenXml.Spreadsheet Imports Newtonsoft.Json Imports VectoAuxiliaries Imports System.Globalization +Imports TUGraz.VectoCommon.Utils Namespace Electrics + Public Class CombinedAlternator + Implements IAlternatorMap, ICombinedAlternator -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 - 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 - 'Interface Implementation - Public Function GetEfficiency(ByVal CrankRPM As Single, ByVal Amps As Single) As AlternatorMapValues Implements IAlternatorMap.GetEfficiency + altSignals.CrankRPM = CrankRPM + altSignals.CurrentDemandAmps = (Amps.Value() / Alternators.Count).SI(Of Ampere)() - altSignals.CrankRPM = CrankRPM - altSignals.CurrentDemandAmps = Amps / Alternators.Count + Dim alternatorMapValues As AlternatorMapValues = Nothing - 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 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 - If alternatorMapValues.Efficiency <= 0 Then - alternatorMapValues = New AlternatorMapValues(0.01) - End If + Return alternatorMapValues + End Function - Return alternatorMapValues + Public Function Initialise() As Boolean Implements IAlternatorMap.Initialise - End Function - Public Function Initialise() As Boolean Implements IAlternatorMap.Initialise + 'From the map we construct this CombinedAlternator object and original CombinedAlternator Object - 'From the map we construct this CombinedAlternator object and original CombinedAlternator Object + Alternators.Clear() + OriginalAlternators.Clear() - Alternators.Clear() - OriginalAlternators.Clear() + For Each alt As IEnumerable(Of ICombinedAlternatorMapRow) In map.GroupBy(Function(g) g.AlternatorName) - For Each alt As IEnumerable(Of ICombinedAlternatorMapRow) In map.GroupBy(Function(g) g.AlternatorName) + Dim altName As String = alt.First().AlternatorName + Dim pulleyRatio As Single = alt.First().PulleyRatio - Dim altName As String = alt.First().AlternatorName - Dim pulleyRatio As Single = alt.First().PulleyRatio + Dim alternator As IAlternator = New Alternator(altSignals, alt.ToList()) - Dim alternator As IAlternator = New Alternator(altSignals, alt.ToList()) + Alternators.Add(alternator) - Alternators.Add(alternator) + Next - Next + Return True + End Function - Return True + 'Constructors + Public Sub New(filePath As String, Optional signals As ISignals = Nothing) - End Function + Dim feedback As String = String.Empty + Me.Signals = signals - 'Constructors - Public Sub New(filePath As String, Optional signals As ISignals = Nothing) + 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 - 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() - 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 - 'IF file exists then read it otherwise create a default. + ' Calculate alternators average which is used only in the pre-run + Dim efficiencySum As Double + Dim efficiencyAverage As Double - If File.Exists(filePath) AndAlso InitialiseMap(filePath) Then - Initialise() - Else - 'Create Default Map - CreateDefaultMap() - Initialise() - End If + 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 - ' Calculate alternators average which is used only in the pre-run - Dim efficiencySum As Single - Dim efficiencyAverage As Single + efficiencySum += alt.InputTable4000.ElementAt(1).Eff + efficiencySum += alt.InputTable4000.ElementAt(2).Eff + efficiencySum += alt.InputTable4000.ElementAt(3).Eff - 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.InputTable6000.ElementAt(1).Eff + efficiencySum += alt.InputTable6000.ElementAt(2).Eff + efficiencySum += alt.InputTable6000.ElementAt(3).Eff + Next - efficiencySum += alt.InputTable4000.ElementAt(1).Eff - efficiencySum += alt.InputTable4000.ElementAt(2).Eff - efficiencySum += alt.InputTable4000.ElementAt(3).Eff + efficiencyAverage = efficiencySum / (Alternators.Count * 9) + AverageAlternatorsEfficiency = New AlternatorMapValues(efficiencyAverage / 100) + End Sub - efficiencySum += alt.InputTable6000.ElementAt(1).Eff - efficiencySum += alt.InputTable6000.ElementAt(2).Eff - efficiencySum += alt.InputTable6000.ElementAt(3).Eff - Next + 'Helpers + Private Sub CreateDefaultMap() - efficiencyAverage = efficiencySum / (Alternators.Count * 9) - AverageAlternatorsEfficiency = New AlternatorMapValues(efficiencyAverage / 100) + map.Clear() - End Sub + 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)) - 'Helpers - Private Sub CreateDefaultMap() + 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.Clear() + 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("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("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("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("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("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", 6000, 10, 53, 3)) + map.Add(New CombinedAlternatorMapRow("Alt2", 6000, 68, 70, 3)) + map.Add(New CombinedAlternatorMapRow("Alt2", 6000, 136, 62, 3)) + End Sub - 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)) + 'Grid Management + Private Function AddNewAlternator(list As List(Of ICombinedAlternatorMapRow), ByRef feeback As String) As Boolean - 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)) + Dim returnValue As Boolean = True - 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)) + Dim altName As String = list.First().AlternatorName + Dim pulleyRatio As Single = 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 - End Sub + Dim alternator As IAlternator = New Alternator(altSignals, list.ToList()) - 'Grid Management - Private Function AddNewAlternator(list As List(Of ICombinedAlternatorMapRow), ByRef feeback As String) As Boolean + Alternators.Add(alternator) - Dim returnValue As Boolean = True - Dim altName As String = list.First().AlternatorName - Dim pulleyRatio As Single = list.First().PulleyRatio + Return returnValue + End Function - '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 + Public Function AddAlternator(rows As List(Of ICombinedAlternatorMapRow), ByRef feedback As String) As Boolean - Dim alternator As IAlternator = New Alternator(altSignals, list.ToList()) + If Not AddNewAlternator(rows, feedback) Then + feedback = String.Format("Unable to add new alternator : {0}", feedback) + Return False + End If - Alternators.Add(alternator) + Return True + End Function + Public Function DeleteAlternator(alternatorName As String, ByRef feedback As String, CountValidation As Boolean) _ + As Boolean - Return returnValue + '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 - End Function - Public Function AddAlternator(rows As List(Of ICombinedAlternatorMapRow), ByRef feedback As String) As Boolean + If Alternators.Where(Function(w) w.AlternatorName = alternatorName).Count = 0 Then + feedback = "This alternator does not exist" + Return False + End If - If Not AddNewAlternator(rows, feedback) Then - feedback = String.Format("Unable to add new alternator : {0}", feedback) - Return False - End If + Dim altToRemove As IAlternator = Alternators.First(Function(w) w.AlternatorName = alternatorName) + Dim numAlternators As Integer = Alternators.Count - Return True + Alternators.Remove(altToRemove) - End Function - Public Function DeleteAlternator(alternatorName As String, ByRef feedback As String, CountValidation As Boolean) As Boolean + 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 - '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 + ' Dim altName As String = rows.First.AlternatorName + ' Dim altToUpd As IAlternator = Alternators.First(Function(w) w.AlternatorName = altName) - If Alternators.Where(Function(w) w.AlternatorName = alternatorName).Count = 0 Then - feedback = "This alternator does not exist" - Return False - End If + ' If Not DeleteAlternator(altName, feedback) Then + ' feedback = feedback + ' Return False - Dim altToRemove As IAlternator = Alternators.First(Function(w) w.AlternatorName = alternatorName) - Dim numAlternators As Integer = Alternators.Count + ' End If - Alternators.Remove(altToRemove) + ' 'Re.create alternator. - 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 + ' Dim replacementAlt As New Alternator(altSignals, rows) + ' Alternators.Add(replacementAlt) - End Function - 'Public Function UpdateAlternator( gridIndex As Integer, rows As List(Of ICombinedAlternatorMapRow), ByRef feedback As String) As Boolean + ' Return True - ' 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 Function - ' End If + 'Persistance Functions + Public Function Save(aaltPath As String) As Boolean - ' 'Re.create alternator. - ' Dim replacementAlt As New Alternator(altSignals, rows) - ' Alternators.Add(replacementAlt) + Dim returnValue As Boolean = True + Dim sb As New StringBuilder() + Dim row As Integer = 0 + Dim amps As Double + Dim eff As Double - ' Return True + 'write headers + sb.AppendLine("[AlternatorName],[RPM],[Amps],[Efficiency],[PulleyRatio]") + 'write details + For Each alt As IAlternator In Alternators.OrderBy(Function(o) o.AlternatorName) - 'End Function - 'Persistance Functions - Public Function Save(aaltPath As String) As Boolean + '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 - Dim returnValue As Boolean = True - Dim sb As New StringBuilder() - Dim row As Integer = 0 - Dim amps, eff As Single + '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 - 'write headers - sb.AppendLine("[AlternatorName],[RPM],[Amps],[Efficiency],[PulleyRatio]") - 'write details - For Each alt As IAlternator In Alternators.OrderBy(Function(o) o.AlternatorName) + Next + 'Add Model Source + sb.AppendLine("[MODELSOURCE]") + sb.Append(Me.ToString()) - '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 + ' Write the stream cotnents to a new file named "AllTxtFiles.txt" + Using outfile As New StreamWriter(aaltPath) + outfile.Write(sb.ToString()) + End Using - '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 + Return returnValue + End Function - '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 + Private Function Load() As Boolean + If Not InitialiseMap(FilePath) Then Return False - Next - 'Add Model Source - sb.AppendLine("[MODELSOURCE]") - sb.Append(Me.ToString()) + Return True + End Function - ' Write the stream cotnents to a new file named "AllTxtFiles.txt" - Using outfile As New StreamWriter(aaltPath) - outfile.Write(sb.ToString()) - End Using + '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 - Return returnValue + Dim returnValue As Boolean = False + Dim elements As String() - End Function - Private Function Load() As Boolean + If File.Exists(filePath) Then + Using sr As StreamReader = New StreamReader(filePath) + 'get array og lines fron csv + Dim lines() As String = sr.ReadToEnd().Split(CType(Environment.NewLine, Char()), + StringSplitOptions.RemoveEmptyEntries) - If Not InitialiseMap(FilePath) Then Return False + '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) - Return True + Dim firstline As Boolean = True - End Function + For Each line As String In lines + If Not firstline Then - '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 + 'Advanced Alternator Source Check. + If line.Contains("[MODELSOURCE") Then Exit For - Dim returnValue As Boolean = False - Dim elements As String() + '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 - 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) + 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))) - '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 + Else + firstline = False + End If + Next line + End Using + Return True + Else + Throw New ArgumentException("Supplied input file does not exist") + End If - map = New List(Of ICombinedAlternatorMapRow) + Return returnValue + End Function - Dim firstline As Boolean = True + 'Can be used to send messages to Vecto. + Public Event AuxiliaryEvent(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) _ + Implements IAuxiliaryEvent.AuxiliaryEvent - For Each line As String In lines - If Not firstline Then + '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 - 'Advanced Alternator Source Check. - If line.Contains("[MODELSOURCE") Then Exit For + Dim sb As New StringBuilder() + Dim a1, a2, a3, e1, e2, e3 As String - '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), CType(elements(1), Single), CType(elements(2), Single), CType(elements(3), Single), CType(elements(4), Single))) + 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("") - Else - firstline = False - End If - Next line - End Using - Return True - Else - Throw New ArgumentException("Supplied input file does not exist") - End If + 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 - Return returnValue + 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 - 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 + Next - '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 + '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 - Dim sb As New StringBuilder() - Dim a1, a2, a3, e1, e2, e3 As String + ' 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 - 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("") + ' sb.Append(eff.ToString("0.000") + vbTab) - 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 + ' Next + ' sb.AppendLine("") - 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 + Return sb.ToString() + End Function - 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 + 'Equality + Public Function IsEqualTo(other As ICombinedAlternator) As Boolean Implements ICombinedAlternator.IsEqualTo - ' sb.Append(a.ToString("0") + vbTab) - ' For Each r As Single In {500, 1500, 2500, 3500, 4500, 5500, 6500, 7500} + 'Count Check. + If Me.Alternators.Count <> other.Alternators.Count Then Return False - ' Dim eff As Single = GetEfficiency(r, a).Efficiency + For Each alt As IAlternator In Me.Alternators - ' sb.Append(eff.ToString("0.000") + vbTab) + 'Can we find the same alternatorName in other + If other.Alternators.Where(Function(f) f.AlternatorName = alt.AlternatorName).Count() <> 1 Then Return False - ' 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 + '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 index eb0b9f748808e3f49130ac2d15000291cc78cda5..d9a141dbbd2b959de8f0744863fc880c92c78d71 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorMapRow.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorMapRow.vb @@ -1,44 +1,36 @@ 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 Single implements ICombinedAlternatorMapRow.RPM - Public Property Amps As Single implements ICombinedAlternatorMapRow.Amps - Public Property Efficiency As Single implements ICombinedAlternatorMapRow.Efficiency - Public Property PulleyRatio As Single implements ICombinedAlternatorMapRow.PulleyRatio - - '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("Efficiency must be between 0 and 100") - If PulleyRatio<=0 then Throw New ArgumentException("Pully ratio must be a positive number") - - 'Assignments - Me.AlternatorName = AlternatorName - Me.RPM = RPM - Me.Amps = Amps - Me.Efficiency = Efficiency - Me.PulleyRatio = PulleyRatio - - End Sub - - -End Class - - + '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 Single Implements ICombinedAlternatorMapRow.RPM + Public Property Amps As Single Implements ICombinedAlternatorMapRow.Amps + Public Property Efficiency As Single Implements ICombinedAlternatorMapRow.Efficiency + Public Property PulleyRatio As Single Implements ICombinedAlternatorMapRow.PulleyRatio + + '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 index 58e7d363a963560852c18ebd56cb8b36a4d6ede8..873d569f5c5fc599ba7aa95ed848a21ad111101d 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorSignals.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/CombinedAlternatorSignals.vb @@ -1,27 +1,18 @@  +Imports TUGraz.VectoCommon.Utils Namespace Electrics + 'Used by the CombinedAlternator class and any other related classes. + Public Class CombinedAlternatorSignals + Implements ICombinedAlternatorSignals -'Used by the CombinedAlternator class and any other related classes. - Public Class CombinedAlternatorSignals - Implements ICombinedAlternatorSignals - - - Public Property CrankRPM As Single Implements ICombinedAlternatorSignals.CrankRPM - - Public Property CurrentDemandAmps As Single Implements ICombinedAlternatorSignals.CurrentDemandAmps - - 'Number of alternators in the Combined Alternator - Public Property NumberOfAlternators As Single Implements ICombinedAlternatorSignals.NumberOfAlternators - - - - End Class + 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/ElectricConstants.vb b/VECTOAux/VectoAuxiliaries/Electrics/ElectricConstants.vb index 37d27d6be243b4fbf8215b0e88fe62741d5eb239..8ab4c624b9580a5ad210baa05e46f2819ecb09af 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/ElectricConstants.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/ElectricConstants.vb @@ -10,36 +10,24 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Namespace Electrics + Public Class ElectricConstants + 'Anticipated Min and Max Allowable values for Powernet, normally 26.3 volts but could be 48 in the future. + Public Const PowenetVoltageMin As Double = 6 + Public Const PowenetVoltageMax As Double = 50 -Public Class ElectricConstants + 'Duty Cycle IE Percentage of use + Public Const PhaseIdleTractionOnMin As Double = 0 + Public Const PhaseIdleTractionMax As Double = 1 - 'Anticipated Min and Max Allowable values for Powernet, normally 26.3 volts but could be 48 in the future. - Public Const PowenetVoltageMin As Single = 6 - Public Const PowenetVoltageMax As Single = 50 - - 'Duty Cycle IE Percentage of use - Public Const PhaseIdleTractionOnMin As Single = 0 - Public Const PhaseIdleTractionMax As Single = 1 - - 'Max Min Expected Consumption for a Single Consumer, negative values allowed as bonuses. - Public Const NonminalConsumerConsumptionAmpsMin As Integer = -10 - Public Const NominalConsumptionAmpsMax As Integer = 100 - - - 'Alternator - public const AlternatorPulleyEfficiencyMin as single =0.1 - public const AlternatorPulleyEfficiencyMax as single =1 - -End Class + 'Max Min Expected Consumption for a Single Consumer, negative values allowed as bonuses. + Public Const NonminalConsumerConsumptionAmpsMin As Integer = - 10 + Public Const NominalConsumptionAmpsMax As Integer = 100 + 'Alternator + public const AlternatorPulleyEfficiencyMin as single = 0.1 + public const AlternatorPulleyEfficiencyMax as single = 1 + End Class End Namespace - - - - - - - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumer.vb b/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumer.vb index 948cbcbe7a78e91fc25c019e16845138fd645d75..dbac602ff539dbc03c972f7def606fbdef6df071 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumer.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumer.vb @@ -1,4 +1,5 @@ Imports System.ComponentModel +Imports TUGraz.VectoCommon.Utils ' Copyright 2015 European Union. ' Licensed under the EUPL (the 'Licence'); @@ -12,171 +13,178 @@ ' 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 Single - Private _NumberInActualVehicle As Integer - Private _PhaseIdle_TractionOn As Single - Private _PowerNetVoltage As Single - Private _Info As String - - 'Calculated - Private Property AvgConsumptionAmps As Single 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 Single Implements IElectricalConsumer.NominalConsumptionAmps - Get - Return _NominalConsumptionAmps - End Get - Set(value As Single) - _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 Single Implements IElectricalConsumer.PhaseIdle_TractionOn - Get - Return _PhaseIdle_TractionOn - End Get - Set(value As Single) - _PhaseIdle_TractionOn = value - NotifyPropertyChanged("PhaseIdle_TractionOn") - End Set - End Property - - Public Property PowerNetVoltage As Single Implements IElectricalConsumer.PowerNetVoltage - Get - Return _PowerNetVoltage - End Get - Set(value As Single) - _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 Single = 0.0) As Single Implements IElectricalConsumer.TotalAvgConumptionAmps - - If ConsumerName = "Doors per Door" Then - Return PhaseIdle_TractionOnBasedOnCycle * NominalConsumptionAmps * NumberInActualVehicle - Else - Return PhaseIdle_TractionOn * NominalConsumptionAmps * NumberInActualVehicle - End If - - - End Function - Public Function TotalAvgConsumptionInWatts(Optional PhaseIdle_TractionOnBasedOnCycle As Single = 0.0) As Single Implements Electrics.IElectricalConsumer.TotalAvgConsumptionInWatts - Return TotalAvgConumptionAmps(PhaseIdle_TractionOnBasedOnCycle) * PowerNetVoltage - End Function - - 'Constructor - Public Sub New(BaseVehicle As Boolean, Category As String, ConsumerName As String, NominalConsumptionAmps As Single, PhaseIdle_TractionOn As Single, PowerNetVoltage As Single, 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 - - 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 - + ''' <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 index e73f5be3e2de3ce7fb78ad67f175963b6e5ab1a4..ff2adda0df37cbb2377866cd0ccfd2c07af3ef77 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumerList.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/ElectricalConsumerList.vb @@ -11,167 +11,219 @@ Imports System.Collections.Generic +Imports TUGraz.VectoCommon.Utils Namespace Electrics - - Public Class ElectricalConsumerList - Implements IElectricalConsumerList - - Private _items As New List(Of IElectricalConsumer) - Private _powernetVoltage As Single - Private _doorDutyCycleZeroToOne As single - - - 'Constructor - Public Sub New(powernetVoltage As Single,doorDutyCycle_ZeroToOne As single, 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.00, 0.096339, _powernetVoltage, 3,""), IElectricalConsumer) - c2 = CType(New ElectricalConsumer(True, "Veh Electronics &Engine", "Controllers,Valves etc", 25.00, 1.00, _powernetVoltage, 1,""), IElectricalConsumer ) - c3 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Radio City", 2.00, 0.80, _powernetVoltage, 1,""), IElectricalConsumer ) - c4 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Radio Intercity", 5.00, 0.80, _powernetVoltage, 0,""), IElectricalConsumer ) - c5 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Radio/Audio Tourism", 9.00, 0.80, _powernetVoltage, 0,""), IElectricalConsumer ) - c6 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Fridge", 4.00, 0.50, _powernetVoltage, 0,""), IElectricalConsumer ) - c7 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Kitchen Standard", 67.00, 0.05, _powernetVoltage, 0,""), IElectricalConsumer ) - c8 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Interior lights City/ Intercity + Doorlights [Should be 1/m]", 1.00, 0.70, _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.60, 0.70, _powernetVoltage, 0,"1 Per metre length of bus"), IElectricalConsumer) - c10 = CType(New ElectricalConsumer(False, "Vehicle basic equipment", "Interior lights Tourism + reading [1/m]", 1.10, 0.70, _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.70, _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.00, _powernetVoltage, 4,""), IElectricalConsumer) - c13 = CType(New ElectricalConsumer(False, "Customer Specific Equipment", "Internal display per unit ( front side rear)", 1.06007067137809, 1.00, _powernetVoltage, 1,""), IElectricalConsumer) - c14 = CType(New ElectricalConsumer(False, "Customer Specific Equipment", "CityBus Ref EBSF Table4 Devices ITS No Displays", 9.30, 1.00, _powernetVoltage, 1,""), IElectricalConsumer) - c15 = CType(New ElectricalConsumer(False, "Lights", "Exterior Lights BULB", 7.40, 1.00, _powernetVoltage, 1,""), IElectricalConsumer) - c16 = CType(New ElectricalConsumer(False, "Lights", "Day running lights LED bonus", -0.723, 1.00, _powernetVoltage, 1,""), IElectricalConsumer) - c17 = CType(New ElectricalConsumer(False, "Lights", "Antifog rear lights LED bonus", -0.17, 1.00, _powernetVoltage, 1,""), IElectricalConsumer) - c18 = CType(New ElectricalConsumer(False, "Lights", "Position lights LED bonus", -1.20, 1.00, _powernetVoltage, 1,""), IElectricalConsumer) - c19 = CType(New ElectricalConsumer(False, "Lights", "Direction lights LED bonus", -0.30, 1.00, _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 single Implements IElectricalConsumerList.DoorDutyCycleFraction - - Get - Return _doorDutyCycleZeroToOne - End Get - Set(value As Single) - _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 Electrics.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 Electrics.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 Single Implements Electrics.IElectricalConsumerList.GetTotalAverageDemandAmps - - Dim Amps As Single - - 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 - + 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 Electrics.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 Electrics.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 Electrics.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 index bb348cbc7f0f8623069489e8907206bdbfb6b63d..6ccffb23e7ba00ab224c3726aa5ca4eabaa60a4d 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/ElectricsUserInputsConfig.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/ElectricsUserInputsConfig.vb @@ -9,47 +9,47 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics -Namespace Electrics - -Public Class ElectricsUserInputsConfig -Implements IElectricsUserInputsConfig - Public Property PowerNetVoltage As Single Implements IElectricsUserInputsConfig.PowerNetVoltage - Public Property AlternatorMap As String Implements IElectricsUserInputsConfig.AlternatorMap - Public Property AlternatorGearEfficiency As Single Implements IElectricsUserInputsConfig.AlternatorGearEfficiency - Public Property ElectricalConsumers As IElectricalConsumerList Implements IElectricsUserInputsConfig.ElectricalConsumers - Public Property DoorActuationTimeSecond As Integer Implements IElectricsUserInputsConfig.DoorActuationTimeSecond - Public Property StoredEnergyEfficiency As Single Implements IElectricsUserInputsConfig.StoredEnergyEfficiency +Namespace Electrics + Public Class ElectricsUserInputsConfig + Implements IElectricsUserInputsConfig - 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 PowerNetVoltage As Double Implements IElectricsUserInputsConfig.PowerNetVoltage + Public Property AlternatorMap As String Implements IElectricsUserInputsConfig.AlternatorMap + Public Property AlternatorGearEfficiency As Double Implements IElectricsUserInputsConfig.AlternatorGearEfficiency - Public Property SmartElectrical As Boolean Implements IElectricsUserInputsConfig.SmartElectrical + Public Property ElectricalConsumers As IElectricalConsumerList _ + Implements IElectricsUserInputsConfig.ElectricalConsumers - Public Sub New(Optional setToDefaults As Boolean = False, Optional vectoInputs As VectoInputs = Nothing) + Public Property DoorActuationTimeSecond As Integer Implements IElectricsUserInputsConfig.DoorActuationTimeSecond + Public Property StoredEnergyEfficiency As Single Implements IElectricsUserInputsConfig.StoredEnergyEfficiency - If setToDefaults Then SetPropertiesToDefaults(vectoInputs) + Public Property ResultCardIdle As IResultCard Implements IElectricsUserInputsConfig.ResultCardIdle + Public Property ResultCardTraction As IResultCard Implements IElectricsUserInputsConfig.ResultCardTraction + Public Property ResultCardOverrun As IResultCard Implements IElectricsUserInputsConfig.ResultCardOverrun - End Sub + Public Property SmartElectrical As Boolean Implements IElectricsUserInputsConfig.SmartElectrical - Public Sub SetPropertiesToDefaults(vectoInputs As VectoInputs) + Public Sub New(Optional setToDefaults As Boolean = False, Optional vectoInputs As VectoInputs = Nothing) - DoorActuationTimeSecond = 4 - StoredEnergyEfficiency = 0.935 - AlternatorGearEfficiency = 0.92 - PowerNetVoltage = vectoInputs.PowerNetVoltage - 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 + If setToDefaults Then SetPropertiesToDefaults(vectoInputs) + End Sub - End Sub -End Class + 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/IAlternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/IAlternator.vb index 6fc9487b728243d2e3c6c684d9b0479c079eb287..de5aea114a40a38171925376be6a97065c85b10e 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IAlternator.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IAlternator.vb @@ -1,41 +1,35 @@  Namespace Electrics + 'Used By Combined Alternator. + 'Model based on CombinedALTS_V02_Editable.xlsx + Public Interface IAlternator + 'D6 + Property AlternatorName As String - 'Used By Combined Alternator. - 'Model based on CombinedALTS_V02_Editable.xlsx - Public Interface IAlternator + 'G6 + Property PulleyRatio As Single - 'D6 - Property AlternatorName As String + 'S9 + ReadOnly Property SpindleSpeed As Double - 'G6 - Property PulleyRatio As Single + 'S10 + ReadOnly Property Efficiency As Double - 'S9 - ReadOnly Property SpindleSpeed As Double + 'C10-D15 + Property InputTable2000 As List(Of AltUserInput) - 'S10 - ReadOnly Property Efficiency As Double + 'F10-G15 + Property InputTable4000 As List(Of AltUserInput) - 'C10-D15 - Property InputTable2000 As List(Of AltUserInput) - - 'F10-G15 - Property InputTable4000 As List(Of AltUserInput) - - 'I10-J15 - Property InputTable6000 As List(Of AltUserInput) - - 'M10-N15 - Property RangeTable As List(Of Table4Row) - - 'Test Equality - Function IsEqualTo(other As IAlternator) As Boolean - - - End Interface + 'I10-J15 + Property InputTable6000 As List(Of AltUserInput) + 'M10-N15 + Property RangeTable As List(Of Table4Row) + 'Test Equality + Function IsEqualTo(other As IAlternator) As Boolean + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/IAlternatorMap.vb b/VECTOAux/VectoAuxiliaries/Electrics/IAlternatorMap.vb index bd5c03e7747b07283cfa1df72c6e8d59acd3575a..01782b03f37f9b837a67b8e0c8a8e21af09da208 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IAlternatorMap.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IAlternatorMap.vb @@ -8,28 +8,25 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Electrics - - - Public Interface IAlternatorMap - Inherits IAuxiliaryEvent - ''' <summary> - ''' Initialise the map from supplied csv data - ''' </summary> - ''' <returns>Boolean - true if map is created successfully</returns> - ''' <remarks></remarks> - Function Initialise() As Boolean - - ''' <summary> - ''' Returns the alternator efficiency at given rpm - ''' </summary> - ''' <param name="rpm">alternator rotation speed</param> - ''' <returns>Single</returns> - ''' <remarks></remarks> - Function GetEfficiency(ByVal rpm As single, ByVal amps As single) As AlternatorMapValues - - End Interface + Public Interface IAlternatorMap + Inherits IAuxiliaryEvent + ''' <summary> + ''' Initialise the map from supplied csv data + ''' </summary> + ''' <returns>Boolean - true if map is created successfully</returns> + ''' <remarks></remarks> + Function Initialise() As Boolean + ''' <summary> + ''' Returns the alternator efficiency at given rpm + ''' </summary> + ''' <param name="rpm">alternator rotation speed</param> + ''' <returns>Single</returns> + ''' <remarks></remarks> + Function GetEfficiency(ByVal rpm As Double, ByVal amps As Ampere) As AlternatorMapValues + End Interface End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternator.vb b/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternator.vb index 6d890da720a986633f4b5cfe8a14ec611225a54e..bfba89d9c8f68c8dd795a2596e95f909e506d4bf 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternator.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternator.vb @@ -1,22 +1,12 @@  Namespace Electrics + Public Interface ICombinedAlternator + 'Alternators List + Property Alternators As List(Of IAlternator) - -Public Interface ICombinedAlternator - - 'Alternators List - Property Alternators As List(Of IAlternator) - - 'Test Equality - Function IsEqualTo( other As ICombinedAlternator ) As Boolean - - - -End Interface - - - - + 'Test Equality + Function IsEqualTo(other As ICombinedAlternator) As Boolean + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorMapRow.vb b/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorMapRow.vb index 6620d8f33959bf623c0e7f527f282293bbd07722..ec881fdcce7517b94d3ce98123242cb4bf2983bc 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorMapRow.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorMapRow.vb @@ -1,19 +1,12 @@  Namespace Electrics - 'Reflects stored data in pesisted CombinedAlternator Map .AALT -Public Interface ICombinedAlternatorMapRow - - - Property AlternatorName As String - Property RPM As Single - Property Amps As Single - Property Efficiency As Single - Property PulleyRatio As Single - - -End Interface - - + Public Interface ICombinedAlternatorMapRow + Property AlternatorName As String + Property RPM As Single + Property Amps As Single + Property Efficiency As Single + Property PulleyRatio As Single + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorSignals.vb b/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorSignals.vb index bc83dd2f73b2969ec25045f6d940ced9762d4fdf..b13f49e89c71fe4d9df6619d4ca1b34992f61c0a 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorSignals.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/ICombinedAlternatorSignals.vb @@ -1,20 +1,13 @@  -Namespace Electrics - -'Used by CombinedAlternator -Public Interface ICombinedAlternatorSignals - - - Property NumberOfAlternators As Single - Property CrankRPM As Single - Property CurrentDemandAmps As Single - - -End Interface - - - +Imports TUGraz.VectoCommon.Utils +Namespace Electrics + 'Used by CombinedAlternator + Public Interface ICombinedAlternatorSignals + Property NumberOfAlternators As Integer + Property CrankRPM As Double + Property CurrentDemandAmps As Ampere + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/IElectricalConsumer.vb b/VECTOAux/VectoAuxiliaries/Electrics/IElectricalConsumer.vb index 6248566b2db99f881713032c6d3f447bdb1d6d68..4a7f0e32dfd88b2c1436e189a94c79963a5c4597 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IElectricalConsumer.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IElectricalConsumer.vb @@ -10,24 +10,22 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.ComponentModel +Imports TUGraz.VectoCommon.Utils Namespace Electrics + Public Interface IElectricalConsumer + Inherits INotifyPropertyChanged - Public Interface IElectricalConsumer - Inherits INotifyPropertyChanged - - Property Category As String - Property ConsumerName As String - Property BaseVehicle As Boolean - Property NominalConsumptionAmps As Single - Property PhaseIdle_TractionOn As Single - Property NumberInActualVehicle As Integer - Property PowerNetVoltage As Single - Property AvgConsumptionAmps As Single - Property Info As String - Function TotalAvgConumptionAmps(Optional PhaseIdle_TractionOnBasedOnCycle As Single = Nothing) As Single - Function TotalAvgConsumptionInWatts(Optional PhaseIdle_TractionOnBasedOnCycle As Single = 0.0) As Single - - End Interface - + Property Category As String + Property ConsumerName As String + Property BaseVehicle As Boolean + Property NominalConsumptionAmps As Double + Property PhaseIdle_TractionOn As Double + Property NumberInActualVehicle As Integer + Property PowerNetVoltage As Double + Property AvgConsumptionAmps As Double + Property Info As String + Function TotalAvgConumptionAmps(Optional PhaseIdle_TractionOnBasedOnCycle As Double = Nothing) As Ampere + Function TotalAvgConsumptionInWatts(Optional PhaseIdle_TractionOnBasedOnCycle As Double = 0.0) As Watt + End Interface End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Electrics/IElectricalConsumerList.vb b/VECTOAux/VectoAuxiliaries/Electrics/IElectricalConsumerList.vb index 6a6aca8de13bdaad3b4984a5c21154d3f08ceec2..0eff826f13ef85203f754bcffc86a22ac41cfa08 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IElectricalConsumerList.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IElectricalConsumerList.vb @@ -8,57 +8,52 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. - +Imports TUGraz.VectoCommon.Utils Namespace Electrics - -Public Interface IElectricalConsumerList - - ''' <summary> - ''' List of Electrical Consumers - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property Items As List(Of IElectricalConsumer) - - ''' <summary> - ''' Add New Electrical Consumer - ''' </summary> - ''' <param name="consumer"></param> - ''' <remarks></remarks> - Sub AddConsumer(consumer As IElectricalConsumer) - - ''' <summary> - ''' Remove Electrical Consumer - ''' </summary> - ''' <param name="consumer"></param> - ''' <remarks></remarks> - Sub RemoveConsumer(consumer As IElectricalConsumer) - - ''' <summary> - ''' Get Total Average Demand In Amps - ''' </summary> - ''' <param name="excludeOnBase">Exclude those on base vehicle</param> - ''' <returns></returns> - ''' <remarks></remarks> - Function GetTotalAverageDemandAmps(excludeOnBase As Boolean) As Single - - ''' <summary> - ''' Door Actuation Time Fraction ( Total Time Spent Operational during cycle ) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property DoorDutyCycleFraction As single - - 'Merge Info data from ElectricalConsumer in a Default set into live set - 'This is required because the info is stored in the AAUX file and we do not want to use a persistance stored version. - Sub MergeInfoData() - -End Interface - - + Public Interface IElectricalConsumerList + ''' <summary> + ''' List of Electrical Consumers + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property Items As List(Of IElectricalConsumer) + + ''' <summary> + ''' Add New Electrical Consumer + ''' </summary> + ''' <param name="consumer"></param> + ''' <remarks></remarks> + Sub AddConsumer(consumer As IElectricalConsumer) + + ''' <summary> + ''' Remove Electrical Consumer + ''' </summary> + ''' <param name="consumer"></param> + ''' <remarks></remarks> + Sub RemoveConsumer(consumer As IElectricalConsumer) + + ''' <summary> + ''' Get Total Average Demand In Amps + ''' </summary> + ''' <param name="excludeOnBase">Exclude those on base vehicle</param> + ''' <returns></returns> + ''' <remarks></remarks> + Function GetTotalAverageDemandAmps(excludeOnBase As Boolean) As Ampere + + ''' <summary> + ''' Door Actuation Time Fraction ( Total Time Spent Operational during cycle ) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property DoorDutyCycleFraction As Double + + 'Merge Info data from ElectricalConsumer in a Default set into live set + 'This is required because the info is stored in the AAUX file and we do not want to use a persistance stored version. + Sub MergeInfoData() + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/IElectricsUserInputsConfig.vb b/VECTOAux/VectoAuxiliaries/Electrics/IElectricsUserInputsConfig.vb index 026da7a5a1ca9aad0c2afd22b5e757297dca50ad..39aba740256742d84dd47bb7659640537b038e5d 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IElectricsUserInputsConfig.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IElectricsUserInputsConfig.vb @@ -12,83 +12,87 @@ Imports VectoAuxiliaries.Electrics Namespace Electrics + Public Interface IElectricsUserInputsConfig + ''' <summary> + ''' Power Net Voltage - The supply voltage used on the vehilce. + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property PowerNetVoltage As Double -Public Interface IElectricsUserInputsConfig + ''' <summary> + ''' The Path for the Alternator map + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property AlternatorMap As String - ''' <summary> - ''' Power Net Voltage - The supply voltage used on the vehilce. - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property PowerNetVoltage As Single - ''' <summary> - ''' The Path for the Alternator map - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property AlternatorMap As String - ''' <summary> - ''' Alternator Gear Efficiency - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property AlternatorGearEfficiency As Single - ''' <summary> - ''' List of Electrical Consumers - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property ElectricalConsumers As IElectricalConsumerList - ''' <summary> - ''' Door Actuation Time In Seconds ( Time Taken to Open/Close the door ) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property DoorActuationTimeSecond As Integer - ''' <summary> - ''' Result Card Taken During Idle. - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property ResultCardIdle As IResultCard - ''' <summary> - ''' Result Card Taken During Traction - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property ResultCardTraction As IResultCard - ''' <summary> - ''' Result Card Taken During Overrun - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property ResultCardOverrun As IResultCard - ''' <summary> - ''' Smart Electrical System - ''' </summary> - ''' <value></value> - ''' <returns>True For Smart Electrical Systems/ False For non Smart.</returns> - ''' <remarks></remarks> - Property SmartElectrical As Boolean - ''' <summary> - ''' Stored Energy Efficiency - ''' </summary> - ''' <value></value> - ''' <returns>Stored Energy Efficiency</returns> - ''' <remarks></remarks> - Property StoredEnergyEfficiency As Single + ''' <summary> + ''' Alternator Gear Efficiency + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property AlternatorGearEfficiency As Double -End Interface + ''' <summary> + ''' List of Electrical Consumers + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property ElectricalConsumers As IElectricalConsumerList + ''' <summary> + ''' Door Actuation Time In Seconds ( Time Taken to Open/Close the door ) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property DoorActuationTimeSecond As Integer + ''' <summary> + ''' Result Card Taken During Idle. + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property ResultCardIdle As IResultCard + + ''' <summary> + ''' Result Card Taken During Traction + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property ResultCardTraction As IResultCard + + ''' <summary> + ''' Result Card Taken During Overrun + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property ResultCardOverrun As IResultCard + + ''' <summary> + ''' Smart Electrical System + ''' </summary> + ''' <value></value> + ''' <returns>True For Smart Electrical Systems/ False For non Smart.</returns> + ''' <remarks></remarks> + Property SmartElectrical As Boolean + + ''' <summary> + ''' Stored Energy Efficiency + ''' </summary> + ''' <value></value> + ''' <returns>Stored Energy Efficiency</returns> + ''' <remarks></remarks> + Property StoredEnergyEfficiency As Single + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/IM0_5_SmartAlternatorSetEfficiency.vb b/VECTOAux/VectoAuxiliaries/Electrics/IM0_5_SmartAlternatorSetEfficiency.vb index 7fe0b76efcba5c1e31bcef51b1e1b1be2e441b66..a05a4815ab561094a8e939a32d39b7e0ead2a9f5 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IM0_5_SmartAlternatorSetEfficiency.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IM0_5_SmartAlternatorSetEfficiency.vb @@ -8,58 +8,58 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. - +Imports TUGraz.VectoCommon.Utils Namespace Electrics + Public Interface IM0_5_SmartAlternatorSetEfficiency + ''' <summary> + ''' Smart Idle Current (A) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartIdleCurrent() As Ampere - Public Interface IM0_5_SmartAlternatorSetEfficiency + ''' <summary> + ''' Alternators Efficiency In Idle ( Fraction ) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property AlternatorsEfficiencyIdleResultCard() As Double - ''' <summary> - ''' Smart Idle Current (A) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly Property SmartIdleCurrent() As single - ''' <summary> - ''' Alternators Efficiency In Idle ( Fraction ) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly Property AlternatorsEfficiencyIdleResultCard( ) As single - ''' <summary> - ''' Smart Traction Current (A) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly Property SmartTractionCurrent As Single - ''' <summary> - ''' Alternators Efficiency In Traction ( Fraction ) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly Property AlternatorsEfficiencyTractionOnResultCard() As Single - ''' <summary> - ''' Smart Overrrun Current (A) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly Property SmartOverrunCurrent As Single - ''' <summary> - ''' Alternators Efficiency In Overrun ( Fraction ) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly Property AlternatorsEfficiencyOverrunResultCard() As single + ''' <summary> + ''' Smart Traction Current (A) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartTractionCurrent As Ampere -End Interface + ''' <summary> + ''' Alternators Efficiency In Traction ( Fraction ) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property AlternatorsEfficiencyTractionOnResultCard() As Double -End Namespace + ''' <summary> + ''' Smart Overrrun Current (A) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property SmartOverrunCurrent As Ampere + ''' <summary> + ''' Alternators Efficiency In Overrun ( Fraction ) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property AlternatorsEfficiencyOverrunResultCard() As Double + End Interface +End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/IM0_NonSmart_AlternatorsSetEfficiency.vb b/VECTOAux/VectoAuxiliaries/Electrics/IM0_NonSmart_AlternatorsSetEfficiency.vb index 11a4729e5ab3c2f5dc531579d2e3cbfece04b782..f3d70844d23b6f40e94aa66cbde0e35761cb49b6 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IM0_NonSmart_AlternatorsSetEfficiency.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IM0_NonSmart_AlternatorsSetEfficiency.vb @@ -8,30 +8,26 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Electrics - - Public Interface IM0_NonSmart_AlternatorsSetEfficiency - - ''' <summary> - ''' Gets HVAC Electrical Power Demand (A) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly Property GetHVACElectricalPowerDemandAmps() As Single - ''' <summary> - ''' Gets Alternator Efficiency (0-1) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Readonly Property AlternatorsEfficiency() As Single - - -End Interface - + Public Interface IM0_NonSmart_AlternatorsSetEfficiency + ''' <summary> + ''' Gets HVAC Electrical Power Demand (A) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property GetHVACElectricalPowerDemandAmps() As Ampere + + ''' <summary> + ''' Gets Alternator Efficiency (0-1) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property AlternatorsEfficiency() As Double + End Interface End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/IM2_AverageElectricalLoadDemand.vb b/VECTOAux/VectoAuxiliaries/Electrics/IM2_AverageElectricalLoadDemand.vb index 12146f4c1d7406d9395d7672fa43b349a6caf1e5..790270baa25c0efe902625a735238f32ca38f7eb 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IM2_AverageElectricalLoadDemand.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IM2_AverageElectricalLoadDemand.vb @@ -8,16 +8,13 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Electrics - - Public Interface IM2_AverageElectricalLoadDemand - - Function GetAveragePowerDemandAtAlternator() As Single - Function GetAveragePowerAtCrankFromElectrics() As Single - -End Interface - + Public Interface IM2_AverageElectricalLoadDemand + Function GetAveragePowerDemandAtAlternator() As Watt + Function GetAveragePowerAtCrankFromElectrics() As Watt + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/IM5_SmartAlternatorSetGeneration.vb b/VECTOAux/VectoAuxiliaries/Electrics/IM5_SmartAlternatorSetGeneration.vb index 7f778842c463c10a04e6ec9ecdf01aa186b98d99..8d2dceb2faffd155b0cce044a72a649be0872b16 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IM5_SmartAlternatorSetGeneration.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IM5_SmartAlternatorSetGeneration.vb @@ -8,33 +8,31 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. - +Imports TUGraz.VectoCommon.Utils Namespace Electrics - - Public Interface IM5_SmartAlternatorSetGeneration - - ''' <summary> - ''' Alternators Generation Power At Crank Idle (W) - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function AlternatorsGenerationPowerAtCrankIdleWatts() As Single - ''' <summary> - ''' Alternators Generation Power At Crank Traction On (W) - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function AlternatorsGenerationPowerAtCrankTractionOnWatts() As Single - ''' <summary> - ''' Alternators Generation Power At Crank Overrun (W) - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function AlternatorsGenerationPowerAtCrankOverrunWatts() As Single - -End Interface - + Public Interface IM5_SmartAlternatorSetGeneration + ''' <summary> + ''' Alternators Generation Power At Crank Idle (W) + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function AlternatorsGenerationPowerAtCrankIdleWatts() As Watt + + ''' <summary> + ''' Alternators Generation Power At Crank Traction On (W) + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function AlternatorsGenerationPowerAtCrankTractionOnWatts() As Watt + + ''' <summary> + ''' Alternators Generation Power At Crank Overrun (W) + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function AlternatorsGenerationPowerAtCrankOverrunWatts() As Watt + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/IResultCard.vb b/VECTOAux/VectoAuxiliaries/Electrics/IResultCard.vb index 6af55813142ed5718fc9eef64d565951c7900485..8c5f8969c9ddc680e9792997f33efff7bbc0d237 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/IResultCard.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/IResultCard.vb @@ -8,29 +8,26 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Electrics - - Public Interface IResultCard - - ''' <summary> - ''' Returns a List of (SmartResult ) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - ReadOnly Property Results As List(Of SmartResult) - ''' <summary> - ''' Returns the Smart Current (A) - ''' </summary> - ''' <param name="Amps"></param> - ''' <returns></returns> - ''' <remarks>Defaults to 10 Amps if no readings present</remarks> - Function GetSmartCurrentResult(Amps As Single) As Single - - End Interface - - + Public Interface IResultCard + ''' <summary> + ''' Returns a List of (SmartResult ) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property Results As List(Of SmartResult) + + ''' <summary> + ''' Returns the Smart Current (A) + ''' </summary> + ''' <param name="Amps"></param> + ''' <returns></returns> + ''' <remarks>Defaults to 10 Amps if no readings present</remarks> + Function GetSmartCurrentResult(ByVal Amps As Ampere) As Ampere + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/M0_5_SmartAlternatorSetEfficiency.vb b/VECTOAux/VectoAuxiliaries/Electrics/M0_5_SmartAlternatorSetEfficiency.vb index ce6d7b6293f63edd3daa6859448697fc78572570..c516b3c7b9ec26f40587525fe1bfb80aa32b2ca7 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/M0_5_SmartAlternatorSetEfficiency.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/M0_5_SmartAlternatorSetEfficiency.vb @@ -10,103 +10,112 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports System.Diagnostics.CodeAnalysis +Imports TUGraz.VectoCommon.Utils Namespace Electrics - - Public Class M0_5_SmartAlternatorSetEfficiency - Implements IM0_5_SmartAlternatorSetEfficiency - - 'Fields - Private _m0 As IM0_NonSmart_AlternatorsSetEfficiency - Private _electricalConsumables As IElectricalConsumerList - Private _alternatorMap As IAlternatorMap - Private _resultCardIdle As IResultCard - Private _resultCardTraction As IResultCard - Private _resultCardOverrun As IResultCard - Private _signals As ISignals - - 'Constructor - Public Sub New(m0 As IM0_NonSmart_AlternatorsSetEfficiency, _ - electricalConsumables As IElectricalConsumerList, _ - alternatorMap As IAlternatorMap, _ - resultCardIdle As IResultCard, _ - resultCardTraction As IResultCard, _ - resultCardOverrun As IResultCard, - signals As ISignals) - - 'Sanity Check on supplied arguments, throw an argument exception - If m0 Is Nothing Then Throw New ArgumentException("Module 0 must be supplied") - If electricalConsumables Is Nothing Then Throw New ArgumentException("ElectricalConsumablesList must be supplied even if empty") - If alternatorMap Is Nothing Then Throw New ArgumentException("Must supply a valid alternator map") - If resultCardIdle Is Nothing Then Throw New ArgumentException("Result Card 'IDLE' must be supplied even if it has no contents") - If resultCardTraction Is Nothing Then Throw New ArgumentException("Result Card 'TRACTION' must be supplied even if it has no contents") - If resultCardOverrun Is Nothing Then Throw New ArgumentException("Result Card 'OVERRUN' must be supplied even if it has no contents") - If signals Is Nothing Then Throw New ArgumentException("No Signals Reference object was provided ") - - 'Assignments to private variables. - _m0 = m0 - _electricalConsumables = electricalConsumables - _alternatorMap = alternatorMap - _resultCardIdle = resultCardIdle - _resultCardTraction = resultCardTraction - _resultCardOverrun = resultCardOverrun - _signals = signals - - - End Sub - - - 'Public Class Outputs (Properties) - Public ReadOnly Property SmartIdleCurrent() As Single Implements IM0_5_SmartAlternatorSetEfficiency.SmartIdleCurrent - Get - Dim hvac_Plus_None_Base As Single = HvacPlusNonBaseCurrents() - Dim smart_idle_current As Single = _resultCardIdle.GetSmartCurrentResult(hvac_Plus_None_Base) - - Return smart_idle_current - End Get - End Property - Public ReadOnly Property AlternatorsEfficiencyIdleResultCard() As Single Implements IM0_5_SmartAlternatorSetEfficiency.AlternatorsEfficiencyIdleResultCard - Get - Return _alternatorMap.GetEfficiency(_signals.EngineSpeed, SmartIdleCurrent()).Efficiency - End Get - End Property - Public ReadOnly Property SmartTractionCurrent As Single Implements IM0_5_SmartAlternatorSetEfficiency.SmartTractionCurrent - Get - Return _resultCardTraction.GetSmartCurrentResult(HvacPlusNonBaseCurrents()) - End Get - End Property - Public ReadOnly Property AlternatorsEfficiencyTractionOnResultCard() As Single Implements IM0_5_SmartAlternatorSetEfficiency.AlternatorsEfficiencyTractionOnResultCard - Get - Return _alternatorMap.GetEfficiency(_signals.EngineSpeed, SmartTractionCurrent()).Efficiency - End Get - End Property - Public ReadOnly Property SmartOverrunCurrent As Single Implements IM0_5_SmartAlternatorSetEfficiency.SmartOverrunCurrent - Get - Return _resultCardOverrun.GetSmartCurrentResult(HvacPlusNonBaseCurrents()) - End Get - End Property - Public ReadOnly Property AlternatorsEfficiencyOverrunResultCard() As Single Implements IM0_5_SmartAlternatorSetEfficiency.AlternatorsEfficiencyOverrunResultCard - Get - Return _alternatorMap.GetEfficiency(_signals.EngineSpeed, SmartOverrunCurrent()).Efficiency - End Get - End Property - - 'Helpers - ''' <summary> - ''' Returns Non Base Currents (A) - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - <ExcludeFromCodeCoverage> - Private Function HvacPlusNonBaseCurrents() As Single - 'Stored Energy Efficience removed from V8.0 21/4/15 by Mike Preston //tb - Return _m0.GetHVACElectricalPowerDemandAmps() + _electricalConsumables.GetTotalAverageDemandAmps(True) '/ElectricConstants.StoredEnergyEfficiency) - - End Function - - - End Class - + Public Class M0_5_SmartAlternatorSetEfficiency + Implements IM0_5_SmartAlternatorSetEfficiency + + 'Fields + Private _m0 As IM0_NonSmart_AlternatorsSetEfficiency + Private _electricalConsumables As IElectricalConsumerList + Private _alternatorMap As IAlternatorMap + Private _resultCardIdle As IResultCard + Private _resultCardTraction As IResultCard + Private _resultCardOverrun As IResultCard + Private _signals As ISignals + + 'Constructor + Public Sub New(m0 As IM0_NonSmart_AlternatorsSetEfficiency, + electricalConsumables As IElectricalConsumerList, + alternatorMap As IAlternatorMap, + resultCardIdle As IResultCard, + resultCardTraction As IResultCard, + resultCardOverrun As IResultCard, + signals As ISignals) + + 'Sanity Check on supplied arguments, throw an argument exception + If m0 Is Nothing Then Throw New ArgumentException("Module 0 must be supplied") + If electricalConsumables Is Nothing Then _ + Throw New ArgumentException("ElectricalConsumablesList must be supplied even if empty") + If alternatorMap Is Nothing Then Throw New ArgumentException("Must supply a valid alternator map") + If resultCardIdle Is Nothing Then _ + Throw New ArgumentException("Result Card 'IDLE' must be supplied even if it has no contents") + If resultCardTraction Is Nothing Then _ + Throw New ArgumentException("Result Card 'TRACTION' must be supplied even if it has no contents") + If resultCardOverrun Is Nothing Then _ + Throw New ArgumentException("Result Card 'OVERRUN' must be supplied even if it has no contents") + If signals Is Nothing Then Throw New ArgumentException("No Signals Reference object was provided ") + + 'Assignments to private variables. + _m0 = m0 + _electricalConsumables = electricalConsumables + _alternatorMap = alternatorMap + _resultCardIdle = resultCardIdle + _resultCardTraction = resultCardTraction + _resultCardOverrun = resultCardOverrun + _signals = signals + End Sub + + + 'Public Class Outputs (Properties) + Public ReadOnly Property SmartIdleCurrent() As Ampere Implements IM0_5_SmartAlternatorSetEfficiency.SmartIdleCurrent + Get + Dim hvac_Plus_None_Base As Ampere = HvacPlusNonBaseCurrents() + Dim smart_idle_current As Ampere = _resultCardIdle.GetSmartCurrentResult(hvac_Plus_None_Base) + + Return smart_idle_current + End Get + End Property + + Public ReadOnly Property AlternatorsEfficiencyIdleResultCard() As Double _ + Implements IM0_5_SmartAlternatorSetEfficiency.AlternatorsEfficiencyIdleResultCard + Get + Return _alternatorMap.GetEfficiency(_signals.EngineSpeed.AsRPM, SmartIdleCurrent()).Efficiency + End Get + End Property + + Public ReadOnly Property SmartTractionCurrent As Ampere _ + Implements IM0_5_SmartAlternatorSetEfficiency.SmartTractionCurrent + Get + Return _resultCardTraction.GetSmartCurrentResult(HvacPlusNonBaseCurrents()) + End Get + End Property + + Public ReadOnly Property AlternatorsEfficiencyTractionOnResultCard() As Double _ + Implements IM0_5_SmartAlternatorSetEfficiency.AlternatorsEfficiencyTractionOnResultCard + Get + Return _alternatorMap.GetEfficiency(CType(_signals.EngineSpeed.AsRPM, Single), SmartTractionCurrent()).Efficiency + End Get + End Property + + Public ReadOnly Property SmartOverrunCurrent As Ampere _ + Implements IM0_5_SmartAlternatorSetEfficiency.SmartOverrunCurrent + Get + Return _resultCardOverrun.GetSmartCurrentResult(HvacPlusNonBaseCurrents()) + End Get + End Property + + Public ReadOnly Property AlternatorsEfficiencyOverrunResultCard() As Double _ + Implements IM0_5_SmartAlternatorSetEfficiency.AlternatorsEfficiencyOverrunResultCard + Get + Return _alternatorMap.GetEfficiency(CType(_signals.EngineSpeed.AsRPM, Single), SmartOverrunCurrent()).Efficiency + End Get + End Property + + 'Helpers + ''' <summary> + ''' Returns Non Base Currents (A) + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + <ExcludeFromCodeCoverage> + Private Function HvacPlusNonBaseCurrents() As Ampere + 'Stored Energy Efficience removed from V8.0 21/4/15 by Mike Preston //tb + Return _m0.GetHVACElectricalPowerDemandAmps() + _electricalConsumables.GetTotalAverageDemandAmps(True) _ + '/ElectricConstants.StoredEnergyEfficiency) + End Function + End Class End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/M0_NonSmart_AlternatorsSetEfficiency.vb b/VECTOAux/VectoAuxiliaries/Electrics/M0_NonSmart_AlternatorsSetEfficiency.vb index 51551a49b60c11650c6facd3c277587b29856467..0d24142c6b4ddea2538a8635a823124663f719f8 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/M0_NonSmart_AlternatorsSetEfficiency.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/M0_NonSmart_AlternatorsSetEfficiency.vb @@ -9,66 +9,65 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Hvac -Namespace Electrics - - - Public Class M0_NonSmart_AlternatorsSetEfficiency - Implements IM0_NonSmart_AlternatorsSetEfficiency - - Private _electricalConsumersList As IElectricalConsumerList - Private _alternatorEfficiencyMap As IAlternatorMap - Private _powernetVoltage As Single - Private _signals As ISignals - Private _steadyStateModelHVAC As ISSMTOOL - - - Private _ElectricalPowerW As Single - Private _MechanicalPowerW As Single - Private _FuelingLPerH As Single - - 'Constructor - Public Sub New(electricalConsumers As IElectricalConsumerList, alternatorEfficiencyMap As IAlternatorMap, powernetVoltage As Single, signals As ISignals, ssmHvac As ISSMTOOL) - - If electricalConsumers Is Nothing Then Throw New ArgumentException("No ElectricalConsumersList Supplied") - If alternatorEfficiencyMap Is Nothing Then Throw New ArgumentException("No Alternator Efficiency Map Supplied") - If (powernetVoltage < ElectricConstants.PowenetVoltageMin Or powernetVoltage > ElectricConstants.PowenetVoltageMax) Then Throw New ArgumentException("Powernet Voltage out of range") - If signals is Nothing then Throw New ArgumentException("No Signals reference was supplied.") - - Me._electricalConsumersList = electricalConsumers - Me._alternatorEfficiencyMap = alternatorEfficiencyMap - Me._powernetVoltage = powernetVoltage - Me._signals = signals - Me._steadyStateModelHVAC = ssmHvac - - _ElectricalPowerW= ssmHvac.ElectricalWAdjusted - _MechanicalPowerW= ssmHvac.MechanicalWBaseAdjusted - _FuelingLPerH = ssmHvac.FuelPerHBaseAdjusted - - - - End Sub - - 'Public class outputs (Properties) - Public ReadOnly Property AlternatorsEfficiency As Single Implements IM0_NonSmart_AlternatorsSetEfficiency.AlternatorsEfficiency - - Get - 'Stored Energy Efficience removed from V8.0 21/4/15 by Mike Preston //tb - Dim baseCurrentDemandAmps As Single = _electricalConsumersList.GetTotalAverageDemandAmps(false)' ElectricConstants.StoredEnergyEfficiency - Dim totalDemandAmps As Single = baseCurrentDemandAmps + GetHVACElectricalPowerDemandAmps - Return _alternatorEfficiencyMap.GetEfficiency(_signals.EngineSpeed, totalDemandAmps).Efficiency - End Get - - End property - Public readonly property GetHVACElectricalPowerDemandAmps As Single Implements IM0_NonSmart_AlternatorsSetEfficiency.GetHVACElectricalPowerDemandAmps - Get - Return _ElectricalPowerW / _powernetVoltage - End Get - End Property - - End Class - +Namespace Electrics + Public Class M0_NonSmart_AlternatorsSetEfficiency + Implements IM0_NonSmart_AlternatorsSetEfficiency + + Private _electricalConsumersList As IElectricalConsumerList + Private _alternatorEfficiencyMap As IAlternatorMap + Private _powernetVoltage As Volt + Private _signals As ISignals + Private _steadyStateModelHVAC As ISSMTOOL + + + Private _ElectricalPowerW As Watt + Private _MechanicalPowerW As Watt + Private _FuelingLPerH As LiterPerSecond + + 'Constructor + Public Sub New(electricalConsumers As IElectricalConsumerList, alternatorEfficiencyMap As IAlternatorMap, + powernetVoltage As Volt, signals As ISignals, ssmHvac As ISSMTOOL) + + If electricalConsumers Is Nothing Then Throw New ArgumentException("No ElectricalConsumersList Supplied") + If alternatorEfficiencyMap Is Nothing Then Throw New ArgumentException("No Alternator Efficiency Map Supplied") + If (powernetVoltage < ElectricConstants.PowenetVoltageMin Or powernetVoltage > ElectricConstants.PowenetVoltageMax) _ + Then Throw New ArgumentException("Powernet Voltage out of range") + If signals Is Nothing Then Throw New ArgumentException("No Signals reference was supplied.") + + Me._electricalConsumersList = electricalConsumers + Me._alternatorEfficiencyMap = alternatorEfficiencyMap + Me._powernetVoltage = powernetVoltage + Me._signals = signals + Me._steadyStateModelHVAC = ssmHvac + + _ElectricalPowerW = ssmHvac.ElectricalWAdjusted.SI(Of Watt)() + _MechanicalPowerW = ssmHvac.MechanicalWBaseAdjusted.SI(Of Watt)() + _FuelingLPerH = ssmHvac.FuelPerHBaseAdjusted.SI(Of LiterPerSecond)() + End Sub + + 'Public class outputs (Properties) + Public ReadOnly Property AlternatorsEfficiency As Double _ + Implements IM0_NonSmart_AlternatorsSetEfficiency.AlternatorsEfficiency + + Get + 'Stored Energy Efficience removed from V8.0 21/4/15 by Mike Preston //tb + Dim baseCurrentDemandAmps As Ampere = _electricalConsumersList.GetTotalAverageDemandAmps(False) _ + ' ElectricConstants.StoredEnergyEfficiency + Dim totalDemandAmps As Ampere = baseCurrentDemandAmps + GetHVACElectricalPowerDemandAmps + Return _alternatorEfficiencyMap.GetEfficiency(_signals.EngineSpeed.AsRPM, totalDemandAmps).Efficiency + End Get + End Property + + Public ReadOnly Property GetHVACElectricalPowerDemandAmps As Ampere _ + Implements IM0_NonSmart_AlternatorsSetEfficiency.GetHVACElectricalPowerDemandAmps + Get + Return _ElectricalPowerW / _powernetVoltage + End Get + End Property + End Class End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Electrics/M2_AverageElectricalLoadDemand.vb b/VECTOAux/VectoAuxiliaries/Electrics/M2_AverageElectricalLoadDemand.vb index dd8784578490126377071d80c659d502698b4156..bba981a94fdaca70a17025a94f7416febc43bda7 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/M2_AverageElectricalLoadDemand.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/M2_AverageElectricalLoadDemand.vb @@ -8,61 +8,62 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Electrics + Public Class M2_AverageElectricalLoadDemand + Implements IM2_AverageElectricalLoadDemand - Public Class M2_AverageElectricalLoadDemand - Implements IM2_AverageElectricalLoadDemand + Public _powerNetVoltage As Volt = 26.3.SI(Of Volt)() + Private _electricalConsumers As IElectricalConsumerList + Private _module0 As IM0_NonSmart_AlternatorsSetEfficiency + Private _alternatorPulleyEffiency As Double + Private _signals As Signals - Public _powerNetVoltage As Single = 26.3 - Private _electricalConsumers As IElectricalConsumerList - Private _module0 As IM0_NonSmart_AlternatorsSetEfficiency - Private _alternatorPulleyEffiency As Single - Private _signals As Signals + 'Constructor + Public Sub New(ByVal electricalConsumers As IElectricalConsumerList, m0 As IM0_NonSmart_AlternatorsSetEfficiency, + altPulleyEfficiency As Double, powerNetVoltage As Volt, signals As ISignals) - 'Constructor - Public Sub New(ByVal electricalConsumers As IElectricalConsumerList, m0 As IM0_NonSmart_AlternatorsSetEfficiency, altPulleyEfficiency As Single, powerNetVoltage As Single, signals as ISignals ) + If electricalConsumers Is Nothing Then Throw New ArgumentException("Electrical Consumer List must be supplied") + If m0 Is Nothing Then Throw New ArgumentException("Must supply module 0") + If altPulleyEfficiency = 0 OrElse altPulleyEfficiency > 1 Then _ + Throw New ArgumentException("Alternator Gear efficiency out of range.") + If powerNetVoltage < ElectricConstants.PowenetVoltageMin OrElse powerNetVoltage > ElectricConstants.PowenetVoltageMax _ + Then + Throw New ArgumentException("Powernet Voltage out of known range.") + End If - If electricalConsumers Is Nothing Then Throw New ArgumentException("Electrical Consumer List must be supplied") - If m0 Is Nothing Then Throw New ArgumentException("Must supply module 0") - If altPulleyEfficiency = 0 OrElse altPulleyEfficiency > 1 Then Throw New ArgumentException("Alternator Gear efficiency out of range.") - If powerNetVoltage < ElectricConstants.PowenetVoltageMin OrElse powerNetVoltage > ElectricConstants.PowenetVoltageMax Then - Throw New ArgumentException("Powernet Voltage out of known range.") - End If + _powerNetVoltage = powerNetVoltage + _electricalConsumers = electricalConsumers + _module0 = m0 + _alternatorPulleyEffiency = altPulleyEfficiency + End Sub - _powerNetVoltage = powerNetVoltage - _electricalConsumers = electricalConsumers - _module0 = m0 - _alternatorPulleyEffiency = altPulleyEfficiency + 'Public class outputs (Properties) + Public Function GetAveragePowerDemandAtAlternator() As Watt _ + Implements IM2_AverageElectricalLoadDemand.GetAveragePowerDemandAtAlternator + 'Stored Energy Efficience removed from V8.0 21/4/15 by Mike Preston //tb + 'Return ( _electricalConsumers.GetTotalAverageDemandAmps(False)/ElectricConstants.StoredEnergyEfficiency) * _powerNetVoltage + Return _powerNetVoltage * _electricalConsumers.GetTotalAverageDemandAmps(False) + End Function - End Sub + Public Function GetAveragePowerAtCrankFromElectrics() As Watt _ + Implements IM2_AverageElectricalLoadDemand.GetAveragePowerAtCrankFromElectrics - 'Public class outputs (Properties) - Public Function GetAveragePowerDemandAtAlternator() As Single Implements IM2_AverageElectricalLoadDemand.GetAveragePowerDemandAtAlternator + Dim ElectricalPowerDemandsWatts As Watt = GetAveragePowerDemandAtAlternator() + Dim alternatorsEfficiency As Double = _module0.AlternatorsEfficiency + Dim ElectricalPowerDemandsWattsDividedByAlternatorEfficiency As Watt = ElectricalPowerDemandsWatts * (1 / + alternatorsEfficiency) - 'Stored Energy Efficience removed from V8.0 21/4/15 by Mike Preston //tb - 'Return ( _electricalConsumers.GetTotalAverageDemandAmps(False)/ElectricConstants.StoredEnergyEfficiency) * _powerNetVoltage - Return _electricalConsumers.GetTotalAverageDemandAmps(False) * _powerNetVoltage + Dim averagePowerDemandAtCrankFromElectricsWatts As Watt - End Function - Public Function GetAveragePowerAtCrankFromElectrics() As Single Implements IM2_AverageElectricalLoadDemand.GetAveragePowerAtCrankFromElectrics - - Dim ElectricalPowerDemandsWatts As Single = GetAveragePowerDemandAtAlternator() - Dim alternatorsEfficiency As Single = _module0.AlternatorsEfficiency - Dim ElectricalPowerDemandsWattsDividedByAlternatorEfficiency as Single = ElectricalPowerDemandsWatts / alternatorsEfficiency - - Dim averagePowerDemandAtCrankFromElectricsWatts As Single - - averagePowerDemandAtCrankFromElectricsWatts = ElectricalPowerDemandsWattsDividedByAlternatorEfficiency / _alternatorPulleyEffiency - - Return averagePowerDemandAtCrankFromElectricsWatts - - End Function - - - End Class + averagePowerDemandAtCrankFromElectricsWatts = ElectricalPowerDemandsWattsDividedByAlternatorEfficiency * (1 / + _alternatorPulleyEffiency) + Return averagePowerDemandAtCrankFromElectricsWatts + End Function + End Class End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Electrics/M5__SmartAlternatorSetGeneration.vb b/VECTOAux/VectoAuxiliaries/Electrics/M5__SmartAlternatorSetGeneration.vb index a49c2cbe22c3a4794125c00c1386e821d64495f9..5d8643347cb248b3f524a7dc4da6d7c8f2b4b2d7 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/M5__SmartAlternatorSetGeneration.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/M5__SmartAlternatorSetGeneration.vb @@ -8,51 +8,58 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Electrics - - Public Class M5__SmartAlternatorSetGeneration - Implements IM5_SmartAlternatorSetGeneration - - Private _powerNetVoltage As Single - Private _m05 As M0_5_SmartAlternatorSetEfficiency - Private _alternatorGearEfficiency As single - - 'Constructor - Public Sub new ( m05 As M0_5_SmartAlternatorSetEfficiency, ByVal powernetVoltage As single, alternatorGearEfficiency As single) - - 'sanity check - If m05 is Nothing then Throw New ArgumentException("Please supply a valid module M05") - If powernetVoltage < ElectricConstants.PowenetVoltageMin orelse powernetVoltage > ElectricConstants.PowenetVoltageMax then Throw New ArgumentException("Powernet Voltage out of range") - If alternatorGearEfficiency < 0 or alternatorGearEfficiency>1 then Throw New ArgumentException("AlternatorGearEfficiency Out of bounds, should be 0 to 1") - - 'assign private variables. - _m05=m05 - _powerNetVoltage=powernetVoltage - _alternatorGearEfficiency = alternatorGearEfficiency - - End Sub - - 'Public class outputs (Functions) - Public Function AlternatorsGenerationPowerAtCrankIdleWatts() As Single Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankIdleWatts - - Return (_m05.SmartIdleCurrent() * _powerNetVoltage) / ( _m05.AlternatorsEfficiencyIdleResultCard() * _alternatorGearEfficiency) - - End Function - Public Function AlternatorsGenerationPowerAtCrankOverrunWatts() As Single Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankOverrunWatts - - Return (_m05.SmartOverrunCurrent() * _powerNetVoltage) / ( _m05.AlternatorsEfficiencyOverrunResultCard() * _alternatorGearEfficiency) - - End Function - Public Function AlternatorsGenerationPowerAtCrankTractionOnWatts() As Single Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankTractionOnWatts - - Return (_m05.SmartTractionCurrent() * _powerNetVoltage) / ( _m05.AlternatorsEfficiencyTractionOnResultCard() * _alternatorGearEfficiency) - - End Function - -End Class - + Public Class M5__SmartAlternatorSetGeneration + Implements IM5_SmartAlternatorSetGeneration + + Private _powerNetVoltage As Volt + Private _m05 As M0_5_SmartAlternatorSetEfficiency + Private _alternatorGearEfficiency As Double + + 'Constructor + Public Sub New(m05 As M0_5_SmartAlternatorSetEfficiency, ByVal powernetVoltage As Volt, + alternatorGearEfficiency As Double) + + 'sanity check + If m05 Is Nothing Then Throw New ArgumentException("Please supply a valid module M05") + If powernetVoltage < ElectricConstants.PowenetVoltageMin OrElse powernetVoltage > ElectricConstants.PowenetVoltageMax _ + Then Throw New ArgumentException("Powernet Voltage out of range") + If alternatorGearEfficiency < 0 Or alternatorGearEfficiency > 1 Then _ + Throw New ArgumentException("AlternatorGearEfficiency Out of bounds, should be 0 to 1") + + 'assign private variables. + _m05 = m05 + _powerNetVoltage = powernetVoltage + _alternatorGearEfficiency = alternatorGearEfficiency + End Sub + + 'Public class outputs (Functions) + Public Function AlternatorsGenerationPowerAtCrankIdleWatts() As Watt _ + Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankIdleWatts + + Return _ + (_m05.SmartIdleCurrent() * _powerNetVoltage) * + (1 / (_m05.AlternatorsEfficiencyIdleResultCard() * _alternatorGearEfficiency)) + End Function + + Public Function AlternatorsGenerationPowerAtCrankOverrunWatts() As Watt _ + Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankOverrunWatts + + Return _ + (_m05.SmartOverrunCurrent() * _powerNetVoltage) * (1 / + (_m05.AlternatorsEfficiencyOverrunResultCard() * _alternatorGearEfficiency)) + End Function + + Public Function AlternatorsGenerationPowerAtCrankTractionOnWatts() As Watt _ + Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankTractionOnWatts + + Return _ + (_m05.SmartTractionCurrent() * _powerNetVoltage) * (1 / + (_m05.AlternatorsEfficiencyTractionOnResultCard() * _alternatorGearEfficiency)) + End Function + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/ResultCard.vb b/VECTOAux/VectoAuxiliaries/Electrics/ResultCard.vb index 0d518dbc4c197cfc79d35cdcf4f7c5e03b965537..22b56c545fa5484a5a78c1e8321a8f4a3b62af35 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/ResultCard.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/ResultCard.vb @@ -9,135 +9,135 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Namespace Electrics + Public Class ResultCard + Implements IResultCard - Public Class ResultCard -Implements IResultCard + Private _results As List(Of SmartResult) - Private _results As List(Of SmartResult) - - 'Constructor - Public Sub New(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.") + If results Is Nothing Then Throw New ArgumentException("A list of smart results must be supplied.") - _results = results + _results = results + End Sub -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(amps As Single) As Single Implements IResultCard.GetSmartCurrentResult + 'Public class outputs + Public ReadOnly Property Results As List(Of SmartResult) Implements IResultCard.Results + Get + Return _results + End Get + End Property - If _results.Count<2 then Return 10 + Public Function GetSmartCurrentResult(ByVal Amps As Ampere) As Ampere Implements IResultCard.GetSmartCurrentResult - Return GetOrInterpolate(amps) + If _results.Count < 2 Then Return 10.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 Single) As Single + Return GetOrInterpolate(Amps.Value()).SI(Of Ampere)() + End Function -Dim pre As Single -Dim post As Single -Dim dAmps As Single -Dim dSmartAmps As Single -Dim smartAmpsSlope As Single -Dim smartAmps As Single -Dim maxKey As Single -Dim minKey As Single - maxKey = _results.Max.Amps - minKey = _results.Min.Amps + '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 compareKey As SmartResult = New SmartResult( amps,0) + 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 - 'Is on boundary check - If _results.Contains(compareKey) Then Return _results.OrderBy( Function(x) x.Amps).First( Function( x ) x.Amps=compareKey.Amps ).SmartAmps + maxKey = _results.Max.Amps + minKey = _results.Min.Amps - 'Is over map - Extrapolate - If amps > maxKey Then + Dim compareKey As SmartResult = New SmartResult(amps, 0) - '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 + 'Is on boundary check + If _results.Contains(compareKey) Then _ + Return _results.OrderBy(Function(x) x.Amps).First(Function(x) x.Amps = compareKey.Amps).SmartAmps - '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 + 'Is over map - Extrapolate + If amps > maxKey Then - 'calculate the slopes - smartAmpsSlope = dSmartAmps / dAmps + '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 - 'calculate the new values - smartAmps = ((amps - post) * smartAmpsSlope) + ( From da In _results Order By da.Amps Where da.Amps=post ).First().SmartAmps + '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 - Return smartAmps + 'calculate the slopes + smartAmpsSlope = dSmartAmps / dAmps - End If + 'calculate the new values + smartAmps = ((amps - post) * smartAmpsSlope) + + (From da In _results Order By da.Amps Where da.Amps = post).First().SmartAmps - 'Is under map - Extrapolate - If amps < minKey Then + Return smartAmps - '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 + End If - '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 + 'Is under map - Extrapolate + If amps < minKey Then - 'calculate the slopes - smartAmpsSlope = dSmartAmps / dAmps + '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 - 'calculate the new values - smartAmps = ((amps - post) * smartAmpsSlope) + ( From da In _results Order By da.Amps Where da.Amps=post ).First().SmartAmps + '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 - Return smartAmps - End If + 'calculate the slopes + smartAmpsSlope = dSmartAmps / dAmps - 'Is Inside map - Interpolate + 'calculate the new values + smartAmps = ((amps - post) * smartAmpsSlope) + + (From da In _results Order By da.Amps Where da.Amps = post).First().SmartAmps - '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 + Return smartAmps + End If - '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 + 'Is Inside map - Interpolate - 'calculate the slopes - smartAmpsSlope = dSmartAmps / dAmps + '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 - 'calculate the new values - smartAmps = ((amps - post) * smartAmpsSlope) + ( From da In _results Order By da.Amps Where da.Amps=post ).First().SmartAmps + '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 - Return smartAmps + 'calculate the new values + smartAmps = ((amps - post) * smartAmpsSlope) + + (From da In _results Order By da.Amps Where da.Amps = post).First().SmartAmps -End Function - - -End Class + Return smartAmps + End Function + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Electrics/SmartResult.vb b/VECTOAux/VectoAuxiliaries/Electrics/SmartResult.vb index 5f07a523985749c0cbc7241b267e884b4881b2cf..8e3bd4e4565b14b22a690a1afa73f60cc3585257 100644 --- a/VECTOAux/VectoAuxiliaries/Electrics/SmartResult.vb +++ b/VECTOAux/VectoAuxiliaries/Electrics/SmartResult.vb @@ -10,51 +10,44 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Namespace Electrics + Public Class SmartResult + Implements IComparable(Of SmartResult) - Public Class SmartResult -Implements IComparable(Of SmartResult) + Public Property Amps As Double + Public Property SmartAmps As Double - - Public Property Amps As Single - Public Property SmartAmps As Single - - 'Constructors - Public Sub new () - 'An empty constructor is requried. Do not remove. - End Sub - Public Sub new( amps As Single , smartAmps As single) + 'Constructors + Public Sub new() + 'An empty constructor is requried. Do not remove. + End Sub - Me.Amps = amps - Me.SmartAmps = smartAmps + Public Sub New(amps As Double, smartAmps As Double) - End Sub - - 'Comparison - Public Function CompareTo(other As SmartResult) As Integer Implements IComparable(Of SmartResult).CompareTo + Me.Amps = amps + Me.SmartAmps = smartAmps + End Sub - If other.Amps> Me.Amps then return -1 - If other.Amps=Me.Amps then Return 0 - - Return 1 + 'Comparison + Public Function CompareTo(other As SmartResult) As Integer Implements IComparable(Of SmartResult).CompareTo - End Function + If other.Amps > Me.Amps then return - 1 + If other.Amps = Me.Amps then Return 0 - 'Comparison Overrides - Public Overrides Function Equals(obj As Object) As Boolean - - Dim other as SmartResult = Ctype( Obj, SmartResult ) + Return 1 + End Function - Return Me.Amps=other.Amps + 'Comparison Overrides + Public Overrides Function Equals(obj As Object) As Boolean - End Function - Public Overrides Function GetHashCode() As Integer - Return 0 - End Function + Dim other as SmartResult = Ctype(Obj, SmartResult) + Return Me.Amps = other.Amps + End Function -End Class - + Public Overrides Function GetHashCode() As Integer + Return 0 + End Function + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/FilePathUtils.vb b/VECTOAux/VectoAuxiliaries/FilePathUtils.vb index 293183af7938ad26d5d391f31d0f387db2434c02..4060d63a7a60c2a84f883bc9981596dabab9306a 100644 --- a/VECTOAux/VectoAuxiliaries/FilePathUtils.vb +++ b/VECTOAux/VectoAuxiliaries/FilePathUtils.vb @@ -10,141 +10,134 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Public Class FilePathUtils + Public Shared Function ValidateFilePath(ByVal filePath As String, ByVal expectedExtension As String, + ByRef message As String) As Boolean -Public shared Function ValidateFilePath( byval filePath As String , byval expectedExtension As String, ByRef message As string ) As Boolean - - - Dim illegalFileNameCharacters As Char() = {"<",">",":","""","/","\","|","?","*","~"} - Dim detectedExtention As String = fileExtentionOnly( filePath) - Dim pathOnly as string = filePathOnly( filePath) - Dim fileNameOnlyWithExtension As String = fileNameOnly(filePath,True) - Dim fileNameOnlyNoExtension As String = fileNameOnly(filePath,false) - - 'Is this filePath empty - If filePath.trim.Length=0 orelse Right( filePath, 1)="\" then - message = "A filename cannot be empty" - Return false - End If - - - 'Extension Expected, but not match - If expectedExtension.Trim.Length>0 then - If String.Compare(expectedExtension,detectedExtention,true)<>0 - message = String.Format("The file extension type does not match the expected type of {0}", expectedExtension) - Return false - End If - End If - - 'Extension Not Expected, but was supplied - If expectedExtension.Trim.Length>0 then - If detectedExtention.Length= 0 then - message=String.Format("No Extension was supplied, but an extension of {0}, this is not required",detectedExtention) - Return false - End If - End If - - - 'Illegal characters - If Not fileNameLegal(fileNameOnlyWithExtension ) - message= String.Format("The filenames have one or more illegal characters") - Return false - End If - - - - message="OK" - Return true - -End Function - - -Public Shared function fileNameLegal( fileName as string) As Boolean - - Dim illegalFileNameCharacters As Char() = {"<",">",":","""","/","\","|","?","*","~"} - - - 'Illegal characters - For Each ch As Char In illegalFileNameCharacters - - If fileName.Contains( ch ) then - - Return false - - End If - Next - Return true - -End Function - - - Public shared function ResolveFilePath( vectoPath as String, filename As string) as string - - 'No Vecto Path supplied - If vectoPath="" then Return filename - - 'This is not relative - If filename.Contains(":\") then - - 'Filepath is already absolute - Return filename - Else - return vectoPath & filename - End If - - End Function - - - - ''' <summary> - ''' File name without the path "C:\temp\TEST.txt" >> "TEST.txt" oder "TEST" - ''' </summary> - ''' <param name="filePath"></param> - ''' <param name="WithExtention"></param> - ''' <returns>Return file portion of the path, with or without the extension</returns> - ''' <remarks></remarks> - Public shared Function fileNameOnly(ByVal filePath As String, ByVal WithExtention As Boolean) As String - Dim x As Int16 - x = filePath.LastIndexOf("\") + 1 - filePath = Microsoft.VisualBasic.Right(filePath, Microsoft.VisualBasic.Len(filePath) - x) - If Not WithExtention Then - x = filePath.LastIndexOf(".") - If x > 0 Then filePath = Microsoft.VisualBasic.Left(filePath, x) - End If - Return filePath - End Function - - - ''' <summary> - ''' Extension alone "C:\temp\TEST.txt" >> ".txt" - ''' </summary> - ''' <param name="filePath"></param> - ''' <returns>Extension alone Including the dot IE .EXT</returns> - ''' <remarks></remarks> - Public shared Function fileExtentionOnly(ByVal filePath As String) As String - Dim x As Int16 - x = filePath.LastIndexOf(".") - If x = -1 Then - Return "" - Else - Return Microsoft.VisualBasic.Right(filePath, Microsoft.VisualBasic.Len(filePath) - x) - End If - End Function - - ''' <summary> - ''' File Path alone "C:\temp\TEST.txt" >> "C:\temp\" - ''' "TEST.txt" >> "" - ''' </summary> - ''' <param name="filePath"></param> - ''' <returns>Filepath without the extension</returns> - ''' <remarks></remarks> - Public Shared Function filePathOnly(ByVal filePath As String) As String - Dim x As Int16 - If filePath Is Nothing OrElse filePath.Length < 3 OrElse filePath.Substring(1, 2) <> ":\" Then Return "" - x = filePath.LastIndexOf("\") - Return Microsoft.VisualBasic.Left(filePath, x + 1) - End Function - + Dim illegalFileNameCharacters As Char() = {"<"c, ">"c, ":"c, """"c, "/"c, "\"c, "|"c, "?"c, "*"c, "~"c} + Dim detectedExtention As String = fileExtentionOnly(filePath) + Dim pathOnly As String = filePathOnly(filePath) + Dim fileNameOnlyWithExtension As String = fileNameOnly(filePath, True) + Dim fileNameOnlyNoExtension As String = fileNameOnly(filePath, False) + 'Is this filePath empty + If filePath.trim.Length = 0 OrElse Right(filePath, 1) = "\" Then + message = "A filename cannot be empty" + Return False + End If + + + 'Extension Expected, but not match + If expectedExtension.Trim.Length > 0 Then + If String.Compare(expectedExtension, detectedExtention, True) <> 0 Then + message = String.Format("The file extension type does not match the expected type of {0}", expectedExtension) + Return False + End If + End If + + 'Extension Not Expected, but was supplied + If expectedExtension.Trim.Length > 0 Then + If detectedExtention.Length = 0 Then + message = String.Format("No Extension was supplied, but an extension of {0}, this is not required", + detectedExtention) + Return False + End If + End If + + + 'Illegal characters + If Not fileNameLegal(fileNameOnlyWithExtension) Then + message = String.Format("The filenames have one or more illegal characters") + Return False + End If + + + message = "OK" + Return True + End Function + + + Public Shared Function fileNameLegal(fileName As String) As Boolean + + Dim illegalFileNameCharacters As Char() = {"<"c, ">"c, ":"c, """"c, "/"c, "\"c, "|"c, "?"c, "*"c, "~"c} + + + 'Illegal characters + For Each ch As Char In illegalFileNameCharacters + + If fileName.Contains(ch) Then + + Return False + + End If + Next + Return True + End Function + + + Public Shared Function ResolveFilePath(vectoPath As String, filename As String) As String + + 'No Vecto Path supplied + If vectoPath = "" Then Return filename + + 'This is not relative + If filename.Contains(":\") Then + + 'Filepath is already absolute + Return filename + Else + Return vectoPath & filename + End If + End Function + + + ''' <summary> + ''' File name without the path "C:\temp\TEST.txt" >> "TEST.txt" oder "TEST" + ''' </summary> + ''' <param name="filePath"></param> + ''' <param name="WithExtention"></param> + ''' <returns>Return file portion of the path, with or without the extension</returns> + ''' <remarks></remarks> + Public Shared Function fileNameOnly(ByVal filePath As String, ByVal WithExtention As Boolean) As String + Dim x As Integer + x = filePath.LastIndexOf("\") + 1 + filePath = Microsoft.VisualBasic.Right(filePath, Microsoft.VisualBasic.Len(filePath) - x) + If Not WithExtention Then + x = filePath.LastIndexOf(".") + If x > 0 Then filePath = Microsoft.VisualBasic.Left(filePath, x) + End If + Return filePath + End Function + + + ''' <summary> + ''' Extension alone "C:\temp\TEST.txt" >> ".txt" + ''' </summary> + ''' <param name="filePath"></param> + ''' <returns>Extension alone Including the dot IE .EXT</returns> + ''' <remarks></remarks> + Public Shared Function fileExtentionOnly(ByVal filePath As String) As String + Dim x As Integer + x = filePath.LastIndexOf(".") + If x = - 1 Then + Return "" + Else + Return Microsoft.VisualBasic.Right(filePath, Microsoft.VisualBasic.Len(filePath) - x) + End If + End Function + + ''' <summary> + ''' File Path alone "C:\temp\TEST.txt" >> "C:\temp\" + ''' "TEST.txt" >> "" + ''' </summary> + ''' <param name="filePath"></param> + ''' <returns>Filepath without the extension</returns> + ''' <remarks></remarks> + Public Shared Function filePathOnly(ByVal filePath As String) As String + Dim x As Integer + If filePath Is Nothing OrElse filePath.Length < 3 OrElse filePath.Substring(1, 2) <> ":\" Then Return "" + x = filePath.LastIndexOf("\") + Return Microsoft.VisualBasic.Left(filePath, x + 1) + End Function End Class diff --git a/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb b/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb index 3bcb76486155441498bedafeab3d0a71afe76d51..53fd82da052c5fbe4bba9d69ddfdbbc2d4d33419 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/Bus.vb @@ -1,198 +1,188 @@ 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 - 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 String - Private _widthInMetres As String - Private _heightInMetres As String - 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 String, - _widthInMetres As String, - _heightInMetres As String, - _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 - + '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 index 9b448cbbae5a2f3ea007bda55b250bf9404ed3f4..783b0ca0652bd25b10ff48fde17e06c6e06da2b3 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/BusDatabase.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/BusDatabase.vb @@ -1,4 +1,5 @@ -Imports System.IO +Imports System.Globalization +Imports System.IO Imports System.Text Namespace Hvac @@ -60,7 +61,7 @@ Namespace Hvac If Not firstline Then 'split the line - Dim elements() As String = line.Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries) + 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") @@ -72,10 +73,10 @@ Namespace Hvac elements(0), elements(1), elements(2), - elements(3), - elements(4), - elements(5), - elements(6), + 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) @@ -98,9 +99,9 @@ Namespace Hvac returnStatus = False End If - Dim uniqueBuses As Object = From b In buses Select New With {Key b.Model, b} Distinct.ToList() + Dim uniqueBuses As Integer = (From b In buses Select New With {Key b.Model, b} Distinct).Count() - If buses.Count <> uniqueBuses.Count Then + If buses.Count <> uniqueBuses Then returnStatus = False End If diff --git a/VECTOAux/VectoAuxiliaries/Hvac/BusEngineType.vb b/VECTOAux/VectoAuxiliaries/Hvac/BusEngineType.vb index 70dd1a4c08897a881378907b0310a94f8d23ab5a..7c6d5f5c65d9c8f6a15bc284cc180c291d6b4dad 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/BusEngineType.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/BusEngineType.vb @@ -1,15 +1,10 @@ Namespace Hvac + Public Enum BusEngineType -Public Enum BusEngineType - - Diesal = 1 - Gas = 2 - Hybrid = 3 - -End Enum - - + Diesal = 1 + Gas = 2 + Hybrid = 3 + End Enum End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb b/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb index 8017fa2c56519e48b1639abf13876989d959e4d3..ae83180688b957f0839fb2be8e3cae9fd82b4015 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/DeleteCell.vb @@ -2,48 +2,48 @@ Imports System.Drawing - - Public Class DeleteCell - Inherits DataGridViewButtonCell + Inherits DataGridViewButtonCell - Public property ToolTip As String = "Delete tech benefit line" - Private del As Image = My.Resources.ResourceManager.GetObject("Delete") + 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) + 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 + 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 - + 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 = My.Resources.ResourceManager.GetObject("Delete") + 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 + 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) - Me.ToolTipText=ToolTip - - cellStyle.BackColor= Color.White - MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts) - graphics.DrawImage(del, cellBounds) + advancedBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Single - End Sub - + 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 index 03baf8586bb1245f856943f1afba378b18fb14d4..d222b9838dd7dbf657a0dfd37e088e2f33694bc6 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/DeleteColumn.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/DeleteColumn.vb @@ -2,35 +2,21 @@ Public Class DeleteColumn - Inherits DataGridViewButtonColumn - - - - Public Sub new() - - MyBase.New() - Me.CellTemplate = New DeleteCell() - - End Sub - - + 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 - - + 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 index a4feb7cdb2fbd79bc30fe204ccb0b89154b789aa..0d9eabda44fa45345b8f7a6e1d4ec354a9a2ff26 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalCondition.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalCondition.vb @@ -1,36 +1,33 @@ Namespace Hvac + Public Class EnvironmentalCondition + Implements IEnvironmentalCondition - Public Class EnvironmentalCondition - Implements IEnvironmentalCondition + Private _temperature As Double + Private _solar As Double + Private _weight As Double - Private _temperature As Double - Private _solar As Double - Private _weight As Double + Public Sub New(temperature As Double, solar As Double, weight As Double) - Public Sub New(temperature As Double, solar As Double, weight As Double) + _temperature = temperature + _solar = solar + _weight = weight + End Sub - _temperature = temperature - _solar = solar - _weight = weight + Public Function GetTemperature() As Double Implements IEnvironmentalCondition.GetTemperature + Return _temperature + End Function - End Sub + Public Function GetSolar() As Double Implements IEnvironmentalCondition.GetSolar + Return _solar + End Function - 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 + 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 index 9e79090a8e185df23c2b17a7132dea4e55a1e7d2..fe22582b6152d64839bab7a4369d08b514afede5 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalConditionsMap.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/EnvironmentalConditionsMap.vb @@ -1,80 +1,80 @@ -Imports System.IO +Imports System.Globalization +Imports System.IO Namespace Hvac + Public Class EnvironmentalConditionsMap + Implements IEnvironmentalConditionsMap - Public Class EnvironmentalConditionsMap - Implements IEnvironmentalConditionsMap + Private filePath As String + Private vectoDirectory As String - Private filePath As String - Private vectoDirectory As String + Private _map As New List(Of IEnvironmentalCondition) - Private _map As New List(Of IEnvironmentalCondition) + Public Sub New(filepath As String, vectoDirectory As String) - Public Sub New(filepath As String, vectoDirectory As String) + Me.filePath = filepath + Me.vectoDirectory = vectoDirectory - Me.filePath = filepath - Me.vectoDirectory = vectoDirectory + Initialise() + End Sub - Initialise() + Public Function Initialise() As Boolean Implements IEnvironmentalConditionsMap.Initialise - End Sub + If (Not String.IsNullOrWhiteSpace(filePath)) Then - Public Function Initialise() As Boolean Implements IEnvironmentalConditionsMap.Initialise + filePath = FilePathUtils.ResolveFilePath(vectoDirectory, filePath) - If (Not String.IsNullOrWhiteSpace(filePath)) Then + If File.Exists(filePath) Then + Using sr As StreamReader = New StreamReader(filePath) - filePath = FilePathUtils.ResolveFilePath(vectoDirectory, filePath) + 'get array og lines fron csv + Dim lines() As String = sr.ReadToEnd().Split(CType(Environment.NewLine, Char()), + StringSplitOptions.RemoveEmptyEntries) - If File.Exists(filePath) Then - Using sr As StreamReader = New StreamReader(filePath) + 'Must have at least 1 entries to make it usable [dont forget the header row] + If (lines.Count() < 2) Then + Return False + End If - 'get array og lines fron csv - Dim lines() As String = sr.ReadToEnd().Split(CType(Environment.NewLine, Char()), StringSplitOptions.RemoveEmptyEntries) + Dim firstline As Boolean = True - 'Must have at least 1 entries to make it usable [dont forget the header row] - If (lines.Count() < 2) Then - Return False - End If + For Each line As String In lines + If Not firstline Then - Dim firstline As Boolean = True + 'split the line + Dim elements() As String = line.Split(New Char() {","c}, StringSplitOptions.RemoveEmptyEntries) - For Each line As String In lines - If Not firstline Then + '3 entries per line required + If (elements.Length <> 4) Then + Return False + End If - 'split the line - Dim elements() As String = line.Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries) + '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)) - '3 entries per line required - If (elements.Length <> 4) Then - Return False - End If + _map.Add(newCondition) - 'Add environment condition - Dim newCondition As EnvironmentalCondition = New EnvironmentalCondition(elements(1), elements(2), elements(3)) + Else + firstline = False + End If + Next line + End Using - _map.Add(newCondition) + Else + Return False + End If + End If - Else - firstline = False - End If - Next line - End Using + Return True + End Function - 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 + 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 index d2719e36b7eb25987878802cb9ee207050e528af..dbe43d9244320fbcc9578f7b805116e8ea5977ed 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/HVACConstants.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/HVACConstants.vb @@ -8,37 +8,40 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Hvac - - Public Class HVACConstants - Implements IHVACConstants - - Private _fuelDensity As Single - - Public Sub New() - _fuelDensity = 0.832 - End Sub - - Public Sub New(fuelDensitySingle As Single) - _fuelDensity = fuelDensitySingle - End Sub - - Public ReadOnly Property DieselGCVJperGram As Single Implements IHVACConstants.DieselGCVJperGram - Get - Return 44800 - End Get - End Property - - Public ReadOnly Property FuelDensity As Single Implements IHVACConstants.FuelDensity - Get - Return _fuelDensity - End Get - End Property - - End Class - + Public Class HVACConstants + Implements IHVACConstants + + Private _fuelDensity As KilogramPerCubicMeter + + Public Sub New() + _fuelDensity = 835.SI(Of KilogramPerCubicMeter)() + End Sub + + Public Sub New(fuelDensitySingle As KilogramPerCubicMeter) + _fuelDensity = fuelDensitySingle + End Sub + + Public ReadOnly Property DieselGCVJperGram As JoulePerKilogramm Implements IHVACConstants.DieselGCVJperGram + Get + Return 44800.SI().Joule.Per.Gramm.Cast(Of JoulePerKilogramm)() + End Get + End Property + + Public ReadOnly Property FuelDensity As KilogramPerCubicMeter Implements IHVACConstants.FuelDensity + Get + Return _fuelDensity + End Get + End Property + + Public ReadOnly Property FuelDensityAsGramPerLiter As Double Implements IHVACConstants.FuelDensityAsGramPerLiter + Get + Return _fuelDensity.Value() * 1000 + End Get + End Property + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/HVACSteadyStateModel.vb b/VECTOAux/VectoAuxiliaries/Hvac/HVACSteadyStateModel.vb index 629a75f113205901a93ca73361cf9eee5318e9a7..241fe5a563c426e2603e5269d171be40f922f9ce 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/HVACSteadyStateModel.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/HVACSteadyStateModel.vb @@ -12,111 +12,101 @@ Imports System.IO Namespace Hvac + Public Class HVACSteadyStateModel + Implements IHVACSteadyStateModel - 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 Property HVACElectricalLoadPowerWatts As Single Implements IHVACSteadyStateModel.HVACElectricalLoadPowerWatts - Public Property HVACFuellingLitresPerHour As Single Implements IHVACSteadyStateModel.HVACFuellingLitresPerHour - Public Property HVACMechanicalLoadPowerWatts As Single Implements IHVACSteadyStateModel.HVACMechanicalLoadPowerWatts + Public Sub New(elecPowerW As Single, mechPowerW As Single, fuellingLPH As Single) - 'Constructors - Public Sub New() + 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 -End Sub - Public Sub New(elecPowerW As Single, mechPowerW As Single, fuellingLPH As Single) - HVACElectricalLoadPowerWatts = elecPowerW - HVACFuellingLitresPerHour = mechPowerW - HVACMechanicalLoadPowerWatts = fuellingLPH + Dim myData As String + Dim linesArray As String() -End Sub - - 'Implementation - Public Function SetValuesFromMap( ByVal filePath As String, byref message As String ) As Boolean Implements IHVACSteadyStateModel.SetValuesFromMap + 'Check map file can be found. + Try + myData = System.IO.File.ReadAllText(filePath, System.Text.Encoding.UTF8) + Catch ex As FileNotFoundException - Dim myData As String - Dim linesArray As String() + message = "HVAC Steady State Model : The map file was not found" + Return false + End Try - 'Check map file can be found. - Try - myData = System.IO.File.ReadAllText(filePath, System.Text.Encoding.UTF8) - Catch ex As FileNotFoundException + linesArray = (From s As String In myData.Split(CType(vbLf, Char)) Select s.Trim).ToArray - message = "HVAC Steady State Model : The map file was not found" - Return false - End Try + '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 - linesArray = (From s As String In myData.Split(vbLf) Select s.Trim).ToArray + End If - '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 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 - '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 + 'OK we have the values so lets set the properties + Dim out1, out2, out3 As single + out1 = HVACElectricalLoadPowerWatts + out2 = HVACMechanicalLoadPowerWatts + out3 = HVACFuellingLitresPerHour + try - 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 + HVACElectricalLoadPowerWatts = Single.Parse(values(0)) + HVACMechanicalLoadPowerWatts = Single.Parse(values(1)) + HVACFuellingLitresPerHour = Single.Parse(values(2)) - 'OK we have the values so lets set the properties - Dim out1,out2,out3 As single - out1= HVACElectricalLoadPowerWatts - out2= HVACMechanicalLoadPowerWatts - out3= HVACFuellingLitresPerHour - try + Catch ex As Exception - HVACElectricalLoadPowerWatts = Single.Parse(values(0)) - HVACMechanicalLoadPowerWatts = Single.Parse(values(1)) - HVACFuellingLitresPerHour = Single.Parse(values(2)) + 'Restore in the event of failure to fully assign + HVACElectricalLoadPowerWatts = out1 + HVACMechanicalLoadPowerWatts = out2 + HVACFuellingLitresPerHour = out3 - Catch ex As Exception + '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 - '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 Try + Return True + End Function + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/HVACUserInputsConfig.vb b/VECTOAux/VectoAuxiliaries/Hvac/HVACUserInputsConfig.vb index 8a8e55605dc777052e3ea62bd2775146aac94f36..cbc00b08341b333bcc064503f60d3fa3a859190c 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/HVACUserInputsConfig.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/HVACUserInputsConfig.vb @@ -14,28 +14,23 @@ Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Namespace Hvac + Public Class HVACUserInputsConfig + Implements IHVACUserInputsConfig - Public Class HVACUserInputsConfig - Implements IHVACUserInputsConfig + 'Constructor + Public Sub New(ssmFilePath As String, busDatabasePath As String, isDisabled As Boolean) - 'Constructor - Public Sub New(ssmFilePath As String, busDatabasePath As String, isDisabled As Boolean) + Me.SSMFilePath = ssmFilePath + Me.BusDatabasePath = busDatabasePath + Me.SSMDisabled = isDisabled + End Sub - Me.SSMFilePath = ssmFilePath - Me.BusDatabasePath = busDatabasePath - Me.SSMDisabled = isDisabled + Public Property SSMFilePath As String Implements IHVACUserInputsConfig.SSMFilePath - 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 + 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 index 3a9c3331ec7268b5d9e42426332ce6c5bd603a5b..d1f5b72190bbac39e51307a27f9487604657a888 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/IBus.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/IBus.vb @@ -1,21 +1,17 @@  Namespace Hvac + Public Interface IBus + ReadOnly Property Id As Integer - 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 - + 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 index c3088e63ddda402803ddd0dd7d6ee31db03d57c4..afa479db3d88c75740c5340beed55f29cbfdf580 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/IBusDatabase.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/IBusDatabase.vb @@ -1,17 +1,13 @@ Namespace Hvac + Public Interface IBusDatabase + Function AddBus(bus As IBus) As Boolean - Public Interface IBusDatabase + Function GetBuses(busModel As String, Optional AsSelectList As Boolean = False) As List(Of IBus) - Function AddBus(bus As IBus) As Boolean + Function Initialise(busFileCSV As String) 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 + 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/IEnvironmentalCondition.vb b/VECTOAux/VectoAuxiliaries/Hvac/IEnvironmentalCondition.vb index f23b94506f3047cc1919828d8ebe93126309d141..2fd07cffcc30d7ece7e5e8785f850c6b7643909d 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/IEnvironmentalCondition.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/IEnvironmentalCondition.vb @@ -1,10 +1,8 @@ Namespace Hvac - Public Interface IEnvironmentalCondition - - Function GetTemperature() As Double - Function GetSolar() As Double - Function GetWeighting() As Double - Function GetNormalisedWeighting(map As List(Of IEnvironmentalCondition)) As Double - - End Interface + Public Interface IEnvironmentalCondition + Function GetTemperature() As Double + Function GetSolar() As Double + Function GetWeighting() As Double + Function GetNormalisedWeighting(map As List(Of IEnvironmentalCondition)) As Double + End Interface End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Hvac/IEnvironmentalConditionsMap.vb b/VECTOAux/VectoAuxiliaries/Hvac/IEnvironmentalConditionsMap.vb index 2b873ff82f0436eb4a683f85427c0f671ca2732d..9100921176c265fee2d65503e642f71d12768827 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/IEnvironmentalConditionsMap.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/IEnvironmentalConditionsMap.vb @@ -1,11 +1,7 @@ Namespace Hvac + Public Interface IEnvironmentalConditionsMap + Function Initialise() As Boolean - Public Interface IEnvironmentalConditionsMap - - Function Initialise() As Boolean - - Function GetEnvironmentalConditions() As List(Of IEnvironmentalCondition) - - End Interface - + Function GetEnvironmentalConditions() As List(Of IEnvironmentalCondition) + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Hvac/IHVACConstants.vb b/VECTOAux/VectoAuxiliaries/Hvac/IHVACConstants.vb index f8af7548ecb9e135726d9ff6a63bbfb581dcdedd..7748f5a9c39d26793239dfbc9f5f63986b427cbf 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/IHVACConstants.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/IHVACConstants.vb @@ -1,14 +1,25 @@ -Namespace Hvac - - - Public Interface IHVACConstants - - ReadOnly Property DieselGCVJperGram As Single - ReadOnly Property FuelDensity As Single - - End Interface - - +Imports TUGraz.VectoCommon.Utils + +Namespace Hvac + Public Interface IHVACConstants + ''' <summary> + ''' Diesel: 44800 [J/g] + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property DieselGCVJperGram As JoulePerKilogramm + + ''' <summary> + ''' 835 [g/l] + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + ReadOnly Property FuelDensity As KilogramPerCubicMeter + + ReadOnly Property FuelDensityAsGramPerLiter As Double + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Hvac/IHVACSteadyStateModel.vb b/VECTOAux/VectoAuxiliaries/Hvac/IHVACSteadyStateModel.vb index 287e6b50109fbdf4a6cc950c7614d904d2228da1..42e31edc0cbdec899faafb5324b45ebea59d6bd0 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/IHVACSteadyStateModel.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/IHVACSteadyStateModel.vb @@ -10,43 +10,40 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Namespace Hvac + Public Interface IHVACSteadyStateModel + ''' <summary> + ''' Initialised Values From Map + ''' </summary> + ''' <param name="filePath"></param> + ''' <param name="message"></param> + ''' <returns>True if successfull, and False if not.</returns> + ''' <remarks></remarks> + Function SetValuesFromMap(byval filePath As String, ByRef message As string) As Boolean - Public Interface IHVACSteadyStateModel - - - ''' <summary> -''' Initialised Values From Map -''' </summary> -''' <param name="filePath"></param> -''' <param name="message"></param> -''' <returns>True if successfull, and False if not.</returns> -''' <remarks></remarks> - Function SetValuesFromMap( byval filePath As String , ByRef message As string) As Boolean - - ''' <summary> -''' HVAC Mechanical Load Power (W) -''' </summary> -''' <value></value> -''' <returns></returns> -''' <remarks></remarks> - Property HVACMechanicalLoadPowerWatts As Single - ''' <summary> -''' HVAC Electrical Load Power (W) -''' </summary> -''' <value></value> -''' <returns></returns> -''' <remarks></remarks> - Property HVACElectricalLoadPowerWatts As Single - ''' <summary> -''' HVAC Fuelling (L/H) -''' </summary> -''' <value></value> -''' <returns>Liters per hour</returns> -''' <remarks></remarks> - Property HVACFuellingLitresPerHour As single + ''' <summary> + ''' HVAC Mechanical Load Power (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property HVACMechanicalLoadPowerWatts As Single -End Interface + ''' <summary> + ''' HVAC Electrical Load Power (W) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property HVACElectricalLoadPowerWatts As Single + ''' <summary> + ''' HVAC Fuelling (L/H) + ''' </summary> + ''' <value></value> + ''' <returns>Liters per hour</returns> + ''' <remarks></remarks> + Property HVACFuellingLitresPerHour As single + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Hvac/IHVACUserInputsConfig.vb b/VECTOAux/VectoAuxiliaries/Hvac/IHVACUserInputsConfig.vb index f37642d95a505a2cd0584d15ef81eae51af508fe..e9216c80ff98cc096c71dd49625de9a2f0e2e63e 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/IHVACUserInputsConfig.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/IHVACUserInputsConfig.vb @@ -14,24 +14,20 @@ Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Hvac Namespace Hvac - - Public Interface IHVACUserInputsConfig - - ' Property SteadyStateModel As IHVACSteadyStateModel - ''' <summary> - ''' PathName of the Steady State Model File - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property SSMFilePath As String - - Property BusDatabasePath As String - - Property SSMDisabled As Boolean - - End Interface - + Public Interface IHVACUserInputsConfig + ' Property SteadyStateModel As IHVACSteadyStateModel + ''' <summary> + ''' PathName of the Steady State Model File + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property SSMFilePath As String + + Property BusDatabasePath As String + + Property SSMDisabled As Boolean + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Hvac/IM1_AverageHVACLoadDemand.vb b/VECTOAux/VectoAuxiliaries/Hvac/IM1_AverageHVACLoadDemand.vb index f3e26a9079fde88bbfc3e5dcbc03516f1ca143a3..36c741a55bfaa68183e97fc6d60d3f96ee6566e1 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/IM1_AverageHVACLoadDemand.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/IM1_AverageHVACLoadDemand.vb @@ -8,38 +8,38 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Hvac + Public Interface IM1_AverageHVACLoadDemand + ''' <summary> + ''' Average Power Demand At Crank From HVAC Mechanicals (W) + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function AveragePowerDemandAtCrankFromHVACMechanicalsWatts() As Watt - Public Interface IM1_AverageHVACLoadDemand + ''' <summary> + ''' Average Power Demand At Alternator From HVAC Electrics (W) + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function AveragePowerDemandAtAlternatorFromHVACElectricsWatts() As Watt - ''' <summary> - ''' Average Power Demand At Crank From HVAC Mechanicals (W) - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function AveragePowerDemandAtCrankFromHVACMechanicalsWatts() As Single - ''' <summary> - ''' Average Power Demand At Alternator From HVAC Electrics (W) - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function AveragePowerDemandAtAlternatorFromHVACElectricsWatts() As Single - ''' <summary> - ''' Average Power Demand At Crank From HVAC Electrics (W) - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function AveragePowerDemandAtCrankFromHVACElectricsWatts() As Single - ''' <summary> - ''' HVAC Fueling (L/H) - ''' </summary> - ''' <returns>Litres Per Hour</returns> - ''' <remarks></remarks> - Function HVACFuelingLitresPerHour() As Single - -End Interface + ''' <summary> + ''' Average Power Demand At Crank From HVAC Electrics (W) + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function AveragePowerDemandAtCrankFromHVACElectricsWatts() As Watt + ''' <summary> + ''' HVAC Fueling (L/H) + ''' </summary> + ''' <returns>Litres Per Hour</returns> + ''' <remarks></remarks> + Function HVACFuelingLitresPerHour() As LiterPerSecond + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Hvac/ISSMCalculate.vb b/VECTOAux/VectoAuxiliaries/Hvac/ISSMCalculate.vb index b70ec8b5f25bc5c7358ebaf223cdc51db522d362..97deff4a13e7b956f7d74d823a934d5606296924 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/ISSMCalculate.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/ISSMCalculate.vb @@ -1,61 +1,61 @@ Namespace Hvac - Public Interface ISSMCalculate + Public Interface ISSMCalculate - Property Run1 As ISSMRun - Property Run2 As ISSMRun + Property Run1 As ISSMRun + Property Run2 As ISSMRun - ReadOnly Property ElectricalWBase As Single - ReadOnly Property MechanicalWBase As Single - ReadOnly Property FuelPerHBase As Single + ReadOnly Property ElectricalWBase As Double + ReadOnly Property MechanicalWBase As Double + ReadOnly Property FuelPerHBase As Double - ReadOnly Property ElectricalWAdjusted As Single - ReadOnly Property MechanicalWBaseAdjusted As Single - ReadOnly Property FuelPerHBaseAdjusted As Single + ReadOnly Property ElectricalWAdjusted As Double + ReadOnly Property MechanicalWBaseAdjusted As Double + ReadOnly Property FuelPerHBaseAdjusted As Double - 'BaseValues - '- Heating - ReadOnly Property BaseHeatingW_Mechanical As Double - ReadOnly Property BaseHeatingW_ElectricalCoolingHeating As Double - ReadOnly Property BaseHeatingW_ElectricalVentilation As Double - ReadOnly Property BaseHeatingW_FuelFiredHeating As Double + 'BaseValues + '- Heating + ReadOnly Property BaseHeatingW_Mechanical As Double + ReadOnly Property BaseHeatingW_ElectricalCoolingHeating As Double + ReadOnly Property BaseHeatingW_ElectricalVentilation As Double + ReadOnly Property BaseHeatingW_FuelFiredHeating As Double - 'Cooling - ReadOnly Property BaseCoolingW_Mechanical As Double - ReadOnly Property BaseCoolingW_ElectricalCoolingHeating As Double - ReadOnly Property BaseCoolingW_ElectricalVentilation As Double - ReadOnly Property BaseCoolingW_FuelFiredHeating As Double + 'Cooling + ReadOnly Property BaseCoolingW_Mechanical As Double + ReadOnly Property BaseCoolingW_ElectricalCoolingHeating As Double + ReadOnly Property BaseCoolingW_ElectricalVentilation As Double + ReadOnly Property BaseCoolingW_FuelFiredHeating As Double - 'Cooling - ReadOnly Property BaseVentilationW_Mechanical As Double - ReadOnly Property BaseVentilationW_ElectricalCoolingHeating As Double - ReadOnly Property BaseVentilationW_ElectricalVentilation As Double - ReadOnly Property BaseVentilationW_FuelFiredHeating As Double + 'Cooling + ReadOnly Property BaseVentilationW_Mechanical As Double + ReadOnly Property BaseVentilationW_ElectricalCoolingHeating As Double + ReadOnly Property BaseVentilationW_ElectricalVentilation As Double + ReadOnly Property BaseVentilationW_FuelFiredHeating As Double - 'TechListBenefits - '- Heating - ReadOnly Property TechListAdjustedHeatingW_Mechanical As Double - ReadOnly Property TechListAdjustedHeatingW_ElectricalCoolingHeating As Double - ReadOnly Property TechListAdjustedHeatingW_ElectricalVentilation As Double - ReadOnly Property TechListAdjustedHeatingW_FuelFiredHeating As Double + 'TechListBenefits + '- Heating + ReadOnly Property TechListAdjustedHeatingW_Mechanical As Double + ReadOnly Property TechListAdjustedHeatingW_ElectricalCoolingHeating As Double + ReadOnly Property TechListAdjustedHeatingW_ElectricalVentilation As Double + ReadOnly Property TechListAdjustedHeatingW_FuelFiredHeating As Double - 'Cooling TechListAdjusted - ReadOnly Property TechListAdjustedCoolingW_Mechanical As Double - ReadOnly Property TechListAdjustedCoolingW_ElectricalCoolingHeating As Double - ReadOnly Property TechListAdjustedCoolingW_ElectricalVentilation As Double - ReadOnly Property TechListAdjustedCoolingW_FuelFiredHeating As Double + 'Cooling TechListAdjusted + ReadOnly Property TechListAdjustedCoolingW_Mechanical As Double + ReadOnly Property TechListAdjustedCoolingW_ElectricalCoolingHeating As Double + ReadOnly Property TechListAdjustedCoolingW_ElectricalVentilation As Double + ReadOnly Property TechListAdjustedCoolingW_FuelFiredHeating As Double - 'Cooling TechListAdjusted - ReadOnly Property TechListAdjustedVentilationW_Mechanical As Double - ReadOnly Property TechListAdjustedVentilationW_ElectricalCoolingHeating As Double - ReadOnly Property TechListAdjustedVentilationW_ElectricalVentilation As Double - ReadOnly Property TechListAdjustedVentilationW_FuelFiredHeating As Double + 'Cooling TechListAdjusted + ReadOnly Property TechListAdjustedVentilationW_Mechanical As Double + ReadOnly Property TechListAdjustedVentilationW_ElectricalCoolingHeating As Double + ReadOnly Property TechListAdjustedVentilationW_ElectricalVentilation As Double + ReadOnly Property TechListAdjustedVentilationW_FuelFiredHeating As Double - End Interface + End Interface diff --git a/VECTOAux/VectoAuxiliaries/Hvac/ISSMGenInputs.vb b/VECTOAux/VectoAuxiliaries/Hvac/ISSMGenInputs.vb index 66cacc7bb415e3e1d0f0cc9284428c1d0e650caa..ccb3f0501447079e691dd62f5485bfda4424773d 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/ISSMGenInputs.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/ISSMGenInputs.vb @@ -1,76 +1,76 @@  Namespace Hvac - Public Interface ISSMGenInputs + Public Interface ISSMGenInputs - 'Bus Parameterisation - Property BP_BusModel As String - Property BP_NumberOfPassengers As Double - Property BP_BusFloorType As String - Property BP_DoubleDecker As Boolean - Property BP_BusLength As Double - Property BP_BusWidth As Double - Property BP_BusHeight As Double + 'Bus Parameterisation + Property BP_BusModel As String + Property BP_NumberOfPassengers As Double + Property BP_BusFloorType As String + Property BP_DoubleDecker As Boolean + Property BP_BusLength As Double + Property BP_BusWidth As Double + Property BP_BusHeight As Double - ReadOnly Property BP_BusFloorSurfaceArea As Double - ReadOnly Property BP_BusWindowSurface As Double - ReadOnly Property BP_BusSurfaceAreaM2 As Double - ReadOnly Property BP_BusVolume As Double + ReadOnly Property BP_BusFloorSurfaceArea As Double + ReadOnly Property BP_BusWindowSurface As Double + ReadOnly Property BP_BusSurfaceAreaM2 As Double + ReadOnly Property BP_BusVolume As Double - 'Boundary Conditions: - Property BC_GFactor As Double - ReadOnly Property BC_SolarClouding As Double - ReadOnly Property BC_HeatPerPassengerIntoCabinW As Double - Property BC_PassengerBoundaryTemperature As Double - ReadOnly Property BC_PassengerDensityLowFloor As Double - ReadOnly Property BC_PassengerDensitySemiLowFloor As Double - ReadOnly Property BC_PassengerDensityRaisedFloor As Double - ReadOnly Property BC_CalculatedPassengerNumber As Double - ReadOnly Property BC_UValues As Double - Property BC_HeatingBoundaryTemperature As Double - Property BC_CoolingBoundaryTemperature As Double - ReadOnly Property BC_TemperatureCoolingTurnsOff As Double - Property BC_HighVentilation As Double - Property BC_lowVentilation As Double - ReadOnly Property BC_High As Double - ReadOnly Property BC_Low As Double - ReadOnly Property BC_HighVentPowerW As Double - ReadOnly Property BC_LowVentPowerW As Double - Property BC_SpecificVentilationPower As Double - Property BC_AuxHeaterEfficiency As Double - Property BC_GCVDieselOrHeatingOil As Double - ReadOnly Property BC_WindowAreaPerUnitBusLength As Double - ReadOnly Property BC_FrontRearWindowArea As Double - Property BC_MaxTemperatureDeltaForLowFloorBusses As Double - Property BC_MaxPossibleBenefitFromTechnologyList As Double + 'Boundary Conditions: + Property BC_GFactor As Double + ReadOnly Property BC_SolarClouding As Double + ReadOnly Property BC_HeatPerPassengerIntoCabinW As Double + Property BC_PassengerBoundaryTemperature As Double + ReadOnly Property BC_PassengerDensityLowFloor As Double + ReadOnly Property BC_PassengerDensitySemiLowFloor As Double + ReadOnly Property BC_PassengerDensityRaisedFloor As Double + ReadOnly Property BC_CalculatedPassengerNumber As Double + ReadOnly Property BC_UValues As Double + Property BC_HeatingBoundaryTemperature As Double + Property BC_CoolingBoundaryTemperature As Double + ReadOnly Property BC_TemperatureCoolingTurnsOff As Double + Property BC_HighVentilation As Double + Property BC_lowVentilation As Double + ReadOnly Property BC_High As Double + ReadOnly Property BC_Low As Double + ReadOnly Property BC_HighVentPowerW As Double + ReadOnly Property BC_LowVentPowerW As Double + Property BC_SpecificVentilationPower As Double + Property BC_AuxHeaterEfficiency As Double + Property BC_GCVDieselOrHeatingOil As Double + ReadOnly Property BC_WindowAreaPerUnitBusLength As Double + ReadOnly Property BC_FrontRearWindowArea As Double + Property BC_MaxTemperatureDeltaForLowFloorBusses As Double + Property BC_MaxPossibleBenefitFromTechnologyList As Double - 'EnviromentalConditions - Property EC_EnviromentalTemperature As Double - Property EC_Solar As Double - ReadOnly Property EC_EnvironmentalConditionsMap As IEnvironmentalConditionsMap - Property EC_EnviromentalConditions_BatchFile As String - Property EC_EnviromentalConditions_BatchEnabled As Boolean + 'EnviromentalConditions + Property EC_EnviromentalTemperature As Double + Property EC_Solar As Double + ReadOnly Property EC_EnvironmentalConditionsMap As IEnvironmentalConditionsMap + Property EC_EnviromentalConditions_BatchFile As String + Property EC_EnviromentalConditions_BatchEnabled As Boolean - 'AC-system - Property AC_CompressorType As String - ReadOnly Property AC_CompressorTypeDerived As String - Property AC_CompressorCapacitykW As Double - ReadOnly Property AC_COP As Double + 'AC-system + Property AC_CompressorType As String + ReadOnly Property AC_CompressorTypeDerived As String + Property AC_CompressorCapacitykW As Double + ReadOnly Property AC_COP As Double - 'Ventilation - Property VEN_VentilationOnDuringHeating As Boolean - Property VEN_VentilationWhenBothHeatingAndACInactive As Boolean - Property VEN_VentilationDuringAC As Boolean - Property VEN_VentilationFlowSettingWhenHeatingAndACInactive As String - Property VEN_VentilationDuringHeating As String - Property VEN_VentilationDuringCooling As String + 'Ventilation + Property VEN_VentilationOnDuringHeating As Boolean + Property VEN_VentilationWhenBothHeatingAndACInactive As Boolean + Property VEN_VentilationDuringAC As Boolean + Property VEN_VentilationFlowSettingWhenHeatingAndACInactive As String + Property VEN_VentilationDuringHeating As String + Property VEN_VentilationDuringCooling As String - 'Aux. Heater - Property AH_EngineWasteHeatkW As Double - Property AH_FuelFiredHeaterkW As Double - Property AH_FuelEnergyToHeatToCoolant As Double - Property AH_CoolantHeatTransferredToAirCabinHeater As Double - End Interface + 'Aux. Heater + Property AH_EngineWasteHeatkW As Double + Property AH_FuelFiredHeaterkW As Double + Property AH_FuelEnergyToHeatToCoolant As Double + Property AH_CoolantHeatTransferredToAirCabinHeater As Double + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Hvac/ISSMRun.vb b/VECTOAux/VectoAuxiliaries/Hvac/ISSMRun.vb index e13032558d844abb64af9d97853e1653c18bb4ed..35ebc4d1ad7f4aa868e3ad6fc0f32661b4a2ccd9 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/ISSMRun.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/ISSMRun.vb @@ -2,20 +2,20 @@ Namespace Hvac -Public Interface ISSMRun - - ReadOnly Property HVACOperation As Double - ReadOnly Property TCalc As Double - ReadOnly Property TemperatureDelta as Double - ReadOnly Property QWall as Double - ReadOnly Property WattsPerPass as double - ReadOnly Property Solar as double - ReadOnly Property TotalW as double - ReadOnly Property TotalKW as double - ReadOnly Property FuelW as double - ReadOnly Property TechListAmendedFuelW as double - -End Interface + Public Interface ISSMRun + + ReadOnly Property HVACOperation As Double + ReadOnly Property TCalc As Double + ReadOnly Property TemperatureDelta As Double + ReadOnly Property QWall As Double + ReadOnly Property WattsPerPass As Double + ReadOnly Property Solar As Double + ReadOnly Property TotalW As Double + ReadOnly Property TotalKW As Double + ReadOnly Property FuelW As Double + ReadOnly Property TechListAmendedFuelW As Double + + End Interface diff --git a/VECTOAux/VectoAuxiliaries/Hvac/ISSMTOOL.vb b/VECTOAux/VectoAuxiliaries/Hvac/ISSMTOOL.vb index 03c0271f82f167750091f1d1d7968931a83db477..8083b01d6bc13fac7f4b000229a89ffda35e9bd9 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/ISSMTOOL.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/ISSMTOOL.vb @@ -1,38 +1,36 @@ -Imports VectoAuxiliaries.Hvac +Imports TUGraz.VectoCommon.Utils +Imports VectoAuxiliaries.Hvac Public Interface ISSMTOOL + Property GenInputs As ISSMGenInputs + Property TechList As ISSMTechList + Property Calculate As ISSMCalculate + Property SSMDisabled As Boolean + Property HVACConstants As IHVACConstants + ReadOnly Property ElectricalWBase As Double 'Watt + ReadOnly Property MechanicalWBase As Double ' Watt + ReadOnly Property FuelPerHBase As Double ' LiterPerHour - Property GenInputs As ISSMGenInputs - Property TechList As ISSMTechList - Property Calculate As ISSMCalculate - Property SSMDisabled As Boolean - Property HVACConstants As IHVACConstants + ReadOnly Property ElectricalWAdjusted As Double ' Watt + ReadOnly Property MechanicalWBaseAdjusted As Double ' Watt + ReadOnly Property FuelPerHBaseAdjusted As Double ' LiterPerHour - ReadOnly Property ElectricalWBase As Single - ReadOnly Property MechanicalWBase As Single - ReadOnly Property FuelPerHBase As Single + Sub Clone(from As ISSMTOOL) - ReadOnly Property ElectricalWAdjusted As Single - ReadOnly Property MechanicalWBaseAdjusted As Single - ReadOnly Property FuelPerHBaseAdjusted As Single + Function Load(filePath As String) As Boolean - Sub Clone(from As ISSMTOOL) + Function Save(filePath As String) As Boolean - Function Load(filePath As String) As Boolean + Function IsEqualTo(source As ISSMTOOL) As Boolean - Function Save(filePath As String) As Boolean - - Function IsEqualTo(source As ISSMTOOL) As Boolean - - ''' <summary> - ''' This alters the waste heat and returns an adjusted fueling value - ''' </summary> - ''' <param name="AverageUseableEngineWasteHeatKW"></param> - ''' <returns></returns> - ''' <remarks></remarks> - Function FuelPerHBaseAsjusted(AverageUseableEngineWasteHeatKW As Single) As Single - - Event Message(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) + ''' <summary> + ''' This alters the waste heat and returns an adjusted fueling value + ''' </summary> + ''' <param name="AverageUseableEngineWasteHeatKW"></param> + ''' <returns></returns> + ''' <remarks></remarks> + Function FuelPerHBaseAsjusted(AverageUseableEngineWasteHeatKW As Double) As Double + Event Message(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) End Interface diff --git a/VECTOAux/VectoAuxiliaries/Hvac/ISSMTechList.vb b/VECTOAux/VectoAuxiliaries/Hvac/ISSMTechList.vb index 4f030766a8dd7406b6bc33c997cec43e4cfa5340..781f3aa8aa988ebb422c4cb23cbdf12fe0b1fab9 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/ISSMTechList.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/ISSMTechList.vb @@ -1,37 +1,37 @@  Namespace Hvac -Public Interface ISSMTechList + Public Interface ISSMTechList - property TechLines As List(Of ITechListBenefitLine) + Property TechLines As List(Of ITechListBenefitLine) - Sub Clear() - Function Add( item As ITechListBenefitLine, byref feedback as String) As Boolean - Function Delete( item As ITechListBenefitLine, byref feedback as String) As Boolean - Function Modify( originalItem As ITechListBenefitLine, modifiedItem As ITechListBenefitLine, byref feedback as String) As Boolean + Sub Clear() + Function Add(item As ITechListBenefitLine, ByRef feedback As String) As Boolean + Function Delete(item As ITechListBenefitLine, ByRef feedback As String) As Boolean + Function Modify(originalItem As ITechListBenefitLine, modifiedItem As ITechListBenefitLine, ByRef feedback As String) As Boolean - Sub SetSSMGeneralInputs( genInputs As ISSMGenInputs) + Sub SetSSMGeneralInputs(genInputs As ISSMGenInputs) - ReadOnly Property HValueVariation As Double - ReadOnly Property VHValueVariation As Double - ReadOnly Property VVValueVariation As Double - ReadOnly Property VCValueVariation As Double - ReadOnly Property CValueVariation As Double + ReadOnly Property HValueVariation As Double + ReadOnly Property VHValueVariation As Double + ReadOnly Property VVValueVariation As Double + ReadOnly Property VCValueVariation As Double + ReadOnly Property CValueVariation As Double - ReadOnly Property HValueVariationKW As Double - ReadOnly Property VHValueVariationKW As Double - ReadOnly Property VVValueVariationKW As Double - ReadOnly Property VCValueVariationKW As Double - ReadOnly Property CValueVariationKW As Double + ReadOnly Property HValueVariationKW As Double + ReadOnly Property VHValueVariationKW As Double + ReadOnly Property VVValueVariationKW As Double + ReadOnly Property VCValueVariationKW As Double + ReadOnly Property CValueVariationKW As Double - Function Initialise() As Boolean - Function Initialise( filePath As String ) As Boolean + Function Initialise() As Boolean + Function Initialise(filePath As String) As Boolean -End Interface + End Interface diff --git a/VECTOAux/VectoAuxiliaries/Hvac/ITechListBenefitLine.vb b/VECTOAux/VectoAuxiliaries/Hvac/ITechListBenefitLine.vb index 3c54ae981be6a3b70560862e04992b0cc3d73bb0..216a9c55409455a14178da0d0c47922c8d845c5a 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/ITechListBenefitLine.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/ITechListBenefitLine.vb @@ -1,46 +1,37 @@ Namespace Hvac - - -Public Interface ITechListBenefitLine - - Property Units As string - Property Category As String - Property BenefitName As String - - Property LowFloorH As double - Property LowFloorV As double - Property LowFloorC As double - - Property SemiLowFloorH As double - Property SemiLowFloorV As double - Property SemiLowFloorC As double - - Property RaisedFloorH As double - Property RaisedFloorV As double - Property RaisedFloorC As double - - Property OnVehicle As Boolean - Property ActiveVH As Boolean - Property ActiveVV As Boolean - Property ActiveVC As Boolean - Property LineType As TechLineType - - ReadOnly Property H As Single - ReadOnly Property VH As Single - ReadOnly Property VV As Single - ReadOnly Property VC As Single - ReadOnly Property C As Single - - Sub CloneFrom( source As ITechListBenefitLine) - - Function IsEqualTo(source As ITechListBenefitLine ) As Boolean - - - -End Interface - - + Public Interface ITechListBenefitLine + Property Units As string + Property Category As String + Property BenefitName As String + + Property LowFloorH As double + Property LowFloorV As double + Property LowFloorC As double + + Property SemiLowFloorH As double + Property SemiLowFloorV As double + Property SemiLowFloorC As double + + Property RaisedFloorH As double + Property RaisedFloorV As double + Property RaisedFloorC As double + + Property OnVehicle As Boolean + Property ActiveVH As Boolean + Property ActiveVV As Boolean + Property ActiveVC As Boolean + Property LineType As TechLineType + + ReadOnly Property H As Double + ReadOnly Property VH As Double + ReadOnly Property VV As Double + ReadOnly Property VC As Double + ReadOnly Property C As Double + + Sub CloneFrom(source As ITechListBenefitLine) + + Function IsEqualTo(source As ITechListBenefitLine) As Boolean + End Interface End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/M1_AverageHVACLoadDemand.vb b/VECTOAux/VectoAuxiliaries/Hvac/M1_AverageHVACLoadDemand.vb index 1eff8cc66d627310215202c2b03c21c5a30889f2..8e3afcc9a5b73fad3f5d6518c7cca779c52bc58e 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/M1_AverageHVACLoadDemand.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/M1_AverageHVACLoadDemand.vb @@ -9,85 +9,90 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Namespace Hvac + Public Class M1_AverageHVACLoadDemand + Implements IM1_AverageHVACLoadDemand - Public Class M1_AverageHVACLoadDemand - Implements IM1_AverageHVACLoadDemand + Private _m0 As IM0_NonSmart_AlternatorsSetEfficiency + Private _alternatorGearEfficiency As Double + Private _compressorGearEfficiency As Double + Private _signals As ISignals + Private _powernetVoltage As Volt + Private _steadyStateModel As ISSMTOOL - - Private _m0 As IM0_NonSmart_AlternatorsSetEfficiency - Private _alternatorGearEfficiency As Single - Private _compressorGearEfficiency As Single - Private _signals As ISignals - Private _powernetVoltage As Single - Private _steadyStateModel As ISSMTOOL + Private _ElectricalPowerW As Watt + Private _MechanicalPowerW As Watt + Private _FuelingLPerH As LiterPerSecond - Private _ElectricalPowerW As Single - Private _MechanicalPowerW As Single - Private _FuelingLPerH As Single - - - 'Constructor - Public Sub New(m0 As IM0_NonSmart_AlternatorsSetEfficiency, altGearEfficiency As Single, compressorGearEfficiency As Single, powernetVoltage As Single, signals As ISignals, ssm As ISSMTOOL) + 'Constructor + Public Sub New(m0 As IM0_NonSmart_AlternatorsSetEfficiency, altGearEfficiency As Double, + compressorGearEfficiency As Double, powernetVoltage As Volt, signals As ISignals, ssm As ISSMTOOL) - 'Sanity Check - Illegal operations without all params. - If m0 Is Nothing Then Throw New ArgumentException("Module0 as supplied is null") + 'Sanity Check - Illegal operations without all params. + If m0 Is Nothing Then Throw New ArgumentException("Module0 as supplied is null") - If altGearEfficiency < ElectricConstants.AlternatorPulleyEfficiencyMin OrElse altGearEfficiency > ElectricConstants.AlternatorPulleyEfficiencyMax Then _ - Throw New ArgumentException(String.Format("Gear efficiency must be between {0} and {1}", ElectricConstants.AlternatorPulleyEfficiencyMin, ElectricConstants.AlternatorPulleyEfficiencyMax)) + If _ + altGearEfficiency < ElectricConstants.AlternatorPulleyEfficiencyMin OrElse + altGearEfficiency > ElectricConstants.AlternatorPulleyEfficiencyMax Then _ + Throw _ + New ArgumentException(String.Format("Gear efficiency must be between {0} and {1}", + ElectricConstants.AlternatorPulleyEfficiencyMin, ElectricConstants.AlternatorPulleyEfficiencyMax)) - If signals Is Nothing Then Throw New Exception("Signals object as supplied is null") - If powernetVoltage < ElectricConstants.PowenetVoltageMin OrElse powernetVoltage > ElectricConstants.PowenetVoltageMax Then _ - Throw New ArgumentException(String.Format("PowenetVoltage supplied must be in the range {0} to {1}", ElectricConstants.PowenetVoltageMin, ElectricConstants.PowenetVoltageMax)) - If ssm Is Nothing Then Throw New ArgumentException("Steady State model was not supplied") - If compressorGearEfficiency < 0 OrElse altGearEfficiency > 1 Then _ - Throw New ArgumentException(String.Format("Compressor Gear efficiency must be between {0} and {1}", 0, 1)) + If signals Is Nothing Then Throw New Exception("Signals object as supplied is null") + If powernetVoltage < ElectricConstants.PowenetVoltageMin OrElse powernetVoltage > ElectricConstants.PowenetVoltageMax _ + Then _ + Throw _ + New ArgumentException(String.Format("PowenetVoltage supplied must be in the range {0} to {1}", + ElectricConstants.PowenetVoltageMin, ElectricConstants.PowenetVoltageMax)) + If ssm Is Nothing Then Throw New ArgumentException("Steady State model was not supplied") + If compressorGearEfficiency < 0 OrElse altGearEfficiency > 1 Then _ + Throw New ArgumentException(String.Format("Compressor Gear efficiency must be between {0} and {1}", 0, 1)) - 'Assign - _m0 = m0 - _alternatorGearEfficiency = altGearEfficiency - _signals = signals - - _compressorGearEfficiency = compressorGearEfficiency - _powernetVoltage = powernetVoltage + 'Assign + _m0 = m0 + _alternatorGearEfficiency = altGearEfficiency + _signals = signals + _compressorGearEfficiency = compressorGearEfficiency + _powernetVoltage = powernetVoltage - _steadyStateModel = ssm - _ElectricalPowerW = ssm.ElectricalWAdjusted - _MechanicalPowerW = ssm.MechanicalWBaseAdjusted - _FuelingLPerH = ssm.FuelPerHBaseAdjusted + _steadyStateModel = ssm - End Sub - - 'Public Methods - Implementation - Public Function AveragePowerDemandAtCrankFromHVACMechanicalsWatts() As Single Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtCrankFromHVACMechanicalsWatts + _ElectricalPowerW = ssm.ElectricalWAdjusted.SI(Of Watt)() + _MechanicalPowerW = ssm.MechanicalWBaseAdjusted.SI(Of Watt)() + _FuelingLPerH = ssm.FuelPerHBaseAdjusted.SI().Liter.Per.Hour.Cast(Of LiterPerSecond)() ' SI(Of LiterPerHour)() + End Sub - Return _MechanicalPowerW/ _compressorGearEfficiency + 'Public Methods - Implementation + Public Function AveragePowerDemandAtCrankFromHVACMechanicalsWatts() As Watt _ + Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtCrankFromHVACMechanicalsWatts - End Function - Public Function AveragePowerDemandAtAlternatorFromHVACElectricsWatts() As Single Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtAlternatorFromHVACElectricsWatts + Return _MechanicalPowerW * (1 / _compressorGearEfficiency) + End Function - Return _ElectricalPowerW + Public Function AveragePowerDemandAtAlternatorFromHVACElectricsWatts() As Watt _ + Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtAlternatorFromHVACElectricsWatts - End Function - Public Function AveragePowerDemandAtCrankFromHVACElectricsWatts() As Single Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtCrankFromHVACElectricsWatts + Return _ElectricalPowerW + End Function - Return _ElectricalPowerW / _m0.AlternatorsEfficiency() / _alternatorGearEfficiency + Public Function AveragePowerDemandAtCrankFromHVACElectricsWatts() As Watt _ + Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtCrankFromHVACElectricsWatts - End Function - Public Function HVACFuelingLitresPerHour() As Single Implements IM1_AverageHVACLoadDemand.HVACFuelingLitresPerHour + Return _ElectricalPowerW * (1 / _m0.AlternatorsEfficiency() / _alternatorGearEfficiency) + End Function - Return _FuelingLPerH - - End Function - - - End Class + Public Function HVACFuelingLitresPerHour() As LiterPerSecond _ + Implements IM1_AverageHVACLoadDemand.HVACFuelingLitresPerHour + Return _FuelingLPerH + End Function + End Class End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMCalculate.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMCalculate.vb index bdb56f36ed1451a3dadb6c97e121bc48ef6e6a93..12b5ac6feaba175e3b03d1099b9cad394e8b699b 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMCalculate.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/SSMCalculate.vb @@ -3,689 +3,793 @@ Imports Microsoft.VisualBasic Imports VectoAuxiliaries.Hvac Namespace Hvac + 'Modeling SSHVAC V07 + Public Class SSMCalculate + Implements ISSMCalculate - '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 - 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) - 'Constructor - Sub New(ssmTool As ISSMTOOL) - - Me.ssmTOOL = ssmTool - Run1 = New SSMRun(Me.ssmTOOL, 1) - Run2 = New SSMRun(Me.ssmTOOL, 2) - - End Sub + 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 Single Implements ISSMCalculate.ElectricalWBase - Get - - Dim ElectricalWBaseWeightedAverage As Single - 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 Single Implements ISSMCalculate.MechanicalWBase - Get - - Dim MechanicalWBaseWeightedAverage As Single - 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 FuelLPerHBase As Single Implements ISSMCalculate.FuelPerHBase - Get - - Dim FuelLPerHBaseWeightedAverage As Single - 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 Single Implements ISSMCalculate.ElectricalWAdjusted - Get - Dim ElectricalWAdjustedAverage As Single - 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 Single Implements ISSMCalculate.MechanicalWBaseAdjusted - Get - - Dim MechanicalWBaseAdjustedAverage As Single - 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 FuelLPerHBaseAdjusted As Single Implements ISSMCalculate.FuelPerHBaseAdjusted - Get - Dim FuelLPerHBaseAdjustedAverage As Single - 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 + '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 + '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 + '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 - sb.AppendLine(String.Format(Space(firstValuePos) + "H{0}VH{0}VV{0}VC{0}C{0}", vbtab)) + 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 - For Each line As ITechListBenefitLine In ssmTOOL.TechList.TechLines + sb.AppendLine(String.Format(Space(firstValuePos) + "H{0}VH{0}VV{0}VC{0}C{0}", vbtab)) - With line - Dim extraNameSpaces, extraCatSpaces, extraUnitSpaces As Integer + For Each line As ITechListBenefitLine In ssmTOOL.TechList.TechLines - extraNameSpaces = nameLength - .BenefitName.Length - extraCatSpaces = catLength - .Category.Length - extraUnitSpaces = unitLength - .Units.Length + With line - 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(" ", ".") + Dim extraNameSpaces, extraCatSpaces, extraUnitSpaces As Integer - 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"))) + extraNameSpaces = nameLength - .BenefitName.Length + extraCatSpaces = catLength - .Category.Length + extraUnitSpaces = unitLength - .Units.Length - End With + 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(" ", ".") - Next + 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"))) - sb.AppendLine("") - sb.AppendLine("TechList Totals") - sb.AppendLine("***********************") + End With - With ssmTOOL.TechList + Next - 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"))) + sb.AppendLine("") + sb.AppendLine("TechList Totals") + sb.AppendLine("***********************") - End With + 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") + 'Runs + sb.AppendLine(Run1.ToString()) + sb.AppendLine(Run2.ToString()) - 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"))) + '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("") - sb.AppendLine("Staging Adjusted Values") - sb.AppendLine("***********************") + 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(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"))) + 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() + Return sb.ToString() + End Function - End Function + Private Function CalculateElectricalWBase(genInputs As ISSMGenInputs, EnviromentalTemperature As Double, + Solar As Double, Weight As Double) As Double - Private Function CalculateElectricalWBase(genInputs As ISSMGenInputs, EnviromentalTemperature As Double, Solar As Double, Weight As Single) As Single + 'MIN(SUM(H94),C54*1000)/C59+SUM(I93:I95) - 'MIN(SUM(H94),C54*1000)/C59+SUM(I93:I95) + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature + genInputs.EC_Solar = Solar - 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 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 - 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 - Return ElectricalWBaseCurrentResult * Weight + Private Function CalculateMechanicalWBase(genInputs As ISSMGenInputs, EnviromentalTemperature As Double, + Solar As Double, Weight As Double) As Double - End Function + '=MIN(F94,C54*1000)/C59 - Private Function CalculateMechanicalWBase(genInputs As ISSMGenInputs, EnviromentalTemperature As Double, Solar As Double, Weight As Single) As Single + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature + genInputs.EC_Solar = Solar - '=MIN(F94,C54*1000)/C59 + 'Dim F94 = BaseCoolingW_Mechanical + 'Dim C54 = genInputs.AC_CompressorCapacitykW + 'Dim C59 = genInputs.AC_COP - genInputs.EC_EnviromentalTemperature = EnviromentalTemperature - genInputs.EC_Solar = Solar + Dim MechanicalWBaseCurrentResult As Double = + Math.Min(BaseCoolingW_Mechanical, genInputs.AC_CompressorCapacitykW * 1000) / genInputs.AC_COP - 'Dim F94 = BaseCoolingW_Mechanical - 'Dim C54 = genInputs.AC_CompressorCapacitykW - 'Dim C59 = genInputs.AC_COP + Return MechanicalWBaseCurrentResult * Weight + End Function - Dim MechanicalWBaseCurrentResult As Double = Math.Min(BaseCoolingW_Mechanical, genInputs.AC_CompressorCapacitykW * 1000) / genInputs.AC_COP + Private Function CalculateFuelLPerHBase(genInputs As ISSMGenInputs, EnviromentalTemperature As Double, Solar As Double, + Weight As Double) As Double - Return MechanicalWBaseCurrentResult * Weight + '=(MIN(ABS(J93/1000),C71)/C37)*(1/(C39*C38)) - End Function + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature + genInputs.EC_Solar = Solar - Private Function CalculateFuelLPerHBase(genInputs As ISSMGenInputs, EnviromentalTemperature As Double, Solar As Double, Weight As Single) As Single + 'Dim J93 = BaseHeatingW_FuelFiredHeating + 'Dim C71 = genInputs.AH_FuelFiredHeaterkW + 'Dim C37 = genInputs.BC_AuxHeaterEfficiency + 'Dim C39 = ssmTOOL.HVACConstants.FuelDensity + 'Dim C38 = genInputs.BC_GCVDieselOrHeatingOil - '=(MIN(ABS(J93/1000),C71)/C37)*(1/(C39*C38)) + Dim FuelLPerHBaseCurrentResult As Double = + (Math.Min(Math.Abs(BaseHeatingW_FuelFiredHeating / 1000), genInputs.AH_FuelFiredHeaterkW) / + genInputs.BC_AuxHeaterEfficiency) * + (1 / (genInputs.BC_GCVDieselOrHeatingOil * ssmTOOL.HVACConstants.FuelDensityAsGramPerLiter)) - genInputs.EC_EnviromentalTemperature = EnviromentalTemperature - genInputs.EC_Solar = Solar + Return FuelLPerHBaseCurrentResult * Weight + End Function - 'Dim J93 = BaseHeatingW_FuelFiredHeating - 'Dim C71 = genInputs.AH_FuelFiredHeaterkW - 'Dim C37 = genInputs.BC_AuxHeaterEfficiency - 'Dim C39 = ssmTOOL.HVACConstants.FuelDensity - 'Dim C38 = genInputs.BC_GCVDieselOrHeatingOil + Private Function CalculateElectricalWAdjusted(genInputs As ISSMGenInputs, tecList As ISSMTechList, + EnviromentalTemperature As Double, Solar As Double, Weight As Double) As Double - Dim FuelLPerHBaseCurrentResult As Double = (Math.Min(Math.Abs(BaseHeatingW_FuelFiredHeating / 1000), genInputs.AH_FuelFiredHeaterkW) / genInputs.BC_AuxHeaterEfficiency) * (1 / (genInputs.BC_GCVDieselOrHeatingOil * ssmTOOL.HVACConstants.FuelDensity)) + '=(MIN((H94*(1-H100)),C54*1000)/C59)+(I93*(1-I99))+(I94*(1-I100))+(I95*(1-I101)) - Return FuelLPerHBaseCurrentResult * Weight + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature + genInputs.EC_Solar = Solar - End Function + 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 - Private Function CalculateElectricalWAdjusted(genInputs As ISSMGenInputs, tecList As ISSMTechList, EnviromentalTemperature As Double, Solar As Double, Weight As Single) As Single + 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 - '=(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 ElectricalWAdjusted As Double = (Math.Min((H94 * (1 - H100)), C54 * 1000) / C59) + (I93 * (1 - I99)) + (I94 * (1 - I100)) + + (I95 * (1 - I101)) - 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 + Return ElectricalWAdjusted * Weight + End Function - 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 + Private Function CalculateMechanicalWBaseAdjusted(genInputs As ISSMGenInputs, tecList As ISSMTechList, + EnviromentalTemperature As Double, Solar As Double, Weight As Double) As Double - Dim ElectricalWAdjusted As Single = (Math.Min((H94 * (1 - H100)), C54 * 1000) / C59) + (I93 * (1 - I99)) + (I94 * (1 - I100)) + (I95 * (1 - I101)) + '=(MIN((F94*(1-F100)),C54*1000)/C59) - Return ElectricalWAdjusted * Weight + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature + genInputs.EC_Solar = Solar - End Function + 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 - Private Function CalculateMechanicalWBaseAdjusted(genInputs As ISSMGenInputs, tecList As ISSMTechList, EnviromentalTemperature As Double, Solar As Double, Weight As Single) As Single + Dim MechanicalWBaseAdjusted As Double = (Math.Min((F94 * (1 - F100)), C54 * 1000) / C59) - '=(MIN((F94*(1-F100)),C54*1000)/C59) - - genInputs.EC_EnviromentalTemperature = EnviromentalTemperature - genInputs.EC_Solar = Solar + Return MechanicalWBaseAdjusted * Weight + End Function - 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 + Private Function CalculateFuelLPerHBaseAdjusted(genInputs As ISSMGenInputs, tecList As ISSMTechList, + EnviromentalTemperature As Double, Solar As Double, Weight As Double) As Double - Dim MechanicalWBaseAdjusted As Single = (Math.Min((F94 * (1 - F100)), C54 * 1000) / C59) + '=MIN(ABS(IF(AND(M89<0,M90<0),VLOOKUP(MAX(M89:M90),M89:P90,4),0)/1000),C71)/C37*(1/(C39*C38)) - Return MechanicalWBaseAdjusted * Weight + genInputs.EC_EnviromentalTemperature = EnviromentalTemperature + genInputs.EC_Solar = Solar - End Function + '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 - Private Function CalculateFuelLPerHBaseAdjusted(genInputs As ISSMGenInputs, tecList As ISSMTechList, EnviromentalTemperature As Double, Solar As Double, Weight As Single) As Single - - '=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 Single = Math.Min(result, genInputs.AH_FuelFiredHeaterkW) / genInputs.BC_AuxHeaterEfficiency * (1 / (genInputs.BC_GCVDieselOrHeatingOil * ssmTOOL.HVACConstants.FuelDensity)) - - Return FuelLPerHBaseAdjusted * Weight - - End Function - End Class + 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 index b0c9f709160ed1bc152770cc18b91a6176ec7767..46f55fe022d97e145d71797805d51862dbb9c3ae 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMGenInputs.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/SSMGenInputs.vb @@ -1,416 +1,437 @@ Imports System.IO Namespace Hvac + 'Used by SSMHVAC Class + Public Class SSMGenInputs + Implements ISSMGenInputs - 'Used by SSMHVAC Class - Public Class SSMGenInputs - Implements ISSMGenInputs - - Private _EC_EnviromentalConditions_BatchFile As String - Private _EC_EnvironmentalConditionsMap As IEnvironmentalConditionsMap - Private _vectoDir As String + 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 - If initialiseDefaults Then SetDefaults() + Sub New(Optional initialiseDefaults As Boolean = False, Optional vectoDir As String = "") - End Sub + _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 + '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 + '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 + '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 + End Property - Public Property EC_EnviromentalConditions_BatchEnabled As Boolean Implements ISSMGenInputs.EC_EnviromentalConditions_BatchEnabled + 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 + '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 + '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 + '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 + '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 + '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 + '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 + '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 + '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 - 'C71 - ( KW ) - Public Property AH_FuelFiredHeaterkW As Double Implements ISSMGenInputs.AH_FuelFiredHeaterkW + Public Property AH_CoolantHeatTransferredToAirCabinHeater As Double _ + Implements ISSMGenInputs.AH_CoolantHeatTransferredToAirCabinHeater - 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 + 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 Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb index 46280347a73c25a02d5b6dc19076c452f28e0619..83f67592f359979585f29aaf677bb4ff7cfc9e54 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb @@ -4,290 +4,293 @@ Imports Newtonsoft.Json Imports System.IO Imports System.Reflection Imports System.Text +Imports TUGraz.VectoCommon.Utils 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 - '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 - 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 - '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 - 'Base Values - Public ReadOnly Property ElectricalWBase As Single Implements ISSMTOOL.ElectricalWBase - Get - Return If(SSMDisabled, 0, Calculate.ElectricalWBase) - End Get - End Property - Public ReadOnly Property MechanicalWBase As Single Implements ISSMTOOL.MechanicalWBase - Get - Return If(SSMDisabled, 0, Calculate.MechanicalWBase) - End Get - End Property - Public ReadOnly Property FuelPerHBase As Single Implements ISSMTOOL.FuelPerHBase - Get - Return If(SSMDisabled, 0, Calculate.FuelPerHBase) - 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 - 'Adjusted Values - Public ReadOnly Property ElectricalWAdjusted As Single Implements ISSMTOOL.ElectricalWAdjusted - Get - Return If(SSMDisabled, 0, Calculate.ElectricalWAdjusted) - End Get - End Property - Public ReadOnly Property MechanicalWBaseAdjusted As Single Implements ISSMTOOL.MechanicalWBaseAdjusted - Get - Dim mechAdjusted As Single = If(SSMDisabled, 0, Calculate.MechanicalWBaseAdjusted) + Public ReadOnly Property FuelPerHBase As Double Implements ISSMTOOL.FuelPerHBase + Get + Return If(SSMDisabled, 0, Calculate.FuelPerHBase()) '.SI(Of LiterPerHour)() + End Get + End Property - If CompressorCapacityInsufficientWarned = False AndAlso (mechAdjusted) / (1000 * GenInputs.AC_COP) > GenInputs.AC_CompressorCapacitykW Then + '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 - OnMessage(Me, "HVAC SSM :AC-Compressor Capacity unable to service cooling, run continues as if capacity was sufficient.", AdvancedAuxiliaryMessageType.Warning) - CompressorCapacityInsufficientWarned = True + Public ReadOnly Property MechanicalWBaseAdjusted As Double Implements ISSMTOOL.MechanicalWBaseAdjusted + Get + Dim mechAdjusted As Double = If(SSMDisabled, 0, Calculate.MechanicalWBaseAdjusted()) - End If + 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 - Return mechAdjusted + End If - End Get - End Property - Public ReadOnly Property FuelPerHBaseAdjusted As Single Implements ISSMTOOL.FuelPerHBaseAdjusted - Get - Return If(SSMDisabled, 0, Calculate.FuelPerHBaseAdjusted) - End Get - End Property - 'Constructors - Sub New(filePath As String, hvacConstants As HVACConstants, Optional isDisabled As Boolean = False, Optional useTestValues As Boolean = False) + Return mechAdjusted ' .SI(Of Watt)() + End Get + End Property - Me.filePath = filePath - Me.SSMDisabled = isDisabled - Me.HVACConstants = hvacConstants + Public ReadOnly Property FuelPerHBaseAdjusted As Double Implements ISSMTOOL.FuelPerHBaseAdjusted + Get + Return If(SSMDisabled, 0, Calculate.FuelPerHBaseAdjusted()) ' .SI(Of LiterPerHour)() + End Get + End Property - GenInputs = New SSMGenInputs(useTestValues, fPATH(filePath)) - TechList = New SSMTechList(filePath, GenInputs, useTestValues) + 'Constructors + Sub New(filePath As String, hvacConstants As HVACConstants, Optional isDisabled As Boolean = False, + Optional useTestValues As Boolean = False) - Calculate = New SSMCalculate(Me) + Me.filePath = filePath + Me.SSMDisabled = isDisabled + Me.HVACConstants = hvacConstants - End Sub + GenInputs = New SSMGenInputs(useTestValues, fPATH(filePath)) + TechList = New SSMTechList(filePath, GenInputs, useTestValues) - 'Clone values from another object of same type - Public Sub Clone(from As ISSMTOOL) Implements ISSMTOOL.Clone + Calculate = New SSMCalculate(Me) + End Sub - Dim feedback As String = String.Empty + 'Clone values from another object of same type + Public Sub Clone(from As ISSMTOOL) Implements ISSMTOOL.Clone - genInputs.InjectFrom(DirectCast(from, SSMTOOL).genInputs) + Dim feedback As String = String.Empty - TechList.Clear() + GenInputs.InjectFrom(DirectCast(from, SSMTOOL).GenInputs) - For Each line As TechListBenefitLine In DirectCast(from, SSMTOOL).TechList.TechLines + TechList.Clear() - 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 + For Each line As TechListBenefitLine In DirectCast(from, SSMTOOL).TechList.TechLines - '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 + Dim newLine As New TechListBenefitLine(Me.GenInputs) + newLine.InjectFrom() + newLine.InjectFrom(line) + TechList.Add(newLine, feedback) - End Try + Next + End Sub - Return returnValue + 'Persistance Functions + Public Function Save(filePath As String) As Boolean Implements ISSMTOOL.Save - 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) + Dim returnValue As Boolean = True + Dim settings As JsonSerializerSettings = New JsonSerializerSettings() + settings.TypeNameHandling = TypeNameHandling.Objects - settings.TypeNameHandling = TypeNameHandling.Objects + 'JSON METHOD + Try - 'JSON METHOD - Try + Dim output As String = JsonConvert.SerializeObject(Me, Formatting.Indented, settings) - Dim output As String = File.ReadAllText(filePath) + File.WriteAllText(filePath, output) + Catch ex As Exception - tmpAux = JsonConvert.DeserializeObject(Of SSMTOOL)(output, settings) + 'Nothing to do except return false. + returnValue = False - tmpAux.TechList.SetSSMGeneralInputs(tmpAux.genInputs) + End Try - For Each tll As TechListBenefitLine In tmpAux.TechList.TechLines + Return returnValue + End Function - tll.inputSheet = tmpAux.genInputs + Public Function Load(filePath As String) As Boolean Implements ISSMTOOL.Load - Next + Dim returnValue As Boolean = True + Dim settings As JsonSerializerSettings = New JsonSerializerSettings() + Dim tmpAux As SSMTOOL ' = New SSMTOOL(filePath, HVACConstants) + settings.TypeNameHandling = TypeNameHandling.Objects - 'This is where we Assume values of loaded( Deserialized ) object. - Clone(tmpAux) + 'JSON METHOD + Try - Catch ex As Exception + Dim output As String = File.ReadAllText(filePath) - 'Nothing to do except return false. - returnValue = False - End Try + tmpAux = JsonConvert.DeserializeObject(Of SSMTOOL)(output, settings) - Return returnValue + tmpAux.TechList.SetSSMGeneralInputs(tmpAux.GenInputs) - End Function + For Each tll As TechListBenefitLine In tmpAux.TechList.TechLines - 'Comparison - Public Function IsEqualTo(source As ISSMTOOL) As Boolean Implements ISSMTOOL.IsEqualTo + tll.inputSheet = tmpAux.GenInputs - '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. + Next - Return compareGenUserInputs(source) AndAlso compareTechListBenefitLines(source) + 'This is where we Assume values of loaded( Deserialized ) object. + Clone(tmpAux) - End Function - Private Function compareGenUserInputs(source As ISSMTOOL) As Boolean + Catch ex As Exception - Dim src As SSMTOOL = DirectCast(source, SSMTOOL) + 'Nothing to do except return false. - Dim returnValue As Boolean = True + returnValue = False + End Try - Dim properties As PropertyInfo() = Me.genInputs.GetType.GetProperties + Return returnValue + End Function - For Each prop As PropertyInfo In properties + 'Comparison + Public Function IsEqualTo(source As ISSMTOOL) As Boolean Implements ISSMTOOL.IsEqualTo - 'If Not prop.GetAccessors.IsReadOnly Then - If prop.CanWrite Then - If prop.GetValue(Me.GenInputs, Nothing) <> prop.GetValue(src.GenInputs, Nothing) Then - returnValue = False - End If + '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. - End If + Return compareGenUserInputs(source) AndAlso compareTechListBenefitLines(source) + End Function - Next + Private Function compareGenUserInputs(source As ISSMTOOL) As Boolean - Return returnValue + Dim src As SSMTOOL = DirectCast(source, SSMTOOL) - End Function - Private Function compareTechListBenefitLines(source As ISSMTOOL) As Boolean + Dim returnValue As Boolean = True + Dim properties As PropertyInfo() = Me.GenInputs.GetType.GetProperties - Dim src As SSMTOOL = DirectCast(source, SSMTOOL) + For Each prop As PropertyInfo In properties - 'Equal numbers of lines check - If Me.TechList.TechLines.Count <> src.TechList.TechLines.Count Then Return False + '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 - For Each tl As ITechListBenefitLine In Me.TechList.TechLines.OrderBy(Function(o) o.Category).ThenBy(Function(n) n.BenefitName) + End If - '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 + Next - Return False - Else + Return returnValue + End Function - 'check are equal + Private Function compareTechListBenefitLines(source As ISSMTOOL) As Boolean - 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 + Dim src As SSMTOOL = DirectCast(source, SSMTOOL) - End If + '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) - Next + '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 - 'All Looks OK - Return True + Return False + Else - End Function + 'check are equal - 'Overrides - Public Overrides Function ToString() As String + 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 - Dim sb As New StringBuilder + End If - sb.AppendLine(Calculate.ToString()) + Next - Return sb.ToString() + 'All Looks OK + Return True + End Function - End Function + 'Overrides + Public Overrides Function ToString() As String - '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 Single) As Single Implements ISSMTOOL.FuelPerHBaseAsjusted - If SSMDisabled Then - Return 0 - End If + Dim sb As New StringBuilder - 'Set Engine Waste Heat - GenInputs.AH_EngineWasteHeatkW = AverageUseableEngineWasteHeatKW - Dim fba As Single = FuelPerHBaseAdjusted + sb.AppendLine(Calculate.ToString()) - 'Dim FuelFiredWarning As Boolean = fba * GenInputs.BC_AuxHeaterEfficiency * HVACConstants.FuelDensity * GenInputs.BC_GCVDieselOrHeatingOil * 1000 > (AverageUseableEngineWasteHeatKW + GenInputs.AH_FuelFiredHeaterkW) - 'If Not FuelFiredHeaterInsufficientWarned AndAlso FuelFiredWarning Then + Return sb.ToString() + End Function - ' FuelFiredHeaterInsufficientWarned = True + '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 - ' OnMessage(Me, " HVAC SSM : Fuel fired heater insufficient for heating requirements, run continues assuming it was sufficient.", AdvancedAuxiliaryMessageType.Warning) + If SSMDisabled Then + Return 0 + End If - 'End If + 'Set Engine Waste Heat + GenInputs.AH_EngineWasteHeatkW = AverageUseableEngineWasteHeatKW + Dim fba As Double = FuelPerHBaseAdjusted - Return fba + 'Dim FuelFiredWarning As Boolean = fba * GenInputs.BC_AuxHeaterEfficiency * HVACConstants.FuelDensity * GenInputs.BC_GCVDieselOrHeatingOil * 1000 > (AverageUseableEngineWasteHeatKW + GenInputs.AH_FuelFiredHeaterkW) - End Function + 'If Not FuelFiredHeaterInsufficientWarned AndAlso FuelFiredWarning Then - 'Events - Public Event Message(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) Implements ISSMTOOL.Message + ' FuelFiredHeaterInsufficientWarned = True - 'Raise Message Event. - Private Sub OnMessage(sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) + ' OnMessage(Me, " HVAC SSM : Fuel fired heater insufficient for heating requirements, run continues assuming it was sufficient.", AdvancedAuxiliaryMessageType.Warning) + 'End If - If Not message Is Nothing Then + Return fba + End Function - RaiseEvent Message(Me, message, messageType) + 'Events + Public Event Message(ByRef sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) _ + Implements ISSMTOOL.Message - End If + 'Raise Message Event. + Private Sub OnMessage(sender As Object, message As String, messageType As AdvancedAuxiliaryMessageType) - End Sub - End Class + 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/Hvac/SSMTechList.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMTechList.vb index bd9fd0ef94ba8eed83469cc766d26d6826ee261d..45dd0d5736d7d3e3ff208dd0266f215d9f0b60ae 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMTechList.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/SSMTechList.vb @@ -1,536 +1,530 @@ Imports System.Globalization Imports System.IO +Imports TUGraz.VectoCommon.Utils Namespace Hvac + 'Used By SSMTOOL Class. + Public Class SSMTechList + Implements ISSMTechList -'Used By SSMTOOL Class. -Public Class SSMTechList - Implements ISSMTechList + 'Private Fields + Private filePath As String + Private _ssmInputs As ISSMGenInputs + Private _dirty As Boolean - 'Private Fields - Private filePath As String - Private _ssmInputs As ISSMGenInputs - Private _dirty As Boolean + Public Property TechLines As List(Of ITechListBenefitLine) Implements ISSMTechList.TechLines - 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) - 'Constructors - Public Sub New(filepath As String, genInputs As ISSMGenInputs, Optional initialiseDefaults As Boolean = False) + Me.TechLines = New List(Of ITechListBenefitLine) - Me.TechLines = New List(Of ITechListBenefitLine) + Me.filePath = filepath - Me.filePath = filepath + Me._ssmInputs = genInputs - Me._ssmInputs = genInputs + If initialiseDefaults Then SetDefaults() + End Sub - If initialiseDefaults Then SetDefaults() - End Sub + Public Sub SetSSMGeneralInputs(genInputs As ISSMGenInputs) Implements ISSMTechList.SetSSMGeneralInputs + _ssmInputs = genInputs + End Sub - Public Sub SetSSMGeneralInputs(genInputs As ISSMGenInputs) Implements ISSMTechList.SetSSMGeneralInputs + 'Initialisation Methods + Public Function Initialise(filePath As String) As Boolean Implements ISSMTechList.Initialise - _ssmInputs = genInputs + Me.filePath = filePath - End Sub + Return Initialise() + End Function - 'Initialisation Methods - Public Function Initialise(filePath As String) As Boolean Implements ISSMTechList.Initialise + Public Function Initialise() As Boolean Implements ISSMTechList.Initialise - Me.filePath = filePath - Return Initialise() + Dim returnStatus As Boolean = True - End Function - Public Function Initialise() As Boolean Implements ISSMTechList.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() < 1) Then + Return False + End If + Dim firstline As Boolean = True - Dim returnStatus As Boolean = True + For Each line As String In lines + If Not firstline Then - 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) + '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 - '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 + ' 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 - Dim firstline As Boolean = True - For Each line As String In lines - If Not firstline Then + 'Bus + Try - 'split the line - Dim elements() As String = line.Split(New Char() {","}, 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 + 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 - 'Bus - Try + 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 - 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), - elements(12), - elements(13), - elements(14), - elements(15), - elements(16)) + Public ReadOnly Property VHValueVariation As Double Implements ISSMTechList.VHValueVariation + Get + 'Dim a,b As double - TechLines.Add(tbline) + 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 - Catch ex As Exception + 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 - 'Indicate problems - returnStatus = False + 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 - 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 + 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 - '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 + 'Member Management + Public Function Add(item As ITechListBenefitLine, ByRef feedback As String) As Boolean Implements ISSMTechList.Add - 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 + Dim initialCount As Integer = TechLines.Count - 'Member Management - Public Function Add(item As ITechListBenefitLine, ByRef feedback As String) As Boolean Implements ISSMTechList.Add + 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 - 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) - Try + If TechLines.Count = initialCount + 1 Then - TechLines.Add(item) + 'Success + feedback = "OK" + _dirty = True + Return True - If TechLines.Count = initialCount + 1 Then + Else - 'Success - feedback = "OK" - _dirty = True - Return True + 'Failure + feedback = "The system was unable to add the new tech benefit list item." + Return False - Else + End If - 'Failure - feedback = "The system was unable to add the new tech benefit list item." - Return False + Catch ex As Exception - End If + feedback = "The system threw an exception and was unable to add the new tech benefit list item." + Return False - Catch ex As Exception + End Try + End Function - feedback = "The system threw an exception and was unable to add the new tech benefit list item." - Return False + Public Sub Clear() Implements ISSMTechList.Clear - End Try + If TechLines.Count > 0 Then _dirty = True + TechLines.Clear() + End Sub - End Function - Public Sub Clear() Implements ISSMTechList.Clear + Public Function Delete(item As ITechListBenefitLine, ByRef feedback As String) As Boolean _ + Implements ISSMTechList.Delete - If TechLines.Count > 0 Then _dirty = True + Dim currentCount As Integer = TechLines.Count - TechLines.Clear() + 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 Sub - Public Function Delete(item As ITechListBenefitLine, ByRef feedback As String) As Boolean Implements ISSMTechList.Delete + End If - Dim currentCount As Integer = TechLines.Count + Catch ex As Exception - If (TechLines.Where(Function(c) c.Category = item.Category AndAlso c.BenefitName = item.BenefitName).Count = 1) Then + feedback = "An exception occured, the removal failed." + Return False - Try - TechLines.RemoveAt(TechLines.FindIndex(Function(c) c.Category = item.Category AndAlso c.BenefitName = item.BenefitName)) + End Try - 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 + Else - Catch ex As Exception + feedback = "the item was not found in the list." + Return False - feedback = "An exception occured, the removal failed." - Return False + End If + End Function - End Try + 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 - Else + If (Not fi Is Nothing) Then - feedback = "the item was not found in the list." - Return False + Try - End If + fi.CloneFrom(newItem) - End Function - Public Function Modify(originalItem As ITechListBenefitLine, newItem As ITechListBenefitLine, ByRef feedback As String) As Boolean Implements ISSMTechList.Modify + '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 - Dim fi As TechListBenefitLine = TechLines.Find(Function(f) (f.Category = originalitem.Category) AndAlso f.BenefitName = originalitem.BenefitName) - Dim originalUnits As String = fi.Units + 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 - If (Not fi Is Nothing) Then + End If - Try + Catch ex As Exception - fi.CloneFrom(newItem) + feedback = "An exception occured, the update failed." + Return False - '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 + End Try - If newItem = 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 + Else - Catch ex As Exception + feedback = "the item was not found so cannot be modified." + Return False - 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 + 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 = 0 - .ActiveVV = 0 - .ActiveVC = 1 - .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 = 1 - .ActiveVV = 0 - .ActiveVC = 0 - .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 = 1 - .ActiveVV = 0 - .ActiveVC = 0 - .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 = 1 - .ActiveVV = 0 - .ActiveVC = 0 - .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 = 1 - .ActiveVV = 0 - .ActiveVC = 0 - .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 = 1 - .ActiveVV = 1 - .ActiveVC = 1 - .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 = 0 - .ActiveVV = 0 - .ActiveVC = 0 - .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 = 1 - .ActiveVV = 1 - .ActiveVC = 1 - .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 + 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 Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Hvac/TechListBenefitLine.vb b/VECTOAux/VectoAuxiliaries/Hvac/TechListBenefitLine.vb index 57456a937853bd468cacb2c4dd6f165c014579da..e4748490caf0edbd26ad65fd42330978c95c5b36 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/TechListBenefitLine.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/TechListBenefitLine.vb @@ -1,326 +1,310 @@  Namespace Hvac - - Public Enum TechLineType - - Normal - HVCActiveSelection - - End Enum - - 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 Single Implements ITechListBenefitLine.H - Get - - Dim returnValue As Single = 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 Single Implements ITechListBenefitLine.VH - Get - - Dim floorValue As Single = 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 TechLineType.HVCActiveSelection AndAlso ActiveVH Then - Return floorValue - Else - Return 0 - End If - - - End Get - - End Property - Public ReadOnly Property VV As Single Implements ITechListBenefitLine.VV - Get - - Dim floorValue As Single = 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 TechLineType.HVCActiveSelection AndAlso ActiveVV Then - Return floorValue - Else - Return 0 - End If - - End Get - End Property - Public ReadOnly Property VC As Single Implements ITechListBenefitLine.VC - Get - - Dim floorValue As Single = 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 TechLineType.HVCActiveSelection AndAlso ActiveVC Then - Return floorValue - Else - Return 0 - End If - - End Get - End Property - Public ReadOnly Property C As Single Implements ITechListBenefitLine.C - Get - - Dim returnValue As Single = 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 - - Return If(Me = source, True, False) - - - End Function - - End Class - + Public Enum TechLineType + + Normal + HVCActiveSelection + End Enum + + 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/IAuxiliaryConfig.vb b/VECTOAux/VectoAuxiliaries/IAuxiliaryConfig.vb index 7886419f77cdcd1ff321f9f8c427fc7dc0333d85..08e0f4853a77664aae891ea10955752d4fc2792e 100644 --- a/VECTOAux/VectoAuxiliaries/IAuxiliaryConfig.vb +++ b/VECTOAux/VectoAuxiliaries/IAuxiliaryConfig.vb @@ -20,29 +20,24 @@ Imports Newtonsoft.Json Public Interface IAuxiliaryConfig + 'Vecto + Property VectoInputs As IVectoInputs + 'Electrical + property ElectricalUserInputsConfig As IElectricsUserInputsConfig - 'Vecto - Property VectoInputs As IVectoInputs - - 'Electrical - property ElectricalUserInputsConfig As IElectricsUserInputsConfig + 'Pneumatics + Property PneumaticUserInputsConfig As IPneumaticUserInputsConfig + Property PneumaticAuxillariesConfig As IPneumaticsAuxilliariesConfig - 'Pneumatics - Property PneumaticUserInputsConfig As IPneumaticUserInputsConfig - Property PneumaticAuxillariesConfig As IPneumaticsAuxilliariesConfig - - 'Hvac - Property HvacUserInputsConfig As IHVACUserInputsConfig - - Function ConfigValuesAreTheSameAs( other As AuxiliaryConfig) As Boolean - - - 'Persistance Functions - Function Save( filePath As String ) As Boolean - Function Load( filePath As String ) As Boolean + 'Hvac + Property HvacUserInputsConfig As IHVACUserInputsConfig + Function ConfigValuesAreTheSameAs(other As AuxiliaryConfig) As Boolean + 'Persistance Functions + Function Save(filePath As String) As Boolean + Function Load(filePath As String) As Boolean End Interface diff --git a/VECTOAux/VectoAuxiliaries/My Project/Application.Designer.vb b/VECTOAux/VectoAuxiliaries/My Project/Application.Designer.vb index 0aecefe6649856e7f2f1917454c1aa12737d11a2..8ab460ba03644d647f67a62136b9e8f010a0d561 100644 --- a/VECTOAux/VectoAuxiliaries/My Project/Application.Designer.vb +++ b/VECTOAux/VectoAuxiliaries/My Project/Application.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' <auto-generated> -' This code was generated by a tool. -' Runtime Version:4.0.30319.18444 +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 ' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. ' </auto-generated> '------------------------------------------------------------------------------ diff --git a/VECTOAux/VectoAuxiliaries/My Project/AssemblyInfo.vb b/VECTOAux/VectoAuxiliaries/My Project/AssemblyInfo.vb index 1b3346b1c0b48399dc16461c95b4582c94c10241..30dd372dbba136e55b0b4c5befa5a85ba14809c0 100644 --- a/VECTOAux/VectoAuxiliaries/My Project/AssemblyInfo.vb +++ b/VECTOAux/VectoAuxiliaries/My Project/AssemblyInfo.vb @@ -8,17 +8,17 @@ Imports System.Runtime.InteropServices ' Review the values of the assembly attributes -<Assembly: AssemblyTitle("VectoAuxiliaries")> -<Assembly: AssemblyDescription("")> -<Assembly: AssemblyCompany("")> -<Assembly: AssemblyProduct("VectoAuxiliaries")> -<Assembly: AssemblyCopyright("Copyright © 2014")> -<Assembly: AssemblyTrademark("")> +<Assembly: AssemblyTitle("VectoAuxiliaries")> +<Assembly: AssemblyDescription("")> +<Assembly: AssemblyCompany("")> +<Assembly: AssemblyProduct("VectoAuxiliaries")> +<Assembly: AssemblyCopyright("Copyright © 2014")> +<Assembly: AssemblyTrademark("")> <Assembly: ComVisible(False)> 'The following GUID is for the ID of the typelib if this project is exposed to COM -<Assembly: Guid("5f94e0a5-9d00-4302-90a4-a73af909bb2c")> +<Assembly: Guid("5f94e0a5-9d00-4302-90a4-a73af909bb2c")> ' Version information for an assembly consists of the following four values: ' @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' <Assembly: AssemblyVersion("1.0.*")> -<Assembly: AssemblyVersion("1.0.0.0")> -<Assembly: AssemblyFileVersion("1.0.0.0")> +<Assembly: AssemblyVersion("1.0.0.0")> +<Assembly: AssemblyFileVersion("1.0.0.0")> diff --git a/VECTOAux/VectoAuxiliaries/My Project/Resources.Designer.vb b/VECTOAux/VectoAuxiliaries/My Project/Resources.Designer.vb index 4653ffe175fa06c074667bd7afa42e9bdc13e598..83fa837c5fdbaac68412e279e6c205ed40f5f634 100644 --- a/VECTOAux/VectoAuxiliaries/My Project/Resources.Designer.vb +++ b/VECTOAux/VectoAuxiliaries/My Project/Resources.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' <auto-generated> -' This code was generated by a tool. -' Runtime Version:4.0.30319.18444 +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 ' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. ' </auto-generated> '------------------------------------------------------------------------------ @@ -15,12 +15,12 @@ Imports System Namespace My.Resources - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. '''<summary> - ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. '''</summary> <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ @@ -33,7 +33,7 @@ Namespace My.Resources Private resourceCulture As Global.System.Globalization.CultureInfo '''<summary> - ''' Returns the cached ResourceManager instance used by this class. + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. '''</summary> <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager @@ -47,8 +47,8 @@ Namespace My.Resources End Property '''<summary> - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. '''</summary> <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ Friend Property Culture() As Global.System.Globalization.CultureInfo @@ -61,7 +61,7 @@ Namespace My.Resources End Property '''<summary> - ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. '''</summary> Friend ReadOnly Property Blank() As System.Drawing.Bitmap Get @@ -71,7 +71,7 @@ Namespace My.Resources End Property '''<summary> - ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. '''</summary> Friend ReadOnly Property Delete() As System.Drawing.Bitmap Get @@ -81,7 +81,7 @@ Namespace My.Resources End Property '''<summary> - ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. '''</summary> Friend ReadOnly Property Info() As System.Drawing.Bitmap Get diff --git a/VECTOAux/VectoAuxiliaries/My Project/Settings.Designer.vb b/VECTOAux/VectoAuxiliaries/My Project/Settings.Designer.vb index 14e244d9bbf3a3c5dfd44f61f996fe1661a78895..950881703c2b39c67a8cc31aaeef5425505c0b26 100644 --- a/VECTOAux/VectoAuxiliaries/My Project/Settings.Designer.vb +++ b/VECTOAux/VectoAuxiliaries/My Project/Settings.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' <auto-generated> -' This code was generated by a tool. -' Runtime Version:4.0.30319.18444 +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 ' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. ' </auto-generated> '------------------------------------------------------------------------------ @@ -22,7 +22,7 @@ Namespace My Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) -#Region "My.Settings Auto-Save Functionality" +#Region "Funktion zum automatischen Speichern von My.Settings" #If _MyType = "WindowsForms" Then Private Shared addedHandler As Boolean diff --git a/VECTOAux/VectoAuxiliaries/My Project/Settings.settings b/VECTOAux/VectoAuxiliaries/My Project/Settings.settings index 85b890b3c66b9beee248abaddd2ec71f8b1df2b2..1aea3ac9cc524838e8a94e86ba7dd879d0769f2d 100644 --- a/VECTOAux/VectoAuxiliaries/My Project/Settings.settings +++ b/VECTOAux/VectoAuxiliaries/My Project/Settings.settings @@ -1,7 +1,9 @@ <?xml version='1.0' encoding='utf-8'?> -<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true"> - <Profiles> - <Profile Name="(Default)" /> - </Profiles> - <Settings /> -</SettingsFile> + +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" + UseMySettingsClassName="true"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile> \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/ActuationsKey.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/ActuationsKey.vb index 7a75304c595bf48f666c216473ab43a6fa4b49a9..d811960588599a498a5e5680a24409f1440bff5d 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/ActuationsKey.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/ActuationsKey.vb @@ -10,50 +10,44 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Namespace Pneumatics - -Public Class ActuationsKey - - -Private _consumerName As String -Private _cycleName As String + Public Class ActuationsKey + Private _consumerName As String + Private _cycleName As String 'Properties -Public ReadOnly Property ConsumerName As String - Get - Return _consumerName - End Get -End Property - -Public ReadOnly Property CycleName As String - Get - Return _cycleName - End Get -End Property + Public ReadOnly Property ConsumerName As String + Get + Return _consumerName + End Get + End Property + + Public ReadOnly Property CycleName As String + Get + Return _cycleName + End Get + End Property 'Constructor -Public Sub New(consumerName As String, cycleName As String) - -If consumerName.Trim.Length = 0 Or cycleName.Trim.Length = 0 Then Throw New ArgumentException("ConsumerName and CycleName must be provided") - _consumerName = consumerName - _cycleName = cycleName - -End Sub - - - 'Overrides to enable this class to be used as a dictionary key in the ActuationsMap. - Public Overrides Function Equals(obj As Object) As Boolean + Public Sub New(consumerName As String, cycleName As String) - Dim other As ActuationsKey = CType(obj, ActuationsKey) + If consumerName.Trim.Length = 0 Or cycleName.Trim.Length = 0 Then _ + Throw New ArgumentException("ConsumerName and CycleName must be provided") + _consumerName = consumerName + _cycleName = cycleName + End Sub - Return other.ConsumerName = Me.ConsumerName AndAlso other.CycleName = Me.CycleName + 'Overrides to enable this class to be used as a dictionary key in the ActuationsMap. + Public Overrides Function Equals(obj As Object) As Boolean - End Function - Public Overrides Function GetHashCode() As Integer - Return 0 - End Function + Dim other As ActuationsKey = CType(obj, ActuationsKey) -End Class + Return other.ConsumerName = Me.ConsumerName AndAlso other.CycleName = Me.CycleName + End Function + Public Overrides Function GetHashCode() As Integer + Return 0 + End Function + End Class End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/CompressorMap.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/CompressorMap.vb index 1e88f01bcd04240967debdf0125bf5708bf3218b..2c8d9b064d2fce2ecc979027e8fa4d7bb3fe407d 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/CompressorMap.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/CompressorMap.vb @@ -9,7 +9,9 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports System.Globalization Imports System.IO +Imports TUGraz.VectoCommon.Utils Namespace Pneumatics ''' <summary> @@ -21,7 +23,7 @@ Namespace Pneumatics IAuxiliaryEvent Private ReadOnly filePath As String - Private _averagePowerDemandPerCompressorUnitFlowRateLitresperSec As Single + Private _averagePowerDemandPerCompressorUnitFlowRateLitresperSec As Double Private _MapBoundariesExceeded As Boolean ''' <summary> @@ -35,7 +37,7 @@ Namespace Pneumatics Private map As Dictionary(Of Integer, CompressorMapValues) 'Returns the AveragePowerDemand per unit flow rate in seconds. - Public Function AveragePowerDemandPerCompressorUnitFlowRate() As Single _ + Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Double _ Implements ICompressorMap.GetAveragePowerDemandPerCompressorUnitFlowRate Return _averagePowerDemandPerCompressorUnitFlowRateLitresperSec @@ -72,11 +74,18 @@ Namespace Pneumatics For Each line As String In lines If Not firstline Then 'split the line - Dim elements() As String = line.Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries) + 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 - map.Add(elements(0), New CompressorMapValues(elements(1), elements(2), elements(3))) + 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 @@ -85,9 +94,10 @@ Namespace Pneumatics '********************************************************************* 'Calculate the Average Power Demand Per Compressor Unit FlowRate / per second. - Dim powerDividedByFlowRateSum As Single = 0 + Dim powerDividedByFlowRateSum As Double = 0 For Each speed As KeyValuePair(Of Integer, CompressorMapValues) In map - powerDividedByFlowRateSum += (speed.Value.PowerCompressorOn - speed.Value.PowerCompressorOff) / speed.Value.FlowRate + 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. @@ -108,7 +118,7 @@ Namespace Pneumatics ''' <param name="rpm">compressor rotation speed</param> ''' <returns></returns> ''' <remarks>Single</remarks> - Public Function GetFlowRate(ByVal rpm As Double) As Single Implements ICompressorMap.GetFlowRate + Public Function GetFlowRate(ByVal rpm As Double) As NormLiterPerSecond Implements ICompressorMap.GetFlowRate Dim val As CompressorMapValues = InterpolatedTuple(rpm) Return val.FlowRate End Function @@ -119,7 +129,7 @@ Namespace Pneumatics ''' <param name="rpm">compressor rotation speed</param> ''' <returns></returns> ''' <remarks>Single</remarks> - Public Function GetPowerCompressorOn(ByVal rpm As Double) As Single Implements ICompressorMap.GetPowerCompressorOn + Public Function GetPowerCompressorOn(ByVal rpm As Double) As Watt Implements ICompressorMap.GetPowerCompressorOn Dim val As CompressorMapValues = InterpolatedTuple(rpm) Return val.PowerCompressorOn End Function @@ -130,7 +140,7 @@ Namespace Pneumatics ''' <param name="rpm">compressor rotation speed</param> ''' <returns></returns> ''' <remarks>Single</remarks> - Public Function GetPowerCompressorOff(ByVal rpm As Double) As Single Implements ICompressorMap.GetPowerCompressorOff + Public Function GetPowerCompressorOff(ByVal rpm As Double) As Watt Implements ICompressorMap.GetPowerCompressorOff Dim val As CompressorMapValues = InterpolatedTuple(rpm) Return val.PowerCompressorOff End Function @@ -160,8 +170,9 @@ Namespace Pneumatics End If 'If supplied rpm is a key, we can just return the appropriate tuple - If map.ContainsKey(rpm) Then - Return map(rpm) + 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 @@ -170,20 +181,20 @@ Namespace Pneumatics 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 Integer = post.Key - pre.Key - Dim dFlowRate As Single = post.Value.FlowRate - pre.Value.FlowRate - Dim dPowerOn As Single = post.Value.PowerCompressorOn - pre.Value.PowerCompressorOn - Dim dPowerOff As Single = post.Value.PowerCompressorOff - pre.Value.PowerCompressorOff + 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 Single = dFlowRate / dRpm - Dim powerOnSlope As Single = dPowerOn / dRpm - Dim powerOffSlope As Single = dPowerOff / dRpm + 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 Single = ((rpm - pre.Key) * flowSlope) + pre.Value.FlowRate - Dim powerCompressorOn As Single = ((rpm - pre.Key) * powerOnSlope) + pre.Value.PowerCompressorOn - Dim powerCompressorOff As Single = ((rpm - pre.Key) * powerOffSlope) + pre.Value.PowerCompressorOff + 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) @@ -203,19 +214,19 @@ Namespace Pneumatics ''' Compressor flowrate ''' </summary> ''' <remarks></remarks> - Public ReadOnly FlowRate As Single + Public ReadOnly FlowRate As NormLiterPerSecond ''' <summary> ''' Power, compressor on ''' </summary> ''' <remarks></remarks> - Public ReadOnly PowerCompressorOn As Single + Public ReadOnly PowerCompressorOn As Watt ''' <summary> ''' Power compressor off ''' </summary> ''' <remarks></remarks> - Public ReadOnly PowerCompressorOff As Single + Public ReadOnly PowerCompressorOff As Watt ''' <summary> ''' Creates a new instance of CompressorMapValues @@ -224,7 +235,8 @@ Namespace Pneumatics ''' <param name="powerCompressorOn">power - compressor on</param> ''' <param name="powerCompressorOff">power - compressor off</param> ''' <remarks></remarks> - Public Sub New(ByVal flowRate As Single, ByVal powerCompressorOn As Single, ByVal powerCompressorOff As Single) + Public Sub New(ByVal flowRate As NormLiterPerSecond, ByVal powerCompressorOn As Watt, + ByVal powerCompressorOff As Watt) Me.FlowRate = flowRate Me.PowerCompressorOn = powerCompressorOn Me.PowerCompressorOff = powerCompressorOff diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/ICompressorMap.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/ICompressorMap.vb index 914a00a2a66656d2da3c633cdf4c39b92371f614..2c8956306d68d0243830d9225d2e0470f167b593 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/ICompressorMap.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/ICompressorMap.vb @@ -8,25 +8,25 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Pneumatics + Public Interface ICompressorMap + Inherits IAuxiliaryEvent - Public Interface ICompressorMap - Inherits IAuxiliaryEvent - - ''' <summary> - ''' Initilaises the map from the supplied csv data - ''' </summary> - ''' <remarks></remarks> - Function Initialise() As Boolean + ''' <summary> + ''' Initilaises the map from the supplied csv data + ''' </summary> + ''' <remarks></remarks> + Function Initialise() As Boolean - ''' <summary> - ''' Returns compressor flow rate at the given rotation speed - ''' </summary> - ''' <param name="rpm">compressor rotation speed</param> - ''' <returns></returns> - ''' <remarks>Single</remarks> - Function GetFlowRate(ByVal rpm As Double) As Single + ''' <summary> + ''' Returns compressor flow rate at the given rotation speed + ''' </summary> + ''' <param name="rpm">compressor rotation speed</param> + ''' <returns></returns> + ''' <remarks>Single</remarks> + Function GetFlowRate(ByVal rpm As Double) As NormLiterPerSecond ''' <summary> ''' Returns mechanical power at rpm when compressor is on @@ -34,7 +34,7 @@ Namespace Pneumatics ''' <param name="rpm">compressor rotation speed</param> ''' <returns></returns> ''' <remarks>Single</remarks> - Function GetPowerCompressorOn(ByVal rpm As Double) As Single + Function GetPowerCompressorOn(ByVal rpm As Double) As Watt ''' <summary> ''' Returns mechanical power at rpm when compressor is off @@ -42,12 +42,9 @@ Namespace Pneumatics ''' <param name="rpm">compressor rotation speed</param> ''' <returns></returns> ''' <remarks>Single</remarks> - Function GetPowerCompressorOff(ByVal rpm As Double) As Single - - 'Returns Average Power Demand Per Compressor Unit FlowRate - Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Single - - - End Interface + Function GetPowerCompressorOff(ByVal rpm As Double) As Watt + 'Returns Average Power Demand Per Compressor Unit FlowRate + Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Double + End Interface End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/IM3_AveragePneumaticLoadDemand.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/IM3_AveragePneumaticLoadDemand.vb index 9fb5e2691367b08d3f631090f1f382bad24eae62..2915abf1239576594659b4a0ab8b72e7155c4c95 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/IM3_AveragePneumaticLoadDemand.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/IM3_AveragePneumaticLoadDemand.vb @@ -8,20 +8,14 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. - +Imports TUGraz.VectoCommon.Utils Namespace Pneumatics + Public Interface IM3_AveragePneumaticLoadDemand + Function GetAveragePowerDemandAtCrankFromPneumatics() As Watt -Public Interface IM3_AveragePneumaticLoadDemand - - Function GetAveragePowerDemandAtCrankFromPneumatics() As Single - Function AverageAirConsumedPerSecondLitre() As Single - - -End Interface - - - + Function AverageAirConsumedPerSecondLitre() As NormLiterPerSecond + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/IM4_AirCompressor.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/IM4_AirCompressor.vb index 47c0277df09323061b35ea6b6c37433d07c89d11..1f7e76b40b7e5b9c576d9bb70b122df5e19d4235 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/IM4_AirCompressor.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/IM4_AirCompressor.vb @@ -8,66 +8,66 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Pneumatics - Public Interface IM4_AirCompressor - ''' <summary> - ''' Ratio of Gear or Pulley used to drive the compressor - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property PulleyGearRatio() As Single + Public Interface IM4_AirCompressor + ''' <summary> + ''' Ratio of Gear or Pulley used to drive the compressor + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property PulleyGearRatio() As Double - ''' <summary> - ''' Efficiency of the Pulley or Gear used to drive the compressor - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Property PulleyGearEfficiency() As Single + ''' <summary> + ''' Efficiency of the Pulley or Gear used to drive the compressor + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Property PulleyGearEfficiency() As Double - ''' <summary> - ''' Initialises the AirCompressor Class - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function Initialise() As Boolean + ''' <summary> + ''' Initialises the AirCompressor Class + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function Initialise() As Boolean - ''' <summary> - ''' Returns the flow rate [litres/second] of compressor for the given engine rpm - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function GetFlowRate() As Single + ''' <summary> + ''' Returns the flow rate [litres/second] of compressor for the given engine rpm + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function GetFlowRate() As NormLiterPerSecond - ''' <summary> - ''' Returns the power consumed for the given engine rpm when compressor is off - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function GetPowerCompressorOff() As Single + ''' <summary> + ''' Returns the power consumed for the given engine rpm when compressor is off + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function GetPowerCompressorOff() As Watt - ''' <summary> - ''' Returns the power consumed for the given engine rpm when compressor is on - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function GetPowerCompressorOn() As Single + ''' <summary> + ''' Returns the power consumed for the given engine rpm when compressor is on + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function GetPowerCompressorOn() As Watt - ''' <summary> - ''' Returns the difference in power between compressonr on and compressor off operation at the given engine rpm - ''' </summary> - ''' <returns>Single / Watts</returns> - ''' <remarks></remarks> - Function GetPowerDifference() As Single + ''' <summary> + ''' Returns the difference in power between compressonr on and compressor off operation at the given engine rpm + ''' </summary> + ''' <returns>Single / Watts</returns> + ''' <remarks></remarks> + Function GetPowerDifference() As Watt - ''' <summary> - ''' Returns Average PoweDemand PeCompressor UnitFlowRate - ''' </summary> - ''' <returns></returns> - ''' <remarks></remarks> - Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Single - - End Interface -End NameSpace \ No newline at end of file + ''' <summary> + ''' Returns Average PoweDemand PeCompressor UnitFlowRate + ''' </summary> + ''' <returns></returns> + ''' <remarks></remarks> + Function GetAveragePowerDemandPerCompressorUnitFlowRate() As SI + End Interface +End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticActuationsMAP.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticActuationsMAP.vb index 087be199e5f09f5cb6a8433480aa9a9bd383e60f..eafc484e6a3e5616b24cfd0c0c132be6ef7c214f 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticActuationsMAP.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticActuationsMAP.vb @@ -11,19 +11,11 @@ Namespace Pneumatics + Public Interface IPneumaticActuationsMAP + Function GetNumActuations(key As ActuationsKey) As Integer - -Public Interface IPneumaticActuationsMAP - - - Function GetNumActuations(key As ActuationsKey) As Integer - - Function Initialise() As Boolean - -End Interface - - - + Function Initialise() As Boolean + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticUserInputsConfig.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticUserInputsConfig.vb index 9f518c227fadd3e038d06e5f1a53b6f3b71f8384..a3e8643fdc5aaaae06c0d93eba835b0e1b7a7351 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticUserInputsConfig.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticUserInputsConfig.vb @@ -11,23 +11,19 @@ Namespace Pneumatics - - Public Interface IPneumaticUserInputsConfig - - Property CompressorMap As String - Property CompressorGearEfficiency As Single - Property CompressorGearRatio As Single - Property ActuationsMap As String - Property SmartAirCompression As Boolean - Property SmartRegeneration As Boolean - Property RetarderBrake As Boolean - Property KneelingHeightMillimeters As Single - Property AirSuspensionControl As String 'mechanical or electrical - Property AdBlueDosing As String 'pnmeumatic or electric - Property Doors As String 'pneumatic or electric - - End Interface - + Public Interface IPneumaticUserInputsConfig + Property CompressorMap As String + Property CompressorGearEfficiency As Double + Property CompressorGearRatio As Double + Property ActuationsMap As String + Property SmartAirCompression As Boolean + Property SmartRegeneration As Boolean + Property RetarderBrake As Boolean + Property KneelingHeightMillimeters As Double + Property AirSuspensionControl As String 'mechanical or electrical + Property AdBlueDosing As String 'pnmeumatic or electric + Property Doors As String 'pneumatic or electric + End Interface End Namespace diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticsAuxilliariesConfig.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticsAuxilliariesConfig.vb index 638cfed34be8151d68a63f7225fe7da7ec4ba799..a5dc01da88c95dd3dd0f177e192cfc7b73b50ded 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticsAuxilliariesConfig.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/IPneumaticsAuxilliariesConfig.vb @@ -10,18 +10,16 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Public Interface IPneumaticsAuxilliariesConfig - -Property OverrunUtilisationForCompressionFraction As Single -Property BrakingWithRetarderNIperKG As Single -Property BrakingNoRetarderNIperKG As Single -Property BreakingPerKneelingNIperKGinMM As Single -Property PerDoorOpeningNI As Single -Property PerStopBrakeActuationNIperKG As Single -Property AirControlledSuspensionNIperMinute As Single -Property AdBlueNIperMinute As Single -Property NonSmartRegenFractionTotalAirDemand As Single -Property SmartRegenFractionTotalAirDemand As Single -Property DeadVolumeLitres As Single -Property DeadVolBlowOutsPerLitresperHour As Single - + Property OverrunUtilisationForCompressionFraction As Double + Property BrakingWithRetarderNIperKG As Double + Property BrakingNoRetarderNIperKG As Double + Property BreakingPerKneelingNIperKGinMM As Double + Property PerDoorOpeningNI As Double + Property PerStopBrakeActuationNIperKG As Double + Property AirControlledSuspensionNIperMinute As Double + Property AdBlueNIperMinute As Double + Property NonSmartRegenFractionTotalAirDemand As Double + Property SmartRegenFractionTotalAirDemand As Double + Property DeadVolumeLitres As Double + Property DeadVolBlowOutsPerLitresperHour As Double End Interface diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/M3_AveragePneumaticLoadDemand.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/M3_AveragePneumaticLoadDemand.vb index 0744553d153faa37aa2ac50147db95faa77cbccd..dea3a4e6b81a494ef0552ef294bb76d63e2f6345 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/M3_AveragePneumaticLoadDemand.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/M3_AveragePneumaticLoadDemand.vb @@ -9,207 +9,212 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Pneumatics Namespace Pneumatics - - Public Class M3_AveragePneumaticLoadDemand - Implements IM3_AveragePneumaticLoadDemand - - - - Private _pneumaticUserInputsConfig As IPneumaticUserInputsConfig - Private _pneumaticAuxillariesConfig As IPneumaticsAuxilliariesConfig - Private _pneumaticsActuationsMap As IPneumaticActuationsMAP - Private _pneumaticsCompressorFlowRateMap As ICompressorMap - Private _averagePowerDemandPerCompressorUnitFlowRateInWPerLitresPerSecond As Single - Private _vehicleMassKG As Single - Private _cycleName As String - Private _cycleDurationMinutes As Single - Private _totalAirDemand As Single - Private _signals As Signals - - - Private ReadOnly Property Sum1 As Single - Get - Return _totalAirDemand / _signals.TotalCycleTimeSeconds - End Get - End Property - Private ReadOnly Property Sum2 As Single - Get - Return Sum8 * Sum1 - End Get - End Property - Private ReadOnly Property Sum3 As Single - Get - Return Sum2 + _pneumaticsCompressorFlowRateMap.GetPowerCompressorOff( _signals.EngineSpeed * _pneumaticUserInputsConfig.CompressorGearRatio) - End Get - End Property - - Private ReadOnly Property Sum4 As Single - Get - Return Sum3 / _pneumaticUserInputsConfig.CompressorGearEfficiency - End Get - End Property - - 'Private ReadOnly Property Sum5 As Single - ' Get - ' 'NOT USED. - ' End Get - 'End Property - - Private ReadOnly Property Sum6 As Single - Get - Return _pneumaticsCompressorFlowRateMap.GetFlowRate(_signals.EngineSpeed * _pneumaticUserInputsConfig.CompressorGearRatio )/60 - End Get - End Property - - Private ReadOnly Property Sum7 As Single - Get - - Dim pon As Single = _pneumaticsCompressorFlowRateMap.GetPowerCompressorOn( _signals.EngineSpeed * _pneumaticUserInputsConfig.CompressorGearRatio) - Dim poff As Single = _pneumaticsCompressorFlowRateMap.GetPowerCompressorOff( _signals.EngineSpeed * _pneumaticUserInputsConfig.CompressorGearRatio) - Dim diff As Single = pon-poff - Return diff - - End Get - End Property - - - Private ReadOnly Property Sum8 As Single - Get - Return Sum7 / Sum6 - End Get - End Property - - Public ReadOnly Property TotalAirDemand As Single - Get - Return _totalAirDemand - End Get - End Property - - - 'Constructors - Public Sub New( - ByRef pneumaticsUserInputConfig As IPneumaticUserInputsConfig, _ - ByRef pneumaticsAuxillariesConfig As IPneumaticsAuxilliariesConfig, _ - ByRef pneumaticsActuationsMap As IPneumaticActuationsMAP, - ByRef pneumaticsCompressorFlowRateMap As ICompressorMap, - vehicleMassKG As Single, _ - cycleName As String, - signals As ISignals - ) - - - _pneumaticUserInputsConfig = pneumaticsUserInputConfig - _pneumaticAuxillariesConfig = pneumaticsAuxillariesConfig - _pneumaticsActuationsMap = pneumaticsActuationsMap - _pneumaticsCompressorFlowRateMap = pneumaticsCompressorFlowRateMap - _vehicleMassKG = vehicleMassKG - _cycleName = cycleName - _signals=signals - - - 'Total up the blow demands from compressor map - _averagePowerDemandPerCompressorUnitFlowRateInWPerLitresPerSecond = _pneumaticsCompressorFlowRateMap.GetAveragePowerDemandPerCompressorUnitFlowRate() /60 - - 'Calculate the Total Required Air Delivery Rate L / S - _totalAirDemand = TotalAirDemandCalculation() - - - End Sub - - - Private Function TotalAirDemandCalculation() As Single - - 'These calculation are done directly from formulae provided from a supplied spreadsheet. - - Dim numActuationsPerCycle As Single - Dim airConsumptionPerActuationNI As Single - Dim TotalAirDemand As Single - - 'Consumers - Dim Breaks As Single - Dim ParkBrakesplus2Doors As Single - Dim Kneeling As Single - Dim AdBlue As Single - Dim Regeneration As Single - Dim DeadVolBlowOuts As Single - Dim AirSuspension As Single - - - '** Breaks ** - numActuationsPerCycle = _pneumaticsActuationsMap.GetNumActuations(New ActuationsKey("Brakes", _cycleName)) - '=IF(K10 = "yes", IF(COUNTBLANK(F33),G33,F33), IF(COUNTBLANK(F34),G34,F34))*K16 - airConsumptionPerActuationNI = If(_pneumaticUserInputsConfig.RetarderBrake, _pneumaticAuxillariesConfig.BrakingWithRetarderNIperKG, _pneumaticAuxillariesConfig.BrakingNoRetarderNIperKG) - Breaks = numActuationsPerCycle * airConsumptionPerActuationNI * _vehicleMassKG - - '** ParkBrakesBreakplus2Doors ** Park break + 2 doors - numActuationsPerCycle = _pneumaticsActuationsMap.GetNumActuations(New ActuationsKey("Park brake + 2 doors", _cycleName)) - '=SUM(IF(K14="electric",0,IF(COUNTBLANK(F36),G36,F36)),PRODUCT(K16*IF(COUNTBLANK(F37),G37,F37))) - airConsumptionPerActuationNI = If(_pneumaticUserInputsConfig.Doors = "Electric", 0, _pneumaticAuxillariesConfig.PerDoorOpeningNI) - airConsumptionPerActuationNI += (_pneumaticAuxillariesConfig.PerStopBrakeActuationNIperKG * _vehicleMassKG) - ParkBrakesplus2Doors = numActuationsPerCycle * airConsumptionPerActuationNI - - '** Kneeling ** - numActuationsPerCycle = _pneumaticsActuationsMap.GetNumActuations(New ActuationsKey("Kneeling", _cycleName)) - '=IF(COUNTBLANK(F35),G35,F35)*K11*K16 - airConsumptionPerActuationNI = _pneumaticAuxillariesConfig.BreakingPerKneelingNIperKGinMM * _vehicleMassKG * _pneumaticUserInputsConfig.KneelingHeightMillimeters - Kneeling = numActuationsPerCycle * airConsumptionPerActuationNI - - '** AdBlue ** - '=IF(K13="electric",0,G39*F54)- Supplied Spreadsheet - AdBlue = If(_pneumaticUserInputsConfig.AdBlueDosing = "Electric", 0, _pneumaticAuxillariesConfig.AdBlueNIperMinute * ( _signals.TotalCycleTimeSeconds/60)) - - '** Regeneration ** - '=SUM(R6:R9)*IF(K9="yes",IF(COUNTBLANK(F41),G41,F41),IF(COUNTBLANK(F40),G40,F40)) - Supplied SpreadSheet - Regeneration = (Breaks + ParkBrakesplus2Doors + Kneeling + AdBlue) - Dim regenFraction As Single = If(_pneumaticUserInputsConfig.SmartRegeneration, _pneumaticAuxillariesConfig.SmartRegenFractionTotalAirDemand, _ - _pneumaticAuxillariesConfig.NonSmartRegenFractionTotalAirDemand) - Regeneration = Regeneration * regenFraction - - '** DeadVolBlowOuts ** - '=IF(COUNTBLANK(F43),G43,F43)/(F54/60) - Supplied SpreadSheet - numActuationsPerCycle = _pneumaticAuxillariesConfig.DeadVolBlowOutsPerLitresperHour / (60 /( _signals.TotalCycleTimeSeconds/60)) - airConsumptionPerActuationNI = _pneumaticAuxillariesConfig.DeadVolumeLitres - DeadVolBlowOuts = numActuationsPerCycle * airConsumptionPerActuationNI - - '** AirSuspension ** - '=IF(K12="electrically",0,G38*F54) - Suplied Spreadsheet - AirSuspension = If(_pneumaticUserInputsConfig.AirSuspensionControl = "Electrically", 0, _pneumaticAuxillariesConfig.AirControlledSuspensionNIperMinute * _cycleDurationMinutes) - - '** Total Air Demand ** - TotalAirDemand = Breaks + ParkBrakesplus2Doors + Kneeling + AdBlue + Regeneration + DeadVolBlowOuts + AirSuspension - - - Return TotalAirDemand - - End Function - - - 'Get Average Power Demand @ Crank From Pneumatics - Public Function GetAveragePowerDemandAtCrankFromPneumatics() As Single Implements IM3_AveragePneumaticLoadDemand.GetAveragePowerDemandAtCrankFromPneumatics - - Return Sum4 - - End Function - - 'Get Total Required Air Delivery Rate - Public Function AverageAirConsumedPerSecondLitre() As Single Implements IM3_AveragePneumaticLoadDemand.AverageAirConsumedPerSecondLitre - - Return Sum1 - - End Function - - - - - - - - - End Class - + Public Class M3_AveragePneumaticLoadDemand + Implements IM3_AveragePneumaticLoadDemand + + Private _pneumaticUserInputsConfig As IPneumaticUserInputsConfig + Private _pneumaticAuxillariesConfig As IPneumaticsAuxilliariesConfig + Private _pneumaticsActuationsMap As IPneumaticActuationsMAP + Private _pneumaticsCompressorFlowRateMap As ICompressorMap + Private _averagePowerDemandPerCompressorUnitFlowRateInWPerLitresPerSecond As SI + Private _vehicleMassKG As Kilogram + Private _cycleName As String + Private _cycleDurationMinutes As Double + Private _totalAirDemand As NormLiter + Private _signals As ISignals + + + Private ReadOnly Property Sum1 As NormLiterPerSecond + Get + Return _totalAirDemand / _signals.TotalCycleTimeSeconds.SI(Of Second)() + End Get + End Property + + Private ReadOnly Property Sum2 As Watt + Get + Return (Sum7.Value() / Sum6.Value() * Sum1.Value()).SI(Of Watt)() ' Watt / Nl/s * Nl/s = Watt + End Get + End Property + + Private ReadOnly Property Sum3 As Watt + Get + Return _ + Sum2 + + _pneumaticsCompressorFlowRateMap.GetPowerCompressorOff( + _signals.EngineSpeed.AsRPM * _pneumaticUserInputsConfig.CompressorGearRatio) + End Get + End Property + + Private ReadOnly Property Sum4 As Watt + Get + Return Sum3 * (1 / _pneumaticUserInputsConfig.CompressorGearEfficiency) + End Get + End Property + + 'Private ReadOnly Property Sum5 As Single + ' Get + ' 'NOT USED. + ' End Get + 'End Property + + Private ReadOnly Property Sum6 As NormLiterPerSecond + Get + Return _ + _pneumaticsCompressorFlowRateMap.GetFlowRate( + _signals.EngineSpeed.AsRPM * _pneumaticUserInputsConfig.CompressorGearRatio) / + 60 + End Get + End Property + + Private ReadOnly Property Sum7 As Watt + Get + + Dim pon As Watt = + _pneumaticsCompressorFlowRateMap.GetPowerCompressorOn( + _signals.EngineSpeed.AsRPM * _pneumaticUserInputsConfig.CompressorGearRatio) + Dim poff As Watt = + _pneumaticsCompressorFlowRateMap.GetPowerCompressorOff( + _signals.EngineSpeed.AsRPM * _pneumaticUserInputsConfig.CompressorGearRatio) + Dim diff As Watt = pon - poff + Return diff + End Get + End Property + + + Public ReadOnly Property TotalAirDemand As NormLiter + Get + Return _totalAirDemand + End Get + End Property + + + 'Constructors + Public Sub New( + ByRef pneumaticsUserInputConfig As IPneumaticUserInputsConfig, + ByRef pneumaticsAuxillariesConfig As IPneumaticsAuxilliariesConfig, + ByRef pneumaticsActuationsMap As IPneumaticActuationsMAP, + ByRef pneumaticsCompressorFlowRateMap As ICompressorMap, + vehicleMassKG As Kilogram, + cycleName As String, + signals As ISignals + ) + + + _pneumaticUserInputsConfig = pneumaticsUserInputConfig + _pneumaticAuxillariesConfig = pneumaticsAuxillariesConfig + _pneumaticsActuationsMap = pneumaticsActuationsMap + _pneumaticsCompressorFlowRateMap = pneumaticsCompressorFlowRateMap + _vehicleMassKG = vehicleMassKG + _cycleName = cycleName + _signals = signals + + + 'Total up the blow demands from compressor map + _averagePowerDemandPerCompressorUnitFlowRateInWPerLitresPerSecond = + (_pneumaticsCompressorFlowRateMap.GetAveragePowerDemandPerCompressorUnitFlowRate() / 60).SI() + + 'Calculate the Total Required Air Delivery Rate L / S + _totalAirDemand = TotalAirDemandCalculation() + End Sub + + + Private Function TotalAirDemandCalculation() As NormLiter + + 'These calculation are done directly from formulae provided from a supplied spreadsheet. + + Dim numActuationsPerCycle As Double + Dim airConsumptionPerActuationNI As Double + Dim TotalAirDemand As NormLiter + + 'Consumers + Dim Breaks As NormLiter + Dim ParkBrakesplus2Doors As NormLiter + Dim Kneeling As NormLiter + Dim AdBlue As NormLiter + Dim Regeneration As NormLiter + Dim DeadVolBlowOuts As NormLiter + Dim AirSuspension As NormLiter + + + '** Breaks ** + numActuationsPerCycle = _pneumaticsActuationsMap.GetNumActuations(New ActuationsKey("Brakes", _cycleName)) + '=IF(K10 = "yes", IF(COUNTBLANK(F33),G33,F33), IF(COUNTBLANK(F34),G34,F34))*K16 + airConsumptionPerActuationNI = + If _ + (_pneumaticUserInputsConfig.RetarderBrake, _pneumaticAuxillariesConfig.BrakingWithRetarderNIperKG, + _pneumaticAuxillariesConfig.BrakingNoRetarderNIperKG) + Breaks = (numActuationsPerCycle * airConsumptionPerActuationNI * _vehicleMassKG.Value()).SI(Of NormLiter)() + + '** ParkBrakesBreakplus2Doors ** Park break + 2 doors + numActuationsPerCycle = _pneumaticsActuationsMap.GetNumActuations(New ActuationsKey("Park brake + 2 doors", + _cycleName)) + '=SUM(IF(K14="electric",0,IF(COUNTBLANK(F36),G36,F36)),PRODUCT(K16*IF(COUNTBLANK(F37),G37,F37))) + airConsumptionPerActuationNI = + If(_pneumaticUserInputsConfig.Doors = "Electric", 0, _pneumaticAuxillariesConfig.PerDoorOpeningNI) + airConsumptionPerActuationNI += (_pneumaticAuxillariesConfig.PerStopBrakeActuationNIperKG * _vehicleMassKG.Value()) + ParkBrakesplus2Doors = (numActuationsPerCycle * airConsumptionPerActuationNI).SI(Of NormLiter)() + + '** Kneeling ** + numActuationsPerCycle = _pneumaticsActuationsMap.GetNumActuations(New ActuationsKey("Kneeling", _cycleName)) + '=IF(COUNTBLANK(F35),G35,F35)*K11*K16 + airConsumptionPerActuationNI = _pneumaticAuxillariesConfig.BreakingPerKneelingNIperKGinMM * _vehicleMassKG.Value() * + _pneumaticUserInputsConfig.KneelingHeightMillimeters + Kneeling = (numActuationsPerCycle * airConsumptionPerActuationNI).SI(Of NormLiter)() + + '** AdBlue ** + '=IF(K13="electric",0,G39*F54)- Supplied Spreadsheet + AdBlue = + If _ + (_pneumaticUserInputsConfig.AdBlueDosing = "Electric", 0, + _pneumaticAuxillariesConfig.AdBlueNIperMinute * (_signals.TotalCycleTimeSeconds / 60)).SI(Of NormLiter)() + + '** Regeneration ** + '=SUM(R6:R9)*IF(K9="yes",IF(COUNTBLANK(F41),G41,F41),IF(COUNTBLANK(F40),G40,F40)) - Supplied SpreadSheet + Regeneration = (Breaks + ParkBrakesplus2Doors + Kneeling + AdBlue) + Dim regenFraction As Double = + If(_pneumaticUserInputsConfig.SmartRegeneration, _pneumaticAuxillariesConfig.SmartRegenFractionTotalAirDemand, + _pneumaticAuxillariesConfig.NonSmartRegenFractionTotalAirDemand) + Regeneration = Regeneration * regenFraction + + '** DeadVolBlowOuts ** + '=IF(COUNTBLANK(F43),G43,F43)/(F54/60) - Supplied SpreadSheet + numActuationsPerCycle = _pneumaticAuxillariesConfig.DeadVolBlowOutsPerLitresperHour / + (60 / (_signals.TotalCycleTimeSeconds / 60)) + airConsumptionPerActuationNI = _pneumaticAuxillariesConfig.DeadVolumeLitres + DeadVolBlowOuts = (numActuationsPerCycle * airConsumptionPerActuationNI).SI(Of NormLiter)() + + '** AirSuspension ** + '=IF(K12="electrically",0,G38*F54) - Suplied Spreadsheet + AirSuspension = + If _ + (_pneumaticUserInputsConfig.AirSuspensionControl = "Electrically", 0, + _pneumaticAuxillariesConfig.AirControlledSuspensionNIperMinute * _cycleDurationMinutes).SI(Of NormLiter)() + + '** Total Air Demand ** + TotalAirDemand = Breaks + ParkBrakesplus2Doors + Kneeling + AdBlue + Regeneration + DeadVolBlowOuts + AirSuspension + + + Return TotalAirDemand + End Function + + + 'Get Average Power Demand @ Crank From Pneumatics + Public Function GetAveragePowerDemandAtCrankFromPneumatics() As Watt _ + Implements IM3_AveragePneumaticLoadDemand.GetAveragePowerDemandAtCrankFromPneumatics + + Return Sum4 + End Function + + 'Get Total Required Air Delivery Rate + Public Function AverageAirConsumedPerSecondLitre() As NormLiterPerSecond _ + Implements IM3_AveragePneumaticLoadDemand.AverageAirConsumedPerSecondLitre + + Return Sum1 + End Function + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/M4_AirCompressor.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/M4_AirCompressor.vb index 450caa370b8fae389587adea39fd5a68dd8f1450..8184910f54757e14c91a55b801abdad58b74e0aa 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/M4_AirCompressor.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/M4_AirCompressor.vb @@ -8,18 +8,19 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Namespace Pneumatics Public Class M4_AirCompressor Implements IM4_AirCompressor - Private Const MinRatio As Single = 1 - Private Const MaxRatio As Single = 10 - Private Const MinEff As Single = 0 - Private Const MaxEff As Single = 1 + Private Const MinRatio As Double = 1 + Private Const MaxRatio As Double = 10 + Private Const MinEff As Double = 0 + Private Const MaxEff As Double = 1 - Private _pulleyGearRatio As Single - Private _pulleyGearEfficiency As Single + Private _pulleyGearRatio As Double + Private _pulleyGearEfficiency As Double Private _map As ICompressorMap Private _signals As ISignals @@ -30,15 +31,15 @@ Namespace Pneumatics ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Public Property PulleyGearRatio() As Single Implements IM4_AirCompressor.PulleyGearRatio + Public Property PulleyGearRatio() As Double Implements IM4_AirCompressor.PulleyGearRatio Get Return _pulleyGearRatio End Get - Set(value As Single) + Set(value As Double) If (value < MinRatio OrElse value > MaxRatio) Then Throw _ - New ArgumentOutOfRangeException( - String.Format("Invalid value, should be in the range {0} to {1}", MinRatio, MaxRatio), value) + New ArgumentOutOfRangeException("pulleyGearRatio", value, + String.Format("Invalid value, should be in the range {0} to {1}", MinRatio, MaxRatio)) Else _pulleyGearRatio = value End If @@ -51,15 +52,16 @@ Namespace Pneumatics ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Public Property PulleyGearEfficiency() As Single Implements IM4_AirCompressor.PulleyGearEfficiency + Public Property PulleyGearEfficiency() As Double Implements IM4_AirCompressor.PulleyGearEfficiency Get Return _pulleyGearEfficiency End Get - Set(value As Single) + Set(value As Double) If (value < MinEff OrElse value > MaxEff) Then Throw _ - New ArgumentOutOfRangeException(String.Format("Invalid value, should be in the range {0} to {1}", MinEff, MaxEff), - value) + New ArgumentOutOfRangeException("pulleyGearEfficiency", value, + String.Format("Invalid value, should be in the range {0} to {1}", MinEff, MaxEff) + ) Else _pulleyGearEfficiency = value End If @@ -74,7 +76,7 @@ Namespace Pneumatics ''' <param name="pulleyGearRatio">Ratio of Pulley/Gear</param> ''' <param name="pulleyGearEfficiency">Efficiency of Pulley/Gear</param> ''' <remarks></remarks> - Public Sub New(ByVal map As ICompressorMap, ByRef pulleyGearRatio As Single, ByRef pulleyGearEfficiency As Single, + Public Sub New(ByVal map As ICompressorMap, ByRef pulleyGearRatio As Double, ByRef pulleyGearEfficiency As Double, signals As ISignals) _map = map @@ -108,8 +110,8 @@ Namespace Pneumatics ''' </summary> ''' <returns></returns> ''' <remarks></remarks> - Public Function GetFlowRate() As Single Implements IM4_AirCompressor.GetFlowRate - Dim compressorRpm As Single = _signals.EngineSpeed * PulleyGearRatio + Public Function GetFlowRate() As NormLiterPerSecond Implements IM4_AirCompressor.GetFlowRate + Dim compressorRpm As Double = _signals.EngineSpeed.AsRPM * PulleyGearRatio ''Flow Rate in the map is Litres/min so divide by 60 to get Units per second. Return _map.GetFlowRate(compressorRpm) / 60 @@ -120,7 +122,7 @@ Namespace Pneumatics ''' </summary> ''' <returns></returns> ''' <remarks></remarks> - Public Function GetPowerCompressorOff() As Single Implements IM4_AirCompressor.GetPowerCompressorOff + Public Function GetPowerCompressorOff() As Watt Implements IM4_AirCompressor.GetPowerCompressorOff Return GetCompressorPower(False) End Function @@ -129,7 +131,7 @@ Namespace Pneumatics ''' </summary> ''' <returns></returns> ''' <remarks></remarks> - Public Function GetPowerCompressorOn() As Single Implements IM4_AirCompressor.GetPowerCompressorOn + Public Function GetPowerCompressorOn() As Watt Implements IM4_AirCompressor.GetPowerCompressorOn Return GetCompressorPower(True) End Function @@ -138,9 +140,9 @@ Namespace Pneumatics ''' </summary> ''' <returns></returns> ''' <remarks></remarks> - Public Function GetPowerDifference() As Single Implements IM4_AirCompressor.GetPowerDifference - Dim powerOn As Single = GetPowerCompressorOn() - Dim powerOff As Single = GetPowerCompressorOff() + Public Function GetPowerDifference() As Watt Implements IM4_AirCompressor.GetPowerDifference + Dim powerOn As Watt = GetPowerCompressorOn() + Dim powerOff As Watt = GetPowerCompressorOff() Return powerOn - powerOff End Function @@ -150,8 +152,8 @@ Namespace Pneumatics ''' <param name="compressorOn">Is compressor on</param> ''' <returns></returns> ''' <remarks></remarks> - Private Function GetCompressorPower(ByVal compressorOn As Boolean) As Single - Dim compressorRpm As Single = _signals.EngineSpeed * PulleyGearRatio + Private Function GetCompressorPower(ByVal compressorOn As Boolean) As Watt + Dim compressorRpm As Double = _signals.EngineSpeed.AsRPM * PulleyGearRatio If compressorOn Then Return _map.GetPowerCompressorOn(compressorRpm) Else @@ -164,10 +166,10 @@ Namespace Pneumatics ''' </summary> ''' <returns></returns> ''' <remarks></remarks> - Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Single _ + Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As SI _ Implements IM4_AirCompressor.GetAveragePowerDemandPerCompressorUnitFlowRate - Return _map.GetAveragePowerDemandPerCompressorUnitFlowRate() + Return _map.GetAveragePowerDemandPerCompressorUnitFlowRate().SI() End Function End Class End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticActuationsMap.vb b/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticActuationsMap.vb index 7191adda32503b3451f698243042cb938a251e83..714e6efb105aaf2fa1f6cc9e9b81aadc835df530 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticActuationsMap.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticActuationsMap.vb @@ -9,99 +9,93 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports System.Globalization Imports System.IO Namespace Pneumatics + Public Class PneumaticActuationsMAP + Implements IPneumaticActuationsMAP -Public Class PneumaticActuationsMAP -Implements IPneumaticActuationsMAP + Private map As Dictionary(Of ActuationsKey, Integer) + Private filePath As String -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 -Public Function GetNumActuations(key As ActuationsKey) As Integer Implements IPneumaticActuationsMAP.GetNumActuations + Return map(key) + End Function - 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) + Public Sub New(filePath As String) + Me.filePath = filePath -End Function + If filePath.Trim.Length = 0 Then _ + Throw New ArgumentException("A filename for the Pneumatic Actuations Map has not been supplied") + Initialise() + End Sub -Public Sub New(filePath As String) + Public Function Initialise() As Boolean Implements IPneumaticActuationsMAP.Initialise - Me.filePath = filePath + Dim newKey As ActuationsKey + Dim numActuations As Integer - If filePath.Trim.Length=0 then Throw New ArgumentException("A filename for the Pneumatic Actuations Map has not been supplied") + 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) - Initialise() + '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") -End Sub + 'add values to map - Public Function Initialise() As Boolean Implements IPneumaticActuationsMAP.Initialise - Dim newKey As ActuationsKey - Dim numActuations As Single + If Not Integer.TryParse(elements(2), numActuations) Then + Throw New ArgumentException("Pneumatic Actuations Map Contains Non Integer values in actuations column") + End If - 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) + 'Should throw exception if ConsumerName or CycleName are empty. + newKey = New ActuationsKey(elements(0).ToString(), elements(1).ToString()) - '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.Add(newKey, Integer.Parse(elements(2), CultureInfo.InvariantCulture)) - map = New Dictionary(Of ActuationsKey, Integer)() - Dim firstline As Boolean = True + Else + firstline = False + End If + Next + End Using - For Each line As String In lines - If Not firstline Then - 'split the line - Dim elements() As String = line.Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries) - '3 entries per line required - If (elements.Length <> 3) Then Throw New ArgumentException("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, CType(elements(2), Single)) - - Else - firstline = False - End If - Next - End Using - - - Else - Throw New ArgumentException(String.Format(" Pneumatic Acutations map '{0}' supplied does not exist", filePath)) - Return False - 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 + 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 index 940621baa91110233daa1448912de51dc3ef3f8d..ece5e02a5eda3dd421ba374e4fc405c91045d549 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticUserInputsConfig.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticUserInputsConfig.vb @@ -10,56 +10,50 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Namespace Pneumatics - - Public Class PneumaticUserInputsConfig - Implements IPneumaticUserInputsConfig - - Public Property CompressorMap As String Implements IPneumaticUserInputsConfig.CompressorMap - Public Property CompressorGearRatio As Single Implements IPneumaticUserInputsConfig.CompressorGearRatio - Public Property CompressorGearEfficiency As Single 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 Single 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 - + 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 index 217356c9545ad4cd4a150ae44129b418a30a1b5c..5e4fc8d7d8d05bfd720c144c7d449a2eb381448e 100644 --- a/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticsAuxilliariesConfig.vb +++ b/VECTOAux/VectoAuxiliaries/Pneumatics/PneumaticsAuxilliariesConfig.vb @@ -10,52 +10,62 @@ ' See the LICENSE.txt for the specific language governing permissions and limitations. Namespace Pneumatics + Public Class PneumaticsAuxilliariesConfig + Implements IPneumaticsAuxilliariesConfig -Public Class PneumaticsAuxilliariesConfig -Implements IPneumaticsAuxilliariesConfig + Public Property AdBlueNIperMinute As Double Implements IPneumaticsAuxilliariesConfig.AdBlueNIperMinute + Public Property AirControlledSuspensionNIperMinute As Double _ + Implements IPneumaticsAuxilliariesConfig.AirControlledSuspensionNIperMinute - Public Property AdBlueNIperMinute As Single Implements IPneumaticsAuxilliariesConfig.AdBlueNIperMinute - Public Property AirControlledSuspensionNIperMinute As Single Implements IPneumaticsAuxilliariesConfig.AirControlledSuspensionNIperMinute - Public Property BrakingNoRetarderNIperKG As Single Implements IPneumaticsAuxilliariesConfig.BrakingNoRetarderNIperKG - Public Property BrakingWithRetarderNIperKG As Single Implements IPneumaticsAuxilliariesConfig.BrakingWithRetarderNIperKG - Public Property BreakingPerKneelingNIperKGinMM As Single Implements IPneumaticsAuxilliariesConfig.BreakingPerKneelingNIperKGinMM - Public Property DeadVolBlowOutsPerLitresperHour As Single Implements IPneumaticsAuxilliariesConfig.DeadVolBlowOutsPerLitresperHour - Public Property DeadVolumeLitres As Single Implements IPneumaticsAuxilliariesConfig.DeadVolumeLitres - Public Property NonSmartRegenFractionTotalAirDemand As Single Implements IPneumaticsAuxilliariesConfig.NonSmartRegenFractionTotalAirDemand - Public Property OverrunUtilisationForCompressionFraction As Single Implements IPneumaticsAuxilliariesConfig.OverrunUtilisationForCompressionFraction - Public Property PerDoorOpeningNI As Single Implements IPneumaticsAuxilliariesConfig.PerDoorOpeningNI - Public Property PerStopBrakeActuationNIperKG As Single Implements IPneumaticsAuxilliariesConfig.PerStopBrakeActuationNIperKG - Public Property SmartRegenFractionTotalAirDemand As Single Implements IPneumaticsAuxilliariesConfig.SmartRegenFractionTotalAirDemand + Public Property BrakingNoRetarderNIperKG As Double Implements IPneumaticsAuxilliariesConfig.BrakingNoRetarderNIperKG + Public Property BrakingWithRetarderNIperKG As Double _ + Implements IPneumaticsAuxilliariesConfig.BrakingWithRetarderNIperKG - Public Sub New(Optional setToDefaults As Boolean = False) + Public Property BreakingPerKneelingNIperKGinMM As Double _ + Implements IPneumaticsAuxilliariesConfig.BreakingPerKneelingNIperKGinMM - If setToDefaults Then SetDefaults() + Public Property DeadVolBlowOutsPerLitresperHour As Double _ + Implements IPneumaticsAuxilliariesConfig.DeadVolBlowOutsPerLitresperHour - End Sub + Public Property DeadVolumeLitres As Double Implements IPneumaticsAuxilliariesConfig.DeadVolumeLitres - 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 + Public Property NonSmartRegenFractionTotalAirDemand As Double _ + Implements IPneumaticsAuxilliariesConfig.NonSmartRegenFractionTotalAirDemand + Public Property OverrunUtilisationForCompressionFraction As Double _ + Implements IPneumaticsAuxilliariesConfig.OverrunUtilisationForCompressionFraction -End Class + Public Property PerDoorOpeningNI As Double Implements IPneumaticsAuxilliariesConfig.PerDoorOpeningNI + Public Property PerStopBrakeActuationNIperKG As Double _ + Implements IPneumaticsAuxilliariesConfig.PerStopBrakeActuationNIperKG + Public Property SmartRegenFractionTotalAirDemand As Double _ + Implements IPneumaticsAuxilliariesConfig.SmartRegenFractionTotalAirDemand -End Namespace + 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 diff --git a/VECTOAux/VectoAuxiliaries/UI/FB_Dialog.vb b/VECTOAux/VectoAuxiliaries/UI/FB_Dialog.vb index af1415d8e8ed4926e0ee39cdb7e839e8aee0b159..b689779c9f6e2b23e61eae1420c934562fc8c1a1 100644 --- a/VECTOAux/VectoAuxiliaries/UI/FB_Dialog.vb +++ b/VECTOAux/VectoAuxiliaries/UI/FB_Dialog.vb @@ -17,995 +17,1012 @@ Imports System.Windows.Forms ''' </summary> ''' <remarks></remarks> Public Class FB_Dialog - - Private MyFolder As String - Private MyFiles() As String - Private MyDrive As String - Private UpdateLock As Boolean - Private Initialized As Boolean - Private MyID As String - Private MyExt() As String - Private LastFile As String - Private bFileMustExist As Boolean - Private bOverwriteCheck As Boolean - Private bMultiFiles As Boolean - Private NoExt As Boolean - Private bBrowseFolder As Boolean - Private bForceExt As Boolean - Private ExtListSingle As ArrayList - Private ExtListMulti As ArrayList - Private LastExt As String - Private bLightMode As Boolean - - Private Const FavText As String = "Edit Favorites..." - Private Const EmptyText As String = " " - Private Const NoFavString As String = "<undefined>" - - 'New - Public Sub New(ByVal LightMode As Boolean) - ' This call is required by the Windows Form Designer. - InitializeComponent() - ' Append any initialization after the InitializeComponent() call. - MyID = "Default" - UpdateLock = False - Initialized = False - MyFolder = "" - MyDrive = "" - LastFile = "" - bOverwriteCheck = False - bFileMustExist = False - bMultiFiles = False - NoExt = True - bBrowseFolder = False - bLightMode = LightMode - Me.ButtonHisFile.Enabled = Not bLightMode - End Sub - - 'Resize - Private Sub FB_Dialog_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize - Resized() - End Sub - - 'Shown - Private Sub FileBrowser_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown - Resized() - Me.TextBoxPath.Focus() - Me.TextBoxPath.SelectAll() - End Sub - - 'Resized ListView Format - Private Sub Resized() - Me.ListViewFolder.Columns(0).Width = -2 - Me.ListViewFiles.Columns(0).Width = -2 - End Sub - - 'SplitterMoved - Private Sub SplitContainer1_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer1.SplitterMoved - If Initialized Then Resized() - End Sub - - 'Closing (Overwrite-Check etc) - Private Sub FileBrowser_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing - Dim x As Int32 - Dim path As String - Dim Ext As String - Dim HasExt As Boolean - HasExt = False - If Me.DialogResult = Windows.Forms.DialogResult.OK Then - If bBrowseFolder Then - path = Trim(Me.TextBoxPath.Text) - 'If empty path: use the Current-folder(MyFolder) - If path = "" Then - path = MyFolder - Else - If Microsoft.VisualBasic.Mid(path, 2, 1) <> ":" Then path = MyFolder & path - End If - If Not IO.Directory.Exists(path) Then - MsgBox("Directory " & path & " does not exist!", MsgBoxStyle.Critical) - e.Cancel = True - Exit Sub - End If - If Microsoft.VisualBasic.Right(path, 1) <> "\" Then path &= "\" - ReDim MyFiles(0) - MyFiles(0) = path - Else - 'Stop if empty path - If Trim(Me.TextBoxPath.Text) = "" Then - e.Cancel = True - Exit Sub - End If - LastExt = Trim(Me.ComboBoxExt.Text) - 'Assume Files in array - If Microsoft.VisualBasic.Left(Me.TextBoxPath.Text, 1) = "<" And Me.ListViewFiles.SelectedItems.Count > 0 Then - 'Multiple files selected - ReDim MyFiles(Me.ListViewFiles.SelectedItems.Count - 1) - x = -1 - For Each lv0 As ListViewItem In Me.ListViewFiles.Items - If lv0.Selected Then - x += 1 - MyFiles(x) = MyFolder & lv0.SubItems(0).Text - End If - Next - bMultiFiles = True - Else - 'Single File - path = Trim(Me.TextBoxPath.Text) - 'Primary extension (eg for bForceExt) - Ext = Trim(Me.ComboBoxExt.Text.Split(",")(0)) - 'If file without path then append path - If Microsoft.VisualBasic.Mid(path, 2, 1) <> ":" Then path = MyFolder & path - 'If instead of File a Folder is entered: Switch to Folder and Abort - If IO.Directory.Exists(path) Then - SetFolder(path) - e.Cancel = True - Exit Sub - End If - 'Force Extension - If bForceExt Then - If UCase(IO.Path.GetExtension(path)) <> "." & UCase(Ext) Then path &= "." & Ext - HasExt = True - Else - 'Check whether specified a File with Ext - HasExt = (Microsoft.VisualBasic.Len(IO.Path.GetExtension(path)) > 1) - End If - 'If File without Extension (after bForceExt question) and it does not exist, then add primary Extension - If Not HasExt Then - If Ext <> "*" And Ext <> "" Then - If Not IO.File.Exists(path) Then path &= "." & Ext - End If - End If - 'Check that File exists - If IO.File.Exists(path) Then - 'Yes: when bOverwriteCheck, check for Overwrite - If bOverwriteCheck Then - If MsgBox("Overwrite " & path & " ?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then - e.Cancel = True - Exit Sub - End If - End If - Else - 'No: abort if bFileMustExist - If bFileMustExist Then - MsgBox("The file " & path & " does not exist!", MsgBoxStyle.Critical) - e.Cancel = True - Exit Sub - End If - End If - 'Define MyFiles - ReDim MyFiles(0) - MyFiles(0) = path - bMultiFiles = False - End If - End If - End If - End Sub - - 'Browse - Custom Dialog - Public Function Browse(ByVal path As String, ByVal FileMustExist As Boolean, ByVal OverwriteCheck As Boolean, ByVal ExtMode As tFbExtMode, ByVal MultiFile As Boolean, ByVal Ext As String, ByVal Title As String) As Boolean - Dim x As Int16 - - If Not Initialized Then Init() - - 'Load Folder History ContextMenu - For x = 0 To 9 - Me.ContextMenuHisFolder.Items(x).Text = FB_FolderHistory(x) - Next - For x = 10 To 19 - Me.ContextMenuHisFolder.Items(x + 1).Text = FB_FolderHistory(x) - Next - - 'Options - bOverwriteCheck = OverwriteCheck - bFileMustExist = FileMustExist - bForceExt = (ExtMode = tFbExtMode.ForceExt) - - 'Form Config - Me.ListViewFiles.MultiSelect = MultiFile - Me.ButtonAll.Visible = MultiFile - Me.Text = Title - - 'Ext-Combobox - Me.ComboBoxExt.Items.Clear() - If NoExt Then - Me.ComboBoxExt.Items.Add("*") - Me.ComboBoxExt.SelectedIndex = 0 - Else - Select Case ExtMode - Case tFbExtMode.ForceExt - If Ext = "" Then Ext = ExtListSingle(0).ToString - Me.ComboBoxExt.Items.AddRange(ExtListSingle.ToArray) - Me.ComboBoxExt.Text = Ext - Me.ComboBoxExt.Enabled = False - Case tFbExtMode.MultiExt, tFbExtMode.SingleExt - If ExtMode = tFbExtMode.MultiExt Then - Me.ComboBoxExt.Items.AddRange(ExtListMulti.ToArray) - Else - Me.ComboBoxExt.Items.AddRange(ExtListSingle.ToArray) - End If - If Ext <> "" Then - Me.ComboBoxExt.Text = Ext - Else - Me.ComboBoxExt.Text = LastExt - End If - Me.ComboBoxExt.Enabled = True - End Select - End If - - - 'Define Path - ' If no path is specified: Last folder, no file name - If path = "" Then path = FB_FolderHistory(0) - - ' If path-length too small (Path is invalid): Last File - If path.Length < 2 Then path = LastFile - - 'Open Folder - If no folder in the path: Last folder - If fPATH(path) = "" Then - 'If given a file without path - If Trim(FB_FolderHistory(0)) = "" Then - SetFolder("C:\") - Else - SetFolder(FB_FolderHistory(0)) - End If - Else - '...Otherwise: - SetFolder(fPATH(path)) - End If - If bBrowseFolder Then - FolderUp() - Me.TextBoxPath.Text = path - Else - Me.TextBoxPath.Text = IO.Path.GetFileName(path) - End If - - 'Show form ------------------------------------------------ ---- - Me.ShowDialog() - If Me.DialogResult = Windows.Forms.DialogResult.OK Then - 'File / Folder History - If bMultiFiles Then - LastFile = MyFolder - UpdateHisFolder(MyFolder) - Else - LastFile = MyFiles(0) - UpdateHisFolder(fPATH(LastFile)) - If Not bBrowseFolder Then UpdateHisFile(LastFile) - End If - 'Update Global History Folder - For x = 0 To 9 - FB_FolderHistory(x) = Me.ContextMenuHisFolder.Items(x).Text - Next - For x = 10 To 19 - FB_FolderHistory(x) = Me.ContextMenuHisFolder.Items(x + 1).Text - Next - Return True - Else - Return False - End If - End Function - - 'Close and save File / Folder History - Public Sub SaveAndClose() - Dim f As System.IO.StreamWriter - Dim x As Int16 - 'Folder History - If FB_Init Then - Try - f = My.Computer.FileSystem.OpenTextFileWriter(FB_FilHisDir & "Directories.txt", False, System.Text.Encoding.UTF8) - For x = 0 To 19 - f.WriteLine(FB_FolderHistory(x)) - Next - f.Close() - f.Dispose() - Catch ex As Exception - End Try - FB_Init = False - End If - 'File History - If Initialized And Not bLightMode Then - If Not bBrowseFolder Then - Try - f = My.Computer.FileSystem.OpenTextFileWriter(FB_FilHisDir & MyID & ".txt", False, System.Text.Encoding.UTF8) - For x = 0 To 9 - f.WriteLine(Me.ContextMenuHisFile.Items(x).Text) - Next - f.Close() - f.Dispose() - Catch ex As Exception - End Try - End If - Initialized = False - End If - f = Nothing - 'Close - Me.Close() - End Sub - - 'Switching to FolderBrowser - Public Sub SetFolderBrowser() - If Initialized Then Exit Sub - bBrowseFolder = True - Me.Width = 500 - Me.ListViewFiles.Enabled = False - Me.ButtonHisFile.Enabled = False - Me.TextBoxSearchFile.Enabled = False - Me.SplitContainer1.Panel2Collapsed = True - Me.Text = "Directory Browser" - End Sub - - 'Initialize - Private Sub Init() - Dim x As Int16 - Dim line As String - Dim f As System.IO.StreamReader - - UpdateLock = True - - 'Initialization for Global File Browser - If Not FB_Init Then GlobalInit() - - 'Load Drive ComboBox - For x = 0 To UBound(FB_Drives) - Me.ComboBoxDrive.Items.Add(FB_Drives(x)) - Next - - 'FolderHistory ContextMenu - Me.ContextMenuHisFolder.Items.Clear() - For x = 0 To 9 - Me.ContextMenuHisFolder.Items.Add("") - Next - Me.ContextMenuHisFolder.Items.Add("-") - For x = 10 To 19 - Me.ContextMenuHisFolder.Items.Add("") - Next - Me.ContextMenuHisFolder.Items.Add("-") - Me.ContextMenuHisFolder.Items.Add(FavText) - - 'FileHistory ContextMenu - If bBrowseFolder Then - LastFile = FB_FolderHistory(0) - ElseIf Not bLightMode Then - For x = 0 To 9 - Me.ContextMenuHisFile.Items.Add("") - Next - If IO.File.Exists(FB_FilHisDir & MyID & ".txt") Then - f = New System.IO.StreamReader(FB_FilHisDir & MyID & ".txt") - x = -1 - Do While Not f.EndOfStream And x < 9 - x += 1 - line = f.ReadLine - Me.ContextMenuHisFile.Items(x).Text = line - If x = 0 Then LastFile = line - Loop - f.Close() - f.Dispose() - End If - End If - - 'Extension-ComboBox - If Not NoExt Then - ExtListSingle = New ArrayList - ExtListMulti = New ArrayList - For x = 0 To UBound(MyExt) - ExtListMulti.Add(MyExt(x)) - For Each line In MyExt(x).Split(",") - ExtListSingle.Add(Trim(line)) - Next - Next - ExtListMulti.Add("*") - ExtListSingle.Add("*") - End If - - Initialized = True - f = Nothing - UpdateLock = False - End Sub - - Private Sub GlobalInit() - Dim drive As String - Dim x As Int16 - - Dim f As System.IO.StreamReader - - 'Create Drive List - ReDim FB_Drives(UBound(IO.Directory.GetLogicalDrives())) - x = -1 - For Each drive In IO.Directory.GetLogicalDrives() - x += 1 - FB_Drives(x) = Microsoft.VisualBasic.Left(drive, 2) - Next - - 'Read Folder History - For x = 0 To 19 - FB_FolderHistory(x) = EmptyText - Next - If IO.File.Exists(FB_FilHisDir & "Directories.txt") Then - f = New System.IO.StreamReader(FB_FilHisDir & "Directories.txt") - x = -1 - Do While Not f.EndOfStream And x < 19 - x += 1 - FB_FolderHistory(x) = f.ReadLine() - Loop - f.Dispose() - f.Close() - End If - - FB_Init = True - - f = Nothing - End Sub - - 'ComboBoxDrive_SelectedIndexChanged - Private Sub ComboBoxDrive_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBoxDrive.SelectedIndexChanged - If Not UpdateLock Then SetFolder(Me.ComboBoxDrive.SelectedItem.ToString) - End Sub - - - 'ButtonFolderBack_Click - Private Sub ButtonFolderBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonFolderBack.Click - FolderUp() - End Sub - - 'TextBoxPath_KeyDown (ENTER) - Private Sub TextBoxPath_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBoxPath.KeyDown - Dim path As String - If e.KeyCode = Keys.Enter Then - path = Me.TextBoxPath.Text - If IO.Directory.Exists(path) Then - If bBrowseFolder Then - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - Else - SetFolder(path) - End If - Else - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - End If - End If - End Sub - - 'ListViewFolder_SelectedIndexChanged - Private Sub ListViewFolder_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListViewFolder.SelectedIndexChanged - If bBrowseFolder Then - UpdateLock = True - If Me.ListViewFolder.SelectedItems.Count > 0 Then - Me.TextBoxPath.Text = Me.ListViewFolder.SelectedItems.Item(0).Text & "\" - End If - UpdateLock = False - End If - End Sub - - 'ListViewFolder_MouseDoubleClick - Private Sub ListViewFolder_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListViewFolder.MouseDoubleClick - If Me.ListViewFolder.SelectedItems.Count = 0 Then Exit Sub - SetFolder(MyFolder & Me.ListViewFolder.SelectedItems.Item(0).Text) - End Sub - - 'ListViewFolder_KeyDown - Private Sub ListViewFolder_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListViewFolder.KeyDown - If e.KeyCode = Keys.Enter Then - If Me.ListViewFolder.SelectedItems.Count = 0 Then Exit Sub - SetFolder(MyFolder & Me.ListViewFolder.SelectedItems.Item(0).Text) - End If - End Sub - - ''<SORTER> - ''Private Sub ListViewFiles_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListViewFiles.ColumnClick - '' ' Determine if the clicked column is already the column that is - '' ' being sorted. - '' If (e.Column = lvwColumnSorter.SortColumn) Then - '' ' Reverse the current sort direction for this column. - '' If (lvwColumnSorter.Order = SortOrder.Ascending) Then - '' lvwColumnSorter.Order = SortOrder.Descending - '' Else - '' lvwColumnSorter.Order = SortOrder.Ascending - '' End If - '' Else - '' ' Set the column number that is to be sorted; default to ascending. - '' lvwColumnSorter.SortColumn = e.Column - '' lvwColumnSorter.Order = SortOrder.Ascending - '' End If - - '' ' Perform the sort with these new sort options. - '' Me.ListViewFiles.Sort() - - ''End Sub - - 'ListViewFiles_SelectedIndexChanged - Private Sub ListViewFiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListViewFiles.SelectedIndexChanged - UpdateLock = True - If Me.ListViewFiles.SelectedItems.Count = 0 Then - Me.TextBoxPath.Text = "" - Else - If Me.ListViewFiles.SelectedItems.Count > 1 Then - Me.TextBoxPath.Text = "<" & Me.ListViewFiles.SelectedItems.Count & " Files selected>" - Else - Me.TextBoxPath.Text = Me.ListViewFiles.SelectedItems.Item(0).Text - Me.TextBoxPath.SelectionStart = Me.TextBoxPath.Text.Length - End If - End If - UpdateLock = False - End Sub - - 'ListViewFiles_MouseDoubleClick - Private Sub ListViewFiles_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListViewFiles.MouseDoubleClick - If Me.ListViewFiles.SelectedItems.Count = 0 Then Exit Sub - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - End Sub - - 'ListViewFiles_KeyDown - Private Sub ListViewFiles_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListViewFiles.KeyDown - If e.KeyCode = Keys.Enter Then - If Me.ListViewFiles.SelectedItems.Count = 0 Then Exit Sub - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - End If - End Sub - - 'TextBoxSearchFolder_KeyDown - Private Sub TextBoxSearchFolder_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBoxSearchFolder.KeyDown - Dim ItemCount As Int32 - Dim SelIndex As Int32 - Dim NoItem As Boolean - ItemCount = Me.ListViewFolder.Items.Count - NoItem = (ItemCount = 0) - If Not NoItem Then - If Me.ListViewFolder.SelectedItems.Count = 0 Then - SelIndex = -1 - Else - SelIndex = Me.ListViewFolder.SelectedIndices(0) - End If - End If - Select Case e.KeyCode - Case Keys.Enter - If NoItem Then Exit Sub - If Me.ListViewFolder.SelectedItems.Count = 0 Then Me.ListViewFolder.SelectedIndices.Add(0) - SetFolder(MyFolder & Me.ListViewFolder.SelectedItems.Item(0).Text) - Case Keys.Up - If Not NoItem Then - If SelIndex < 1 Then - SelIndex = 1 - Else - Me.ListViewFolder.Items(SelIndex).Selected = False - End If - Me.ListViewFolder.Items(SelIndex - 1).Selected = True - Me.ListViewFolder.Items(SelIndex - 1).EnsureVisible() - End If - Case Keys.Down - If Not NoItem And SelIndex < ItemCount - 1 Then - If Not SelIndex = -1 Then Me.ListViewFolder.Items(SelIndex).Selected = False - Me.ListViewFolder.Items(SelIndex + 1).Selected = True - Me.ListViewFolder.Items(SelIndex + 1).EnsureVisible() - End If - Case Keys.Back - If Me.TextBoxSearchFolder.Text = "" Then FolderUp() - End Select - End Sub - - 'TextBoxSearchFolder_TextChanged - Private Sub TextBoxSearchFolder_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxSearchFolder.TextChanged - If Not UpdateLock Then LoadListFolder() - End Sub - - 'TextBoxSearchFile_KeyDown - Private Sub TextBoxSearchFile_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBoxSearchFile.KeyDown - Dim ItemCount As Int32 - Dim SelIndex As Int32 - Dim NoItem As Boolean - ItemCount = Me.ListViewFiles.Items.Count - NoItem = (ItemCount = 0) - If Not NoItem Then - If Me.ListViewFiles.SelectedItems.Count = 0 Then - SelIndex = -1 - Else - SelIndex = Me.ListViewFiles.SelectedIndices(0) - End If - End If - Select Case e.KeyCode - Case Keys.Enter - If NoItem Then Exit Sub - If Me.ListViewFiles.SelectedItems.Count = 0 Then Me.ListViewFiles.SelectedIndices.Add(0) - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() - Case Keys.Up - If Not NoItem Then - If SelIndex < 1 Then - SelIndex = 1 - Else - Me.ListViewFiles.Items(SelIndex).Selected = False - End If - Me.ListViewFiles.Items(SelIndex - 1).Selected = True - Me.ListViewFiles.Items(SelIndex - 1).EnsureVisible() - End If - Case Keys.Down - If Not NoItem And SelIndex < ItemCount - 1 Then - If Not SelIndex = -1 Then Me.ListViewFiles.Items(SelIndex).Selected = False - Me.ListViewFiles.Items(SelIndex + 1).Selected = True - Me.ListViewFiles.Items(SelIndex + 1).EnsureVisible() - End If - End Select - End Sub - - 'TextBoxSearchFile_TextChanged - Private Sub TextBoxSearchFile_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxSearchFile.TextChanged - If Not UpdateLock Then LoadListFiles() - End Sub - - 'ComboBoxExt_TextChanged - Private Sub ComboBoxExt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBoxExt.TextChanged - If Not UpdateLock Then LoadListFiles() - End Sub - - 'ButtonHisFolder_Click - Private Sub ButtonHisFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonHisFolder.Click - Me.ContextMenuHisFolder.Show(Control.MousePosition) - End Sub - - 'ButtonHisFile_Click - Private Sub ButtonHisFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonHisFile.Click - Me.ContextMenuHisFile.Show(Control.MousePosition) - End Sub - - 'Select All - Click - Private Sub ButtonAll_Click(sender As System.Object, e As System.EventArgs) Handles ButtonAll.Click - Dim i As Integer - Me.ListViewFiles.BeginUpdate() - For i = 0 To Me.ListViewFiles.Items.Count - 1 - Me.ListViewFiles.Items(i).Selected = True - Next - Me.ListViewFiles.EndUpdate() - End Sub - - 'ContextMenuHisFile_ItemClicked - Private Sub ContextMenuHisFile_ItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ContextMenuHisFile.ItemClicked - Dim path As String - - path = e.ClickedItem.Text.ToString - - If path = EmptyText Then Exit Sub - - SetFolder(fPATH(path)) - - Me.TextBoxPath.Text = IO.Path.GetFileName(path) - - End Sub - - 'ContextMenuHisFolder_ItemClicked - Private Sub ContextMenuHisFolder_ItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ContextMenuHisFolder.ItemClicked - Dim path As String - Dim favdlog As FB_FavDlog - Dim x As Integer - - path = e.ClickedItem.Text.ToString - - If path = EmptyText Then Exit Sub - - If path = FavText Then - favdlog = New FB_FavDlog - If favdlog.ShowDialog = Windows.Forms.DialogResult.OK Then - For x = 10 To 19 - path = favdlog.ListBox1.Items(x - 10) - If path = NoFavString Then - FB_FolderHistory(x) = EmptyText - Else - FB_FolderHistory(x) = path - End If - Me.ContextMenuHisFolder.Items(x + 1).Text = FB_FolderHistory(x) - Next - End If - Else - SetFolder(path) - End If - - End Sub - - 'TextBoxCurrent_MouseClick - Private Sub TextBoxCurrent_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBoxCurrent.MouseClick - Dim x As Int32 - Dim x1 As Int32 - Dim path As String - Dim newpath As String - newpath = "" - x = Me.TextBoxCurrent.SelectionStart - path = Me.TextBoxCurrent.Text - x1 = path.Length - If x = x1 Then Exit Sub - If x < 4 Then - SetFolder(Microsoft.VisualBasic.Left(path, 2)) - Exit Sub - End If - Do While x1 > x - newpath = path - 'path = Microsoft.VisualBasic.Left(path, x1 - 1) - path = Microsoft.VisualBasic.Left(path, path.LastIndexOf("\")) - x1 = path.Length - Loop - SetFolder(newpath) - End Sub - - 'ButtonDesktop_Click - Private Sub ButtonDesktop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDesktop.Click - SetFolder(FileIO.SpecialDirectories.Desktop.ToString) - End Sub - - 'Context Menu Update - Private Sub UpdateHisFile(ByVal path As String) - Dim x As Int16 - Dim y As Int16 - If bLightMode Then Exit Sub - 'Sort Context Menu - For x = 0 To 8 - If UCase(Me.ContextMenuHisFile.Items(x).Text.ToString) = UCase(path) Then Exit For - Next - For y = x To 1 Step -1 - Me.ContextMenuHisFile.Items(y).Text = Me.ContextMenuHisFile.Items(y - 1).Text - Next - Me.ContextMenuHisFile.Items(0).Text = path - End Sub - Private Sub UpdateHisFolder(ByVal path As String) - Dim x As Int16 - Dim y As Int16 - - 'Sort Context Menu - For x = 0 To 8 - If UCase(Me.ContextMenuHisFolder.Items(x).Text.ToString) = UCase(path) Then Exit For - Next - - For y = x To 1 Step -1 - Me.ContextMenuHisFolder.Items(y).Text = Me.ContextMenuHisFolder.Items(y - 1).Text - Next - - Me.ContextMenuHisFolder.Items(0).Text = path - - End Sub - - 'Manuelles History-Update - Public Sub UpdateHistory(ByVal path As String) - Dim x As Int16 - Dim y As Int16 - 'Init - If Not Initialized Then Init() - 'Files - UpdateHisFile(path) - 'Folder - path = fPATH(path) - For x = 0 To 8 - If UCase(FB_FolderHistory(x)) = UCase(path) Then Exit For - Next - For y = x To 1 Step -1 - FB_FolderHistory(y) = FB_FolderHistory(y - 1) - Next - FB_FolderHistory(0) = path - End Sub - - 'Change folder - Private Sub SetFolder(ByVal Path As String) - - 'Abort if no drive specified - If Microsoft.VisualBasic.Mid(Path, 2, 1) <> ":" Then Exit Sub - - UpdateLock = True - - 'Delete Search-fields - Me.TextBoxSearchFile.Text = "" - Me.TextBoxSearchFolder.Text = "" - - 'Set Drive - If MyDrive <> Microsoft.VisualBasic.Left(Path, 2) Then - MyDrive = UCase(Microsoft.VisualBasic.Left(Path, 2)) - Me.ComboBoxDrive.SelectedItem = MyDrive - End If - - 'Set Folder - MyFolder = Path - If Microsoft.VisualBasic.Right(MyFolder, 1) <> "\" Then MyFolder &= "\" - LoadListFolder() - LoadListFiles() - - If bBrowseFolder Then Me.TextBoxPath.Text = "" - - Me.TextBoxCurrent.Text = MyFolder - - 'Me.TextBoxPath.SelectionStart = Me.TextBoxPath.Text.Length - UpdateLock = False - - End Sub - - 'Folder one level up - Private Sub FolderUp() - Dim path As String - Dim x As Int32 - If MyFolder <> "" Then - path = Microsoft.VisualBasic.Left(MyFolder, MyFolder.Length - 1) - x = path.LastIndexOf("\") - If x > 0 Then SetFolder(Microsoft.VisualBasic.Left(path, x)) - End If - End Sub - - 'Load Folder-List - Private Sub LoadListFolder() - Dim SearchPat As String - 'Delete Folder-List - Me.ListViewFolder.Items.Clear() - SearchPat = "*" & Me.TextBoxSearchFolder.Text & "*" - Try - 'Add Folder - Dim di As New IO.DirectoryInfo(MyFolder) - Dim aryFi As IO.DirectoryInfo() - Dim fi As IO.DirectoryInfo - aryFi = di.GetDirectories(SearchPat) - For Each fi In aryFi - Me.ListViewFolder.Items.Add(fi.ToString) - Next - Catch ex As Exception - Me.ListViewFolder.Items.Add("<ERROR: " & ex.Message.ToString & ">") - End Try - End Sub - - 'Load File-list - Private Sub LoadListFiles() - Dim x As Int32 - Dim SearchPat As String - Dim SearchFile As String - Dim SearchExt As String - Dim ExtStr As String() - - 'Abort if bBrowseFolder - If bBrowseFolder Then Exit Sub - - Me.LabelFileAnz.Text = "0 Files" - 'Define Extension-filter - If Trim(Me.ComboBoxExt.Text.ToString) = "" Then - ExtStr = New String() {"*"} - Else - ExtStr = Me.ComboBoxExt.Text.ToString.Split(",") - End If - - 'Delete File-List - Me.ListViewFiles.Items.Clear() - - SearchFile = Me.TextBoxSearchFile.Text - - Me.ListViewFiles.BeginUpdate() - Try - 'Add Folder - Dim di As New IO.DirectoryInfo(MyFolder) - Dim aryFi As IO.FileInfo() - Dim fi As IO.FileInfo - x = -1 - For Each SearchExt In ExtStr - SearchPat = "*" & Trim(SearchFile) & "*." & Trim(SearchExt) - aryFi = di.GetFiles(SearchPat) - For Each fi In aryFi - x += 1 - Me.ListViewFiles.Items.Add(fi.ToString) - Next - Next - If x = 0 Then - Me.LabelFileAnz.Text = "1 File" - Else - Me.LabelFileAnz.Text = x + 1 & " Files" - End If - Catch ex As Exception - Me.ListViewFiles.Items.Add("<ERROR: " & ex.Message.ToString & ">") - End Try - - Me.ListViewFiles.EndUpdate() - - End Sub - - 'Rename File - Private Sub RenameFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RenameFileToolStripMenuItem.Click - Dim file0 As String - Dim file As String - If Me.ListViewFiles.SelectedItems.Count = 1 Then - file0 = Me.ListViewFiles.SelectedItems(0).Text - file = file0 -lb1: - file = InputBox("New Filename", "Rename " & file0, file) - If file <> "" Then - If IO.File.Exists(MyFolder & file) Then - MsgBox("File " & file & " already exists!") - GoTo lb1 - End If - Try - My.Computer.FileSystem.RenameFile(MyFolder & file0, file) - LoadListFiles() - Catch ex As Exception - MsgBox("Cannot rename " & file0 & "!") - End Try - End If - End If - End Sub - - 'Delete File - Private Sub DeleteFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteFileToolStripMenuItem.Click - Dim x As Int32 - Dim c As Int32 - c = Me.ListViewFiles.SelectedItems.Count - If c > 0 Then - If c = 1 Then - If MsgBox("Delete " & MyFolder & Me.ListViewFiles.SelectedItems(0).Text & "?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then Exit Sub - Else - If MsgBox("Delete " & c & " files?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then Exit Sub - End If - For x = 0 To c - 1 - Try - IO.File.Delete(MyFolder & Me.ListViewFiles.SelectedItems(x).Text) - Catch ex As Exception - End Try - Next - LoadListFiles() - End If - End Sub - - 'Neuer Ordner - Private Sub ButtonNewDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonNewDir.Click - Dim f As String - f = "New Folder" -lb10: - f = InputBox("Create New Folder", "New Folder", f) - If f <> "" Then - If IO.Directory.Exists(MyFolder & f) Then - MsgBox("Folder " & MyFolder & f & " already exists!") - GoTo lb10 - End If - Try - IO.Directory.CreateDirectory(MyFolder & f) - SetFolder(MyFolder & f) - Catch ex As Exception - MsgBox("Cannot create " & f & "!") - End Try - End If - End Sub - - ''Private Function fTimeString(ByVal T As Date) As String - '' Return T.Year & "-" & T.Month.ToString("00") & "-" & T.Day.ToString("00") & " " & T.Hour.ToString("00") & ":" & T.Minute.ToString("00") & ":" & T.Second.ToString("00") - ''End Function - - - Private Function fPATH(ByVal Pfad As String) As String - Dim x As Int16 - x = Pfad.LastIndexOf("\") - If x = -1 Then - Return Microsoft.VisualBasic.Left(Pfad, 0) - Else - Return Microsoft.VisualBasic.Left(Pfad, x + 1) - End If - End Function - - Public ReadOnly Property Folder() As String - Get - Return MyFolder - End Get - End Property - - Public ReadOnly Property Files() As String() - Get - Return MyFiles - End Get - End Property - - Public Property ID() As String - Get - Return MyID - End Get - Set(ByVal value As String) - MyID = value - End Set - End Property - - Public Property Extensions() As String() - Get - Return MyExt - End Get - Set(ByVal value As String()) - MyExt = value - LastExt = MyExt(0) - NoExt = False - End Set - End Property - - + Private MyFolder As String + Private MyFiles() As String + Private MyDrive As String + Private UpdateLock As Boolean + Private Initialized As Boolean + Private MyID As String + Private MyExt() As String + Private LastFile As String + Private bFileMustExist As Boolean + Private bOverwriteCheck As Boolean + Private bMultiFiles As Boolean + Private NoExt As Boolean + Private bBrowseFolder As Boolean + Private bForceExt As Boolean + Private ExtListSingle As ArrayList + Private ExtListMulti As ArrayList + Private LastExt As String + Private bLightMode As Boolean + + Private Const FavText As String = "Edit Favorites..." + Private Const EmptyText As String = " " + Private Const NoFavString As String = "<undefined>" + + 'New + Public Sub New(ByVal LightMode As Boolean) + ' This call is required by the Windows Form Designer. + InitializeComponent() + ' Append any initialization after the InitializeComponent() call. + MyID = "Default" + UpdateLock = False + Initialized = False + MyFolder = "" + MyDrive = "" + LastFile = "" + bOverwriteCheck = False + bFileMustExist = False + bMultiFiles = False + NoExt = True + bBrowseFolder = False + bLightMode = LightMode + Me.ButtonHisFile.Enabled = Not bLightMode + End Sub + + 'Resize + Private Sub FB_Dialog_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize + Resized() + End Sub + + 'Shown + Private Sub FileBrowser_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown + Resized() + Me.TextBoxPath.Focus() + Me.TextBoxPath.SelectAll() + End Sub + + 'Resized ListView Format + Private Sub Resized() + Me.ListViewFolder.Columns(0).Width = - 2 + Me.ListViewFiles.Columns(0).Width = - 2 + End Sub + + 'SplitterMoved + Private Sub SplitContainer1_SplitterMoved(ByVal sender As System.Object, + ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer1.SplitterMoved + If Initialized Then Resized() + End Sub + + 'Closing (Overwrite-Check etc) + Private Sub FileBrowser_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) _ + Handles Me.FormClosing + Dim x As Int32 + Dim path As String + Dim Ext As String + Dim HasExt As Boolean + HasExt = False + If Me.DialogResult = Windows.Forms.DialogResult.OK Then + If bBrowseFolder Then + path = Trim(Me.TextBoxPath.Text) + 'If empty path: use the Current-folder(MyFolder) + If path = "" Then + path = MyFolder + Else + If Microsoft.VisualBasic.Mid(path, 2, 1) <> ":" Then path = MyFolder & path + End If + If Not IO.Directory.Exists(path) Then + MsgBox("Directory " & path & " does not exist!", MsgBoxStyle.Critical) + e.Cancel = True + Exit Sub + End If + If Microsoft.VisualBasic.Right(path, 1) <> "\" Then path &= "\" + ReDim MyFiles(0) + MyFiles(0) = path + Else + 'Stop if empty path + If Trim(Me.TextBoxPath.Text) = "" Then + e.Cancel = True + Exit Sub + End If + LastExt = Trim(Me.ComboBoxExt.Text) + 'Assume Files in array + If Microsoft.VisualBasic.Left(Me.TextBoxPath.Text, 1) = "<" And Me.ListViewFiles.SelectedItems.Count > 0 Then + 'Multiple files selected + ReDim MyFiles(Me.ListViewFiles.SelectedItems.Count - 1) + x = - 1 + For Each lv0 As ListViewItem In Me.ListViewFiles.Items + If lv0.Selected Then + x += 1 + MyFiles(x) = MyFolder & lv0.SubItems(0).Text + End If + Next + bMultiFiles = True + Else + 'Single File + path = Trim(Me.TextBoxPath.Text) + 'Primary extension (eg for bForceExt) + Ext = Trim(Me.ComboBoxExt.Text.Split(","c)(0)) + 'If file without path then append path + If Microsoft.VisualBasic.Mid(path, 2, 1) <> ":" Then path = MyFolder & path + 'If instead of File a Folder is entered: Switch to Folder and Abort + If IO.Directory.Exists(path) Then + SetFolder(path) + e.Cancel = True + Exit Sub + End If + 'Force Extension + If bForceExt Then + If UCase(IO.Path.GetExtension(path)) <> "." & UCase(Ext) Then path &= "." & Ext + HasExt = True + Else + 'Check whether specified a File with Ext + HasExt = (Microsoft.VisualBasic.Len(IO.Path.GetExtension(path)) > 1) + End If + 'If File without Extension (after bForceExt question) and it does not exist, then add primary Extension + If Not HasExt Then + If Ext <> "*" And Ext <> "" Then + If Not IO.File.Exists(path) Then path &= "." & Ext + End If + End If + 'Check that File exists + If IO.File.Exists(path) Then + 'Yes: when bOverwriteCheck, check for Overwrite + If bOverwriteCheck Then + If MsgBox("Overwrite " & path & " ?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then + e.Cancel = True + Exit Sub + End If + End If + Else + 'No: abort if bFileMustExist + If bFileMustExist Then + MsgBox("The file " & path & " does not exist!", MsgBoxStyle.Critical) + e.Cancel = True + Exit Sub + End If + End If + 'Define MyFiles + ReDim MyFiles(0) + MyFiles(0) = path + bMultiFiles = False + End If + End If + End If + End Sub + + 'Browse - Custom Dialog + Public Function Browse(ByVal path As String, ByVal FileMustExist As Boolean, ByVal OverwriteCheck As Boolean, + ByVal ExtMode As tFbExtMode, ByVal MultiFile As Boolean, ByVal Ext As String, ByVal Title As String) As Boolean + Dim x As Int16 + + If Not Initialized Then Init() + + 'Load Folder History ContextMenu + For x = 0 To 9 + Me.ContextMenuHisFolder.Items(x).Text = FB_FolderHistory(x) + Next + For x = 10 To 19 + Me.ContextMenuHisFolder.Items(x + 1).Text = FB_FolderHistory(x) + Next + + 'Options + bOverwriteCheck = OverwriteCheck + bFileMustExist = FileMustExist + bForceExt = (ExtMode = tFbExtMode.ForceExt) + + 'Form Config + Me.ListViewFiles.MultiSelect = MultiFile + Me.ButtonAll.Visible = MultiFile + Me.Text = Title + + 'Ext-Combobox + Me.ComboBoxExt.Items.Clear() + If NoExt Then + Me.ComboBoxExt.Items.Add("*") + Me.ComboBoxExt.SelectedIndex = 0 + Else + Select Case ExtMode + Case tFbExtMode.ForceExt + If Ext = "" Then Ext = ExtListSingle(0).ToString + Me.ComboBoxExt.Items.AddRange(ExtListSingle.ToArray) + Me.ComboBoxExt.Text = Ext + Me.ComboBoxExt.Enabled = False + Case tFbExtMode.MultiExt, tFbExtMode.SingleExt + If ExtMode = tFbExtMode.MultiExt Then + Me.ComboBoxExt.Items.AddRange(ExtListMulti.ToArray) + Else + Me.ComboBoxExt.Items.AddRange(ExtListSingle.ToArray) + End If + If Ext <> "" Then + Me.ComboBoxExt.Text = Ext + Else + Me.ComboBoxExt.Text = LastExt + End If + Me.ComboBoxExt.Enabled = True + End Select + End If + + + 'Define Path + ' If no path is specified: Last folder, no file name + If path = "" Then path = FB_FolderHistory(0) + + ' If path-length too small (Path is invalid): Last File + If path.Length < 2 Then path = LastFile + + 'Open Folder - If no folder in the path: Last folder + If fPATH(path) = "" Then + 'If given a file without path + If Trim(FB_FolderHistory(0)) = "" Then + SetFolder("C:\") + Else + SetFolder(FB_FolderHistory(0)) + End If + Else + '...Otherwise: + SetFolder(fPATH(path)) + End If + If bBrowseFolder Then + FolderUp() + Me.TextBoxPath.Text = path + Else + Me.TextBoxPath.Text = IO.Path.GetFileName(path) + End If + + 'Show form ------------------------------------------------ ---- + Me.ShowDialog() + If Me.DialogResult = Windows.Forms.DialogResult.OK Then + 'File / Folder History + If bMultiFiles Then + LastFile = MyFolder + UpdateHisFolder(MyFolder) + Else + LastFile = MyFiles(0) + UpdateHisFolder(fPATH(LastFile)) + If Not bBrowseFolder Then UpdateHisFile(LastFile) + End If + 'Update Global History Folder + For x = 0 To 9 + FB_FolderHistory(x) = Me.ContextMenuHisFolder.Items(x).Text + Next + For x = 10 To 19 + FB_FolderHistory(x) = Me.ContextMenuHisFolder.Items(x + 1).Text + Next + Return True + Else + Return False + End If + End Function + + 'Close and save File / Folder History + Public Sub SaveAndClose() + Dim f As System.IO.StreamWriter + Dim x As Int16 + 'Folder History + If FB_Init Then + Try + f = My.Computer.FileSystem.OpenTextFileWriter(FB_FilHisDir & "Directories.txt", False, System.Text.Encoding.UTF8) + For x = 0 To 19 + f.WriteLine(FB_FolderHistory(x)) + Next + f.Close() + f.Dispose() + Catch ex As Exception + End Try + FB_Init = False + End If + 'File History + If Initialized And Not bLightMode Then + If Not bBrowseFolder Then + Try + f = My.Computer.FileSystem.OpenTextFileWriter(FB_FilHisDir & MyID & ".txt", False, System.Text.Encoding.UTF8) + For x = 0 To 9 + f.WriteLine(Me.ContextMenuHisFile.Items(x).Text) + Next + f.Close() + f.Dispose() + Catch ex As Exception + End Try + End If + Initialized = False + End If + f = Nothing + 'Close + Me.Close() + End Sub + + 'Switching to FolderBrowser + Public Sub SetFolderBrowser() + If Initialized Then Exit Sub + bBrowseFolder = True + Me.Width = 500 + Me.ListViewFiles.Enabled = False + Me.ButtonHisFile.Enabled = False + Me.TextBoxSearchFile.Enabled = False + Me.SplitContainer1.Panel2Collapsed = True + Me.Text = "Directory Browser" + End Sub + + 'Initialize + Private Sub Init() + Dim x As Integer + Dim line As String + Dim f As System.IO.StreamReader + + UpdateLock = True + + 'Initialization for Global File Browser + If Not FB_Init Then GlobalInit() + + 'Load Drive ComboBox + For x = 0 To UBound(FB_Drives) + Me.ComboBoxDrive.Items.Add(FB_Drives(x)) + Next + + 'FolderHistory ContextMenu + Me.ContextMenuHisFolder.Items.Clear() + For x = 0 To 9 + Me.ContextMenuHisFolder.Items.Add("") + Next + Me.ContextMenuHisFolder.Items.Add("-") + For x = 10 To 19 + Me.ContextMenuHisFolder.Items.Add("") + Next + Me.ContextMenuHisFolder.Items.Add("-") + Me.ContextMenuHisFolder.Items.Add(FavText) + + 'FileHistory ContextMenu + If bBrowseFolder Then + LastFile = FB_FolderHistory(0) + ElseIf Not bLightMode Then + For x = 0 To 9 + Me.ContextMenuHisFile.Items.Add("") + Next + If IO.File.Exists(FB_FilHisDir & MyID & ".txt") Then + f = New System.IO.StreamReader(FB_FilHisDir & MyID & ".txt") + x = - 1 + Do While Not f.EndOfStream And x < 9 + x += 1 + line = f.ReadLine + Me.ContextMenuHisFile.Items(x).Text = line + If x = 0 Then LastFile = line + Loop + f.Close() + f.Dispose() + End If + End If + + 'Extension-ComboBox + If Not NoExt Then + ExtListSingle = New ArrayList + ExtListMulti = New ArrayList + For x = 0 To UBound(MyExt) + ExtListMulti.Add(MyExt(x)) + For Each line In MyExt(x).Split(","c) + ExtListSingle.Add(Trim(line)) + Next + Next + ExtListMulti.Add("*") + ExtListSingle.Add("*") + End If + + Initialized = True + f = Nothing + UpdateLock = False + End Sub + + Private Sub GlobalInit() + Dim drive As String + Dim x As Integer + + Dim f As System.IO.StreamReader + + 'Create Drive List + ReDim FB_Drives(UBound(IO.Directory.GetLogicalDrives())) + x = - 1 + For Each drive In IO.Directory.GetLogicalDrives() + x += 1 + FB_Drives(x) = Microsoft.VisualBasic.Left(drive, 2) + Next + + 'Read Folder History + For x = 0 To 19 + FB_FolderHistory(x) = EmptyText + Next + If IO.File.Exists(FB_FilHisDir & "Directories.txt") Then + f = New System.IO.StreamReader(FB_FilHisDir & "Directories.txt") + x = - 1 + Do While Not f.EndOfStream And x < 19 + x += 1 + FB_FolderHistory(x) = f.ReadLine() + Loop + f.Dispose() + f.Close() + End If + + FB_Init = True + + f = Nothing + End Sub + + 'ComboBoxDrive_SelectedIndexChanged + Private Sub ComboBoxDrive_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles ComboBoxDrive.SelectedIndexChanged + If Not UpdateLock Then SetFolder(Me.ComboBoxDrive.SelectedItem.ToString) + End Sub + + + 'ButtonFolderBack_Click + Private Sub ButtonFolderBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles ButtonFolderBack.Click + FolderUp() + End Sub + + 'TextBoxPath_KeyDown (ENTER) + Private Sub TextBoxPath_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ + Handles TextBoxPath.KeyDown + Dim path As String + If e.KeyCode = Keys.Enter Then + path = Me.TextBoxPath.Text + If IO.Directory.Exists(path) Then + If bBrowseFolder Then + Me.DialogResult = Windows.Forms.DialogResult.OK + Me.Close() + Else + SetFolder(path) + End If + Else + Me.DialogResult = Windows.Forms.DialogResult.OK + Me.Close() + End If + End If + End Sub + + 'ListViewFolder_SelectedIndexChanged + Private Sub ListViewFolder_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles ListViewFolder.SelectedIndexChanged + If bBrowseFolder Then + UpdateLock = True + If Me.ListViewFolder.SelectedItems.Count > 0 Then + Me.TextBoxPath.Text = Me.ListViewFolder.SelectedItems.Item(0).Text & "\" + End If + UpdateLock = False + End If + End Sub + + 'ListViewFolder_MouseDoubleClick + Private Sub ListViewFolder_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _ + Handles ListViewFolder.MouseDoubleClick + If Me.ListViewFolder.SelectedItems.Count = 0 Then Exit Sub + SetFolder(MyFolder & Me.ListViewFolder.SelectedItems.Item(0).Text) + End Sub + + 'ListViewFolder_KeyDown + Private Sub ListViewFolder_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ + Handles ListViewFolder.KeyDown + If e.KeyCode = Keys.Enter Then + If Me.ListViewFolder.SelectedItems.Count = 0 Then Exit Sub + SetFolder(MyFolder & Me.ListViewFolder.SelectedItems.Item(0).Text) + End If + End Sub + + ''<SORTER> + ''Private Sub ListViewFiles_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListViewFiles.ColumnClick + '' ' Determine if the clicked column is already the column that is + '' ' being sorted. + '' If (e.Column = lvwColumnSorter.SortColumn) Then + '' ' Reverse the current sort direction for this column. + '' If (lvwColumnSorter.Order = SortOrder.Ascending) Then + '' lvwColumnSorter.Order = SortOrder.Descending + '' Else + '' lvwColumnSorter.Order = SortOrder.Ascending + '' End If + '' Else + '' ' Set the column number that is to be sorted; default to ascending. + '' lvwColumnSorter.SortColumn = e.Column + '' lvwColumnSorter.Order = SortOrder.Ascending + '' End If + + '' ' Perform the sort with these new sort options. + '' Me.ListViewFiles.Sort() + + ''End Sub + + 'ListViewFiles_SelectedIndexChanged + Private Sub ListViewFiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles ListViewFiles.SelectedIndexChanged + UpdateLock = True + If Me.ListViewFiles.SelectedItems.Count = 0 Then + Me.TextBoxPath.Text = "" + Else + If Me.ListViewFiles.SelectedItems.Count > 1 Then + Me.TextBoxPath.Text = "<" & Me.ListViewFiles.SelectedItems.Count & " Files selected>" + Else + Me.TextBoxPath.Text = Me.ListViewFiles.SelectedItems.Item(0).Text + Me.TextBoxPath.SelectionStart = Me.TextBoxPath.Text.Length + End If + End If + UpdateLock = False + End Sub + + 'ListViewFiles_MouseDoubleClick + Private Sub ListViewFiles_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _ + Handles ListViewFiles.MouseDoubleClick + If Me.ListViewFiles.SelectedItems.Count = 0 Then Exit Sub + Me.DialogResult = Windows.Forms.DialogResult.OK + Me.Close() + End Sub + + 'ListViewFiles_KeyDown + Private Sub ListViewFiles_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ + Handles ListViewFiles.KeyDown + If e.KeyCode = Keys.Enter Then + If Me.ListViewFiles.SelectedItems.Count = 0 Then Exit Sub + Me.DialogResult = Windows.Forms.DialogResult.OK + Me.Close() + End If + End Sub + + 'TextBoxSearchFolder_KeyDown + Private Sub TextBoxSearchFolder_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ + Handles TextBoxSearchFolder.KeyDown + Dim ItemCount As Int32 + Dim SelIndex As Int32 + Dim NoItem As Boolean + ItemCount = Me.ListViewFolder.Items.Count + NoItem = (ItemCount = 0) + If Not NoItem Then + If Me.ListViewFolder.SelectedItems.Count = 0 Then + SelIndex = - 1 + Else + SelIndex = Me.ListViewFolder.SelectedIndices(0) + End If + End If + Select Case e.KeyCode + Case Keys.Enter + If NoItem Then Exit Sub + If Me.ListViewFolder.SelectedItems.Count = 0 Then Me.ListViewFolder.SelectedIndices.Add(0) + SetFolder(MyFolder & Me.ListViewFolder.SelectedItems.Item(0).Text) + Case Keys.Up + If Not NoItem Then + If SelIndex < 1 Then + SelIndex = 1 + Else + Me.ListViewFolder.Items(SelIndex).Selected = False + End If + Me.ListViewFolder.Items(SelIndex - 1).Selected = True + Me.ListViewFolder.Items(SelIndex - 1).EnsureVisible() + End If + Case Keys.Down + If Not NoItem And SelIndex < ItemCount - 1 Then + If Not SelIndex = - 1 Then Me.ListViewFolder.Items(SelIndex).Selected = False + Me.ListViewFolder.Items(SelIndex + 1).Selected = True + Me.ListViewFolder.Items(SelIndex + 1).EnsureVisible() + End If + Case Keys.Back + If Me.TextBoxSearchFolder.Text = "" Then FolderUp() + End Select + End Sub + + 'TextBoxSearchFolder_TextChanged + Private Sub TextBoxSearchFolder_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles TextBoxSearchFolder.TextChanged + If Not UpdateLock Then LoadListFolder() + End Sub + + 'TextBoxSearchFile_KeyDown + Private Sub TextBoxSearchFile_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _ + Handles TextBoxSearchFile.KeyDown + Dim ItemCount As Int32 + Dim SelIndex As Int32 + Dim NoItem As Boolean + ItemCount = Me.ListViewFiles.Items.Count + NoItem = (ItemCount = 0) + If Not NoItem Then + If Me.ListViewFiles.SelectedItems.Count = 0 Then + SelIndex = - 1 + Else + SelIndex = Me.ListViewFiles.SelectedIndices(0) + End If + End If + Select Case e.KeyCode + Case Keys.Enter + If NoItem Then Exit Sub + If Me.ListViewFiles.SelectedItems.Count = 0 Then Me.ListViewFiles.SelectedIndices.Add(0) + Me.DialogResult = Windows.Forms.DialogResult.OK + Me.Close() + Case Keys.Up + If Not NoItem Then + If SelIndex < 1 Then + SelIndex = 1 + Else + Me.ListViewFiles.Items(SelIndex).Selected = False + End If + Me.ListViewFiles.Items(SelIndex - 1).Selected = True + Me.ListViewFiles.Items(SelIndex - 1).EnsureVisible() + End If + Case Keys.Down + If Not NoItem And SelIndex < ItemCount - 1 Then + If Not SelIndex = - 1 Then Me.ListViewFiles.Items(SelIndex).Selected = False + Me.ListViewFiles.Items(SelIndex + 1).Selected = True + Me.ListViewFiles.Items(SelIndex + 1).EnsureVisible() + End If + End Select + End Sub + + 'TextBoxSearchFile_TextChanged + Private Sub TextBoxSearchFile_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles TextBoxSearchFile.TextChanged + If Not UpdateLock Then LoadListFiles() + End Sub + + 'ComboBoxExt_TextChanged + Private Sub ComboBoxExt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) _ + Handles ComboBoxExt.TextChanged + If Not UpdateLock Then LoadListFiles() + End Sub + + 'ButtonHisFolder_Click + Private Sub ButtonHisFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles ButtonHisFolder.Click + Me.ContextMenuHisFolder.Show(Control.MousePosition) + End Sub + + 'ButtonHisFile_Click + Private Sub ButtonHisFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonHisFile.Click + Me.ContextMenuHisFile.Show(Control.MousePosition) + End Sub + + 'Select All - Click + Private Sub ButtonAll_Click(sender As System.Object, e As System.EventArgs) Handles ButtonAll.Click + Dim i As Integer + Me.ListViewFiles.BeginUpdate() + For i = 0 To Me.ListViewFiles.Items.Count - 1 + Me.ListViewFiles.Items(i).Selected = True + Next + Me.ListViewFiles.EndUpdate() + End Sub + + 'ContextMenuHisFile_ItemClicked + Private Sub ContextMenuHisFile_ItemClicked(ByVal sender As Object, + ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ContextMenuHisFile.ItemClicked + Dim path As String + + path = e.ClickedItem.Text.ToString + + If path = EmptyText Then Exit Sub + + SetFolder(fPATH(path)) + + Me.TextBoxPath.Text = IO.Path.GetFileName(path) + End Sub + + 'ContextMenuHisFolder_ItemClicked + Private Sub ContextMenuHisFolder_ItemClicked(ByVal sender As Object, + ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ContextMenuHisFolder.ItemClicked + Dim path As String + Dim favdlog As FB_FavDlog + Dim x As Integer + + path = e.ClickedItem.Text.ToString + + If path = EmptyText Then Exit Sub + + If path = FavText Then + favdlog = New FB_FavDlog + If favdlog.ShowDialog = Windows.Forms.DialogResult.OK Then + For x = 10 To 19 + path = CType(favdlog.ListBox1.Items(x - 10), String) + If path = NoFavString Then + FB_FolderHistory(x) = EmptyText + Else + FB_FolderHistory(x) = path + End If + Me.ContextMenuHisFolder.Items(x + 1).Text = FB_FolderHistory(x) + Next + End If + Else + SetFolder(path) + End If + End Sub + + 'TextBoxCurrent_MouseClick + Private Sub TextBoxCurrent_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _ + Handles TextBoxCurrent.MouseClick + Dim x As Int32 + Dim x1 As Int32 + Dim path As String + Dim newpath As String + newpath = "" + x = Me.TextBoxCurrent.SelectionStart + path = Me.TextBoxCurrent.Text + x1 = path.Length + If x = x1 Then Exit Sub + If x < 4 Then + SetFolder(Microsoft.VisualBasic.Left(path, 2)) + Exit Sub + End If + Do While x1 > x + newpath = path + 'path = Microsoft.VisualBasic.Left(path, x1 - 1) + path = Microsoft.VisualBasic.Left(path, path.LastIndexOf("\")) + x1 = path.Length + Loop + SetFolder(newpath) + End Sub + + 'ButtonDesktop_Click + Private Sub ButtonDesktop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDesktop.Click + SetFolder(FileIO.SpecialDirectories.Desktop.ToString) + End Sub + + 'Context Menu Update + Private Sub UpdateHisFile(ByVal path As String) + Dim x As Int16 + Dim y As Int16 + If bLightMode Then Exit Sub + 'Sort Context Menu + For x = 0 To 8 + If UCase(Me.ContextMenuHisFile.Items(x).Text.ToString) = UCase(path) Then Exit For + Next + For y = x To 1 Step - 1 + Me.ContextMenuHisFile.Items(y).Text = Me.ContextMenuHisFile.Items(y - 1).Text + Next + Me.ContextMenuHisFile.Items(0).Text = path + End Sub + + Private Sub UpdateHisFolder(ByVal path As String) + Dim x As Int16 + Dim y As Int16 + + 'Sort Context Menu + For x = 0 To 8 + If UCase(Me.ContextMenuHisFolder.Items(x).Text.ToString) = UCase(path) Then Exit For + Next + + For y = x To 1 Step - 1 + Me.ContextMenuHisFolder.Items(y).Text = Me.ContextMenuHisFolder.Items(y - 1).Text + Next + + Me.ContextMenuHisFolder.Items(0).Text = path + End Sub + + 'Manuelles History-Update + Public Sub UpdateHistory(ByVal path As String) + Dim x As Int16 + Dim y As Int16 + 'Init + If Not Initialized Then Init() + 'Files + UpdateHisFile(path) + 'Folder + path = fPATH(path) + For x = 0 To 8 + If UCase(FB_FolderHistory(x)) = UCase(path) Then Exit For + Next + For y = x To 1 Step - 1 + FB_FolderHistory(y) = FB_FolderHistory(y - 1) + Next + FB_FolderHistory(0) = path + End Sub + + 'Change folder + Private Sub SetFolder(ByVal Path As String) + + 'Abort if no drive specified + If Microsoft.VisualBasic.Mid(Path, 2, 1) <> ":" Then Exit Sub + + UpdateLock = True + + 'Delete Search-fields + Me.TextBoxSearchFile.Text = "" + Me.TextBoxSearchFolder.Text = "" + + 'Set Drive + If MyDrive <> Microsoft.VisualBasic.Left(Path, 2) Then + MyDrive = UCase(Microsoft.VisualBasic.Left(Path, 2)) + Me.ComboBoxDrive.SelectedItem = MyDrive + End If + + 'Set Folder + MyFolder = Path + If Microsoft.VisualBasic.Right(MyFolder, 1) <> "\" Then MyFolder &= "\" + LoadListFolder() + LoadListFiles() + + If bBrowseFolder Then Me.TextBoxPath.Text = "" + + Me.TextBoxCurrent.Text = MyFolder + + 'Me.TextBoxPath.SelectionStart = Me.TextBoxPath.Text.Length + UpdateLock = False + End Sub + + 'Folder one level up + Private Sub FolderUp() + Dim path As String + Dim x As Int32 + If MyFolder <> "" Then + path = Microsoft.VisualBasic.Left(MyFolder, MyFolder.Length - 1) + x = path.LastIndexOf("\") + If x > 0 Then SetFolder(Microsoft.VisualBasic.Left(path, x)) + End If + End Sub + + 'Load Folder-List + Private Sub LoadListFolder() + Dim SearchPat As String + 'Delete Folder-List + Me.ListViewFolder.Items.Clear() + SearchPat = "*" & Me.TextBoxSearchFolder.Text & "*" + Try + 'Add Folder + Dim di As New IO.DirectoryInfo(MyFolder) + Dim aryFi As IO.DirectoryInfo() + Dim fi As IO.DirectoryInfo + aryFi = di.GetDirectories(SearchPat) + For Each fi In aryFi + Me.ListViewFolder.Items.Add(fi.ToString) + Next + Catch ex As Exception + Me.ListViewFolder.Items.Add("<ERROR: " & ex.Message.ToString & ">") + End Try + End Sub + + 'Load File-list + Private Sub LoadListFiles() + Dim x As Int32 + Dim SearchPat As String + Dim SearchFile As String + Dim SearchExt As String + Dim ExtStr As String() + + 'Abort if bBrowseFolder + If bBrowseFolder Then Exit Sub + + Me.LabelFileAnz.Text = "0 Files" + 'Define Extension-filter + If Trim(Me.ComboBoxExt.Text.ToString) = "" Then + ExtStr = New String() {"*"} + Else + ExtStr = Me.ComboBoxExt.Text.ToString.Split(","c) + End If + + 'Delete File-List + Me.ListViewFiles.Items.Clear() + + SearchFile = Me.TextBoxSearchFile.Text + + Me.ListViewFiles.BeginUpdate() + Try + 'Add Folder + Dim di As New IO.DirectoryInfo(MyFolder) + Dim aryFi As IO.FileInfo() + Dim fi As IO.FileInfo + x = - 1 + For Each SearchExt In ExtStr + SearchPat = "*" & Trim(SearchFile) & "*." & Trim(SearchExt) + aryFi = di.GetFiles(SearchPat) + For Each fi In aryFi + x += 1 + Me.ListViewFiles.Items.Add(fi.ToString) + Next + Next + If x = 0 Then + Me.LabelFileAnz.Text = "1 File" + Else + Me.LabelFileAnz.Text = x + 1 & " Files" + End If + Catch ex As Exception + Me.ListViewFiles.Items.Add("<ERROR: " & ex.Message.ToString & ">") + End Try + + Me.ListViewFiles.EndUpdate() + End Sub + + 'Rename File + Private Sub RenameFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles RenameFileToolStripMenuItem.Click + Dim file0 As String + Dim file As String + If Me.ListViewFiles.SelectedItems.Count = 1 Then + file0 = Me.ListViewFiles.SelectedItems(0).Text + file = file0 + lb1: + file = InputBox("New Filename", "Rename " & file0, file) + If file <> "" Then + If IO.File.Exists(MyFolder & file) Then + MsgBox("File " & file & " already exists!") + GoTo lb1 + End If + Try + My.Computer.FileSystem.RenameFile(MyFolder & file0, file) + LoadListFiles() + Catch ex As Exception + MsgBox("Cannot rename " & file0 & "!") + End Try + End If + End If + End Sub + + 'Delete File + Private Sub DeleteFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ + Handles DeleteFileToolStripMenuItem.Click + Dim x As Int32 + Dim c As Int32 + c = Me.ListViewFiles.SelectedItems.Count + If c > 0 Then + If c = 1 Then + If MsgBox("Delete " & MyFolder & Me.ListViewFiles.SelectedItems(0).Text & "?", MsgBoxStyle.YesNo) = MsgBoxResult.No _ + Then Exit Sub + Else + If MsgBox("Delete " & c & " files?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then Exit Sub + End If + For x = 0 To c - 1 + Try + IO.File.Delete(MyFolder & Me.ListViewFiles.SelectedItems(x).Text) + Catch ex As Exception + End Try + Next + LoadListFiles() + End If + End Sub + + 'Neuer Ordner + Private Sub ButtonNewDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonNewDir.Click + Dim f As String + f = "New Folder" + lb10: + f = InputBox("Create New Folder", "New Folder", f) + If f <> "" Then + If IO.Directory.Exists(MyFolder & f) Then + MsgBox("Folder " & MyFolder & f & " already exists!") + GoTo lb10 + End If + Try + IO.Directory.CreateDirectory(MyFolder & f) + SetFolder(MyFolder & f) + Catch ex As Exception + MsgBox("Cannot create " & f & "!") + End Try + End If + End Sub + + ''Private Function fTimeString(ByVal T As Date) As String + '' Return T.Year & "-" & T.Month.ToString("00") & "-" & T.Day.ToString("00") & " " & T.Hour.ToString("00") & ":" & T.Minute.ToString("00") & ":" & T.Second.ToString("00") + ''End Function + + + Private Function fPATH(ByVal Pfad As String) As String + Dim x As Integer + x = Pfad.LastIndexOf("\") + If x = - 1 Then + Return Microsoft.VisualBasic.Left(Pfad, 0) + Else + Return Microsoft.VisualBasic.Left(Pfad, x + 1) + End If + End Function + + Public ReadOnly Property Folder() As String + Get + Return MyFolder + End Get + End Property + + Public ReadOnly Property Files() As String() + Get + Return MyFiles + End Get + End Property + + Public Property ID() As String + Get + Return MyID + End Get + Set(ByVal value As String) + MyID = value + End Set + End Property + + Public Property Extensions() As String() + Get + Return MyExt + End Get + Set(ByVal value As String()) + MyExt = value + LastExt = MyExt(0) + NoExt = False + End Set + End Property End Class diff --git a/VECTOAux/VectoAuxiliaries/UI/FB_FavDlog.vb b/VECTOAux/VectoAuxiliaries/UI/FB_FavDlog.vb index 630a84ae1262044e29c54d3f27ecf7747df70208..2ec78b13f01c4b9fd863d8790971cbdc01298ce1 100644 --- a/VECTOAux/VectoAuxiliaries/UI/FB_FavDlog.vb +++ b/VECTOAux/VectoAuxiliaries/UI/FB_FavDlog.vb @@ -15,53 +15,50 @@ Imports System.Windows.Forms ''' </summary> ''' <remarks></remarks> Public Class FB_FavDlog + Private Const NoFavString As String = "<undefined>" + Private Const EmptyText As String = " " - Private Const NoFavString As String = "<undefined>" - Private Const EmptyText As String = " " + Private Sub FB_FavDlog_Load(sender As Object, e As System.EventArgs) Handles Me.Load + Dim x As Integer + Dim txt As String + For x = 10 To 19 + txt = FB_FolderHistory(x) + If txt = EmptyText Then + Me.ListBox1.Items.Add(NoFavString) + Else + Me.ListBox1.Items.Add(txt) + End If + Next + End Sub - Private Sub FB_FavDlog_Load(sender As Object, e As System.EventArgs) Handles Me.Load - Dim x As Integer - Dim txt As String - For x = 10 To 19 - txt = FB_FolderHistory(x) - If txt = EmptyText Then - Me.ListBox1.Items.Add(NoFavString) - Else - Me.ListBox1.Items.Add(txt) - End If - Next - End Sub + Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.OK + Me.Close() + End Sub - Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click - Me.DialogResult = System.Windows.Forms.DialogResult.OK - Me.Close() - End Sub + Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click + Me.DialogResult = System.Windows.Forms.DialogResult.Cancel + Me.Close() + End Sub - Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click - Me.DialogResult = System.Windows.Forms.DialogResult.Cancel - Me.Close() - End Sub + Private Sub ListBox1_MouseDoubleClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) _ + Handles ListBox1.MouseDoubleClick + Dim i As Integer + Dim txt As String + Dim fb As cFileBrowser - Private Sub ListBox1_MouseDoubleClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick - Dim i As Integer - Dim txt As String - Dim fb As cFileBrowser + i = Me.ListBox1.SelectedIndex - i = Me.ListBox1.SelectedIndex + txt = Me.ListBox1.Items(i).ToString - txt = Me.ListBox1.Items(i).ToString - - If txt = NoFavString Then txt = "" - - fb = New cFileBrowser("DirBr", True, True) - - If fb.OpenDialog(txt) Then - txt = fb.Files(0) - Me.ListBox1.Items.Insert(i, txt) - Me.ListBox1.Items.RemoveAt(i + 1) - End If - - End Sub + If txt = NoFavString Then txt = "" + fb = New cFileBrowser("DirBr", True, True) + If fb.OpenDialog(txt) Then + txt = fb.Files(0) + Me.ListBox1.Items.Insert(i, txt) + Me.ListBox1.Items.RemoveAt(i + 1) + End If + End Sub End Class diff --git a/VECTOAux/VectoAuxiliaries/UI/FB_Global.vb b/VECTOAux/VectoAuxiliaries/UI/FB_Global.vb index 0bc09407f0159eee2b83e751682612e37fa1a014..a0031d06066785e4847a70309510562f7c9098bc 100644 --- a/VECTOAux/VectoAuxiliaries/UI/FB_Global.vb +++ b/VECTOAux/VectoAuxiliaries/UI/FB_Global.vb @@ -14,160 +14,156 @@ ''' </summary> ''' <remarks></remarks> Module FB_Global + Public FB_FolderHistory(19) As String + Public FB_Drives() As String + Public FB_Init As Boolean + Public FB_FilHisDir As String + '----------------------------- + Public fbFolder As cFileBrowser + Public fbVECTO As cFileBrowser + Public fbFileLists As cFileBrowser + Public fbVEH As cFileBrowser + Public fbDRI As cFileBrowser + Public fbMAP As cFileBrowser + Public fbFLD As cFileBrowser + + Public fbENG As cFileBrowser + Public fbGBX As cFileBrowser + Public fbACC As cFileBrowser + Public fbAUX As cFileBrowser + + Public fbGBS As cFileBrowser + Public fbTLM As cFileBrowser + Public fbRLM As cFileBrowser + Public fbTCC As cFileBrowser + Public fbCDx As cFileBrowser + + Public fbVMOD As cFileBrowser + + 'Paths + Private MyAppPath As String = My.Application.Info.DirectoryPath & "\" + Private MyConfPath As String = MyAppPath & "Config\" + Private MyDeclPath As String = MyAppPath & "Declaration\" + 'private FB_FilHisDir = MyConfPath & "FileHistory\" + Private HomePath As String = "<HOME>" + Private JobPath As String = "<JOBPATH>" + Private DefVehPath As String = "<VEHDIR>" + Private NoFile As String = "<NOFILE>" + Private EmptyString As String = "<EMPTYSTRING>" + Private Break As String = "<//>" + + Private Normed As String = "NORM" + + Private PauxSply As String = "<AUX_" + +#Region "File path functions" + + 'When no path is specified, then insert either HomeDir or MainDir Special-folders + Public Function fFileRepl(ByVal file As String, Optional ByVal MainDir As String = "") As String + + Dim ReplPath As String + + 'Trim Path + file = Trim(file) + + 'If empty file => Abort + If file = "" Then Return "" + + 'Replace sKeys + file = Microsoft.VisualBasic.Strings.Replace(file, DefVehPath & "\", MyAppPath & "Default Vehicles\", 1, - 1, + CompareMethod.Text) + file = Microsoft.VisualBasic.Strings.Replace(file, DefVehPath & "\", MyAppPath, 1, - 1, CompareMethod.Text) + + 'Replace - Determine folder + If MainDir = "" Then + ReplPath = MyAppPath + Else + ReplPath = MainDir + End If + + ' "..\" => One folder-level up + Do While ReplPath.Length > 0 AndAlso Left(file, 3) = "..\" + ReplPath = fPathUp(ReplPath) + file = file.Substring(3) + Loop + + + 'Supplement Path, if not available + If fPATH(file) = "" Then + + Return ReplPath & file + + Else + Return file + End If + End Function + + 'Path one-level-up "C:\temp\ordner1\" >> "C:\temp\" + Private Function fPathUp(ByVal Pfad As String) As String + Dim x As Integer + + Pfad = Pfad.Substring(0, Pfad.Length - 1) + + x = Pfad.LastIndexOf("\") + + If x = - 1 Then Return "" + + Return Pfad.Substring(0, x + 1) + End Function + + 'File name without the path "C:\temp\TEST.txt" >> "TEST.txt" oder "TEST" + Public Function fFILE(ByVal Pfad As String, ByVal MitEndung As Boolean) As String + Dim x As Integer + x = Pfad.LastIndexOf("\") + 1 + Pfad = Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x) + If Not MitEndung Then + x = Pfad.LastIndexOf(".") + If x > 0 Then Pfad = Microsoft.VisualBasic.Left(Pfad, x) + End If + Return Pfad + End Function + + 'Filename without extension "C:\temp\TEST.txt" >> "C:\temp\TEST" + Public Function fFileWoExt(ByVal Path As String) As String + Return fPATH(Path) & fFILE(Path, False) + End Function + + 'Filename without path if Path = WorkDir or MainDir + Public Function fFileWoDir(ByVal file As String, Optional ByVal MainDir As String = "") As String + Dim path As String + + If MainDir = "" Then + path = MyAppPath + Else + path = MainDir + End If - Public FB_FolderHistory(19) As String - Public FB_Drives() As String - Public FB_Init As Boolean - Public FB_FilHisDir As String - '----------------------------- - Public fbFolder As cFileBrowser - Public fbVECTO As cFileBrowser - Public fbFileLists As cFileBrowser - Public fbVEH As cFileBrowser - Public fbDRI As cFileBrowser - Public fbMAP As cFileBrowser - Public fbFLD As cFileBrowser - - Public fbENG As cFileBrowser - Public fbGBX As cFileBrowser - Public fbACC As cFileBrowser - Public fbAUX As cFileBrowser - - Public fbGBS As cFileBrowser - Public fbTLM As cFileBrowser - Public fbRLM As cFileBrowser - Public fbTCC As cFileBrowser - Public fbCDx As cFileBrowser - - Public fbVMOD As cFileBrowser - - 'Paths - private MyAppPath As String = My.Application.Info.DirectoryPath & "\" - private MyConfPath As String = MyAppPath & "Config\" - private MyDeclPath As String = MyAppPath & "Declaration\" - 'private FB_FilHisDir = MyConfPath & "FileHistory\" - private HomePath As String = "<HOME>" - private JobPath As String = "<JOBPATH>" - private DefVehPath As String = "<VEHDIR>" - private NoFile As String = "<NOFILE>" - private EmptyString As String = "<EMPTYSTRING>" - private Break As String = "<//>" - - private Normed As String = "NORM" - - private PauxSply As String = "<AUX_" - #Region "File path functions" - - 'When no path is specified, then insert either HomeDir or MainDir Special-folders - Public Function fFileRepl(ByVal file As String, Optional ByVal MainDir As String = "") As String - - Dim ReplPath As String - - 'Trim Path - file = Trim(file) - - 'If empty file => Abort - If file = "" Then Return "" - - 'Replace sKeys - file = Microsoft.VisualBasic.Strings.Replace(file, DefVehPath & "\", MyAppPath & "Default Vehicles\", 1, -1, CompareMethod.Text) - file = Microsoft.VisualBasic.Strings.Replace(file, DefVehPath & "\", MyAppPath, 1, -1, CompareMethod.Text) - - 'Replace - Determine folder - If MainDir = "" Then - ReplPath = MyAppPath - Else - ReplPath = MainDir - End If - - ' "..\" => One folder-level up - Do While ReplPath.Length > 0 AndAlso Left(file, 3) = "..\" - ReplPath = fPathUp(ReplPath) - file = file.Substring(3) - Loop - - - 'Supplement Path, if not available - If fPATH(file) = "" Then - - Return ReplPath & file - - Else - Return file - End If - - End Function - - 'Path one-level-up "C:\temp\ordner1\" >> "C:\temp\" - Private Function fPathUp(ByVal Pfad As String) As String - Dim x As Int16 - - Pfad = Pfad.Substring(0, Pfad.Length - 1) - - x = Pfad.LastIndexOf("\") - - If x = -1 Then Return "" - - Return Pfad.Substring(0, x + 1) - - End Function - - 'File name without the path "C:\temp\TEST.txt" >> "TEST.txt" oder "TEST" - Public Function fFILE(ByVal Pfad As String, ByVal MitEndung As Boolean) As String - Dim x As Int16 - x = Pfad.LastIndexOf("\") + 1 - Pfad = Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x) - If Not MitEndung Then - x = Pfad.LastIndexOf(".") - If x > 0 Then Pfad = Microsoft.VisualBasic.Left(Pfad, x) - End If - Return Pfad - End Function - - 'Filename without extension "C:\temp\TEST.txt" >> "C:\temp\TEST" - Public Function fFileWoExt(ByVal Path As String) As String - Return fPATH(Path) & fFILE(Path, False) - End Function - - 'Filename without path if Path = WorkDir or MainDir - Public Function fFileWoDir(ByVal file As String, Optional ByVal MainDir As String = "") As String - Dim path As String - - If MainDir = "" Then - path = MyAppPath - Else - path = MainDir - End If - - If UCase(fPATH(file)) = UCase(path) Then file = fFILE(file, True) - - Return file - - End Function - - 'Path alone "C:\temp\TEST.txt" >> "C:\temp\" - ' "TEST.txt" >> "" - Public Function fPATH(ByVal Pfad As String) As String - Dim x As Int16 - If Pfad Is Nothing OrElse Pfad.Length < 3 OrElse Pfad.Substring(1, 2) <> ":\" Then Return "" - x = Pfad.LastIndexOf("\") - Return Microsoft.VisualBasic.Left(Pfad, x + 1) - End Function + If UCase(fPATH(file)) = UCase(path) Then file = fFILE(file, True) + + Return file + End Function + + 'Path alone "C:\temp\TEST.txt" >> "C:\temp\" + ' "TEST.txt" >> "" + Public Function fPATH(ByVal Pfad As String) As String + Dim x As Integer + If Pfad Is Nothing OrElse Pfad.Length < 3 OrElse Pfad.Substring(1, 2) <> ":\" Then Return "" + x = Pfad.LastIndexOf("\") + Return Microsoft.VisualBasic.Left(Pfad, x + 1) + End Function - 'Extension alone "C:\temp\TEST.txt" >> ".txt" - Public Function fEXT(ByVal Pfad As String) As String - Dim x As Int16 - x = Pfad.LastIndexOf(".") - If x = -1 Then - Return "" - Else - Return Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x) - End If - End Function + 'Extension alone "C:\temp\TEST.txt" >> ".txt" + Public Function fEXT(ByVal Pfad As String) As String + Dim x As Integer + x = Pfad.LastIndexOf(".") + If x = - 1 Then + Return "" + Else + Return Microsoft.VisualBasic.Right(Pfad, Microsoft.VisualBasic.Len(Pfad) - x) + End If + End Function #End Region - - End Module diff --git a/VECTOAux/VectoAuxiliaries/UI/VECTO_Types.vb b/VECTOAux/VectoAuxiliaries/UI/VECTO_Types.vb index 2a7b4fe35db61d9cc42698c54fec423ac2ffe7ac..0007ae17cef3246b4dfbc101a0aeb421589e9bdd 100644 --- a/VECTOAux/VectoAuxiliaries/UI/VECTO_Types.vb +++ b/VECTOAux/VectoAuxiliaries/UI/VECTO_Types.vb @@ -14,168 +14,163 @@ ''' </summary> ''' <remarks></remarks> Public Enum tFbExtMode As Integer - ForceExt = 0 - MultiExt = 1 - SingleExt = 2 + ForceExt = 0 + MultiExt = 1 + SingleExt = 2 End Enum Public Enum tWorkMsgType - StatusBar - StatusListBox - ProgBars - JobStatus - CycleStatus - InitProgBar - Abort + StatusBar + StatusListBox + ProgBars + JobStatus + CycleStatus + InitProgBar + Abort End Enum Public Enum tMsgID - NewJob - Normal - Warn - Err + NewJob + Normal + Warn + Err End Enum Public Enum tCalcResult - Err - Abort - Done + Err + Abort + Done End Enum Public Enum tJobStatus - Running - Queued - OK - Err - Warn - Undef + Running + Queued + OK + Err + Warn + Undef End Enum Public Enum tDriComp - t - V - Grad - Alt - nU - Gears - Padd - Pe - VairVres - VairBeta - Undefined - s - StopTime - Torque + t + V + Grad + Alt + nU + Gears + Padd + Pe + VairVres + VairBeta + Undefined + s + StopTime + Torque End Enum Public Enum tVehState - Cruise - Acc - Dec - Stopped + Cruise + Acc + Dec + Stopped End Enum Public Enum tEngState - Idle - Drag - FullDrag - Load - FullLoad - Stopped - Undef + Idle + Drag + FullDrag + Load + FullLoad + Stopped + Undef End Enum Public Enum tEngClutch - Closed - Opened - Slipping + Closed + Opened + Slipping End Enum Public Enum tAuxComp - Psupply - Undefined + Psupply + Undefined End Enum Public Enum tCdMode - ConstCd0 = 0 - CdOfV = 1 - CdOfBeta = 2 + ConstCd0 = 0 + CdOfV = 1 + CdOfBeta = 2 End Enum Public Enum tRtType - None = 0 - Primary = 1 - Secondary = 2 + None = 0 + Primary = 1 + Secondary = 2 End Enum Public Enum tGearbox - Manual = 0 - SemiAutomatic = 1 - Automatic = 2 - Custom = 3 + Manual = 0 + SemiAutomatic = 1 + Automatic = 2 + Custom = 3 End Enum Public Enum tVehCat As Integer - Undef = 0 - RigidTruck = 1 - Tractor = 2 - Citybus = 3 - InterurbanBus = 4 - Coach = 5 + Undef = 0 + RigidTruck = 1 + Tractor = 2 + Citybus = 3 + InterurbanBus = 4 + Coach = 5 End Enum Public Enum tAxleConf As Integer - Undef = 0 - a4x2 = 1 - a4x4 = 2 - a6x2 = 3 - a6x4 = 4 - a6x6 = 5 - a8x2 = 6 - a8x4 = 7 - a8x6 = 8 - a8x8 = 9 + Undef = 0 + a4x2 = 1 + a4x4 = 2 + a6x2 = 3 + a6x4 = 4 + a6x6 = 5 + a8x2 = 6 + a8x4 = 7 + a8x6 = 8 + a8x8 = 9 End Enum Public Enum tLoading - FullLoaded - EmptyLoaded - RefLoaded - UserDefLoaded + FullLoaded + EmptyLoaded + RefLoaded + UserDefLoaded End Enum Public Enum tMission - LongHaul - RegionalDelivery - UrbanDelivery - MunicipalUtility - Construction - HeavyUrban - Urban - Suburban - Interurban - Coach - Undef + LongHaul + RegionalDelivery + UrbanDelivery + MunicipalUtility + Construction + HeavyUrban + Urban + Suburban + Interurban + Coach + Undef End Enum Public Enum tWHTCpart - Urban - Rural - Motorway + Urban + Rural + Motorway End Enum Public Enum tAux - Fan - SteerPump - HVAC - ElectricSys - PneumSys + Fan + SteerPump + HVAC + ElectricSys + PneumSys End Enum - - - - - diff --git a/VECTOAux/VectoAuxiliaries/UI/cFileBrowser.vb b/VECTOAux/VectoAuxiliaries/UI/cFileBrowser.vb index 66a9353654b33024bf1b843fc4843f38a6cb3c45..6aab08424f84c2c3e3559c64c517b1939470bd99 100644 --- a/VECTOAux/VectoAuxiliaries/UI/cFileBrowser.vb +++ b/VECTOAux/VectoAuxiliaries/UI/cFileBrowser.vb @@ -22,140 +22,143 @@ Imports System.Collections ''' File history is unique for each ID. Folder history is global. ''' </remarks> Public Class cFileBrowser + Private Initialized As Boolean + Private MyID As String + Private MyExt As String() + Private Dlog As FB_Dialog + Private NoExt As Boolean + Private bFolderBrowser As Boolean + Private bLightMode As Boolean - Private Initialized As Boolean - Private MyID As String - Private MyExt As String() - Private Dlog As FB_Dialog - Private NoExt As Boolean - Private bFolderBrowser As Boolean - Private bLightMode As Boolean + ''' <summary> + ''' New cFileBrowser instance + ''' </summary> + ''' <param name="ID">Needed to save the file history when not using LightMode.</param> + ''' <param name="FolderBrowser">Browse folders instead of files.</param> + ''' <param name="LightMode">If enabled file history is not saved.</param> + ''' <remarks></remarks> + Public Sub New(ByVal ID As String, Optional ByVal FolderBrowser As Boolean = False, + Optional ByVal LightMode As Boolean = False) + Initialized = False + MyID = ID + NoExt = True + bFolderBrowser = FolderBrowser + bLightMode = LightMode + End Sub - ''' <summary> - ''' New cFileBrowser instance - ''' </summary> - ''' <param name="ID">Needed to save the file history when not using LightMode.</param> - ''' <param name="FolderBrowser">Browse folders instead of files.</param> - ''' <param name="LightMode">If enabled file history is not saved.</param> - ''' <remarks></remarks> - Public Sub New(ByVal ID As String, Optional ByVal FolderBrowser As Boolean = False, Optional ByVal LightMode As Boolean = False) - Initialized = False - MyID = ID - NoExt = True - bFolderBrowser = FolderBrowser - bLightMode = LightMode - End Sub + ''' <summary> + ''' Opens dialog for OPENING files. Selected file must exist. Returns False if cancelled by user, else True. + ''' </summary> + ''' <param name="path">Initial selected file. If empty the last selected file is used. If file without directoy the last directory will be used.</param> + ''' <param name="MultiFile">Allow selecting multiple files.</param> + ''' <param name="Ext">Set extension. If not defined the first predefined extension is used.</param> + ''' <returns></returns> + ''' <remarks></remarks> + Public Function OpenDialog(ByVal path As String, Optional ByVal MultiFile As Boolean = False, + Optional ByVal Ext As String = "") As Boolean + Return CustomDialog(path, True, False, tFbExtMode.MultiExt, MultiFile, Ext, "Open") + End Function - ''' <summary> - ''' Opens dialog for OPENING files. Selected file must exist. Returns False if cancelled by user, else True. - ''' </summary> - ''' <param name="path">Initial selected file. If empty the last selected file is used. If file without directoy the last directory will be used.</param> - ''' <param name="MultiFile">Allow selecting multiple files.</param> - ''' <param name="Ext">Set extension. If not defined the first predefined extension is used.</param> - ''' <returns></returns> - ''' <remarks></remarks> - Public Function OpenDialog(ByVal path As String, Optional ByVal MultiFile As Boolean = False, Optional ByVal Ext As String = "") As Boolean - Return CustomDialog(path, True, False, tFbExtMode.MultiExt, MultiFile, Ext, "Open") - End Function + ''' <summary> + ''' Opens dialog for SAVING files. If file already exists user will be asked to overwrite. Returns False if cancelled by user, else True. + ''' </summary> + ''' <param name="path">Initial selected file. If empty the last selected file is used. If file without directoy the last directory will be used.</param> + ''' <param name="ForceExt">Force predefined file extension.</param> + ''' <param name="Ext">Set extension. If not defined the first predefined extension is used.</param> + ''' <returns></returns> + ''' <remarks></remarks> + Public Function SaveDialog(ByVal path As String, Optional ByVal ForceExt As Boolean = True, + Optional ByVal Ext As String = "") As Boolean + Dim x As tFbExtMode + If ForceExt Then + x = tFbExtMode.ForceExt + Else + x = tFbExtMode.SingleExt + End If + Return CustomDialog(path, False, True, x, False, Ext, "Save As") + End Function - ''' <summary> - ''' Opens dialog for SAVING files. If file already exists user will be asked to overwrite. Returns False if cancelled by user, else True. - ''' </summary> - ''' <param name="path">Initial selected file. If empty the last selected file is used. If file without directoy the last directory will be used.</param> - ''' <param name="ForceExt">Force predefined file extension.</param> - ''' <param name="Ext">Set extension. If not defined the first predefined extension is used.</param> - ''' <returns></returns> - ''' <remarks></remarks> - Public Function SaveDialog(ByVal path As String, Optional ByVal ForceExt As Boolean = True, Optional ByVal Ext As String = "") As Boolean - Dim x As tFbExtMode - If ForceExt Then - x = tFbExtMode.ForceExt - Else - x = tFbExtMode.SingleExt - End If - Return CustomDialog(path, False, True, x, False, Ext, "Save As") - End Function + ''' <summary> + ''' Custom open/save dialog. Returns False if cancelled by user, else True. + ''' </summary> + ''' <param name="path">Initial selected file. If empty the last selected file is used. If file without directoy the last directory will be used.</param> + ''' <param name="FileMustExist">Selected file must exist.</param> + ''' <param name="OverwriteCheck">If file already exists user will be asked to overwrite.</param> + ''' <param name="ExtMode">ForceExt= First predefined extension (or Ext parameter) will be forced (Default for SaveDialog), MultiExt= All files with predefined extensions are shown (Default for OpenDialog), SingleExt= All files with the first predefined extension will be shown.</param> + ''' <param name="MultiFile">Allow to select multiple files.</param> + ''' <param name="Ext">Set extension. If not defined the first predefined extension is used.</param> + ''' <param name="Title">Dialog title.</param> + ''' <returns></returns> + ''' <remarks></remarks> + Public Function CustomDialog(ByVal path As String, ByVal FileMustExist As Boolean, ByVal OverwriteCheck As Boolean, + ByVal ExtMode As tFbExtMode, ByVal MultiFile As Boolean, ByVal Ext As String, + Optional Title As String = "File Browser") As Boolean + If Not Initialized Then Init() + Return Dlog.Browse(path, FileMustExist, OverwriteCheck, ExtMode, MultiFile, Ext, Title) + End Function - ''' <summary> - ''' Custom open/save dialog. Returns False if cancelled by user, else True. - ''' </summary> - ''' <param name="path">Initial selected file. If empty the last selected file is used. If file without directoy the last directory will be used.</param> - ''' <param name="FileMustExist">Selected file must exist.</param> - ''' <param name="OverwriteCheck">If file already exists user will be asked to overwrite.</param> - ''' <param name="ExtMode">ForceExt= First predefined extension (or Ext parameter) will be forced (Default for SaveDialog), MultiExt= All files with predefined extensions are shown (Default for OpenDialog), SingleExt= All files with the first predefined extension will be shown.</param> - ''' <param name="MultiFile">Allow to select multiple files.</param> - ''' <param name="Ext">Set extension. If not defined the first predefined extension is used.</param> - ''' <param name="Title">Dialog title.</param> - ''' <returns></returns> - ''' <remarks></remarks> - Public Function CustomDialog(ByVal path As String, ByVal FileMustExist As Boolean, ByVal OverwriteCheck As Boolean, ByVal ExtMode As tFbExtMode, ByVal MultiFile As Boolean, ByVal Ext As String, Optional Title As String = "File Browser") As Boolean - If Not Initialized Then Init() - Return Dlog.Browse(path, FileMustExist, OverwriteCheck, ExtMode, MultiFile, Ext, Title) - End Function + 'Manually update File History + ''' <summary> + ''' Add file to file history. + ''' </summary> + ''' <param name="Path">File to be added to file history.</param> + ''' <remarks></remarks> + Public Sub UpdateHistory(ByVal Path As String) + If Not Initialized Then Init() + Dlog.UpdateHistory(Path) + End Sub - 'Manually update File History - ''' <summary> - ''' Add file to file history. - ''' </summary> - ''' <param name="Path">File to be added to file history.</param> - ''' <remarks></remarks> - Public Sub UpdateHistory(ByVal Path As String) - If Not Initialized Then Init() - Dlog.UpdateHistory(Path) - End Sub + ''' <summary> + ''' Save file history (if not LightMode) and global folder history. + ''' </summary> + ''' <remarks></remarks> + Public Sub Close() + If Initialized Then + Dlog.SaveAndClose() + Initialized = False + End If + Dlog = Nothing + End Sub - ''' <summary> - ''' Save file history (if not LightMode) and global folder history. - ''' </summary> - ''' <remarks></remarks> - Public Sub Close() - If Initialized Then - Dlog.SaveAndClose() - Initialized = False - End If - Dlog = Nothing - End Sub + Private Sub Init() + Dlog = New FB_Dialog(bLightMode) + Dlog.ID = MyID + If Not NoExt Then Dlog.Extensions = MyExt + If bFolderBrowser Then Dlog.SetFolderBrowser() + Initialized = True + End Sub - Private Sub Init() - Dlog = New FB_Dialog(bLightMode) - Dlog.ID = MyID - If Not NoExt Then Dlog.Extensions = MyExt - If bFolderBrowser Then Dlog.SetFolderBrowser() - Initialized = True - End Sub - - ''' <summary> - ''' Predefined file extensions. Must be set before Open/Save dialog is used for the first time. - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Public Property Extensions() As String() - Get - Return MyExt - End Get - Set(ByVal value As String()) - MyExt = value - NoExt = False - End Set - End Property - - ''' <summary> - ''' Selected file(s) oder folder (if FolderBrowser) - ''' </summary> - ''' <value></value> - ''' <returns></returns> - ''' <remarks></remarks> - Public ReadOnly Property Files() As String() - Get - If Initialized Then - Return Dlog.Files - Else - Return New String() {""} - End If - End Get - End Property + ''' <summary> + ''' Predefined file extensions. Must be set before Open/Save dialog is used for the first time. + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Public Property Extensions() As String() + Get + Return MyExt + End Get + Set(ByVal value As String()) + MyExt = value + NoExt = False + End Set + End Property + ''' <summary> + ''' Selected file(s) oder folder (if FolderBrowser) + ''' </summary> + ''' <value></value> + ''' <returns></returns> + ''' <remarks></remarks> + Public ReadOnly Property Files() As String() + Get + If Initialized Then + Return Dlog.Files + Else + Return New String() {""} + End If + End Get + End Property End Class diff --git a/VECTOAux/VectoAuxiliaries/UI/frmAuxiliaryConfig.vb b/VECTOAux/VectoAuxiliaries/UI/frmAuxiliaryConfig.vb index 50f2bdd404a22edd37389262fa872c95ea0c6441..3e825e0fefa890a96c1f10d0d6e3127eb0c2ad1c 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmAuxiliaryConfig.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmAuxiliaryConfig.vb @@ -23,1516 +23,1507 @@ Public Class frmAuxiliaryConfig #Region "Fields" - Public auxConfig As AuxiliaryConfig - Public originalConfig As AuxiliaryConfig ' required to test if the form is dirty - Private TabColors As Dictionary(Of TabPage, Color) = New Dictionary(Of TabPage, Color)() - Private processing As Boolean = False - Private SecondsIntoCycle As Integer = 0 - Private vectoFile As String = "" - Private vectoPath As String = "" - Private auxFile As String - Private cmFilesList As String() - Private SaveClicked As Boolean - Private electricalConsumerBinding As New BindingList(Of IElectricalConsumer) + Public auxConfig As AuxiliaryConfig + Public originalConfig As AuxiliaryConfig ' required to test if the form is dirty + Private TabColors As Dictionary(Of TabPage, Color) = New Dictionary(Of TabPage, Color)() + Private processing As Boolean = False + Private SecondsIntoCycle As Integer = 0 + Private vectoFile As String = "" + Private vectoPath As String = "" + Private auxFile As String + Private cmFilesList As String() + Private SaveClicked As Boolean + Private electricalConsumerBinding As New BindingList(Of IElectricalConsumer) #End Region - Private Function ValidateAuxFileName(filename As String) As Boolean + Private Function ValidateAuxFileName(filename As String) As Boolean - Dim message As String = String.Empty + Dim message As String = String.Empty - If Not FilePathUtils.ValidateFilePath(filename, ".aaux", message) Then - MessageBox.Show(message) - End If + If Not FilePathUtils.ValidateFilePath(filename, ".aaux", message) Then + MessageBox.Show(message) + End If - Return True + Return True + End Function - End Function + 'Constructor + Public Sub New(ByVal fileName As String, ByVal vectoFileName As String) - 'Constructor - Public Sub New(ByVal fileName As String, ByVal vectoFileName As String) + If Not ValidateAuxFileName(fileName) Then + Me.DialogResult = Windows.Forms.DialogResult.Abort + Me.Close() + End If - If Not ValidateAuxFileName(fileName) Then - Me.DialogResult = Windows.Forms.DialogResult.Abort - Me.Close() - End If + Me.vectoFile = vectoFileName + Me.vectoPath = FilePathUtils.filePathOnly(vectoFileName) - Me.vectoFile = vectoFileName - Me.vectoPath = FilePathUtils.filePathOnly(vectoFileName) + ' This call is required by the designer. + InitializeComponent() - ' This call is required by the designer. - InitializeComponent() + ' Add any initialization after the InitializeComponent() call. + auxFile = fileName - ' Add any initialization after the InitializeComponent() call. - auxFile = fileName + Try - Try + auxConfig = New AuxiliaryConfig(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) + originalConfig = New AuxiliaryConfig(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) - auxConfig = New AuxiliaryConfig(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) - originalConfig = New AuxiliaryConfig(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) + Catch ex As Exception - Catch ex As Exception + MessageBox.Show("The filename you supplied {0} was invalid or could not be found ", fileName) + Me.DialogResult = Windows.Forms.DialogResult.Abort + Me.Close() - MessageBox.Show("The filename you supplied {0} was invalid or could not be found ", fileName) - Me.DialogResult = Windows.Forms.DialogResult.Abort - Me.Close() + End Try + End Sub - End Try + 'Validation - - - End Sub - - 'Validation #Region "Validation Helpers" - Public Function IsPostiveNumber(ByVal test As String) As Boolean - - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False - - Dim number As Single + Public Function IsPostiveNumber(ByVal test As String) As Boolean - If Not Single.TryParse(test, number) Then Return False + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - If number <= 0 Then Return False + Dim number As Single + If Not Single.TryParse(test, number) Then Return False - Return True + If number <= 0 Then Return False - End Function - Public Function IsZeroOrPostiveNumber(ByVal test As String) As Boolean + Return True + End Function - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + Public Function IsZeroOrPostiveNumber(ByVal test As String) As Boolean - Dim number As Single + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - If Not Single.TryParse(test, number) Then Return False + Dim number As Single - If number < 0 Then Return False + If Not Single.TryParse(test, number) Then Return False + If number < 0 Then Return False - Return True - End Function + Return True + End Function - Public Function IsNumberBetweenZeroandOne(test As String) As Boolean + Public Function IsNumberBetweenZeroandOne(test As String) As Boolean - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - Dim number As Single + Dim number As Single - If Not Single.TryParse(test, number) Then Return False + If Not Single.TryParse(test, number) Then Return False - If number < 0 OrElse number > 1 Then Return False + If number < 0 OrElse number > 1 Then Return False - Return True + Return True + End Function - End Function + Public Function IsIntegerZeroOrPositiveNumber(test As String) As Boolean - Public Function IsIntegerZeroOrPositiveNumber(test As String) As Boolean + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + 'if not integer then return false - 'if not integer then return false + Dim number As Integer - Dim number As Integer + If Not Integer.TryParse(test, number) Then Return False - If Not Integer.TryParse(test, number) Then Return False + If number < 0 Then Return False - If number < 0 Then Return False - - Return True - - - End Function + Return True + End Function #End Region -#Region "Validation Control" - - - '****** PNEUMATIC VALIDATION - Public Sub Validating_PneumaticHandler(sender As Object, e As CancelEventArgs) Handles txtAdBlueNIperMinute.Validating, txtBrakingWithRetarderNIperKG.Validating, txtBrakingNoRetarderNIperKG.Validating, txtAirControlledSuspensionNIperMinute.Validating, txtBreakingPerKneelingNIperKGinMM.Validating, txtSmartRegenFractionTotalAirDemand.Validating, txtPerStopBrakeActuationNIperKG.Validating, txtPerDoorOpeningNI.Validating, txtOverrunUtilisationForCompressionFraction.Validating, txtNonSmartRegenFractionTotalAirDemand.Validating, txtDeadVolumeLitres.Validating, txtDeadVolBlowOutsPerLitresperHour.Validating, txtKneelingHeightMillimeters.Validating, txtCompressorMap.Validating, txtCompressorGearRatio.Validating, txtCompressorGearEfficiency.Validating, txtActuationsMap.Validating, cboDoors.Validating, cboAirSuspensionControl.Validating, cboAdBlueDosing.Validating - - e.Cancel = Not Validate_Pneumatics() - - End Sub - Public Function Validate_Pneumatics() As Boolean - - Dim result As Boolean = True - - 'PNEUMATIC AUXILLARIES PART - '*************************** - - - 'AdBlue NI per Minute : txtAdBlueNIperMinute - If Not IsZeroOrPostiveNumber(txtAdBlueNIperMinute.Text) Then - ErrorProvider.SetError(txtAdBlueNIperMinute, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtAdBlueNIperMinute, String.Empty) - End If - - 'Overrun Utilisation For Compression Fraction : txtOverrunUtilisationForCompressionFraction - If Not IsNumberBetweenZeroandOne(txtOverrunUtilisationForCompressionFraction.Text) Then - ErrorProvider.SetError(txtOverrunUtilisationForCompressionFraction, "Please provide a non negative between 0 and 1.") - result = False - Else - ErrorProvider.SetError(txtOverrunUtilisationForCompressionFraction, String.Empty) - End If - - 'Braking With Retarder NI per KG : txtBrakingWithRetarderNIperKG - If Not IsZeroOrPostiveNumber(txtBrakingWithRetarderNIperKG.Text) Then - ErrorProvider.SetError(txtBrakingWithRetarderNIperKG, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtBrakingWithRetarderNIperKG, String.Empty) - End If - - 'Braking No Retarder NI per KG : txtBrakingNoRetarderNIperKG - If Not IsZeroOrPostiveNumber(txtBrakingNoRetarderNIperKG.Text) Then - ErrorProvider.SetError(txtBrakingNoRetarderNIperKG, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtBrakingNoRetarderNIperKG, String.Empty) - End If - - 'Breaking Per Kneeling NI per KG in MM : txtBreakingPerKneelingNIperKGinMM - If Not IsZeroOrPostiveNumber(txtBreakingPerKneelingNIperKGinMM.Text) Then - ErrorProvider.SetError(txtBreakingPerKneelingNIperKGinMM, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtBreakingPerKneelingNIperKGinMM, String.Empty) - End If - - 'Per Door Opening NI : txtPerDoorOpeningNI - If Not IsZeroOrPostiveNumber(txtPerDoorOpeningNI.Text) Then - ErrorProvider.SetError(txtPerDoorOpeningNI, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtPerDoorOpeningNI, String.Empty) - End If - - 'Per Stop Brake Actuation NI per KG : txtPerStopBrakeActuationNIperKG - If Not IsZeroOrPostiveNumber(txtPerStopBrakeActuationNIperKG.Text) Then - ErrorProvider.SetError(txtPerStopBrakeActuationNIperKG, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtPerStopBrakeActuationNIperKG, String.Empty) - End If - - 'Air Controlled Suspension NI per Minute : txtAirControlledSuspensionNIperMinute - If Not IsZeroOrPostiveNumber(txtAirControlledSuspensionNIperMinute.Text) Then - ErrorProvider.SetError(txtAirControlledSuspensionNIperMinute, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtAirControlledSuspensionNIperMinute, String.Empty) - End If - - 'Non Smart Regen Fraction Total Air Demand : txtNonSmartRegenFractionTotalAirDemand - If Not IsZeroOrPostiveNumber(txtNonSmartRegenFractionTotalAirDemand.Text) Then - ErrorProvider.SetError(txtNonSmartRegenFractionTotalAirDemand, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtNonSmartRegenFractionTotalAirDemand, String.Empty) - End If - - 'Smart Regen Fraction Total Air Demand : txtSmartRegenFractionTotalAirDemand - If Not IsNumberBetweenZeroandOne(txtSmartRegenFractionTotalAirDemand.Text) Then - ErrorProvider.SetError(txtSmartRegenFractionTotalAirDemand, "Please provide a non negative between 0 and 1.") - result = False - Else - ErrorProvider.SetError(txtSmartRegenFractionTotalAirDemand, String.Empty) - End If - - - 'Dead Volume Litres : txtDeadVolumeLitres - If Not IsZeroOrPostiveNumber(txtDeadVolumeLitres.Text) Then - ErrorProvider.SetError(txtDeadVolumeLitres, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtDeadVolumeLitres, String.Empty) - End If - - - 'Dead Vol BlowOuts Per Litresper Hour : txtDeadVolBlowOutsPerLitresperHour - If Not IsZeroOrPostiveNumber(txtDeadVolBlowOutsPerLitresperHour.Text) Then - ErrorProvider.SetError(txtDeadVolBlowOutsPerLitresperHour, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtDeadVolBlowOutsPerLitresperHour, String.Empty) - End If - - - 'USER CONFIG PART - '***************************************************************************************** - 'Compressor Map path : txtCompressorMap - 'Test for empty after trim - If txtCompressorMap.Text.Trim.Length = 0 Then - ErrorProvider.SetError(txtCompressorMap, "Please enter the localtion of a valid compressor map.") - result = False - Else - ErrorProvider.SetError(txtCompressorMap, String.Empty) - End If - 'Test File is valid - Dim comp As CompressorMap - Try - - comp = New CompressorMap(FilePathUtils.ResolveFilePath(vectoPath, txtCompressorMap.Text)) - comp.Initialise() - ErrorProvider.SetError(txtCompressorMap, String.Empty) - Catch ex As Exception - ErrorProvider.SetError(txtCompressorMap, "Error : map is invalid or cannot be found, please select a Cvalid compressor map") - result = False - End Try - - 'Compressor Gear Efficiency : txtCompressorGearEfficiency" - If Not IsNumberBetweenZeroandOne(txtCompressorGearEfficiency.Text) Then - ErrorProvider.SetError(txtCompressorGearEfficiency, "Please enter a number between 0 and 1") - result = False - Else - ErrorProvider.SetError(txtCompressorGearEfficiency, String.Empty) - End If - - 'Compressor Gear Ratio : txtCompressorGearRatio - If Not IsPostiveNumber(txtCompressorGearRatio.Text) Then - ErrorProvider.SetError(txtCompressorGearRatio, "Please enter a number greater than 0.") - result = False - Else - ErrorProvider.SetError(txtCompressorGearRatio, String.Empty) - End If - - - 'Actuations Map : txtActuationsMap - If txtActuationsMap.Text.Trim.Length = 0 Then - ErrorProvider.SetError(txtActuationsMap, "Please enter the localtion of a valid Pneumatic Actuations map.") - result = False - Else - ErrorProvider.SetError(txtActuationsMap, String.Empty) - End If - 'Test File is valid - Dim actuations As PneumaticActuationsMAP - Try - - actuations = New PneumaticActuationsMAP(FilePathUtils.ResolveFilePath(vectoPath, txtActuationsMap.Text)) - actuations.Initialise() - ErrorProvider.SetError(txtActuationsMap, String.Empty) - Catch ex As Exception - ErrorProvider.SetError(txtActuationsMap, "Error : Pneumatic Actuations map is invalid or cannot be found, please select a valid map") - result = False - End Try - - - - 'NOT Required but included here so readers can see this is a positive ommission - '****************************************************************************** - 'Smart Air Compression : chkSmartAirCompression - 'Smart Regeneration : chkSmartRegeneration - 'Retarder Brake : chkRetarderBrake - - 'txtKneelingHeightMillimeters : txtKneelingHeightMillimeters - If Not IsZeroOrPostiveNumber(txtKneelingHeightMillimeters.Text) Then - ErrorProvider.SetError(txtKneelingHeightMillimeters, "Please enter a number greater than 0.") - result = False - Else - ErrorProvider.SetError(txtKneelingHeightMillimeters, String.Empty) - End If - - 'cboAirSuspensionControl : cboAirSuspensionControl - If cboAirSuspensionControl.SelectedIndex < 1 Then - ErrorProvider.SetError(cboAirSuspensionControl, "Please make a selection.") - result = False - Else - ErrorProvider.SetError(cboAirSuspensionControl, String.Empty) - End If - - 'cboAdBlueDosing : cboAdBlueDosing - If cboAdBlueDosing.SelectedIndex < 1 Then - ErrorProvider.SetError(cboAdBlueDosing, "Please make a selection.") - result = False - Else - ErrorProvider.SetError(cboAdBlueDosing, String.Empty) - End If - - 'cboDoors : cboDoors - If cboDoors.SelectedIndex < 1 Then - ErrorProvider.SetError(cboDoors, "Please make a selection.") - result = False - Else - ErrorProvider.SetError(cboDoors, String.Empty) - End If - - - 'Set Tab Color - - UpdateTabStatus("tabPneumaticConfig", result) - - - - - Return result - - - End Function - - '***** ELECTRICAL VALIDATION - Public Sub Validating_ElectricsHandler(sender As Object, e As CancelEventArgs) Handles txtPowernetVoltage.Validating, txtAlternatorMapPath.Validating, txtAlternatorGearEfficiency.Validating, txtDoorActuationTimeSeconds.Validating, txtStoredEnergyEfficiency.Validating - - e.Cancel = Not Validate_Electrics() - - End Sub - Public Function Validate_Electrics() As Boolean - - Dim result As Boolean = True - - - 'Powernet Voltage : txtPowernetVoltage - If Not IsPostiveNumber(txtPowernetVoltage.Text) Then - ErrorProvider.SetError(txtPowernetVoltage, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtPowernetVoltage, String.Empty) - End If - - - 'Alternator Map path : txtAlternatorMapPath - 'Test for empty after trim - If txtAlternatorMapPath.Text.Trim.Length = 0 Then - ErrorProvider.SetError(txtAlternatorMapPath, "Please enter the localtion of a valid alternator map.") - result = False - Else - ErrorProvider.SetError(txtAlternatorMapPath, String.Empty) - End If - - 'Test File is valid - Dim alt As ICombinedAlternator - Try - alt = New CombinedAlternator(FilePathUtils.ResolveFilePath(vectoPath, txtAlternatorMapPath.Text)) - ErrorProvider.SetError(txtAlternatorMapPath, String.Empty) - Catch ex As Exception - ErrorProvider.SetError(txtAlternatorMapPath, "Error : map is invalid or cannot be found, please select a valid alternator map") - result = False - End Try - - 'Alternator Gear Efficiency : txtAlternatorGearEfficiency - If Not IsNumberBetweenZeroandOne(txtAlternatorGearEfficiency.Text) Then - ErrorProvider.SetError(txtAlternatorGearEfficiency, "Please enter a number between 0 an 1") - result = False - Else - ErrorProvider.SetError(txtAlternatorGearEfficiency, String.Empty) - End If +#Region "Validation Control" - 'Door Action Time : txtDoorActuationTimeSeconds - If Not IsPostiveNumber(txtDoorActuationTimeSeconds.Text) Then - ErrorProvider.SetError(txtDoorActuationTimeSeconds, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtDoorActuationTimeSeconds, String.Empty) - End If + '****** PNEUMATIC VALIDATION + Public Sub Validating_PneumaticHandler(sender As Object, e As CancelEventArgs) _ + Handles txtAdBlueNIperMinute.Validating, txtBrakingWithRetarderNIperKG.Validating, + txtBrakingNoRetarderNIperKG.Validating, txtAirControlledSuspensionNIperMinute.Validating, + txtBreakingPerKneelingNIperKGinMM.Validating, txtSmartRegenFractionTotalAirDemand.Validating, + txtPerStopBrakeActuationNIperKG.Validating, txtPerDoorOpeningNI.Validating, + txtOverrunUtilisationForCompressionFraction.Validating, txtNonSmartRegenFractionTotalAirDemand.Validating, + txtDeadVolumeLitres.Validating, txtDeadVolBlowOutsPerLitresperHour.Validating, + txtKneelingHeightMillimeters.Validating, txtCompressorMap.Validating, txtCompressorGearRatio.Validating, + txtCompressorGearEfficiency.Validating, txtActuationsMap.Validating, cboDoors.Validating, + cboAirSuspensionControl.Validating, cboAdBlueDosing.Validating + + e.Cancel = Not Validate_Pneumatics() + End Sub + + Public Function Validate_Pneumatics() As Boolean + + Dim result As Boolean = True + + 'PNEUMATIC AUXILLARIES PART + '*************************** + + + 'AdBlue NI per Minute : txtAdBlueNIperMinute + If Not IsZeroOrPostiveNumber(txtAdBlueNIperMinute.Text) Then + ErrorProvider.SetError(txtAdBlueNIperMinute, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtAdBlueNIperMinute, String.Empty) + End If + + 'Overrun Utilisation For Compression Fraction : txtOverrunUtilisationForCompressionFraction + If Not IsNumberBetweenZeroandOne(txtOverrunUtilisationForCompressionFraction.Text) Then + ErrorProvider.SetError(txtOverrunUtilisationForCompressionFraction, "Please provide a non negative between 0 and 1.") + result = False + Else + ErrorProvider.SetError(txtOverrunUtilisationForCompressionFraction, String.Empty) + End If + + 'Braking With Retarder NI per KG : txtBrakingWithRetarderNIperKG + If Not IsZeroOrPostiveNumber(txtBrakingWithRetarderNIperKG.Text) Then + ErrorProvider.SetError(txtBrakingWithRetarderNIperKG, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtBrakingWithRetarderNIperKG, String.Empty) + End If + + 'Braking No Retarder NI per KG : txtBrakingNoRetarderNIperKG + If Not IsZeroOrPostiveNumber(txtBrakingNoRetarderNIperKG.Text) Then + ErrorProvider.SetError(txtBrakingNoRetarderNIperKG, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtBrakingNoRetarderNIperKG, String.Empty) + End If + + 'Breaking Per Kneeling NI per KG in MM : txtBreakingPerKneelingNIperKGinMM + If Not IsZeroOrPostiveNumber(txtBreakingPerKneelingNIperKGinMM.Text) Then + ErrorProvider.SetError(txtBreakingPerKneelingNIperKGinMM, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtBreakingPerKneelingNIperKGinMM, String.Empty) + End If + + 'Per Door Opening NI : txtPerDoorOpeningNI + If Not IsZeroOrPostiveNumber(txtPerDoorOpeningNI.Text) Then + ErrorProvider.SetError(txtPerDoorOpeningNI, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtPerDoorOpeningNI, String.Empty) + End If + + 'Per Stop Brake Actuation NI per KG : txtPerStopBrakeActuationNIperKG + If Not IsZeroOrPostiveNumber(txtPerStopBrakeActuationNIperKG.Text) Then + ErrorProvider.SetError(txtPerStopBrakeActuationNIperKG, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtPerStopBrakeActuationNIperKG, String.Empty) + End If + + 'Air Controlled Suspension NI per Minute : txtAirControlledSuspensionNIperMinute + If Not IsZeroOrPostiveNumber(txtAirControlledSuspensionNIperMinute.Text) Then + ErrorProvider.SetError(txtAirControlledSuspensionNIperMinute, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtAirControlledSuspensionNIperMinute, String.Empty) + End If + + 'Non Smart Regen Fraction Total Air Demand : txtNonSmartRegenFractionTotalAirDemand + If Not IsZeroOrPostiveNumber(txtNonSmartRegenFractionTotalAirDemand.Text) Then + ErrorProvider.SetError(txtNonSmartRegenFractionTotalAirDemand, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtNonSmartRegenFractionTotalAirDemand, String.Empty) + End If + + 'Smart Regen Fraction Total Air Demand : txtSmartRegenFractionTotalAirDemand + If Not IsNumberBetweenZeroandOne(txtSmartRegenFractionTotalAirDemand.Text) Then + ErrorProvider.SetError(txtSmartRegenFractionTotalAirDemand, "Please provide a non negative between 0 and 1.") + result = False + Else + ErrorProvider.SetError(txtSmartRegenFractionTotalAirDemand, String.Empty) + End If + + + 'Dead Volume Litres : txtDeadVolumeLitres + If Not IsZeroOrPostiveNumber(txtDeadVolumeLitres.Text) Then + ErrorProvider.SetError(txtDeadVolumeLitres, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtDeadVolumeLitres, String.Empty) + End If + + + 'Dead Vol BlowOuts Per Litresper Hour : txtDeadVolBlowOutsPerLitresperHour + If Not IsZeroOrPostiveNumber(txtDeadVolBlowOutsPerLitresperHour.Text) Then + ErrorProvider.SetError(txtDeadVolBlowOutsPerLitresperHour, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtDeadVolBlowOutsPerLitresperHour, String.Empty) + End If + + + 'USER CONFIG PART + '***************************************************************************************** + 'Compressor Map path : txtCompressorMap + 'Test for empty after trim + If txtCompressorMap.Text.Trim.Length = 0 Then + ErrorProvider.SetError(txtCompressorMap, "Please enter the localtion of a valid compressor map.") + result = False + Else + ErrorProvider.SetError(txtCompressorMap, String.Empty) + End If + 'Test File is valid + Dim comp As CompressorMap + Try + + comp = New CompressorMap(FilePathUtils.ResolveFilePath(vectoPath, txtCompressorMap.Text)) + comp.Initialise() + ErrorProvider.SetError(txtCompressorMap, String.Empty) + Catch ex As Exception + ErrorProvider.SetError(txtCompressorMap, + "Error : map is invalid or cannot be found, please select a Cvalid compressor map") + result = False + End Try + + 'Compressor Gear Efficiency : txtCompressorGearEfficiency" + If Not IsNumberBetweenZeroandOne(txtCompressorGearEfficiency.Text) Then + ErrorProvider.SetError(txtCompressorGearEfficiency, "Please enter a number between 0 and 1") + result = False + Else + ErrorProvider.SetError(txtCompressorGearEfficiency, String.Empty) + End If + + 'Compressor Gear Ratio : txtCompressorGearRatio + If Not IsPostiveNumber(txtCompressorGearRatio.Text) Then + ErrorProvider.SetError(txtCompressorGearRatio, "Please enter a number greater than 0.") + result = False + Else + ErrorProvider.SetError(txtCompressorGearRatio, String.Empty) + End If + + + 'Actuations Map : txtActuationsMap + If txtActuationsMap.Text.Trim.Length = 0 Then + ErrorProvider.SetError(txtActuationsMap, "Please enter the localtion of a valid Pneumatic Actuations map.") + result = False + Else + ErrorProvider.SetError(txtActuationsMap, String.Empty) + End If + 'Test File is valid + Dim actuations As PneumaticActuationsMAP + Try + + actuations = New PneumaticActuationsMAP(FilePathUtils.ResolveFilePath(vectoPath, txtActuationsMap.Text)) + actuations.Initialise() + ErrorProvider.SetError(txtActuationsMap, String.Empty) + Catch ex As Exception + ErrorProvider.SetError(txtActuationsMap, + "Error : Pneumatic Actuations map is invalid or cannot be found, please select a valid map") + result = False + End Try + + + 'NOT Required but included here so readers can see this is a positive ommission + '****************************************************************************** + 'Smart Air Compression : chkSmartAirCompression + 'Smart Regeneration : chkSmartRegeneration + 'Retarder Brake : chkRetarderBrake + + 'txtKneelingHeightMillimeters : txtKneelingHeightMillimeters + If Not IsZeroOrPostiveNumber(txtKneelingHeightMillimeters.Text) Then + ErrorProvider.SetError(txtKneelingHeightMillimeters, "Please enter a number greater than 0.") + result = False + Else + ErrorProvider.SetError(txtKneelingHeightMillimeters, String.Empty) + End If + + 'cboAirSuspensionControl : cboAirSuspensionControl + If cboAirSuspensionControl.SelectedIndex < 1 Then + ErrorProvider.SetError(cboAirSuspensionControl, "Please make a selection.") + result = False + Else + ErrorProvider.SetError(cboAirSuspensionControl, String.Empty) + End If + + 'cboAdBlueDosing : cboAdBlueDosing + If cboAdBlueDosing.SelectedIndex < 1 Then + ErrorProvider.SetError(cboAdBlueDosing, "Please make a selection.") + result = False + Else + ErrorProvider.SetError(cboAdBlueDosing, String.Empty) + End If + + 'cboDoors : cboDoors + If cboDoors.SelectedIndex < 1 Then + ErrorProvider.SetError(cboDoors, "Please make a selection.") + result = False + Else + ErrorProvider.SetError(cboDoors, String.Empty) + End If + + + 'Set Tab Color + + UpdateTabStatus("tabPneumaticConfig", result) + + + Return result + End Function + + '***** ELECTRICAL VALIDATION + Public Sub Validating_ElectricsHandler(sender As Object, e As CancelEventArgs) _ + Handles txtPowernetVoltage.Validating, txtAlternatorMapPath.Validating, txtAlternatorGearEfficiency.Validating, + txtDoorActuationTimeSeconds.Validating, txtStoredEnergyEfficiency.Validating + + e.Cancel = Not Validate_Electrics() + End Sub + + Public Function Validate_Electrics() As Boolean + + Dim result As Boolean = True + + + 'Powernet Voltage : txtPowernetVoltage + If Not IsPostiveNumber(txtPowernetVoltage.Text) Then + ErrorProvider.SetError(txtPowernetVoltage, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtPowernetVoltage, String.Empty) + End If + + + 'Alternator Map path : txtAlternatorMapPath + 'Test for empty after trim + If txtAlternatorMapPath.Text.Trim.Length = 0 Then + ErrorProvider.SetError(txtAlternatorMapPath, "Please enter the localtion of a valid alternator map.") + result = False + Else + ErrorProvider.SetError(txtAlternatorMapPath, String.Empty) + End If - 'Stored Energy Efficiency : txtStoredEnergyEfficiency - If Not IsPostiveNumber(txtStoredEnergyEfficiency.Text) Then - ErrorProvider.SetError(txtStoredEnergyEfficiency, "Please provide a non negative number.") - result = False - Else - ErrorProvider.SetError(txtStoredEnergyEfficiency, String.Empty) - End If + 'Test File is valid + Dim alt As ICombinedAlternator + Try + alt = New CombinedAlternator(FilePathUtils.ResolveFilePath(vectoPath, txtAlternatorMapPath.Text)) + ErrorProvider.SetError(txtAlternatorMapPath, String.Empty) + Catch ex As Exception + ErrorProvider.SetError(txtAlternatorMapPath, + "Error : map is invalid or cannot be found, please select a valid alternator map") + result = False + End Try - UpdateTabStatus("tabElectricalConfig", result) + 'Alternator Gear Efficiency : txtAlternatorGearEfficiency + If Not IsNumberBetweenZeroandOne(txtAlternatorGearEfficiency.Text) Then + ErrorProvider.SetError(txtAlternatorGearEfficiency, "Please enter a number between 0 an 1") + result = False + Else + ErrorProvider.SetError(txtAlternatorGearEfficiency, String.Empty) + End If - Return result + 'Door Action Time : txtDoorActuationTimeSeconds + If Not IsPostiveNumber(txtDoorActuationTimeSeconds.Text) Then + ErrorProvider.SetError(txtDoorActuationTimeSeconds, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtDoorActuationTimeSeconds, String.Empty) + End If + 'Stored Energy Efficiency : txtStoredEnergyEfficiency + If Not IsPostiveNumber(txtStoredEnergyEfficiency.Text) Then + ErrorProvider.SetError(txtStoredEnergyEfficiency, "Please provide a non negative number.") + result = False + Else + ErrorProvider.SetError(txtStoredEnergyEfficiency, String.Empty) + End If - End Function - '****** HVAC VALIDATION - Public Sub Validating_HVACHandler(sender As Object, e As CancelEventArgs) Handles txtSSMFilePath.Validating, txtBusDatabaseFilePath.Validating + UpdateTabStatus("tabElectricalConfig", result) - e.Cancel = Not Validate_HVAC() - End Sub - Public Function Validate_HVAC() As Boolean + Return result + End Function - Dim result As Boolean = True - Dim message As String = "" + '****** HVAC VALIDATION + Public Sub Validating_HVACHandler(sender As Object, e As CancelEventArgs) _ + Handles txtSSMFilePath.Validating, txtBusDatabaseFilePath.Validating - 'Validate abdb - Bus Database - Dim abdbFile As String = FilePathUtils.ResolveFilePath(vectoPath, txtBusDatabaseFilePath.Text) - Dim bdb As New BusDatabase() - If bdb.Initialise(abdbFile) Then - ErrorProvider.SetError(txtBusDatabaseFilePath, String.Empty) - Else - result = False - ErrorProvider.SetError(Me.txtBusDatabaseFilePath, "Please choose a valid Steady State Model File (*.ABDB") - End If + e.Cancel = Not Validate_HVAC() + End Sub + Public Function Validate_HVAC() As Boolean - 'Try ahsm - HVac Steady State Model - Try + Dim result As Boolean = True + Dim message As String = "" - Dim ahsmFile As String = FilePathUtils.ResolveFilePath(vectoPath, txtSSMFilePath.Text) - Dim ssmTool As SSMTOOL = New SSMTOOL(ahsmFile, New HVACConstants, False) + 'Validate abdb - Bus Database + Dim abdbFile As String = FilePathUtils.ResolveFilePath(vectoPath, txtBusDatabaseFilePath.Text) + Dim bdb As New BusDatabase() + If bdb.Initialise(abdbFile) Then + ErrorProvider.SetError(txtBusDatabaseFilePath, String.Empty) + Else + result = False + ErrorProvider.SetError(Me.txtBusDatabaseFilePath, "Please choose a valid Steady State Model File (*.ABDB") + End If - If ssmTool.Load(ahsmFile) Then - ErrorProvider.SetError(txtSSMFilePath, String.Empty) - Else - result = False - ErrorProvider.SetError(txtSSMFilePath, "Please choose a valid Steady State Model File (*.AHSM") - End If - Catch ex As Exception - 'Just in case - ErrorProvider.SetError(txtSSMFilePath, "Please choose a valid Steady State Model File (*.AHSM") - result = False + 'Try ahsm - HVac Steady State Model + Try - End Try + Dim ahsmFile As String = FilePathUtils.ResolveFilePath(vectoPath, txtSSMFilePath.Text) + Dim ssmTool As SSMTOOL = New SSMTOOL(ahsmFile, New HVACConstants, False) + If ssmTool.Load(ahsmFile) Then + ErrorProvider.SetError(txtSSMFilePath, String.Empty) + Else + result = False + ErrorProvider.SetError(txtSSMFilePath, "Please choose a valid Steady State Model File (*.AHSM") + End If - UpdateTabStatus("tabHVACConfig", result) + Catch ex As Exception + 'Just in case + ErrorProvider.SetError(txtSSMFilePath, "Please choose a valid Steady State Model File (*.AHSM") + result = False - Return result + End Try - End Function + UpdateTabStatus("tabHVACConfig", result) + Return result + End Function - Public Function ValidateAll() As Boolean - If Validate_Pneumatics() = False Or Validate_Electrics() = False Or Validate_HVAC() = False Then - Return False - End If + Public Function ValidateAll() As Boolean - Return True + If Validate_Pneumatics() = False Or Validate_Electrics() = False Or Validate_HVAC() = False Then + Return False + End If - End Function + Return True + End Function - '***** IMPUTS VALIDATION + '***** IMPUTS VALIDATION #End Region - 'Form Controls & Events - Private Sub Dashboard_Load(sender As Object, e As EventArgs) Handles MyBase.Load - - 'Required for OwnerDraw, this is required in order to color the tabs when a validation error occurs to draw - 'The attention of the user to the fact that attention is required on a particlar tab. - TabColors.Add(tabGeneralConfig, Control.DefaultBackColor) - TabColors.Add(tabElectricalConfig, Control.DefaultBackColor) - TabColors.Add(tabPneumaticConfig, Control.DefaultBackColor) - TabColors.Add(tabHVACConfig, Control.DefaultBackColor) + 'Form Controls & Events + Private Sub Dashboard_Load(sender As Object, e As EventArgs) Handles MyBase.Load + 'Required for OwnerDraw, this is required in order to color the tabs when a validation error occurs to draw + 'The attention of the user to the fact that attention is required on a particlar tab. + TabColors.Add(tabGeneralConfig, Control.DefaultBackColor) + TabColors.Add(tabElectricalConfig, Control.DefaultBackColor) + TabColors.Add(tabPneumaticConfig, Control.DefaultBackColor) + TabColors.Add(tabHVACConfig, Control.DefaultBackColor) - 'This is here only for testing purposes, the actual cycle will be a result of Vecto input. - cboCycle.SelectedIndex = 0 - 'General Setup of all controls - SetupControls() + 'This is here only for testing purposes, the actual cycle will be a result of Vecto input. + cboCycle.SelectedIndex = 0 - 'Binding Values in Aux environment to the input controls on relevent tabs in the form. - CreateBindings() + 'General Setup of all controls + SetupControls() - 'This function is neccesary because binding does not occur when the page is invisible, so a track across all of them - 'Is required in order to set the binding. This only needs to be done once at at setup time. after values are set in the - 'Aux environment either by setting defaults of reading and setting from the Auxillaries persistance file. - EnsureBinding() + 'Binding Values in Aux environment to the input controls on relevent tabs in the form. + CreateBindings() + 'This function is neccesary because binding does not occur when the page is invisible, so a track across all of them + 'Is required in order to set the binding. This only needs to be done once at at setup time. after values are set in the + 'Aux environment either by setting defaults of reading and setting from the Auxillaries persistance file. + EnsureBinding() - 'Additional atatched events - 'For Tab Coloring, this is the place where the background will get filled on the tab when attention is required. - AddHandler tabMain.DrawItem, New System.Windows.Forms.DrawItemEventHandler(AddressOf tabMain_DrawItem) - 'Select Electric Tab - tabMain.SelectTab(tabMain.TabPages("tabElectricalConfig")) + 'Additional atatched events + 'For Tab Coloring, this is the place where the background will get filled on the tab when attention is required. + AddHandler tabMain.DrawItem, New System.Windows.Forms.DrawItemEventHandler(AddressOf tabMain_DrawItem) + 'Select Electric Tab + tabMain.SelectTab(tabMain.TabPages("tabElectricalConfig")) - 'Enabled / Disables Smart Cards based on chkSmartElectrical - SetSmartCardEmabledStatus() - 'Merge Info data from ElectricalConsumer in a Default set into live set - 'This is required because the info is stored in the AAUX file and we do not want to use a persistance stored version. - auxConfig.ElectricalUserInputsConfig.ElectricalConsumers.MergeInfoData() + 'Enabled / Disables Smart Cards based on chkSmartElectrical + SetSmartCardEmabledStatus() + 'Merge Info data from ElectricalConsumer in a Default set into live set + 'This is required because the info is stored in the AAUX file and we do not want to use a persistance stored version. + auxConfig.ElectricalUserInputsConfig.ElectricalConsumers.MergeInfoData() + End Sub - End Sub - Private Sub frmAuxiliaryConfig_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing + Private Sub frmAuxiliaryConfig_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing - If Me.DialogResult = Windows.Forms.DialogResult.Cancel Then Return + If Me.DialogResult = Windows.Forms.DialogResult.Cancel Then Return - Dim result As DialogResult + Dim result As DialogResult - If Not File.Exists(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) OrElse - Not auxConfig.ConfigValuesAreTheSameAs(originalConfig) Then + If Not File.Exists(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) OrElse + Not auxConfig.ConfigValuesAreTheSameAs(originalConfig) Then - result = (MessageBox.Show("Would you like to save changes before closing?", "Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) + result = + (MessageBox.Show("Would you like to save changes before closing?", "Save Changes", MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Question)) - Select Case result + Select Case result - Case DialogResult.Yes - 'save - If Not SaveFile() Then - e.Cancel = True - End If + Case DialogResult.Yes + 'save + If Not SaveFile() Then + e.Cancel = True + End If - Case DialogResult.No - 'just allow the form to close - 'without saving - Me.DialogResult = Windows.Forms.DialogResult.Cancel + Case DialogResult.No + 'just allow the form to close + 'without saving + Me.DialogResult = Windows.Forms.DialogResult.Cancel - Case DialogResult.Cancel - 'cancel the close - e.Cancel = True - Me.DialogResult = Windows.Forms.DialogResult.Cancel + Case DialogResult.Cancel + 'cancel the close + e.Cancel = True + Me.DialogResult = Windows.Forms.DialogResult.Cancel - End Select - Else - Me.DialogResult = Windows.Forms.DialogResult.Cancel - e.Cancel = False - End If + End Select + Else + Me.DialogResult = Windows.Forms.DialogResult.Cancel + e.Cancel = False + End If + End Sub - - End Sub #Region "GridHandlers" - Private Sub gvElectricalConsumables_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) Handles gvElectricalConsumables.CellValidating - - Dim column As DataGridViewColumn = gvElectricalConsumables.Columns(e.ColumnIndex) - Dim s As Single - - - If e.ColumnIndex = -1 Then - - e.Cancel = True - Exit Sub - - End If - - - - If column.ReadOnly Then Return - - - - - Select Case column.Name - - Case "NominalConsumptionAmps" - If Not IsNumeric(e.FormattedValue) Then - MessageBox.Show("This value must be numeric") - e.Cancel = True - End If - - Case "NumberInActualVehicle" - If Not IsNumeric(e.FormattedValue) Then - MessageBox.Show("This value must be numeric") - e.Cancel = True - Else - s = Single.Parse(e.FormattedValue) - End If - If s Mod 1 > 0 OrElse s < 0 Then - MessageBox.Show("This value must be a positive whole number ( Integer ) ") - e.Cancel = True - End If - - 'Veh Electronics &Engine - If e.RowIndex = 1 Then - If Not IsNumeric(e.FormattedValue) Then - MessageBox.Show("This value must be numeric") - e.Cancel = True - End If + Private Sub gvElectricalConsumables_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) _ + Handles gvElectricalConsumables.CellValidating + + Dim column As DataGridViewColumn = gvElectricalConsumables.Columns(e.ColumnIndex) + Dim s As Single + + + If e.ColumnIndex = - 1 Then + + e.Cancel = True + Exit Sub + + End If - If chkSmartElectricals.Checked AndAlso s <> 0 Then - MessageBox.Show("This must be set to 0 in smart mode") - e.Cancel = True - ElseIf Not chkSmartElectricals.Checked AndAlso s <> 1 Then - MessageBox.Show("This must be set to 1 in classic mode") - e.Cancel = True - End If - End If + If column.ReadOnly Then Return + + Select Case column.Name - 'Exterior Bulb - If e.RowIndex = 14 Then - If Not IsNumeric(e.FormattedValue) Then - MessageBox.Show("This value must be numeric") - e.Cancel = True - End If - If s <> 1 Then - MessageBox.Show("This must be set 1") - e.Cancel = True - End If - End If + Case "NominalConsumptionAmps" + If Not IsNumeric(e.FormattedValue) Then + MessageBox.Show("This value must be numeric") + e.Cancel = True + End If - 'Bonus Bulbs - If e.RowIndex >= 15 AndAlso e.RowIndex <= 19 Then + Case "NumberInActualVehicle" + If Not IsNumeric(e.FormattedValue) Then + MessageBox.Show("This value must be numeric") + e.Cancel = True + Else + s = Single.Parse(e.FormattedValue.ToString()) + End If + If s Mod 1 > 0 OrElse s < 0 Then + MessageBox.Show("This value must be a positive whole number ( Integer ) ") + e.Cancel = True + End If - If Not IsNumeric(e.FormattedValue) Then - MessageBox.Show("This value must be numeric") - e.Cancel = True - End If - If s <> 0 AndAlso s <> 1 Then - MessageBox.Show("This must be set to 0 or 1") - e.Cancel = True - End If + 'Veh Electronics &Engine + If e.RowIndex = 1 Then + If Not IsNumeric(e.FormattedValue) Then + MessageBox.Show("This value must be numeric") + e.Cancel = True + End If - End If + If chkSmartElectricals.Checked AndAlso s <> 0 Then + MessageBox.Show("This must be set to 0 in smart mode") + e.Cancel = True + ElseIf Not chkSmartElectricals.Checked AndAlso s <> 1 Then + MessageBox.Show("This must be set to 1 in classic mode") + e.Cancel = True + End If + End If + 'Exterior Bulb + If e.RowIndex = 14 Then + If Not IsNumeric(e.FormattedValue) Then + MessageBox.Show("This value must be numeric") + e.Cancel = True + End If + If s <> 1 Then + MessageBox.Show("This must be set 1") + e.Cancel = True + End If + End If - Case "PhaseIdle_TractionOn" - If Not IsNumeric(e.FormattedValue) Then - MessageBox.Show("This value must be numeric") - e.Cancel = True - Else - s = Single.Parse(e.FormattedValue) - End If - If s < 0 OrElse s > 1 Then - MessageBox.Show("This must be a value between 0 and 1 ") - e.Cancel = True - End If + 'Bonus Bulbs + If e.RowIndex >= 15 AndAlso e.RowIndex <= 19 Then + If Not IsNumeric(e.FormattedValue) Then + MessageBox.Show("This value must be numeric") + e.Cancel = True + End If + If s <> 0 AndAlso s <> 1 Then + MessageBox.Show("This must be set to 0 or 1") + e.Cancel = True + End If + End If - End Select + Case "PhaseIdle_TractionOn" + If Not IsNumeric(e.FormattedValue) Then + MessageBox.Show("This value must be numeric") + e.Cancel = True + Else + s = Single.Parse(e.FormattedValue.ToString()) + End If + If s < 0 OrElse s > 1 Then + MessageBox.Show("This must be a value between 0 and 1 ") + e.Cancel = True + End If - End Sub - Private Sub SmartResult_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) Handles gvResultsCardIdle.CellValidating, gvResultsCardTraction.CellValidating, gvResultsCardOverrun.CellValidating - Dim column As DataGridViewColumn = gvElectricalConsumables.Columns(e.ColumnIndex) + End Select + End Sub - If Not IsNumeric(e.FormattedValue) Then - MessageBox.Show("This value must be numeric") - e.Cancel = True - End If + Private Sub SmartResult_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) _ + Handles gvResultsCardIdle.CellValidating, gvResultsCardTraction.CellValidating, gvResultsCardOverrun.CellValidating - End Sub - Private Sub resultCard_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles gvResultsCardIdle.CellMouseUp, gvResultsCardTraction.CellMouseUp, gvResultsCardOverrun.CellMouseUp + Dim column As DataGridViewColumn = gvElectricalConsumables.Columns(e.ColumnIndex) - Dim dgv As DataGridView = CType(sender, DataGridView) + If Not IsNumeric(e.FormattedValue) Then + MessageBox.Show("This value must be numeric") + e.Cancel = True + End If + End Sub + Private Sub resultCard_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) _ + Handles gvResultsCardIdle.CellMouseUp, gvResultsCardTraction.CellMouseUp, gvResultsCardOverrun.CellMouseUp - If e.Button = MouseButtons.Right Then + Dim dgv As DataGridView = CType(sender, DataGridView) - resultCardContextMenu.Show(dgv, e.Location) - resultCardContextMenu.Show(Cursor.Position) - End If + If e.Button = MouseButtons.Right Then + resultCardContextMenu.Show(dgv, e.Location) + resultCardContextMenu.Show(Cursor.Position) - End Sub - Private Sub resultCardContextMenu_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles resultCardContextMenu.ItemClicked + End If + End Sub - Dim menu As ContextMenuStrip = CType(sender, ContextMenuStrip) + Private Sub resultCardContextMenu_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) _ + Handles resultCardContextMenu.ItemClicked - Dim grid As DataGridView = DirectCast(menu.SourceControl, DataGridView) + Dim menu As ContextMenuStrip = CType(sender, ContextMenuStrip) - Select Case e.ClickedItem.Text + Dim grid As DataGridView = DirectCast(menu.SourceControl, DataGridView) + Select Case e.ClickedItem.Text - Case "Delete" - For Each selectedRow As DataGridViewRow In grid.SelectedRows + Case "Delete" - If Not selectedRow.IsNewRow Then + For Each selectedRow As DataGridViewRow In grid.SelectedRows - grid.Rows.RemoveAt(selectedRow.Index) + If Not selectedRow.IsNewRow Then - End If + grid.Rows.RemoveAt(selectedRow.Index) - Next + End If - Case "Insert" + Next + Case "Insert" - End Select + End Select + End Sub + Private Sub gvElectricalConsumables_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) _ + Handles gvElectricalConsumables.CellFormatting + End Sub + Private Sub gvElectricalConsumables_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) _ + Handles gvElectricalConsumables.CellBeginEdit + If e.ColumnIndex = 4 AndAlso e.RowIndex = 0 Then + MessageBox.Show("This cell is calculated and cannot be edited") + e.Cancel = True - - - - End Sub - Private Sub gvElectricalConsumables_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles gvElectricalConsumables.CellFormatting - - End Sub - Private Sub gvElectricalConsumables_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles gvElectricalConsumables.CellBeginEdit - - If e.ColumnIndex = 4 AndAlso e.RowIndex = 0 Then - - MessageBox.Show("This cell is calculated and cannot be edited") - e.Cancel = True - - End If - - - End Sub + End If + End Sub #End Region -#Region "Button Handlers" - Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click - - - If SaveFile() Then - - originalConfig.AssumeValuesOfOther(auxConfig) - Me.Close() - - - End If - - - - End Sub - Private Function SaveFile() As Boolean - - Dim result As Boolean +#Region "Button Handlers" - If Not ValidateAll() Then - If (MessageBox.Show("There are invalid values. Do you want so save anyway?", "Save Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No) Then - Return False - End If - End If + Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click - result = auxConfig.Save(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) - If Not result Then MessageBox.Show(String.Format("Unable to Save the file '{0}'", auxFile)) + If SaveFile() Then - Return result + originalConfig.AssumeValuesOfOther(auxConfig) + Me.Close() - End Function - Private Function LoadFile() As Boolean - 'JSON METHOD - Dim result As Boolean + End If + End Sub - 'Release existing databindings - UnbindAllControls(Me) + Private Function SaveFile() As Boolean - result = auxConfig.Load(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) + Dim result As Boolean - If Not result Then - MessageBox.Show(String.Format("Unable to load the file '{0}'", auxFile)) - Else - CreateBindings() - End If + If Not ValidateAll() Then + If _ + (MessageBox.Show("There are invalid values. Do you want so save anyway?", "Save Changes", MessageBoxButtons.YesNo, + MessageBoxIcon.Question) = DialogResult.No) Then + Return False + End If + End If - Return result + result = auxConfig.Save(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) - End Function - Private Sub btnFuelMap_Click(sender As Object, e As EventArgs) Handles btnFuelMap.Click + If Not result Then MessageBox.Show(String.Format("Unable to Save the file '{0}'", auxFile)) - Dim fbAux As New cFileBrowser(True, False) + Return result + End Function + Private Function LoadFile() As Boolean + 'JSON METHOD + Dim result As Boolean - ' Dim vectoFile As String = "C:\Users\tb28\Source\Workspaces\VECTO\AuxillaryTestHarness\bin\Debug\vectopath.vecto" - Dim fname As String = fFILE(vectoFile, True) + 'Release existing databindings + UnbindAllControls(Me) - fbAux.Extensions = New String() {"vmap"} - ' If fbAux.OpenDialog(fFileRepl(fname, fPATH(VECTOfile))) Then - If fbAux.OpenDialog(fPATH(vectoFile)) Then + result = auxConfig.Load(FilePathUtils.ResolveFilePath(vectoPath, auxFile)) - txtFuelMap.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) + If Not result Then + MessageBox.Show(String.Format("Unable to load the file '{0}'", auxFile)) + Else + CreateBindings() + End If - End If + Return result + End Function + Private Sub btnFuelMap_Click(sender As Object, e As EventArgs) Handles btnFuelMap.Click - End Sub - Private Sub btnAlternatorMapPath_Click(sender As Object, e As EventArgs) Handles btnAlternatorMapPath.Click + Dim fbAux As New cFileBrowser("AAUXFuelMap", True, False) - Dim fbAux As New cFileBrowser(True, False) - fbAux.Extensions = New String() {"AALT"} - Dim suppliedAALTPath As String = txtAlternatorMapPath.Text - Dim absoluteAALTPath As String = FilePathUtils.ResolveFilePath(fPATH(vectoFile), suppliedAALTPath) - Dim message As String = String.Empty - Dim newFile As Boolean = False + ' Dim vectoFile As String = "C:\Users\tb28\Source\Workspaces\VECTO\AuxillaryTestHarness\bin\Debug\vectopath.vecto" + Dim fname As String = fFILE(vectoFile, True) - Dim validAALTFile As Boolean = FilePathUtils.ValidateFilePath(absoluteAALTPath, ".aalt", message) - Dim fileExists As Boolean = File.Exists(absoluteAALTPath) + fbAux.Extensions = New String() {"vmap"} + ' If fbAux.OpenDialog(fFileRepl(fname, fPATH(VECTOfile))) Then + If fbAux.OpenDialog(fPATH(vectoFile)) Then - If suppliedAALTPath.Length > 0 AndAlso Not validAALTFile Then - MessageBox.Show(message) - Return - End If + txtFuelMap.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) - 'If file Exists, Check validity, else fire up a default SSM Config. - If fileExists Then - Try - Dim aaltFile As String = FilePathUtils.ResolveFilePath(vectoPath, absoluteAALTPath) - Dim combinedAlt As ICombinedAlternator = New CombinedAlternator(aaltFile) - Catch ex As Exception - MessageBox.Show("The supplied .AALT File was invalid, aborting.") - Return - End Try - End If + End If + End Sub - If Not fileExists Then + Private Sub btnAlternatorMapPath_Click(sender As Object, e As EventArgs) Handles btnAlternatorMapPath.Click - Dim needToFindOrCreateFile As Boolean = True - While needToFindOrCreateFile + Dim fbAux As New cFileBrowser("AAUXALT", True, False) + fbAux.Extensions = New String() {"AALT"} - 'Find / Create file and configure. - If fbAux.CustomDialog(absoluteAALTPath, False, False, tFbExtMode.ForceExt, False, String.Empty) Then - txtAlternatorMapPath.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) - suppliedAALTPath = txtAlternatorMapPath.Text - absoluteAALTPath = FilePathUtils.ResolveFilePath(fPATH(vectoFile), suppliedAALTPath) + Dim suppliedAALTPath As String = txtAlternatorMapPath.Text + Dim absoluteAALTPath As String = FilePathUtils.ResolveFilePath(fPATH(vectoFile), suppliedAALTPath) + Dim message As String = String.Empty + Dim newFile As Boolean = False - If IO.File.Exists(absoluteAALTPath) OrElse MsgBox("Do you want to create a new .AALT file?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then - needToFindOrCreateFile = False - newFile = True - End If - Else - needToFindOrCreateFile = False - End If + Dim validAALTFile As Boolean = FilePathUtils.ValidateFilePath(absoluteAALTPath, ".aalt", message) + Dim fileExists As Boolean = File.Exists(absoluteAALTPath) - End While + If suppliedAALTPath.Length > 0 AndAlso Not validAALTFile Then + MessageBox.Show(message) + Return + End If - End If + 'If file Exists, Check validity, else fire up a default SSM Config. + If fileExists Then + Try + Dim aaltFile As String = FilePathUtils.ResolveFilePath(vectoPath, absoluteAALTPath) + Dim combinedAlt As ICombinedAlternator = New CombinedAlternator(aaltFile) + Catch ex As Exception + MessageBox.Show("The supplied .AALT File was invalid, aborting.") + Return + End Try + End If - If fileExists OrElse newFile Then + If Not fileExists Then - Using frm As New frmCombinedAlternators(absoluteAALTPath, New CombinedAlternatorSignals) - 'If Dialog result is OK, then take action else bail - If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then - If suppliedAALTPath.Contains(":\") AndAlso Not String.IsNullOrEmpty(vectoPath) Then - txtAlternatorMapPath.Text = If(suppliedAALTPath.Contains(vectoPath), suppliedAALTPath.Replace(vectoPath, ""), suppliedAALTPath) - Else - txtAlternatorMapPath.Text = fFileWoDir(suppliedAALTPath) - End If - Else - Return - End If - End Using + Dim needToFindOrCreateFile As Boolean = True + While needToFindOrCreateFile - Validate_Electrics() + 'Find / Create file and configure. + If fbAux.CustomDialog(absoluteAALTPath, False, False, tFbExtMode.ForceExt, False, String.Empty) Then + txtAlternatorMapPath.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) + suppliedAALTPath = txtAlternatorMapPath.Text + absoluteAALTPath = FilePathUtils.ResolveFilePath(fPATH(vectoFile), suppliedAALTPath) - End If + If _ + IO.File.Exists(absoluteAALTPath) OrElse + MsgBox("Do you want to create a new .AALT file?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + needToFindOrCreateFile = False + newFile = True + End If + Else + needToFindOrCreateFile = False + End If - End Sub - Private Sub btnCompressorMap_Click(sender As Object, e As EventArgs) Handles btnCompressorMap.Click + End While + End If - Dim fbAux As New cFileBrowser(True, False) + If fileExists OrElse newFile Then + Using frm As New frmCombinedAlternators(absoluteAALTPath, New CombinedAlternatorSignals) + 'If Dialog result is OK, then take action else bail + If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then + If suppliedAALTPath.Contains(":\") AndAlso Not String.IsNullOrEmpty(vectoPath) Then + txtAlternatorMapPath.Text = + If(suppliedAALTPath.Contains(vectoPath), suppliedAALTPath.Replace(vectoPath, ""), suppliedAALTPath) + Else + txtAlternatorMapPath.Text = fFileWoDir(suppliedAALTPath) + End If + Else + Return + End If + End Using + Validate_Electrics() - ' Dim vectoFile As String = "C:\Users\tb28\Source\Workspaces\VECTO\AuxillaryTestHarness\bin\Debug\vectopath.vecto" - Dim fname As String = fFILE(vectoFile, True) + End If + End Sub - fbAux.Extensions = New String() {"ACMP"} - If fbAux.OpenDialog(fPATH(vectoFile)) Then + Private Sub btnCompressorMap_Click(sender As Object, e As EventArgs) Handles btnCompressorMap.Click - txtCompressorMap.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) - End If + Dim fbAux As New cFileBrowser("AAUXComp", True, False) - Validate_Pneumatics() - 'Causes binding to fire - txtCompressorMap.Focus() + ' Dim vectoFile As String = "C:\Users\tb28\Source\Workspaces\VECTO\AuxillaryTestHarness\bin\Debug\vectopath.vecto" + Dim fname As String = fFILE(vectoFile, True) + fbAux.Extensions = New String() {"ACMP"} + If fbAux.OpenDialog(fPATH(vectoFile)) Then - End Sub - Private Sub btnActuationsMap_Click(sender As Object, e As EventArgs) Handles btnActuationsMap.Click + txtCompressorMap.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) - Dim fbAux As New cFileBrowser(True, False) + End If - ' Dim vectoFile As String = "C:\Users\tb28\Source\Workspaces\VECTO\AuxillaryTestHarness\bin\Debug\vectopath.vecto" - Dim fname As String = fFILE(vectoFile, True) + Validate_Pneumatics() - fbAux.Extensions = New String() {"APAC"} - If fbAux.OpenDialog(fPATH(vectoFile)) Then + 'Causes binding to fire + txtCompressorMap.Focus() + End Sub - txtActuationsMap.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) + Private Sub btnActuationsMap_Click(sender As Object, e As EventArgs) Handles btnActuationsMap.Click - End If + Dim fbAux As New cFileBrowser("AAUXPneuAct", True, False) - Validate_Pneumatics() + ' Dim vectoFile As String = "C:\Users\tb28\Source\Workspaces\VECTO\AuxillaryTestHarness\bin\Debug\vectopath.vecto" + Dim fname As String = fFILE(vectoFile, True) - 'Causes Binding to fire. - txtActuationsMap.Focus() + fbAux.Extensions = New String() {"APAC"} + If fbAux.OpenDialog(fPATH(vectoFile)) Then - End Sub - Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click + txtActuationsMap.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) + End If - Me.DialogResult = Windows.Forms.DialogResult.Cancel - Me.Close() + Validate_Pneumatics() + 'Causes Binding to fire. + txtActuationsMap.Focus() + End Sub - End Sub + Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click - Private Sub btnBusDatabaseSource_Click(sender As Object, e As EventArgs) Handles btnBusDatabaseSource.Click - Dim fbAux As New cFileBrowser(True, False) - Dim message As String = String.Empty + Me.DialogResult = Windows.Forms.DialogResult.Cancel + Me.Close() + End Sub + Private Sub btnBusDatabaseSource_Click(sender As Object, e As EventArgs) Handles btnBusDatabaseSource.Click - fbAux.Extensions = New String() {"abdb"} + Dim fbAux As New cFileBrowser("AAUXBusDB", True, False) + Dim message As String = String.Empty - If fbAux.OpenDialog(fPATH(vectoFile)) Then - txtBusDatabaseFilePath.Focus() - txtBusDatabaseFilePath.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) + fbAux.Extensions = New String() {"abdb"} - Dim busDB As New BusDatabase() + If fbAux.OpenDialog(fPATH(vectoFile)) Then - If Not busDB.Initialise(FilePathUtils.ResolveFilePath(vectoPath, txtBusDatabaseFilePath.Text)) Then + txtBusDatabaseFilePath.Focus() + txtBusDatabaseFilePath.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) - MessageBox.Show("Unable to load") + Dim busDB As New BusDatabase() - End If + If Not busDB.Initialise(FilePathUtils.ResolveFilePath(vectoPath, txtBusDatabaseFilePath.Text)) Then - Validate_HVAC() - End If + MessageBox.Show("Unable to load") + End If - End Sub - Private Sub btnSSMBSource_Click(sender As Object, e As EventArgs) Handles btnSSMBSource.Click + Validate_HVAC() + End If + End Sub - Dim fbAux As New cFileBrowser(True, False) - fbAux.Extensions = New String() {"AHSM"} + Private Sub btnSSMBSource_Click(sender As Object, e As EventArgs) Handles btnSSMBSource.Click - Dim suppliedSSMPath As String = txtSSMFilePath.Text.Trim() - Dim absoluteSSMPath As String = FilePathUtils.ResolveFilePath(fPATH(vectoFile), suppliedSSMPath) - Dim absoluteBusDatabasePath As String = FilePathUtils.ResolveFilePath(fPATH(vectoFile), Me.txtBusDatabaseFilePath.Text.Trim()) - Dim message As String = String.Empty - Dim newFile As Boolean = False + Dim fbAux As New cFileBrowser("AAUXSSM", True, False) + fbAux.Extensions = New String() {"AHSM"} - Dim validSSMTFile As Boolean = FilePathUtils.ValidateFilePath(absoluteSSMPath, ".ahsm", message) - Dim fileExists As Boolean = File.Exists(absoluteSSMPath) + Dim suppliedSSMPath As String = txtSSMFilePath.Text.Trim() + Dim absoluteSSMPath As String = FilePathUtils.ResolveFilePath(fPATH(vectoFile), suppliedSSMPath) + Dim absoluteBusDatabasePath As String = FilePathUtils.ResolveFilePath(fPATH(vectoFile), + Me.txtBusDatabaseFilePath.Text.Trim()) + Dim message As String = String.Empty + Dim newFile As Boolean = False - If suppliedSSMPath.Length > 0 AndAlso Not validSSMTFile Then - MessageBox.Show(message) - Return - End If + Dim validSSMTFile As Boolean = FilePathUtils.ValidateFilePath(absoluteSSMPath, ".ahsm", message) + Dim fileExists As Boolean = File.Exists(absoluteSSMPath) - 'If file Exists, Check validity, else fire up a default SSM Config. - If File.Exists(absoluteSSMPath) Then - 'is file valid Try ahsm - HVac Steady State Model - Try - Dim ahsmFile As String = FilePathUtils.ResolveFilePath(vectoPath, absoluteSSMPath) - Dim ssmTool As SSMTOOL = New SSMTOOL(ahsmFile, New HVACConstants, False) - ssmTool.Load(ahsmFile) - Catch ex As Exception - MessageBox.Show("The supplied AHSM File was invalid, aborting.") - Return - End Try - End If + If suppliedSSMPath.Length > 0 AndAlso Not validSSMTFile Then + MessageBox.Show(message) + Return + End If - If Not fileExists Then + 'If file Exists, Check validity, else fire up a default SSM Config. + If File.Exists(absoluteSSMPath) Then + 'is file valid Try ahsm - HVac Steady State Model + Try + Dim ahsmFile As String = FilePathUtils.ResolveFilePath(vectoPath, absoluteSSMPath) + Dim ssmTool As SSMTOOL = New SSMTOOL(ahsmFile, New HVACConstants, False) + ssmTool.Load(ahsmFile) + Catch ex As Exception + MessageBox.Show("The supplied AHSM File was invalid, aborting.") + Return + End Try + End If - Dim needToFindOrCreateFile As Boolean = True - While needToFindOrCreateFile + If Not fileExists Then - 'Find / Create file and configure. - If fbAux.CustomDialog(absoluteSSMPath, False, False, tFbExtMode.ForceExt, False, String.Empty) Then - txtSSMFilePath.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) - suppliedSSMPath = txtSSMFilePath.Text - absoluteSSMPath = FilePathUtils.ResolveFilePath(fPATH(vectoFile), suppliedSSMPath) - If IO.File.Exists(absoluteSSMPath) OrElse MsgBox("Do you want to create a new .AHSM file?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then - needToFindOrCreateFile = False - newFile = True - End If - Else - needToFindOrCreateFile = False - End If + Dim needToFindOrCreateFile As Boolean = True + While needToFindOrCreateFile - End While + 'Find / Create file and configure. + If fbAux.CustomDialog(absoluteSSMPath, False, False, tFbExtMode.ForceExt, False, String.Empty) Then + txtSSMFilePath.Text = fFileWoDir(fbAux.Files(0), fPATH(vectoFile)) + suppliedSSMPath = txtSSMFilePath.Text + absoluteSSMPath = FilePathUtils.ResolveFilePath(fPATH(vectoFile), suppliedSSMPath) + If _ + IO.File.Exists(absoluteSSMPath) OrElse + MsgBox("Do you want to create a new .AHSM file?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + needToFindOrCreateFile = False + newFile = True + End If + Else + needToFindOrCreateFile = False + End If - End If + End While - If fileExists OrElse newFile Then + End If - Using frm As New frmHVACTool(absoluteBusDatabasePath, absoluteSSMPath, vectoFile, Not fileExists) - If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then - If suppliedSSMPath.Contains(":\") AndAlso Not String.IsNullOrEmpty(vectoPath) Then - txtSSMFilePath.Text = If(suppliedSSMPath.Contains(vectoPath), suppliedSSMPath.Replace(vectoPath, ""), suppliedSSMPath) - Else - txtSSMFilePath.Text = fFileWoDir(suppliedSSMPath) - End If - Else - Return - End If - End Using + If fileExists OrElse newFile Then - Validate_HVAC() + Using frm As New frmHVACTool(absoluteBusDatabasePath, absoluteSSMPath, vectoFile, Not fileExists) + If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then + If suppliedSSMPath.Contains(":\") AndAlso Not String.IsNullOrEmpty(vectoPath) Then + txtSSMFilePath.Text = + If(suppliedSSMPath.Contains(vectoPath), suppliedSSMPath.Replace(vectoPath, ""), suppliedSSMPath) + Else + txtSSMFilePath.Text = fFileWoDir(suppliedSSMPath) + End If + Else + Return + End If + End Using - End If + Validate_HVAC() - End Sub + End If + End Sub #End Region - Private Sub chkSmartElectricals_CheckedChanged(sender As Object, e As EventArgs) Handles chkSmartElectricals.CheckedChanged - SetSmartCardEmabledStatus() + Private Sub chkSmartElectricals_CheckedChanged(sender As Object, e As EventArgs) _ + Handles chkSmartElectricals.CheckedChanged - End Sub -#Region "File Viewer Button Events" - - Private Sub btnAALTOpen_Click(sender As Object, e As EventArgs) Handles btnAALTOpen.Click + SetSmartCardEmabledStatus() + End Sub - OpenFiles(fFileRepl(Me.txtAlternatorMapPath.Text, fPATH(vectoFile))) +#Region "File Viewer Button Events" - End Sub - Private Sub btnOpenACMP_Click(sender As Object, e As EventArgs) Handles btnOpenACMP.Click + Private Sub btnAALTOpen_Click(sender As Object, e As EventArgs) Handles btnAALTOpen.Click + OpenFiles(fFileRepl(Me.txtAlternatorMapPath.Text, fPATH(vectoFile))) + End Sub - OpenFiles(fFileRepl(Me.txtCompressorMap.Text, fPATH(vectoFile))) + Private Sub btnOpenACMP_Click(sender As Object, e As EventArgs) Handles btnOpenACMP.Click - End Sub - Private Sub btnOpenAPAC_Click(sender As Object, e As EventArgs) Handles btnOpenAPAC.Click - OpenFiles(fFileRepl(Me.txtActuationsMap.Text, fPATH(vectoFile))) + OpenFiles(fFileRepl(Me.txtCompressorMap.Text, fPATH(vectoFile))) + End Sub - End Sub - Private Sub btnOpenAHSM_Click(sender As Object, e As EventArgs) Handles btnOpenAHSM.Click + Private Sub btnOpenAPAC_Click(sender As Object, e As EventArgs) Handles btnOpenAPAC.Click - OpenFiles(fFileRepl(Me.txtSSMFilePath.Text, fPATH(vectoFile))) + OpenFiles(fFileRepl(Me.txtActuationsMap.Text, fPATH(vectoFile))) + End Sub + Private Sub btnOpenAHSM_Click(sender As Object, e As EventArgs) Handles btnOpenAHSM.Click - End Sub - Private Sub btnOpenABDB_Click(sender As Object, e As EventArgs) Handles btnOpenABDB.Click + OpenFiles(fFileRepl(Me.txtSSMFilePath.Text, fPATH(vectoFile))) + End Sub + Private Sub btnOpenABDB_Click(sender As Object, e As EventArgs) Handles btnOpenABDB.Click - OpenFiles(fFileRepl(Me.txtBusDatabaseFilePath.Text, fPATH(vectoFile))) - End Sub + OpenFiles(fFileRepl(Me.txtBusDatabaseFilePath.Text, fPATH(vectoFile))) + End Sub #End Region - 'Overrides - Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean - - If keyData = Keys.Enter AndAlso Me.AcceptButton Is Nothing Then - - If TypeOf (Me.ActiveControl) Is TextBoxBase Then - Dim box As TextBoxBase = CType(Me.ActiveControl, TextBoxBase) + 'Overrides + Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean - If box Is Nothing OrElse Not box.Multiline Then + If keyData = Keys.Enter AndAlso Me.AcceptButton Is Nothing Then - Me.SelectNextControl(Me.ActiveControl, True, True, True, True) - Return True + If TypeOf (Me.ActiveControl) Is TextBoxBase Then + Dim box As TextBoxBase = CType(Me.ActiveControl, TextBoxBase) - End If - End If + If box Is Nothing OrElse Not box.Multiline Then - End If + Me.SelectNextControl(Me.ActiveControl, True, True, True, True) + Return True - Return MyBase.ProcessCmdKey(msg, keyData) + End If + End If - End Function + End If - 'Helpers - Private Sub OpenFiles(ParamArray files() As String) + Return MyBase.ProcessCmdKey(msg, keyData) + End Function - If files.Length = 0 Then Exit Sub - - cmFilesList = files - - OpenWithToolStripMenuItem.Text = "Open with notepad" - - CmFiles.Show(Cursor.Position) - - End Sub - Private Sub OpenWithToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles OpenWithToolStripMenuItem.Click - If Not FileOpenAlt(cmFilesList(0)) Then MsgBox("Failed to open file!") - End Sub - Private Sub ShowInFolderToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ShowInFolderToolStripMenuItem.Click - If IO.File.Exists(cmFilesList(0)) Then - Try - System.Diagnostics.Process.Start("explorer", "/select,""" & cmFilesList(0) & "") - Catch ex As Exception - MsgBox("Failed to open file!") - End Try - Else - MsgBox("File not found!") - End If - End Sub -#Region "Tab Header Color Change" + 'Helpers + Private Sub OpenFiles(ParamArray files() As String) - Private Sub UpdateTabStatus(pageName As String, resultGood As Boolean) + If files.Length = 0 Then Exit Sub + cmFilesList = files - Dim page As TabPage = tabMain.TabPages(pageName) + OpenWithToolStripMenuItem.Text = "Open with notepad" - If Not resultGood Then + CmFiles.Show(Cursor.Position) + End Sub - SetTabHeader(page, Color.Red) + Private Sub OpenWithToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Handles OpenWithToolStripMenuItem.Click + If Not FileOpenAlt(cmFilesList(0)) Then MsgBox("Failed to open file!") + End Sub - Else - SetTabHeader(page, Control.DefaultBackColor) + Private Sub ShowInFolderToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Handles ShowInFolderToolStripMenuItem.Click + If IO.File.Exists(cmFilesList(0)) Then + Try + System.Diagnostics.Process.Start("explorer", "/select,""" & cmFilesList(0) & "") + Catch ex As Exception + MsgBox("Failed to open file!") + End Try + Else + MsgBox("File not found!") + End If + End Sub - End If +#Region "Tab Header Color Change" + Private Sub UpdateTabStatus(pageName As String, resultGood As Boolean) + Dim page As TabPage = tabMain.TabPages(pageName) - End Sub - Private Sub SetTabHeader(page As TabPage, color As Color) + If Not resultGood Then - TabColors(page) = color - tabMain.Invalidate() + SetTabHeader(page, Color.Red) - End Sub - Private Sub tabMain_DrawItem(sender As Object, e As DrawItemEventArgs) + Else + SetTabHeader(page, Control.DefaultBackColor) - Dim br As Brush = New SolidBrush(TabColors(tabMain.TabPages(e.Index))) + End If + End Sub + Private Sub SetTabHeader(page As TabPage, color As Color) - Using (br) + TabColors(page) = color + tabMain.Invalidate() + End Sub - e.Graphics.FillRectangle(br, e.Bounds) - Dim sz As SizeF = e.Graphics.MeasureString(tabMain.TabPages(e.Index).Text, e.Font) - e.Graphics.DrawString(tabMain.TabPages(e.Index).Text, e.Font, Brushes.Black, e.Bounds.Left + (e.Bounds.Width - sz.Width) / 2, e.Bounds.Top + (e.Bounds.Height - sz.Height) / 2 + 1) + Private Sub tabMain_DrawItem(sender As Object, e As DrawItemEventArgs) - Dim rect As Rectangle = e.Bounds - rect.Offset(-1, -1) - rect.Inflate(1, 1) - ' e.Graphics.DrawRectangle(Pens.DarkGray, rect) - 'e.DrawFocusRectangle() + Dim br As Brush = New SolidBrush(TabColors(tabMain.TabPages(e.Index))) - End Using + Using (br) + e.Graphics.FillRectangle(br, e.Bounds) + Dim sz As SizeF = e.Graphics.MeasureString(tabMain.TabPages(e.Index).Text, e.Font) + e.Graphics.DrawString(tabMain.TabPages(e.Index).Text, e.Font, Brushes.Black, + e.Bounds.Left + (e.Bounds.Width - sz.Width)/2, e.Bounds.Top + (e.Bounds.Height - sz.Height)/2 + 1) + Dim rect As Rectangle = e.Bounds + rect.Offset(- 1, - 1) + rect.Inflate(1, 1) + ' e.Graphics.DrawRectangle(Pens.DarkGray, rect) + 'e.DrawFocusRectangle() - End Sub + End Using + End Sub #End Region - Public Sub UnbindAllControls(ByRef container As Control) - 'Clear all of the controls within the container object - 'If "Recurse" is true, then also clear controls within any sub-containers - Dim ctrl As Control = Nothing - - For Each ctrl In container.Controls - - ctrl.DataBindings.Clear() - If ctrl.HasChildren Then - UnbindAllControls(ctrl) - End If + Public Sub UnbindAllControls(ByRef container As Control) + 'Clear all of the controls within the container object + 'If "Recurse" is true, then also clear controls within any sub-containers + Dim ctrl As Control = Nothing - Next + For Each ctrl In container.Controls - End Sub - Private Function GetSSMMAP(ByVal filePath As String, ByRef message As String) As Hvac.IHVACSteadyStateModel + ctrl.DataBindings.Clear() - Dim ssmMap As New Hvac.HVACSteadyStateModel() + If ctrl.HasChildren Then + UnbindAllControls(ctrl) + End If + Next + End Sub - Try + Private Function GetSSMMAP(ByVal filePath As String, ByRef message As String) As Hvac.IHVACSteadyStateModel - If ssmMap.SetValuesFromMap(FilePathUtils.ResolveFilePath(vectoPath, txtSSMFilePath.Text), message) Then + Dim ssmMap As New Hvac.HVACSteadyStateModel() - Return ssmMap - End If + Try - Catch ex As Exception + If ssmMap.SetValuesFromMap(FilePathUtils.ResolveFilePath(vectoPath, txtSSMFilePath.Text), message) Then - MessageBox.Show("Unable to retreive values from map") + Return ssmMap - End Try + End If - Return Nothing + Catch ex As Exception - End Function - Private Sub SetupControls() + MessageBox.Show("Unable to retreive values from map") + End Try - Dim cIndex As Integer = 0 + Return Nothing + End Function - gvElectricalConsumables.AutoGenerateColumns = False + Private Sub SetupControls() - 'ElectricalConsumerGrid - 'Columns - cIndex = gvElectricalConsumables.Columns.Add("Category", "Category") - gvElectricalConsumables.Columns(cIndex).DataPropertyName = "Category" - gvElectricalConsumables.Columns(cIndex).MinimumWidth = 150 - gvElectricalConsumables.Columns(cIndex).ReadOnly = True - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - cIndex = gvElectricalConsumables.Columns.Add("ConsumerName", "Name") + Dim cIndex As Integer = 0 - gvElectricalConsumables.Columns(cIndex).DataPropertyName = "ConsumerName" - gvElectricalConsumables.Columns(cIndex).MinimumWidth = 308 - gvElectricalConsumables.Columns(cIndex).ReadOnly = True - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + gvElectricalConsumables.AutoGenerateColumns = False - Dim baseVehicle As New DataGridViewCheckBoxColumn(False) - baseVehicle.HeaderText = "Base Vehicle" - cIndex = gvElectricalConsumables.Columns.Add(baseVehicle) - gvElectricalConsumables.Columns(cIndex).DataPropertyName = "BaseVehicle" - gvElectricalConsumables.Columns(cIndex).Width = 75 - gvElectricalConsumables.Columns(cIndex).Visible = False - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = "Energy included in the calculations of base vehicle" + 'ElectricalConsumerGrid + 'Columns + cIndex = gvElectricalConsumables.Columns.Add("Category", "Category") + gvElectricalConsumables.Columns(cIndex).DataPropertyName = "Category" + gvElectricalConsumables.Columns(cIndex).MinimumWidth = 150 + gvElectricalConsumables.Columns(cIndex).ReadOnly = True + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - cIndex = gvElectricalConsumables.Columns.Add("NominalConsumptionAmps", "Nominal Amps") - gvElectricalConsumables.Columns(cIndex).DataPropertyName = "NominalConsumptionAmps" - gvElectricalConsumables.Columns(cIndex).Width = 60 - gvElectricalConsumables.Columns(cIndex).ReadOnly = True - gvElectricalConsumables.Columns(cIndex).DefaultCellStyle = New DataGridViewCellStyle() With {.BackColor = Color.LightGray} - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = "Nominal consumption in AMPS" + cIndex = gvElectricalConsumables.Columns.Add("ConsumerName", "Name") - cIndex = gvElectricalConsumables.Columns.Add("PhaseIdle_TractionOn", "PhaseIdle/ TractionOn") - gvElectricalConsumables.Columns(cIndex).DataPropertyName = "PhaseIdle_TractionOn" - gvElectricalConsumables.Columns(cIndex).Width = 60 - gvElectricalConsumables.Columns(cIndex).ReadOnly = True - gvElectricalConsumables.Columns(cIndex).DefaultCellStyle = New DataGridViewCellStyle() With {.BackColor = Color.LightGray} - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = "Represents the amount of time (during engine fueling) as " & vbCrLf & "percentage that the consumer is active during the cycle." + gvElectricalConsumables.Columns(cIndex).DataPropertyName = "ConsumerName" + gvElectricalConsumables.Columns(cIndex).MinimumWidth = 308 + gvElectricalConsumables.Columns(cIndex).ReadOnly = True + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - cIndex = gvElectricalConsumables.Columns.Add("NumberInActualVehicle", "Num in Vehicle") - gvElectricalConsumables.Columns(cIndex).DataPropertyName = "NumberInActualVehicle" - gvElectricalConsumables.Columns(cIndex).Width = 55 - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = "Number of consumables of this" & vbCrLf & "type installed on the vehicle." + Dim baseVehicle As New DataGridViewCheckBoxColumn(False) + baseVehicle.HeaderText = "Base Vehicle" + cIndex = gvElectricalConsumables.Columns.Add(baseVehicle) + gvElectricalConsumables.Columns(cIndex).DataPropertyName = "BaseVehicle" + gvElectricalConsumables.Columns(cIndex).Width = 75 + gvElectricalConsumables.Columns(cIndex).Visible = False + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = "Energy included in the calculations of base vehicle" + cIndex = gvElectricalConsumables.Columns.Add("NominalConsumptionAmps", "Nominal Amps") + gvElectricalConsumables.Columns(cIndex).DataPropertyName = "NominalConsumptionAmps" + gvElectricalConsumables.Columns(cIndex).Width = 60 + gvElectricalConsumables.Columns(cIndex).ReadOnly = True + gvElectricalConsumables.Columns(cIndex).DefaultCellStyle = New DataGridViewCellStyle() _ + With {.BackColor = Color.LightGray} + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = "Nominal consumption in AMPS" - 'INFO COLUMN - cIndex = gvElectricalConsumables.Columns.Add("info", "Info") - ' cIndex = gvElectricalConsumables.Columns.Add( New ImageColumn()) + cIndex = gvElectricalConsumables.Columns.Add("PhaseIdle_TractionOn", "PhaseIdle/ TractionOn") + gvElectricalConsumables.Columns(cIndex).DataPropertyName = "PhaseIdle_TractionOn" + gvElectricalConsumables.Columns(cIndex).Width = 60 + gvElectricalConsumables.Columns(cIndex).ReadOnly = True + gvElectricalConsumables.Columns(cIndex).DefaultCellStyle = New DataGridViewCellStyle() _ + With {.BackColor = Color.LightGray} + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = + "Represents the amount of time (during engine fueling) as " & vbCrLf & + "percentage that the consumer is active during the cycle." - gvElectricalConsumables.Columns(cIndex).DataPropertyName = "Info" - gvElectricalConsumables.Columns(cIndex).Width = 120 - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = "Further Information" + cIndex = gvElectricalConsumables.Columns.Add("NumberInActualVehicle", "Num in Vehicle") + gvElectricalConsumables.Columns(cIndex).DataPropertyName = "NumberInActualVehicle" + gvElectricalConsumables.Columns(cIndex).Width = 55 + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = "Number of consumables of this" & vbCrLf & + "type installed on the vehicle." - ' ResultCard Grids - 'IDLE + 'INFO COLUMN + cIndex = gvElectricalConsumables.Columns.Add("info", "Info") + ' cIndex = gvElectricalConsumables.Columns.Add( New ImageColumn()) - cIndex = gvResultsCardIdle.Columns.Add("Amps", "Amps") - gvResultsCardIdle.Columns(cIndex).DataPropertyName = "Amps" - gvResultsCardIdle.Columns(cIndex).Width = 65 + gvElectricalConsumables.Columns(cIndex).DataPropertyName = "Info" + gvElectricalConsumables.Columns(cIndex).Width = 120 + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvElectricalConsumables.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + gvElectricalConsumables.Columns(cIndex).HeaderCell.ToolTipText = "Further Information" - cIndex = gvResultsCardIdle.Columns.Add("SmartAmps", "SmartAmps") - gvResultsCardIdle.Columns(cIndex).DataPropertyName = "SmartAmps" - gvResultsCardIdle.Columns(cIndex).Width = 65 + ' ResultCard Grids - 'TRACTION - cIndex = gvResultsCardTraction.Columns.Add("Amps", "Amps") - gvResultsCardTraction.Columns(cIndex).DataPropertyName = "Amps" - gvResultsCardTraction.Columns(cIndex).Width = 65 + 'IDLE - cIndex = gvResultsCardTraction.Columns.Add("SmartAmps", "SmartAmps") - gvResultsCardTraction.Columns(cIndex).DataPropertyName = "SmartAmps" - gvResultsCardTraction.Columns(cIndex).Width = 65 + cIndex = gvResultsCardIdle.Columns.Add("Amps", "Amps") + gvResultsCardIdle.Columns(cIndex).DataPropertyName = "Amps" + gvResultsCardIdle.Columns(cIndex).Width = 65 - 'OVERRUN - cIndex = gvResultsCardOverrun.Columns.Add("Amps", "Amps") - gvResultsCardOverrun.Columns(cIndex).DataPropertyName = "Amps" - gvResultsCardOverrun.Columns(cIndex).Width = 65 + cIndex = gvResultsCardIdle.Columns.Add("SmartAmps", "SmartAmps") + gvResultsCardIdle.Columns(cIndex).DataPropertyName = "SmartAmps" + gvResultsCardIdle.Columns(cIndex).Width = 65 + + 'TRACTION + cIndex = gvResultsCardTraction.Columns.Add("Amps", "Amps") + gvResultsCardTraction.Columns(cIndex).DataPropertyName = "Amps" + gvResultsCardTraction.Columns(cIndex).Width = 65 + + cIndex = gvResultsCardTraction.Columns.Add("SmartAmps", "SmartAmps") + gvResultsCardTraction.Columns(cIndex).DataPropertyName = "SmartAmps" + gvResultsCardTraction.Columns(cIndex).Width = 65 + + 'OVERRUN + cIndex = gvResultsCardOverrun.Columns.Add("Amps", "Amps") + gvResultsCardOverrun.Columns(cIndex).DataPropertyName = "Amps" + gvResultsCardOverrun.Columns(cIndex).Width = 65 + + cIndex = gvResultsCardOverrun.Columns.Add("SmartAmps", "SmartAmps") + gvResultsCardOverrun.Columns(cIndex).DataPropertyName = "SmartAmps" + gvResultsCardOverrun.Columns(cIndex).Width = 65 + End Sub - cIndex = gvResultsCardOverrun.Columns.Add("SmartAmps", "SmartAmps") - gvResultsCardOverrun.Columns(cIndex).DataPropertyName = "SmartAmps" - gvResultsCardOverrun.Columns(cIndex).Width = 65 - - - - - End Sub #Region "Binding Control" - Private Sub CreateBindings() - - 'auxConfig.Vecto Bindings - txtPowernetVoltage.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "PowerNetVoltage") - 'txtVehicleWeightKG.DataBindings.Add("Text", auxConfig.VectoInputs, "VehicleWeightKG") - 'cboCycle.DataBindings.Add("Text", auxConfig.VectoInputs, "Cycle") - txtFuelMap.DataBindings.Add("Text", auxConfig.VectoInputs, "FuelMap") - - 'Electricals General - txtAlternatorMapPath.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "AlternatorMap") - txtAlternatorGearEfficiency.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "AlternatorGearEfficiency") - txtDoorActuationTimeSeconds.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "DoorActuationTimeSecond") - txtStoredEnergyEfficiency.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "StoredEnergyEfficiency") - chkSmartElectricals.DataBindings.Add("Checked", auxConfig.ElectricalUserInputsConfig, "SmartElectrical", False, DataSourceUpdateMode.OnPropertyChanged) - - - 'Electrical ConsumablesGrid - electricalConsumerBinding = New BindingList(Of IElectricalConsumer)(auxConfig.ElectricalUserInputsConfig.ElectricalConsumers.Items) - gvElectricalConsumables.DataSource = electricalConsumerBinding - - - - 'ResultCards - - 'IDLE - Dim idleBinding As BindingList(Of SmartResult) - idleBinding = New BindingList(Of SmartResult)(auxConfig.ElectricalUserInputsConfig.ResultCardIdle.Results) - idleBinding.AllowNew = True - idleBinding.AllowRemove = True - gvResultsCardIdle.DataSource = idleBinding - - 'TRACTION - Dim tractionBinding As BindingList(Of SmartResult) - tractionBinding = New BindingList(Of SmartResult)(auxConfig.ElectricalUserInputsConfig.ResultCardTraction.Results) - tractionBinding.AllowNew = True - tractionBinding.AllowRemove = True - gvResultsCardTraction.DataSource = tractionBinding - - 'OVERRUN - Dim overrunBinding As BindingList(Of SmartResult) - overrunBinding = New BindingList(Of SmartResult)(auxConfig.ElectricalUserInputsConfig.ResultCardOverrun.Results) - overrunBinding.AllowNew = True - overrunBinding.AllowRemove = True - gvResultsCardOverrun.DataSource = overrunBinding - - - 'Pneumatic Auxillaries Binding - txtAdBlueNIperMinute.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "AdBlueNIperMinute") - - txtOverrunUtilisationForCompressionFraction.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "OverrunUtilisationForCompressionFraction") - txtBrakingWithRetarderNIperKG.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "BrakingWithRetarderNIperKG") - txtBrakingNoRetarderNIperKG.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "BrakingNoRetarderNIperKG") - txtBreakingPerKneelingNIperKGinMM.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "BreakingPerKneelingNIperKGinMM", True, DataSourceUpdateMode.OnPropertyChanged, Nothing, "0.########") - txtPerDoorOpeningNI.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "PerDoorOpeningNI") - txtPerStopBrakeActuationNIperKG.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "PerStopBrakeActuationNIperKG") - txtAirControlledSuspensionNIperMinute.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "AirControlledSuspensionNIperMinute") - txtNonSmartRegenFractionTotalAirDemand.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "NonSmartRegenFractionTotalAirDemand") - txtSmartRegenFractionTotalAirDemand.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "SmartRegenFractionTotalAirDemand") - txtDeadVolumeLitres.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "DeadVolumeLitres") - txtDeadVolBlowOutsPerLitresperHour.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "DeadVolBlowOutsPerLitresperHour") - - 'Pneumatic UserInputsConfig Binding - txtCompressorMap.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "CompressorMap") - txtCompressorGearEfficiency.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "CompressorGearEfficiency") - txtCompressorGearRatio.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "CompressorGearRatio") - txtActuationsMap.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "ActuationsMap") - chkSmartAirCompression.DataBindings.Add("Checked", auxConfig.PneumaticUserInputsConfig, "SmartAirCompression", False, DataSourceUpdateMode.OnPropertyChanged) - - chkSmartRegeneration.DataBindings.Add("Checked", auxConfig.PneumaticUserInputsConfig, "SmartRegeneration", False, DataSourceUpdateMode.OnPropertyChanged) - chkRetarderBrake.DataBindings.Add("Checked", auxConfig.PneumaticUserInputsConfig, "RetarderBrake") - txtKneelingHeightMillimeters.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "KneelingHeightMillimeters") - cboAirSuspensionControl.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "AirSuspensionControl", False) - cboAdBlueDosing.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "AdBlueDosing") - cboDoors.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "Doors") - - txtSSMFilePath.DataBindings.Add("Text", auxConfig.HvacUserInputsConfig, "SSMFilePath") - txtBusDatabaseFilePath.DataBindings.Add("Text", auxConfig.HvacUserInputsConfig, "BusDatabasePath") - chkDisableHVAC.DataBindings.Add("Checked", auxConfig.HvacUserInputsConfig, "SSMDisabled", False, DataSourceUpdateMode.OnPropertyChanged) - - SetSmartCardEmabledStatus() - - End Sub - - Private Sub EnsureBinding() - With tabMain - Dim lastSelectedTabIndex As Integer = .SelectedIndex - If lastSelectedTabIndex < 0 OrElse lastSelectedTabIndex > .TabCount Then lastSelectedTabIndex = 0 - For currentTab As Integer = 0 To .TabCount - 1 - .SelectedIndex = currentTab - Next - .SelectedIndex = 0 - End With - - SetSmartCardEmabledStatus() - - End Sub + Private Sub CreateBindings() + + 'auxConfig.Vecto Bindings + txtPowernetVoltage.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "PowerNetVoltage") + 'txtVehicleWeightKG.DataBindings.Add("Text", auxConfig.VectoInputs, "VehicleWeightKG") + 'cboCycle.DataBindings.Add("Text", auxConfig.VectoInputs, "Cycle") + txtFuelMap.DataBindings.Add("Text", auxConfig.VectoInputs, "FuelMap") + + 'Electricals General + txtAlternatorMapPath.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "AlternatorMap") + txtAlternatorGearEfficiency.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "AlternatorGearEfficiency") + txtDoorActuationTimeSeconds.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "DoorActuationTimeSecond") + txtStoredEnergyEfficiency.DataBindings.Add("Text", auxConfig.ElectricalUserInputsConfig, "StoredEnergyEfficiency") + chkSmartElectricals.DataBindings.Add("Checked", auxConfig.ElectricalUserInputsConfig, "SmartElectrical", False, + DataSourceUpdateMode.OnPropertyChanged) + + + 'Electrical ConsumablesGrid + electricalConsumerBinding = + New BindingList(Of IElectricalConsumer)(auxConfig.ElectricalUserInputsConfig.ElectricalConsumers.Items) + gvElectricalConsumables.DataSource = electricalConsumerBinding + + + 'ResultCards + + 'IDLE + Dim idleBinding As BindingList(Of SmartResult) + idleBinding = New BindingList(Of SmartResult)(auxConfig.ElectricalUserInputsConfig.ResultCardIdle.Results) + idleBinding.AllowNew = True + idleBinding.AllowRemove = True + gvResultsCardIdle.DataSource = idleBinding + + 'TRACTION + Dim tractionBinding As BindingList(Of SmartResult) + tractionBinding = New BindingList(Of SmartResult)(auxConfig.ElectricalUserInputsConfig.ResultCardTraction.Results) + tractionBinding.AllowNew = True + tractionBinding.AllowRemove = True + gvResultsCardTraction.DataSource = tractionBinding + + 'OVERRUN + Dim overrunBinding As BindingList(Of SmartResult) + overrunBinding = New BindingList(Of SmartResult)(auxConfig.ElectricalUserInputsConfig.ResultCardOverrun.Results) + overrunBinding.AllowNew = True + overrunBinding.AllowRemove = True + gvResultsCardOverrun.DataSource = overrunBinding + + + 'Pneumatic Auxillaries Binding + txtAdBlueNIperMinute.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "AdBlueNIperMinute") + + txtOverrunUtilisationForCompressionFraction.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, + "OverrunUtilisationForCompressionFraction") + txtBrakingWithRetarderNIperKG.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, + "BrakingWithRetarderNIperKG") + txtBrakingNoRetarderNIperKG.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "BrakingNoRetarderNIperKG") + txtBreakingPerKneelingNIperKGinMM.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, + "BreakingPerKneelingNIperKGinMM", True, DataSourceUpdateMode.OnPropertyChanged, Nothing, "0.########") + txtPerDoorOpeningNI.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "PerDoorOpeningNI") + txtPerStopBrakeActuationNIperKG.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, + "PerStopBrakeActuationNIperKG") + txtAirControlledSuspensionNIperMinute.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, + "AirControlledSuspensionNIperMinute") + txtNonSmartRegenFractionTotalAirDemand.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, + "NonSmartRegenFractionTotalAirDemand") + txtSmartRegenFractionTotalAirDemand.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, + "SmartRegenFractionTotalAirDemand") + txtDeadVolumeLitres.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, "DeadVolumeLitres") + txtDeadVolBlowOutsPerLitresperHour.DataBindings.Add("Text", auxConfig.PneumaticAuxillariesConfig, + "DeadVolBlowOutsPerLitresperHour") + + 'Pneumatic UserInputsConfig Binding + txtCompressorMap.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "CompressorMap") + txtCompressorGearEfficiency.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "CompressorGearEfficiency") + txtCompressorGearRatio.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "CompressorGearRatio") + txtActuationsMap.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "ActuationsMap") + chkSmartAirCompression.DataBindings.Add("Checked", auxConfig.PneumaticUserInputsConfig, "SmartAirCompression", False, + DataSourceUpdateMode.OnPropertyChanged) + + chkSmartRegeneration.DataBindings.Add("Checked", auxConfig.PneumaticUserInputsConfig, "SmartRegeneration", False, + DataSourceUpdateMode.OnPropertyChanged) + chkRetarderBrake.DataBindings.Add("Checked", auxConfig.PneumaticUserInputsConfig, "RetarderBrake") + txtKneelingHeightMillimeters.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "KneelingHeightMillimeters") + cboAirSuspensionControl.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "AirSuspensionControl", False) + cboAdBlueDosing.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "AdBlueDosing") + cboDoors.DataBindings.Add("Text", auxConfig.PneumaticUserInputsConfig, "Doors") + + txtSSMFilePath.DataBindings.Add("Text", auxConfig.HvacUserInputsConfig, "SSMFilePath") + txtBusDatabaseFilePath.DataBindings.Add("Text", auxConfig.HvacUserInputsConfig, "BusDatabasePath") + chkDisableHVAC.DataBindings.Add("Checked", auxConfig.HvacUserInputsConfig, "SSMDisabled", False, + DataSourceUpdateMode.OnPropertyChanged) + + SetSmartCardEmabledStatus() + End Sub + + Private Sub EnsureBinding() + With tabMain + Dim lastSelectedTabIndex As Integer = .SelectedIndex + If lastSelectedTabIndex < 0 OrElse lastSelectedTabIndex > .TabCount Then lastSelectedTabIndex = 0 + For currentTab As Integer = 0 To .TabCount - 1 + .SelectedIndex = currentTab + Next + .SelectedIndex = 0 + End With + + SetSmartCardEmabledStatus() + End Sub #End Region - Protected Sub SetSmartCardEmabledStatus() - - If chkSmartElectricals.Checked Then - - gvResultsCardIdle.Enabled = True - gvResultsCardTraction.Enabled = True - gvResultsCardOverrun.Enabled = True - - gvResultsCardIdle.BackgroundColor = Color.Gray - gvResultsCardTraction.BackgroundColor = Color.Gray - gvResultsCardOverrun.BackgroundColor = Color.Gray - - electricalConsumerBinding.Single(Function(c) c.Category = "Veh Electronics &Engine").NumberInActualVehicle = 0 - Else - - gvResultsCardIdle.Enabled = False - gvResultsCardTraction.Enabled = False - gvResultsCardOverrun.Enabled = False + Protected Sub SetSmartCardEmabledStatus() + If chkSmartElectricals.Checked Then - gvResultsCardIdle.BackgroundColor = Color.White - gvResultsCardTraction.BackgroundColor = Color.White - gvResultsCardOverrun.BackgroundColor = Color.White + gvResultsCardIdle.Enabled = True + gvResultsCardTraction.Enabled = True + gvResultsCardOverrun.Enabled = True - electricalConsumerBinding.Single(Function(c) c.Category = "Veh Electronics &Engine").NumberInActualVehicle = 1 - End If + gvResultsCardIdle.BackgroundColor = Color.Gray + gvResultsCardTraction.BackgroundColor = Color.Gray + gvResultsCardOverrun.BackgroundColor = Color.Gray + electricalConsumerBinding.Single(Function(c) c.Category = "Veh Electronics &Engine").NumberInActualVehicle = 0 + Else + gvResultsCardIdle.Enabled = False + gvResultsCardTraction.Enabled = False + gvResultsCardOverrun.Enabled = False - End Sub - Public Function FileOpenAlt(ByVal file As String) As Boolean - Dim PSI As New ProcessStartInfo - If Not IO.File.Exists(file) Then Return False + gvResultsCardIdle.BackgroundColor = Color.White + gvResultsCardTraction.BackgroundColor = Color.White + gvResultsCardOverrun.BackgroundColor = Color.White - PSI.FileName = "notepad.exe" - PSI.Arguments = ChrW(34) & file & ChrW(34) - Try - Process.Start(PSI) - Return True - Catch ex As Exception - Return False - End Try + electricalConsumerBinding.Single(Function(c) c.Category = "Veh Electronics &Engine").NumberInActualVehicle = 1 + End If + End Sub - End Function + Public Function FileOpenAlt(ByVal file As String) As Boolean + Dim PSI As New ProcessStartInfo - Private Sub chkDisableHVAC_CheckedChanged(sender As Object, e As EventArgs) Handles chkDisableHVAC.CheckedChanged + If Not IO.File.Exists(file) Then Return False - If chkDisableHVAC.Checked Then + PSI.FileName = "notepad.exe" + PSI.Arguments = ChrW(34) & file & ChrW(34) + Try + Process.Start(PSI) + Return True + Catch ex As Exception + Return False + End Try + End Function - txtSSMFilePath.ReadOnly = True - txtBusDatabaseFilePath.ReadOnly = True - btnSSMBSource.Enabled = False - btnBusDatabaseSource.Enabled = False - btnOpenAHSM.Enabled = False - btnOpenABDB.Enabled = False + Private Sub chkDisableHVAC_CheckedChanged(sender As Object, e As EventArgs) Handles chkDisableHVAC.CheckedChanged - Else + If chkDisableHVAC.Checked Then - txtSSMFilePath.ReadOnly = False - txtBusDatabaseFilePath.ReadOnly = False - btnSSMBSource.Enabled = True - btnBusDatabaseSource.Enabled = True - btnOpenAHSM.Enabled = True - btnOpenABDB.Enabled = True + txtSSMFilePath.ReadOnly = True + txtBusDatabaseFilePath.ReadOnly = True + btnSSMBSource.Enabled = False + btnBusDatabaseSource.Enabled = False + btnOpenAHSM.Enabled = False + btnOpenABDB.Enabled = False - End If + Else + txtSSMFilePath.ReadOnly = False + txtBusDatabaseFilePath.ReadOnly = False + btnSSMBSource.Enabled = True + btnBusDatabaseSource.Enabled = True + btnOpenAHSM.Enabled = True + btnOpenABDB.Enabled = True - End Sub + End If + End Sub - Protected Overrides Sub Finalize() - MyBase.Finalize() - End Sub + Protected Overrides Sub Finalize() + MyBase.Finalize() + End Sub End Class \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.vb b/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.vb index 35616ea45f25bae500c0c0c436a50d7d403f73bf..8b14f2d0f64343a5684c01ce4ee87b46d8ebeeba 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmCombinedAlternators.vb @@ -7,641 +7,636 @@ Imports System.ComponentModel Imports VectoAuxiliaries.Hvac - Public Class frmCombinedAlternators + Private combinedAlt As CombinedAlternator + Private originalAlt As CombinedAlternator + Private altSignals As ICombinedAlternatorSignals + Protected gbColor As System.Drawing.Color = Color.LightGreen + Private UserHitCancel As Boolean = False + Private UserHitSave As Boolean = False + Private aaltPath As String = "" - Private combinedAlt As CombinedAlternator - Private originalAlt As CombinedAlternator - Private altSignals As ICombinedAlternatorSignals - Protected gbColor As System.Drawing.Color = Color.LightGreen - Private UserHitCancel As Boolean = False - Private UserHitSave As Boolean = False - Private aaltPath As String = "" - - 'Constructor(s) - Public Sub New(aaltPath As String, altSignals As ICombinedAlternatorSignals) - - ' This call is required by the designer. - InitializeComponent() - - ' Add any initialization after the InitializeComponent() call. - Me.aaltpath = aaltPath - - combinedAlt = New CombinedAlternator(aaltPath) - originalAlt = New CombinedAlternator(aaltPath) - - SetupControls() - BindGrid() - - - End Sub - - - 'General Helpders - Private Sub BindGrid() - - gvAlternators.DataSource = New BindingList(Of IAlternator)(combinedAlt.Alternators.OrderBy(Function(o) o.AlternatorName).ToList()) - - End Sub - Private Sub SetupControls() - - 'gvAlternators - gvAlternators.AutoGenerateColumns = False - - Dim cIndex As Integer - - 'Column - AlternatorName - cIndex = gvAlternators.Columns.Add("AlternatorName", "AlternatorName") - gvAlternators.Columns(cIndex).DataPropertyName = "AlternatorName" - gvAlternators.Columns(cIndex).Width = 250 - gvAlternators.Columns(cIndex).ReadOnly = True - gvAlternators.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvAlternators.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - - - 'Column - PulleyRatio - cIndex = gvAlternators.Columns.Add("PulleyRatio", "PulleyRatio") - gvAlternators.Columns(cIndex).DataPropertyName = "PulleyRatio" - gvAlternators.Columns(cIndex).Width = 70 - gvAlternators.Columns(cIndex).ReadOnly = True - gvAlternators.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvAlternators.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - - - Dim deleteColumn As New DeleteAlternatorColumn() - With deleteColumn - .HeaderText = "" - .ToolTipText = "Delete this row" - .Name = "Delete" - .Width = 25 - .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter - End With - - ' deleteColumn.CellTemplate.ToolTipText="Delete this alternator" - gvAlternators.Columns.Add(deleteColumn) - - - - End Sub - Public Sub UpdateButtonText() - - If txtIndex.Text = String.Empty Then - btnUpdate.Text = "Add" - Else - btnUpdate.Text = "Update" - End If - - End Sub - Private Sub CreateDiagnostics() - - txtDiagnostics.Text = combinedAlt.ToString() - - End Sub + 'Constructor(s) + Public Sub New(aaltPath As String, altSignals As ICombinedAlternatorSignals) + ' This call is required by the designer. + InitializeComponent() - 'Validation Helpers - Private Sub IsTextBoxNumber(control As TextBox, errorProviderMessage As String, ByRef result As Boolean) + ' Add any initialization after the InitializeComponent() call. + Me.aaltpath = aaltPath - If Not IsNumeric(control.Text) Then - ErrorProvider1.SetError(control, errorProviderMessage) - result = False - Else - ErrorProvider1.SetError(control, String.Empty) + combinedAlt = New CombinedAlternator(aaltPath) + originalAlt = New CombinedAlternator(aaltPath) - End If + SetupControls() + BindGrid() + End Sub - End Sub - Private Sub IsEmptyString(text As String, control As Control, errorProviderMessage As String, ByRef result As Boolean) - If String.IsNullOrEmpty(text) Then - ErrorProvider1.SetError(control, errorProviderMessage) - result = False - Else - ErrorProvider1.SetError(control, String.Empty) + 'General Helpders + Private Sub BindGrid() - End If + gvAlternators.DataSource = + New BindingList(Of IAlternator)(combinedAlt.Alternators.OrderBy(Function(o) o.AlternatorName).ToList()) + End Sub - End Sub - Private Function IsPostiveInteger(ByVal test As String) As Boolean + Private Sub SetupControls() - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + 'gvAlternators + gvAlternators.AutoGenerateColumns = False - Dim number As Integer + Dim cIndex As Integer - If Not Integer.TryParse(test, number) Then Return False + 'Column - AlternatorName + cIndex = gvAlternators.Columns.Add("AlternatorName", "AlternatorName") + gvAlternators.Columns(cIndex).DataPropertyName = "AlternatorName" + gvAlternators.Columns(cIndex).Width = 250 + gvAlternators.Columns(cIndex).ReadOnly = True + gvAlternators.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvAlternators.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - If number <= 0 Then Return False + 'Column - PulleyRatio + cIndex = gvAlternators.Columns.Add("PulleyRatio", "PulleyRatio") + gvAlternators.Columns(cIndex).DataPropertyName = "PulleyRatio" + gvAlternators.Columns(cIndex).Width = 70 + gvAlternators.Columns(cIndex).ReadOnly = True + gvAlternators.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvAlternators.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - Return True - End Function - Private Function IsPostiveNumber(ByVal test As String) As Boolean + Dim deleteColumn As New DeleteAlternatorColumn() + With deleteColumn + .HeaderText = "" + .ToolTipText = "Delete this row" + .Name = "Delete" + .Width = 25 + .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter + End With - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + ' deleteColumn.CellTemplate.ToolTipText="Delete this alternator" + gvAlternators.Columns.Add(deleteColumn) + End Sub - Dim number As Double + Public Sub UpdateButtonText() - If Not Double.TryParse(test, number) Then Return False + If txtIndex.Text = String.Empty Then + btnUpdate.Text = "Add" + Else + btnUpdate.Text = "Update" + End If + End Sub - If number <= 0 Then Return False + Private Sub CreateDiagnostics() + txtDiagnostics.Text = combinedAlt.ToString() + End Sub - Return True - End Function - Private Function IsZeroOrPostiveNumber(ByVal test As String) As Boolean + 'Validation Helpers + Private Sub IsTextBoxNumber(control As TextBox, errorProviderMessage As String, ByRef result As Boolean) - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + If Not IsNumeric(control.Text) Then + ErrorProvider1.SetError(control, errorProviderMessage) + result = False + Else + ErrorProvider1.SetError(control, String.Empty) - Dim number As Double + End If + End Sub - If Not Double.TryParse(test, number) Then Return False + Private Sub IsEmptyString(text As String, control As Control, errorProviderMessage As String, ByRef result As Boolean) - If number < 0 Then Return False + If String.IsNullOrEmpty(text) Then + ErrorProvider1.SetError(control, errorProviderMessage) + result = False + Else + ErrorProvider1.SetError(control, String.Empty) + End If + End Sub - Return True + Private Function IsPostiveInteger(ByVal test As String) As Boolean - End Function - Private Function IsNumberBetweenZeroandOne(test As String) As Boolean + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + Dim number As Integer - Dim number As Double + If Not Integer.TryParse(test, number) Then Return False - If Not Double.TryParse(test, number) Then Return False + If number <= 0 Then Return False - If number < 0 OrElse number > 1 Then Return False - Return True + Return True + End Function - End Function - Private Function IsNumberBetweenOverZeroAndLessThan100(txtBox As TextBox) As Boolean + Private Function IsPostiveNumber(ByVal test As String) As Boolean - 'Is this numeric sanity check. - If Not IsNumeric(txtBox.Text) Then - ErrorProvider1.SetError(txtBox, "Please enter a number") - Return False - Else - ErrorProvider1.SetError(txtBox, "") - End If + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False + Dim number As Double + If Not Double.TryParse(test, number) Then Return False + If number <= 0 Then Return False - Dim number As Double = 0 - If Not Double.TryParse(txtBox.Text, number) Then - ErrorProvider1.SetError(txtBox, "Please enter a number >0 and <100") - Return False + Return True + End Function - Else - ErrorProvider1.SetError(txtBox, String.Empty) - End If + Private Function IsZeroOrPostiveNumber(ByVal test As String) As Boolean - If number <= 0 OrElse number >= 100 Then + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - ErrorProvider1.SetError(txtBox, "Please enter a number >0 and <100") - Return False - Else - ErrorProvider1.SetError(txtBox, String.Empty) - Return True + Dim number As Double - End If + If Not Double.TryParse(test, number) Then Return False + If number < 0 Then Return False - Return True - End Function - Private Function IsNumberGreaterThan10(txtBox As TextBox) As Boolean + Return True + End Function - 'Is this numeric sanity check. - If Not IsNumeric(txtBox.Text) Then - ErrorProvider1.SetError(txtBox, "Please enter a number") - Return False - Else - ErrorProvider1.SetError(txtBox, "") - End If + Private Function IsNumberBetweenZeroandOne(test As String) As Boolean - Dim number As Double = 0 + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - If Not Double.TryParse(txtBox.Text, number) Then - ErrorProvider1.SetError(txtBox, "Please enter a number >10") - Return False + Dim number As Double - Else - ErrorProvider1.SetError(txtBox, String.Empty) - End If + If Not Double.TryParse(test, number) Then Return False - If number <= 10 Then + If number < 0 OrElse number > 1 Then Return False - ErrorProvider1.SetError(txtBox, "Please enter a number > 10") - Return False - Else - ErrorProvider1.SetError(txtBox, String.Empty) - Return True - End If + Return True + End Function + Private Function IsNumberBetweenOverZeroAndLessThan100(txtBox As TextBox) As Boolean - Return True + 'Is this numeric sanity check. + If Not IsNumeric(txtBox.Text) Then + ErrorProvider1.SetError(txtBox, "Please enter a number") + Return False + Else + ErrorProvider1.SetError(txtBox, "") + End If - End Function - Private Function IsIntegerZeroOrPositiveNumber(test As String) As Boolean - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + Dim number As Double = 0 - 'if not integer then return false + If Not Double.TryParse(txtBox.Text, number) Then + ErrorProvider1.SetError(txtBox, "Please enter a number >0 and <100") + Return False - Dim number As Integer + Else + ErrorProvider1.SetError(txtBox, String.Empty) + End If - If Not Integer.TryParse(test, number) Then Return False + If number <= 0 OrElse number >= 100 Then - If number < 0 Then Return False + ErrorProvider1.SetError(txtBox, "Please enter a number >0 and <100") + Return False + Else + ErrorProvider1.SetError(txtBox, String.Empty) + Return True - Return True + End If - End Function + Return True + End Function - 'Other events - Private Sub groupBoxUserInput_Paint(sender As Object, e As Windows.Forms.PaintEventArgs) Handles grpTable2000PRM.Paint, grpTable6000PRM.Paint, grpTable4000PRM.Paint + Private Function IsNumberGreaterThan10(txtBox As TextBox) As Boolean + 'Is this numeric sanity check. + If Not IsNumeric(txtBox.Text) Then + ErrorProvider1.SetError(txtBox, "Please enter a number") + Return False + Else + ErrorProvider1.SetError(txtBox, "") + End If - Dim p As Pen = Nothing + Dim number As Double = 0 - Dim sdr As Control = DirectCast(sender, Control) + If Not Double.TryParse(txtBox.Text, number) Then + ErrorProvider1.SetError(txtBox, "Please enter a number >10") + Return False - Select Case sdr.Name + Else + ErrorProvider1.SetError(txtBox, String.Empty) + End If - Case "grpTable2000PRM" - p = New Pen(Color.LightGreen, 3) - Case "grpTable4000PRM" - p = New Pen(Color.Yellow, 3) - Case "grpTable6000PRM" - p = New Pen(Color.LightPink, 3) - Case Else - p = New Pen(Color.Black, 3) + If number <= 10 Then - End Select + ErrorProvider1.SetError(txtBox, "Please enter a number > 10") + Return False + Else + ErrorProvider1.SetError(txtBox, String.Empty) + Return True + End If - Dim gfx As Graphics = e.Graphics - gfx.DrawLine(p, 0, 5, 0, e.ClipRectangle.Height - 2) - gfx.DrawLine(p, 0, 5, 10, 5) - gfx.DrawLine(p, 85, 5, e.ClipRectangle.Width - 2, 5) - gfx.DrawLine(p, e.ClipRectangle.Width - 2, 5, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2) - gfx.DrawLine(p, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2, 0, e.ClipRectangle.Height - 2) + Return True + End Function - End Sub + Private Function IsIntegerZeroOrPositiveNumber(test As String) As Boolean + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - 'Grid Events - Private Sub gvAlternators_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles gvAlternators.CellClick + 'if not integer then return false - If e.ColumnIndex < 0 OrElse e.RowIndex < 0 Then Return + Dim number As Integer - If gvAlternators.Columns(e.ColumnIndex).Name = "Delete" Then + If Not Integer.TryParse(test, number) Then Return False + If number < 0 Then Return False - Dim feedback As String = String.Empty - Dim alternatorName As String = gvAlternators.Rows(e.RowIndex).Cells(0).Value.ToString() + Return True + End Function - Select Case gvAlternators.Columns(e.ColumnIndex).Name + 'Other events + Private Sub groupBoxUserInput_Paint(sender As Object, e As Windows.Forms.PaintEventArgs) _ + Handles grpTable2000PRM.Paint, grpTable6000PRM.Paint, grpTable4000PRM.Paint - Case "Delete" - Dim dr As DialogResult = MessageBox.Show(String.Format("Do you want to delete '{0}' ?", alternatorName), "", MessageBoxButtons.YesNo) - If dr = Windows.Forms.DialogResult.Yes Then - If combinedAlt.DeleteAlternator(alternatorName, feedback, True) Then - BindGrid() - Else - MessageBox.Show(feedback) - End If + Dim p As Pen = Nothing - End If + Dim sdr As Control = DirectCast(sender, Control) - End Select + Select Case sdr.Name - End If + Case "grpTable2000PRM" + p = New Pen(Color.LightGreen, 3) + Case "grpTable4000PRM" + p = New Pen(Color.Yellow, 3) + Case "grpTable6000PRM" + p = New Pen(Color.LightPink, 3) + Case Else + p = New Pen(Color.Black, 3) - End Sub - Private Sub gvAlternators_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles gvAlternators.CellDoubleClick + End Select - If gvAlternators.SelectedCells.Count < 1 Then Return + Dim gfx As Graphics = e.Graphics - Dim row As Integer = gvAlternators.SelectedCells(0).OwningRow.Index + gfx.DrawLine(p, 0, 5, 0, e.ClipRectangle.Height - 2) + gfx.DrawLine(p, 0, 5, 10, 5) + gfx.DrawLine(p, 85, 5, e.ClipRectangle.Width - 2, 5) + gfx.DrawLine(p, e.ClipRectangle.Width - 2, 5, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2) + gfx.DrawLine(p, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2, 0, e.ClipRectangle.Height - 2) + End Sub - Dim alternatorName As String - alternatorName = gvAlternators.Rows(row).Cells("AlternatorName").Value.ToString() + 'Grid Events + Private Sub gvAlternators_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles gvAlternators.CellClick - Dim alt As IAlternator = combinedAlt.Alternators.First(Function(w) w.AlternatorName = alternatorName) + If e.ColumnIndex < 0 OrElse e.RowIndex < 0 Then Return + If gvAlternators.Columns(e.ColumnIndex).Name = "Delete" Then - FillEditPanel(row) - UpdateButtonText() + Dim feedback As String = String.Empty + Dim alternatorName As String = gvAlternators.Rows(e.RowIndex).Cells(0).Value.ToString() + Select Case gvAlternators.Columns(e.ColumnIndex).Name - End Sub + Case "Delete" + Dim dr As DialogResult = MessageBox.Show(String.Format("Do you want to delete '{0}' ?", alternatorName), "", + MessageBoxButtons.YesNo) + If dr = Windows.Forms.DialogResult.Yes Then + If combinedAlt.DeleteAlternator(alternatorName, feedback, True) Then + BindGrid() + Else + MessageBox.Show(feedback) - 'Button Events - Private Sub btnClearForm_Click(sender As Object, e As EventArgs) Handles btnClearForm.Click + End If - ClearEditPanel() - UpdateButtonText() + End If - End Sub - Public Function GetAlternatorFromPanel() As List(Of ICombinedAlternatorMapRow) + End Select - Dim newAlt As New List(Of ICombinedAlternatorMapRow) + End If + End Sub - newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 2000, Convert.ToSingle(txt2K10Amps.Text), Convert.ToSingle(txt2K10Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) - newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 2000, Convert.ToSingle(txt2KMax2Amps.Text), Convert.ToSingle(txt2KMax2Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) - newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 2000, Convert.ToSingle(txt2KMaxAmps.Text), Convert.ToSingle(txt2KMaxEfficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) + Private Sub gvAlternators_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) _ + Handles gvAlternators.CellDoubleClick - newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 4000, Convert.ToSingle(txt4K10Amps.Text), Convert.ToSingle(txt4K10Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) - newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 4000, Convert.ToSingle(txt4KMax2Amps.Text), Convert.ToSingle(txt4KMax2Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) - newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 4000, Convert.ToSingle(txt4KMaxAmps.Text), Convert.ToSingle(txt4KMaxEfficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) + If gvAlternators.SelectedCells.Count < 1 Then Return - newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 6000, Convert.ToSingle(txt6K10Amps.Text), Convert.ToSingle(txt6K10Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) - newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 6000, Convert.ToSingle(txt6KMax2Amps.Text), Convert.ToSingle(txt6KMax2Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) - newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 6000, Convert.ToSingle(txt6KMaxAmps.Text), Convert.ToSingle(txt6KMaxEfficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) + Dim row As Integer = gvAlternators.SelectedCells(0).OwningRow.Index - Return newAlt + Dim alternatorName As String - End Function - Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click + alternatorName = gvAlternators.Rows(row).Cells("AlternatorName").Value.ToString() + Dim alt As IAlternator = combinedAlt.Alternators.First(Function(w) w.AlternatorName = alternatorName) - Dim feedback As String = String.Empty - If Not Validate_UpdatePanel() Then Return + FillEditPanel(row) - If txtIndex.Text.Trim.Length = 0 Then - 'This is an Add - If Not combinedAlt.AddAlternator(GetAlternatorFromPanel(), feedback) Then - MessageBox.Show(feedback) - Else + UpdateButtonText() + End Sub + 'Button Events + Private Sub btnClearForm_Click(sender As Object, e As EventArgs) Handles btnClearForm.Click - BindGrid() + ClearEditPanel() + UpdateButtonText() + End Sub - UpdateButtonText() + Public Function GetAlternatorFromPanel() As List(Of ICombinedAlternatorMapRow) - End If + Dim newAlt As New List(Of ICombinedAlternatorMapRow) - Else + newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 2000, Convert.ToSingle(txt2K10Amps.Text), + Convert.ToSingle(txt2K10Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) + newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 2000, Convert.ToSingle(txt2KMax2Amps.Text), + Convert.ToSingle(txt2KMax2Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) + newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 2000, Convert.ToSingle(txt2KMaxAmps.Text), + Convert.ToSingle(txt2KMaxEfficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) - 'Get Existing row name. - Dim altName As String = gvAlternators.Rows(Convert.ToInt32(txtIndex.Text)).Cells("AlternatorName").Value.ToString() + newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 4000, Convert.ToSingle(txt4K10Amps.Text), + Convert.ToSingle(txt4K10Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) + newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 4000, Convert.ToSingle(txt4KMax2Amps.Text), + Convert.ToSingle(txt4KMax2Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) + newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 4000, Convert.ToSingle(txt4KMaxAmps.Text), + Convert.ToSingle(txt4KMaxEfficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) - 'Does name used in update exist in other alternators excluding the original being edited ?, if so abort. - If combinedAlt.Alternators.Where(Function(f) f.AlternatorName <> altName AndAlso f.AlternatorName = txtAlternatorName.Text).Count > 0 Then - MessageBox.Show(String.Format("The lternator '{0}' name you are using to update the alternator '{1}' already exists, operation aborted", txtAlternatorName.Text, altName)) - Return - End If + newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 6000, Convert.ToSingle(txt6K10Amps.Text), + Convert.ToSingle(txt6K10Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) + newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 6000, Convert.ToSingle(txt6KMax2Amps.Text), + Convert.ToSingle(txt6KMax2Efficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) + newAlt.Add(New CombinedAlternatorMapRow(txtAlternatorName.Text, 6000, Convert.ToSingle(txt6KMaxAmps.Text), + Convert.ToSingle(txt6KMaxEfficiency.Text), Convert.ToSingle(txtPulleyRatio.Text))) - 'This is an update so delete the one being updated + Return newAlt + End Function - If combinedAlt.DeleteAlternator(altName, feedback, False) AndAlso combinedAlt.AddAlternator(GetAlternatorFromPanel(), feedback) Then + Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click - BindGrid() - ClearEditPanel() - UpdateButtonText() - Else - MessageBox.Show(feedback) - End If + Dim feedback As String = String.Empty - End If + If Not Validate_UpdatePanel() Then Return + If txtIndex.Text.Trim.Length = 0 Then + 'This is an Add + If Not combinedAlt.AddAlternator(GetAlternatorFromPanel(), feedback) Then + MessageBox.Show(feedback) + Else - End Sub - Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click + BindGrid() - UserHitCancel = True - Me.close() + UpdateButtonText() - End Sub - Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click + End If - ' If Not ValidateAll then Return + Else - UserHitSave = True + 'Get Existing row name. + Dim altName As String = gvAlternators.Rows(Convert.ToInt32(txtIndex.Text)).Cells("AlternatorName").Value.ToString() - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() + 'Does name used in update exist in other alternators excluding the original being edited ?, if so abort. + If _ + combinedAlt.Alternators.Where( + Function(f) f.AlternatorName <> altName AndAlso f.AlternatorName = txtAlternatorName.Text).Count > 0 Then + MessageBox.Show( + String.Format( + "The lternator '{0}' name you are using to update the alternator '{1}' already exists, operation aborted", + txtAlternatorName.Text, altName)) + Return + End If + 'This is an update so delete the one being updated + If _ + combinedAlt.DeleteAlternator(altName, feedback, False) AndAlso + combinedAlt.AddAlternator(GetAlternatorFromPanel(), feedback) Then - End Sub + BindGrid() + ClearEditPanel() + UpdateButtonText() + Else + MessageBox.Show(feedback) + End If - 'Form / Tab Events - Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged + End If + End Sub - If TabControl1.SelectedIndex = 1 Then - CreateDiagnostics() - End If + Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click - End Sub - Private Sub frmCombinedAlternators_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing + UserHitCancel = True + Me.close() + End Sub + Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click - Dim result As DialogResult + ' If Not ValidateAll then Return - 'If UserHitCancel then bail - If UserHitCancel Then - DialogResult = Windows.Forms.DialogResult.Cancel - UserHitCancel = False - Return - End If + UserHitSave = True - 'UserHitSave - If UserHitSave Then - DialogResult = Windows.Forms.DialogResult.Cancel - If Not combinedAlt.Save(aaltPath) Then - MessageBox.Show("Unable to save file, aborting.") - e.Cancel = True - End If - UserHitSave = False - DialogResult = Windows.Forms.DialogResult.OK - Return - End If + Me.DialogResult = Windows.Forms.DialogResult.OK + Me.Close() + End Sub - ''This must be a close box event. If nothing changed, then bail, otherwise ask user if they wanna save - If Not combinedAlt.IsEqualTo(originalAlt) Then + 'Form / Tab Events + Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged - result = (MessageBox.Show("Would you like to save changes before closing?", "Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) + If TabControl1.SelectedIndex = 1 Then + CreateDiagnostics() + End If + End Sub + Private Sub frmCombinedAlternators_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing - Select Case result - Case DialogResult.Yes - 'save + Dim result As DialogResult - If Not combinedAlt.Save(aaltPath) Then - e.Cancel = True - End If + 'If UserHitCancel then bail + If UserHitCancel Then + DialogResult = Windows.Forms.DialogResult.Cancel + UserHitCancel = False + Return + End If - Case DialogResult.No - 'just allow the form to close - 'without saving - Me.DialogResult = Windows.Forms.DialogResult.Cancel + 'UserHitSave + If UserHitSave Then + DialogResult = Windows.Forms.DialogResult.Cancel + If Not combinedAlt.Save(aaltPath) Then + MessageBox.Show("Unable to save file, aborting.") + e.Cancel = True + End If + UserHitSave = False + DialogResult = Windows.Forms.DialogResult.OK + Return + End If - Case DialogResult.Cancel - 'cancel the close - e.Cancel = True - Me.DialogResult = Windows.Forms.DialogResult.Cancel - End Select + ''This must be a close box event. If nothing changed, then bail, otherwise ask user if they wanna save + If Not combinedAlt.IsEqualTo(originalAlt) Then - End If + result = + (MessageBox.Show("Would you like to save changes before closing?", "Save Changes", MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Question)) - UserHitCancel = False - UserHitSave = False + Select Case result + Case DialogResult.Yes + 'save - End Sub + If Not combinedAlt.Save(aaltPath) Then + e.Cancel = True + End If + Case DialogResult.No + 'just allow the form to close + 'without saving + Me.DialogResult = Windows.Forms.DialogResult.Cancel - 'List Management - Private Sub ClearEditPanel() + Case DialogResult.Cancel + 'cancel the close + e.Cancel = True + Me.DialogResult = Windows.Forms.DialogResult.Cancel - txtIndex.Text = String.Empty - txtAlternatorName.Text = String.Empty - txt2K10Efficiency.Text = String.Empty - txt2KMax2Efficiency.Text = String.Empty - txt2KMaxEfficiency.Text = String.Empty + End Select - txt4K10Efficiency.Text = String.Empty - txt4KMax2Efficiency.Text = String.Empty - txt4KMaxEfficiency.Text = String.Empty + End If - txt6K10Efficiency.Text = String.Empty - txt6KMax2Efficiency.Text = String.Empty - txt6KMaxEfficiency.Text = String.Empty + UserHitCancel = False + UserHitSave = False + End Sub - txt2KMax2Amps.Text = String.Empty - txt2KMaxAmps.Text = String.Empty - txt4KMax2Amps.Text = String.Empty - txt4KMaxAmps.Text = String.Empty + 'List Management + Private Sub ClearEditPanel() - txt6KMax2Amps.Text = String.Empty - txt6KMaxAmps.Text = String.Empty + txtIndex.Text = String.Empty + txtAlternatorName.Text = String.Empty + txt2K10Efficiency.Text = String.Empty + txt2KMax2Efficiency.Text = String.Empty + txt2KMaxEfficiency.Text = String.Empty - txtPulleyRatio.Text = String.Empty + txt4K10Efficiency.Text = String.Empty + txt4KMax2Efficiency.Text = String.Empty + txt4KMaxEfficiency.Text = String.Empty - ErrorProvider1.SetError(txtAlternatorName, String.empty) - ErrorProvider1.SetError(txt2K10Efficiency, String.empty) - ErrorProvider1.SetError(txt2KMax2Efficiency, String.empty) - ErrorProvider1.SetError(txt2KMaxEfficiency, String.empty) - ErrorProvider1.SetError(txt4K10Efficiency, String.empty) - ErrorProvider1.SetError(txt4KMax2Efficiency, String.empty) - ErrorProvider1.SetError(txt4KMaxEfficiency, String.empty) - ErrorProvider1.SetError(txt6K10Efficiency, String.empty) - ErrorProvider1.SetError(txt6KMax2Efficiency, String.empty) - ErrorProvider1.SetError(txt6KMaxEfficiency, String.empty) + txt6K10Efficiency.Text = String.Empty + txt6KMax2Efficiency.Text = String.Empty + txt6KMaxEfficiency.Text = String.Empty - ErrorProvider1.SetError(txtPulleyRatio, String.empty) + txt2KMax2Amps.Text = String.Empty + txt2KMaxAmps.Text = String.Empty + txt4KMax2Amps.Text = String.Empty + txt4KMaxAmps.Text = String.Empty - End Sub - Public Function Validate_UpdatePanel() As Boolean + txt6KMax2Amps.Text = String.Empty + txt6KMaxAmps.Text = String.Empty - Dim returnResult As Boolean = True + txtPulleyRatio.Text = String.Empty - IsEmptyString(txtAlternatorName.Text, txtAlternatorName, "Please enter a name for the alternator, names must be unique", returnResult) + ErrorProvider1.SetError(txtAlternatorName, String.empty) + ErrorProvider1.SetError(txt2K10Efficiency, String.empty) + ErrorProvider1.SetError(txt2KMax2Efficiency, String.empty) + ErrorProvider1.SetError(txt2KMaxEfficiency, String.empty) + ErrorProvider1.SetError(txt4K10Efficiency, String.empty) + ErrorProvider1.SetError(txt4KMax2Efficiency, String.empty) + ErrorProvider1.SetError(txt4KMaxEfficiency, String.empty) + ErrorProvider1.SetError(txt6K10Efficiency, String.empty) + ErrorProvider1.SetError(txt6KMax2Efficiency, String.empty) + ErrorProvider1.SetError(txt6KMaxEfficiency, String.empty) - If Not IsNumberBetweenOverZeroAndLessThan100(txt2K10Efficiency) Then returnResult = False - If Not IsNumberBetweenOverZeroAndLessThan100(txt2KMax2Efficiency) Then returnResult = False - If Not IsNumberBetweenOverZeroAndLessThan100(txt2KMaxEfficiency) Then returnResult = False + ErrorProvider1.SetError(txtPulleyRatio, String.empty) + End Sub - If Not IsNumberBetweenOverZeroAndLessThan100(txt4K10Efficiency) Then returnResult = False - If Not IsNumberBetweenOverZeroAndLessThan100(txt4KMax2Efficiency) Then returnResult = False - If Not IsNumberBetweenOverZeroAndLessThan100(txt4KMaxEfficiency) Then returnResult = False + Public Function Validate_UpdatePanel() As Boolean - If Not IsNumberBetweenOverZeroAndLessThan100(txt6K10Efficiency) Then returnResult = False - If Not IsNumberBetweenOverZeroAndLessThan100(txt6KMax2Efficiency) Then returnResult = False - If Not IsNumberBetweenOverZeroAndLessThan100(txt6KMaxEfficiency) Then returnResult = False + Dim returnResult As Boolean = True - If Not IsNumberGreaterThan10(txt2KMax2Amps) Then returnResult = False - If Not IsNumberGreaterThan10(txt2KMaxAmps) Then returnResult = False + IsEmptyString(txtAlternatorName.Text, txtAlternatorName, + "Please enter a name for the alternator, names must be unique", returnResult) - If Not IsNumberGreaterThan10(txt4KMax2Amps) Then returnResult = False - If Not IsNumberGreaterThan10(txt4KMaxAmps) Then returnResult = False + If Not IsNumberBetweenOverZeroAndLessThan100(txt2K10Efficiency) Then returnResult = False + If Not IsNumberBetweenOverZeroAndLessThan100(txt2KMax2Efficiency) Then returnResult = False + If Not IsNumberBetweenOverZeroAndLessThan100(txt2KMaxEfficiency) Then returnResult = False - If Not IsNumberGreaterThan10(txt6KMax2Amps) Then returnResult = False - If Not IsNumberGreaterThan10(txt6KMaxAmps) Then returnResult = False + If Not IsNumberBetweenOverZeroAndLessThan100(txt4K10Efficiency) Then returnResult = False + If Not IsNumberBetweenOverZeroAndLessThan100(txt4KMax2Efficiency) Then returnResult = False + If Not IsNumberBetweenOverZeroAndLessThan100(txt4KMaxEfficiency) Then returnResult = False - If Not IsPostiveNumber(txtPulleyRatio.text) Then - ErrorProvider1.SetError(txtPulleyRatio, "Please enter a sensible positive number") - returnResult = False - Else - ErrorProvider1.SetError(txtPulleyRatio, String.Empty) - End If + If Not IsNumberBetweenOverZeroAndLessThan100(txt6K10Efficiency) Then returnResult = False + If Not IsNumberBetweenOverZeroAndLessThan100(txt6KMax2Efficiency) Then returnResult = False + If Not IsNumberBetweenOverZeroAndLessThan100(txt6KMaxEfficiency) Then returnResult = False - Return returnResult + If Not IsNumberGreaterThan10(txt2KMax2Amps) Then returnResult = False + If Not IsNumberGreaterThan10(txt2KMaxAmps) Then returnResult = False - End Function - Private Sub FillEditPanel(index As Integer) + If Not IsNumberGreaterThan10(txt4KMax2Amps) Then returnResult = False + If Not IsNumberGreaterThan10(txt4KMaxAmps) Then returnResult = False - Dim alt As IAlternator - Dim alternatorName As String = gvAlternators.Rows(index).Cells("AlternatorName").Value.ToString() + If Not IsNumberGreaterThan10(txt6KMax2Amps) Then returnResult = False + If Not IsNumberGreaterThan10(txt6KMaxAmps) Then returnResult = False - alt = combinedAlt.Alternators.First(Function(f) f.AlternatorName = alternatorName) + If Not IsPostiveNumber(txtPulleyRatio.text) Then + ErrorProvider1.SetError(txtPulleyRatio, "Please enter a sensible positive number") + returnResult = False + Else + ErrorProvider1.SetError(txtPulleyRatio, String.Empty) + End If - txtIndex.Text = index.ToString() - txtAlternatorName.Text = alt.AlternatorName + Return returnResult + End Function - 'Table1 - 2K Table - txt2K10Amps.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(1).First().Amps.ToString() - txt2K10Efficiency.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(1).First().Eff.ToString() + Private Sub FillEditPanel(index As Integer) - txt2KMax2Amps.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(2).First().Amps.ToString() - txt2KMax2Efficiency.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(2).First().Eff.ToString() + Dim alt As IAlternator + Dim alternatorName As String = gvAlternators.Rows(index).Cells("AlternatorName").Value.ToString() - txt2KMaxAmps.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(3).First().Amps.ToString() - txt2KMaxEfficiency.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(3).First().Eff.ToString() + alt = combinedAlt.Alternators.First(Function(f) f.AlternatorName = alternatorName) - 'Table2 - 4K Table - txt4K10Amps.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(1).First().Amps.ToString() - txt4K10Efficiency.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(1).First().Eff.ToString() + txtIndex.Text = index.ToString() + txtAlternatorName.Text = alt.AlternatorName - txt4KMax2Amps.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(2).First().Amps.ToString() - txt4KMax2Efficiency.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(2).First().Eff.ToString() + 'Table1 - 2K Table + txt2K10Amps.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(1).First().Amps.ToString() + txt2K10Efficiency.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(1).First().Eff.ToString() - txt4KMaxAmps.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(3).First().Amps.ToString() - txt4KMaxEfficiency.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(3).First().Eff.ToString() + txt2KMax2Amps.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(2).First().Amps.ToString() + txt2KMax2Efficiency.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(2).First().Eff.ToString() - 'Table3 - 6K Table - txt6K10Amps.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(1).First().Amps.ToString() - txt6K10Efficiency.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(1).First().Eff.ToString() + txt2KMaxAmps.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(3).First().Amps.ToString() + txt2KMaxEfficiency.Text = alt.InputTable2000.OrderBy(Function(x) x.Amps).Skip(3).First().Eff.ToString() - txt6KMax2Amps.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(2).First().Amps.ToString() - txt6KMax2Efficiency.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(2).First().Eff.ToString() + 'Table2 - 4K Table + txt4K10Amps.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(1).First().Amps.ToString() + txt4K10Efficiency.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(1).First().Eff.ToString() - txt6KMaxAmps.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(3).First().Amps.ToString() - txt6KMaxEfficiency.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(3).First().Eff.ToString() - - txtPulleyRatio.Text = alt.PulleyRatio.ToString() + txt4KMax2Amps.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(2).First().Amps.ToString() + txt4KMax2Efficiency.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(2).First().Eff.ToString() + txt4KMaxAmps.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(3).First().Amps.ToString() + txt4KMaxEfficiency.Text = alt.InputTable4000.OrderBy(Function(x) x.Amps).Skip(3).First().Eff.ToString() - End Sub + 'Table3 - 6K Table + txt6K10Amps.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(1).First().Amps.ToString() + txt6K10Efficiency.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(1).First().Eff.ToString() + txt6KMax2Amps.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(2).First().Amps.ToString() + txt6KMax2Efficiency.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(2).First().Eff.ToString() + txt6KMaxAmps.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(3).First().Amps.ToString() + txt6KMaxEfficiency.Text = alt.InputTable6000.OrderBy(Function(x) x.Amps).Skip(3).First().Eff.ToString() + txtPulleyRatio.Text = alt.PulleyRatio.ToString() + End Sub End Class diff --git a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb index a7090020c88f376739ff5750d9a9925204126cfc..0d96c240f22b73072c6c0bfaba6cb0b8aeaa4a80 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb @@ -2,1389 +2,1410 @@ Imports VectoAuxiliaries.Hvac Imports System.ComponentModel Imports System.Drawing +Imports System.Globalization Public Class frmHVACTool + 'Fields + Private captureDiagnostics As Boolean + Private busDatabasePath As String + Private ahsmFilePath As String + Private buses As IBusDatabase + Private ssmTOOL As SSMTOOL + Private originalssmTOOL As SSMTOOL + Private TabColors As Dictionary(Of TabPage, Color) = New Dictionary(Of TabPage, Color)() + Private editTechLine As ITechListBenefitLine = New TechListBenefitLine(Nothing) + Private gvTechListBinding As BindingList(Of ITechListBenefitLine) + Private DefaultCategories As String() = {"Cooling", "Heating", "Insulation", "Ventiliation"} + Private vectoFile As String = String.Empty + Private UserHitCancel As Boolean = False + Private UserHitSave As Boolean = False + Private IsAddingBus As Boolean = False + Private IsUpdatingBus As Boolean = False + Private busesList As BindingList(Of IBus) - 'Fields - Private captureDiagnostics As Boolean - Private busDatabasePath As String - Private ahsmFilePath As String - Private buses As IBusDatabase - Private ssmTOOL As SSMTOOL - Private originalssmTOOL As SSMTOOL - Private TabColors As Dictionary(Of TabPage, Color) = New Dictionary(Of TabPage, Color)() - Private editTechLine As ITechListBenefitLine = New TechListBenefitLine(Nothing) - Private gvTechListBinding As BindingList(Of ITechListBenefitLine) - Private DefaultCategories As String() = {"Cooling", "Heating", "Insulation", "Ventiliation"} - Private vectoFile As String = String.Empty - Private UserHitCancel As Boolean = False - Private UserHitSave As Boolean = False - Private IsAddingBus As Boolean = False - Private IsUpdatingBus As Boolean = False - Private busesList As BindingList(Of IBus) + 'Helpers + Public Sub UpdateButtonText() - 'Helpers - Public Sub UpdateButtonText() + If txtIndex.Text = String.Empty Then + btnUpdate.Text = "Add" + Else + btnUpdate.Text = "Update" + End If + End Sub - If txtIndex.Text = String.Empty Then - btnUpdate.Text = "Add" - Else - btnUpdate.Text = "Update" - End If + Private Function ValidateSSMTOOLFileName(filename As String) As Boolean - End Sub - Private Function ValidateSSMTOOLFileName(filename As String) As Boolean + Dim message As String = String.Empty - Dim message As String = String.Empty + If Not FilePathUtils.ValidateFilePath(filename, ".ahsm", message) Then + MessageBox.Show(message) + End If - If Not FilePathUtils.ValidateFilePath(filename, ".ahsm", message) Then - MessageBox.Show(message) - End If + Return True + End Function - Return True + Private Sub BindGrid() + + Dim _ + gvTechListBinding As _ + New BindingList(Of ITechListBenefitLine)( + ssmTOOL.TechList.TechLines.OrderBy(Function(o) o.Category).ThenBy(Function(t) t.BenefitName).ToList()) + Me.gvTechBenefitLines.DataSource = gvTechListBinding + End Sub + + Private Function GetCategories() As List(Of String) + + If Not ssmTOOL Is Nothing AndAlso Not ssmTOOL.TechList Is Nothing AndAlso ssmTOOL.TechList.TechLines.Count > 0 Then + + 'Fuse Lists + Dim fusedList As List(Of String) = DefaultCategories.ToList() + + For Each s As String In ssmTOOL.TechList.TechLines.Select(Function(sel) sel.Category) + + If Not fusedList.Contains(s) Then + fusedList.Add(s) + End If + + Next + + Return fusedList.OrderBy(Function(o) o.ToString()).ToList() + + Else + + Return New List(Of String)(DefaultCategories) + + End If + End Function + + 'Constructors + Public Sub New(busDatabasePath As String, ahsmFilePath As String, vectoFilePath As String, + Optional useDefaults As Boolean = False) + + ' This call is required by the designer. + InitializeComponent() + + vectoFile = vectoFilePath + + 'Add any initialization after the InitializeComponent() call. + Me.busDatabasePath = busDatabasePath + Me.ahsmFilePath = ahsmFilePath + + ssmTOOL = New SSMTOOL(ahsmFilePath, New HVACConstants, False, useDefaults) + originalssmTOOL = New SSMTOOL(ahsmFilePath, New HVACConstants, False, useDefaults) + + If IO.File.Exists(ahsmFilePath) Then + If ssmTOOL.Load(ahsmFilePath) AndAlso originalssmTOOL.Load(ahsmFilePath) Then + Timer1.Enabled = True + Else + MessageBox.Show( + "The file format for the Steady State Model (.AHSM) was corrupted or is an alpha version. Please refer to the documentation or help to discover more.") + Timer1.Enabled = False + End If + Else + Timer1.Enabled = True + End If + + setupBuses() + setupControls() + setupBindings() + End Sub + + 'Setup Methods + Private Sub setupBuses() + + 'Setup Buses + buses = New BusDatabase() + If Not buses.Initialise(busDatabasePath) Then + MessageBox.Show("Problems initialising the Bus Database, some buses may not appear") + End If + + busesList = New BindingList(Of IBus)(buses.GetBuses(String.Empty, True)) + + cboBuses.DataSource = busesList + cboBuses.DisplayMember = "Model" + End Sub + + Private Sub setupControls() + + 'gvTechBenefitLines + gvTechBenefitLines.AutoGenerateColumns = False + + Dim cIndex As Integer + + 'Column - Category + cIndex = gvTechBenefitLines.Columns.Add("Category", "Category") + gvTechBenefitLines.Columns(cIndex).DataPropertyName = "Category" + gvTechBenefitLines.Columns(cIndex).Width = 70 + gvTechBenefitLines.Columns(cIndex).ReadOnly = True + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + + 'Column - BenefitName + cIndex = gvTechBenefitLines.Columns.Add("BenefitName", "BenefitName") + gvTechBenefitLines.Columns(cIndex).DataPropertyName = "BenefitName" + gvTechBenefitLines.Columns(cIndex).Width = 330 + gvTechBenefitLines.Columns(cIndex).ReadOnly = True + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + + 'Column - H + cIndex = gvTechBenefitLines.Columns.Add("H", "H") + gvTechBenefitLines.Columns(cIndex).DataPropertyName = "H" + gvTechBenefitLines.Columns(cIndex).Width = 60 + gvTechBenefitLines.Columns(cIndex).ReadOnly = True + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + + 'Column - VH + cIndex = gvTechBenefitLines.Columns.Add("VH", "VH") + gvTechBenefitLines.Columns(cIndex).DataPropertyName = "VH" + gvTechBenefitLines.Columns(cIndex).Width = 60 + gvTechBenefitLines.Columns(cIndex).ReadOnly = True + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + + + 'Column - VV + cIndex = gvTechBenefitLines.Columns.Add("VV", "VV") + gvTechBenefitLines.Columns(cIndex).DataPropertyName = "VV" + gvTechBenefitLines.Columns(cIndex).Width = 60 + gvTechBenefitLines.Columns(cIndex).ReadOnly = True + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + + 'Column - VC + cIndex = gvTechBenefitLines.Columns.Add("VC", "VC") + gvTechBenefitLines.Columns(cIndex).DataPropertyName = "VC" + gvTechBenefitLines.Columns(cIndex).Width = 60 + gvTechBenefitLines.Columns(cIndex).ReadOnly = True + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + + 'Column - C + cIndex = gvTechBenefitLines.Columns.Add("C", "C") + gvTechBenefitLines.Columns(cIndex).DataPropertyName = "C" + gvTechBenefitLines.Columns(cIndex).Width = 60 + gvTechBenefitLines.Columns(cIndex).ReadOnly = True + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + + 'Column - OnVehicle + + Dim onV As New DataGridViewCheckBoxColumn() + + cIndex = gvTechBenefitLines.Columns.Add(onV) + gvTechBenefitLines.Columns(cIndex).Name = "OnVehicle" + gvTechBenefitLines.Columns(cIndex).DataPropertyName = "OnVehicle" + gvTechBenefitLines.Columns(cIndex).Width = 60 + gvTechBenefitLines.Columns(cIndex).ReadOnly = True + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter + gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + + + Dim deleteColumn As New DeleteColumn + With deleteColumn + .HeaderText = "" + .ToolTipText = "Delete this row" + .Name = "Delete" + .Width = 20 + .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter + End With + gvTechBenefitLines.Columns.Add(deleteColumn) + + 'Techlist Edit Panel + cboCategory.DataSource = GetCategories() + cboUnits.DataSource = {"Fraction"} + cboLineType.DataSource = {"Normal", "ActiveVentilation"} + + txtEC_EnvironmentConditionsFilePath.Tag = ssmTOOL.GenInputs.EC_EnviromentalConditions_BatchFile + txtEC_EnvironmentConditionsFilePath.Text = fFileWoDir(ssmTOOL.GenInputs.EC_EnviromentalConditions_BatchFile, + fPATH(vectoFile)) + txtEC_EnvironmentConditionsFilePath.ReadOnly = True + btnEnvironmentConditionsSource.Enabled = False + btnOpenAenv.Enabled = False + + btnNewBus.Tag = "New" + btnEditBus.Tag = "Edit" + + BusParamGroupEdit.Location = New Point(30, 51) + End Sub + + Private Sub setupBindings() + + UpdateButtonText() + + 'TechBenefitLines + BindGrid() + + 'Bus Parameterisation + txtBusModel.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusModel", False, DataSourceUpdateMode.OnPropertyChanged) + txtRegisteredPassengers.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_NumberOfPassengers", False, + DataSourceUpdateMode.OnPropertyChanged) + cmbBusFloorType.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusFloorType", False, + DataSourceUpdateMode.OnPropertyChanged) + chkIsDoubleDecker.DataBindings.Add("Checked", ssmTOOL.GenInputs, "BP_DoubleDecker", False, + DataSourceUpdateMode.OnPropertyChanged) + txtBusLength.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusLength") + txtBusWidth.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusWidth") + txtBusHeight.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusHeight") + + txtBusFloorSurfaceArea.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusFloorSurfaceArea", False, + DataSourceUpdateMode.OnPropertyChanged) + txtBusWindowSurfaceArea.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusWindowSurface") + txtBusSurfaceArea.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusSurfaceAreaM2") + txtBusVolume.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusVolume") + + 'Boundary Conditions + txtBC_GFactor.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_GFactor") + txtBC_SolarClouding.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_SolarClouding") + txtBC_HeatPerPassengerIntoCabinW.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_HeatPerPassengerIntoCabinW") + txtBC_PassengerBoundaryTemperature.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_PassengerBoundaryTemperature") + txtBC_PassengerDensityLowFloor.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_PassengerDensityLowFloor") + txtBC_PassengerDensitySemiLowFloor.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_PassengerDensitySemiLowFloor") + txtBC_PassengerDensityRaisedFloor.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_PassengerDensityRaisedFloor") + txtBC_CalculatedPassengerNumber.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_CalculatedPassengerNumber") + txtBC_UValues.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_UValues") + txtBC_HeatingBoundaryTemperature.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_HeatingBoundaryTemperature") + txtBC_CoolingBoundaryTemperature.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_CoolingBoundaryTemperature") + txtBC_TemperatureCoolingOff.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_TemperatureCoolingTurnsOff") + txtBC_HighVentilation.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_HighVentilation") + txtBC_lowVentilation.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_lowVentilation") + txtBC_High.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_High") + txtBC_Low.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_Low") + txtBC_HighVentPowerW.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_HighVentPowerW") + txtBC_LowVentPowerW.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_LowVentPowerW") + txtBC_SpecificVentilationPower.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_SpecificVentilationPower") + txtBC_AuxHeaterEfficiency.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_AuxHeaterEfficiency") + txtBC_GCVDieselOrHeatingOil.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_GCVDieselOrHeatingOil") + txtBC_WindowAreaPerUnitBusLength.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_WindowAreaPerUnitBusLength") + txtBC_FrontRearWindowArea.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_FrontRearWindowArea") + txtBC_MaxTemperatureDeltaForLowFloorBusses.DataBindings.Add("Text", ssmTOOL.GenInputs, + "BC_MaxTemperatureDeltaForLowFloorBusses") + txtBC_MaxPossibleBenefitFromTechnologyList.DataBindings.Add("Text", ssmTOOL.GenInputs, + "BC_MaxPossibleBenefitFromTechnologyList") + + 'EnviromentalConditions + txtEC_EnviromentalTemperature.DataBindings.Add("Text", ssmTOOL.GenInputs, "EC_EnviromentalTemperature") + txtEC_Solar.DataBindings.Add("Text", ssmTOOL.GenInputs, "EC_Solar") + chkEC_BatchMode.DataBindings.Add("Checked", ssmTOOL.GenInputs, "EC_EnviromentalConditions_BatchEnabled", False, + DataSourceUpdateMode.OnPropertyChanged) + + 'AC-system + cboAC_CompressorType.DataBindings.Add("Text", ssmTOOL.GenInputs, "AC_CompressorType", False, + DataSourceUpdateMode.OnPropertyChanged) + txtAC_CompressorType.DataBindings.Add("Text", ssmTOOL.GenInputs, "AC_CompressorTypeDerived") + txtAC_CompressorCapacitykW.DataBindings.Add("Text", ssmTOOL.GenInputs, "AC_CompressorCapacitykW") + txtAC_COP.DataBindings.Add("Text", ssmTOOL.GenInputs, "AC_COP") + + 'Ventilation + chkVEN_VentilationOnDuringHeating.DataBindings.Add("Checked", ssmTOOL.GenInputs, "VEN_VentilationOnDuringHeating", + False, DataSourceUpdateMode.OnPropertyChanged) + chkVEN_VentilationWhenBothHeatingAndACInactive.DataBindings.Add("Checked", ssmTOOL.GenInputs, + "VEN_VentilationWhenBothHeatingAndACInactive", False, DataSourceUpdateMode.OnPropertyChanged) + chkVEN_VentilationDuringAC.DataBindings.Add("Checked", ssmTOOL.GenInputs, "VEN_VentilationDuringAC", False, + DataSourceUpdateMode.OnPropertyChanged) + cboVEN_VentilationFlowSettingWhenHeatingAndACInactive.DataBindings.Add("Text", ssmTOOL.GenInputs, + "VEN_VentilationFlowSettingWhenHeatingAndACInactive") + cboVEN_VentilationDuringHeating.DataBindings.Add("Text", ssmTOOL.GenInputs, "VEN_VentilationDuringHeating") + cboVEN_VentilationDuringCooling.DataBindings.Add("Text", ssmTOOL.GenInputs, "VEN_VentilationDuringCooling") + + 'Aux. Heater + txtAH_FuelFiredHeaterkW.DataBindings.Add("Text", ssmTOOL.GenInputs, "AH_FuelFiredHeaterkW") + txtAH_FuelEnergyHeatToCoolant.DataBindings.Add("Text", ssmTOOL.GenInputs, "AH_FuelEnergyToHeatToCoolant") + txtAH_CoolantHeatToAirCabinHeater.DataBindings.Add("Text", ssmTOOL.GenInputs, + "AH_CoolantHeatTransferredToAirCabinHeater") + End Sub + + 'GeneralInputControlEvents + Private Sub cboBuses_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboBuses.SelectedIndexChanged + + If cboBuses.SelectedIndex > 0 Then + + Dim bus As IBus = DirectCast(cboBuses.SelectedItem, IBus) + + ssmTOOL.GenInputs.BP_BusModel = bus.Model + ssmTOOL.GenInputs.BP_NumberOfPassengers = bus.RegisteredPassengers + ssmTOOL.GenInputs.BP_BusFloorType = bus.FloorType + ssmTOOL.GenInputs.BP_DoubleDecker = bus.IsDoubleDecker + ssmTOOL.GenInputs.BP_BusLength = bus.LengthInMetres + ssmTOOL.GenInputs.BP_BusWidth = bus.WidthInMetres + ssmTOOL.GenInputs.BP_BusHeight = bus.HeightInMetres + + txtBusModel.Text = bus.Model + txtRegisteredPassengers.Text = bus.RegisteredPassengers.ToString() + cmbBusFloorType.Text = bus.FloorType + txtBusLength.Text = bus.LengthInMetres.ToString() + txtBusWidth.Text = bus.WidthInMetres.ToString() + txtBusHeight.Text = bus.HeightInMetres.ToString() + chkIsDoubleDecker.Checked = bus.IsDoubleDecker + + txtBusFloorSurfaceArea.Text = ssmTOOL.GenInputs.BP_BusFloorSurfaceArea.ToString() + txtBusWindowSurfaceArea.Text = ssmTOOL.GenInputs.BP_BusWindowSurface.ToString() + txtBusSurfaceArea.Text = ssmTOOL.GenInputs.BP_BusSurfaceAreaM2.ToString() + txtBusVolume.Text = ssmTOOL.GenInputs.BP_BusVolume.ToString() + + btnEditBus.Enabled = True + + Else + btnEditBus.Enabled = False + End If + End Sub + + 'Validators + Public Sub Validating_GeneralInputsBP(sender As Object, e As CancelEventArgs) _ + Handles txtRegisteredPassengers.Validating, txtBusWidth.Validating, txtBusHeight.Validating, txtBusLength.Validating, + txtBusModel.Validating + + e.Cancel = Not Validate_GeneralInputsBP() + End Sub + + Public Sub Validating_GeneralInputsBC(sender As Object, e As CancelEventArgs) _ + Handles txtBC_GFactor.Validating, txtBC_SpecificVentilationPower.Validating, + txtBC_MaxTemperatureDeltaForLowFloorBusses.Validating, txtBC_MaxPossibleBenefitFromTechnologyList.Validating, + txtBC_lowVentilation.Validating, txtBC_HighVentilation.Validating, txtBC_HeatingBoundaryTemperature.Validating, + txtBC_GCVDieselOrHeatingOil.Validating, txtBC_CoolingBoundaryTemperature.Validating, + txtBC_AuxHeaterEfficiency.Validating, txtBC_PassengerBoundaryTemperature.Validating + + e.Cancel = Not Validate_GeneralInputsBC() + End Sub + + Public Sub Validating_GeneralInputsOther(sender As Object, e As CancelEventArgs) _ + Handles txtEC_Solar.Validating, txtEC_EnviromentalTemperature.Validating, txtAH_FuelFiredHeaterkW.Validating, + txtAC_CompressorCapacitykW.Validating, txtEC_EnvironmentConditionsFilePath.Validating, + txtAH_FuelEnergyHeatToCoolant.Validating, txtAH_CoolantHeatToAirCabinHeater.Validating + + e.Cancel = Not Validate_GeneralInputsOther() + End Sub + + Public Function Validate_GeneralInputsBP() As Boolean + + Dim result As Boolean = True + + 'BUS PARAMETERISATION + '******************** + + 'txtBusModel + If txtBusModel.Text.Trim.Length = 0 Then + ErrorProvider1.SetError(txtBusModel, "Please enter a bus model") + result = False + Else + ErrorProvider1.SetError(txtBusModel, String.Empty) + End If + + + 'txtRegisteredPassengers + If Not IsNumberGreaterThanOne(txtRegisteredPassengers.Text) Then + ErrorProvider1.SetError(txtRegisteredPassengers, + "Please enter an integer of one or higher ( Bus : Number of Passengers )") + result = False + Else + ErrorProvider1.SetError(txtRegisteredPassengers, String.Empty) + End If + + 'txtBusWidth + If Not IsPostiveNumber(txtBusWidth.Text) Then + ErrorProvider1.SetError(txtBusWidth, "Please enter a positive number ( BusWidth : linear metres )") + result = False + Else + ErrorProvider1.SetError(txtBusWidth, String.Empty) + End If + + 'txtBusHeight + If Not IsPostiveNumber(txtBusHeight.Text) Then + ErrorProvider1.SetError(txtBusHeight, "Please enter a positive number ( BusHeight : linear metres )") + result = False + Else + ErrorProvider1.SetError(txtBusHeight, String.Empty) + End If + + 'txtBusLength + If Not IsPostiveNumber(txtBusLength.Text) Then + ErrorProvider1.SetError(txtBusLength, "Please enter a positive number ( BusLength : linear metres )") + result = False + Else + ErrorProvider1.SetError(txtBusLength, String.Empty) + End If + + 'Set Tab Color + UpdateTabStatus("tabGeneralInputsBP", result) + + Return result + End Function + + Public Function Validate_GeneralInputsBPEdit() As Boolean + + Dim result As Boolean = True + + 'BUS PARAMETERISATION + '******************** + + 'txtBusModel + If txtEditBusModel.Text.Trim.Length = 0 Then + ErrorProvider1.SetError(txtEditBusModel, "Please enter a bus model") + result = False + Else + ErrorProvider1.SetError(txtEditBusModel, String.Empty) + End If + + 'cmbEditFloorType + If cmbEditFloorType.Text.Trim.Length = 0 Then + ErrorProvider1.SetError(cmbEditFloorType, "Please select a floor type") + result = False + Else + ErrorProvider1.SetError(cmbEditFloorType, String.Empty) + End If + + 'cmbEditEngineType + If cmbEditEngineType.Text.Trim.Length = 0 Then + ErrorProvider1.SetError(cmbEditEngineType, "Please select an engine type") + result = False + Else + ErrorProvider1.SetError(cmbEditEngineType, String.Empty) + End If + + 'txtRegisteredPassengers + If Not IsNumberGreaterThanOne(txtEditBusPassengers.Text) Then + ErrorProvider1.SetError(txtEditBusPassengers, + "Please enter an integer of one or higher ( Bus : Number of Passengers )") + result = False + Else + ErrorProvider1.SetError(txtEditBusPassengers, String.Empty) + End If + + 'txtBusLength + If Not IsPostiveNumber(txtEditBusLength.Text) Then + ErrorProvider1.SetError(txtEditBusLength, "Please enter a positive number ( Buslength : linear metres )") + result = False + Else + ErrorProvider1.SetError(txtEditBusLength, String.Empty) + End If + + 'txtBusWidth + If Not IsPostiveNumber(txtEditBusWidth.Text) Then + ErrorProvider1.SetError(txtEditBusWidth, "Please enter a positive number ( BusWidth : linear metres )") + result = False + Else + ErrorProvider1.SetError(txtEditBusWidth, String.Empty) + End If + + 'txtBusHeight + If Not IsPostiveNumber(txtEditBusHeight.Text) Then + ErrorProvider1.SetError(txtEditBusHeight, "Please enter a positive number ( BusHeight : linear metres )") + result = False + Else + ErrorProvider1.SetError(txtEditBusHeight, String.Empty) + End If + + 'Set Tab Color + UpdateTabStatus("tabGeneralInputsBP", result) + + Return result + End Function + + Public Function Validate_GeneralInputsBC() As Boolean + + Dim result As Boolean = True + + 'BOUNDARY CONDITIONS + '******************* + + 'txtBC_GFactor + IsTextBoxNumber(txtBC_GFactor, "Please enter a number ( GFactor )", result) + 'BC_SolarClouding : Calculated + 'BC_HeatPerPassengerIntoCabinW : Calculated + 'txtBC_PassengerBoundaryTemperature + IsTextBoxNumber(txtBC_PassengerBoundaryTemperature, "Please enter a number ( Passenger Boundary Temperature )", result) + 'txtBC_PassengerDensityLowFloor : Calculated + 'txtBC_PassengerDensitySemiLowFloor : Calculated + 'txtBC_PassengerDensityRaisedFloor : Calculated + 'txtBC_CalculatedPassengerNumber : Calculated + 'txtBC_UValues : Calculated + 'txtBC_HeatingBoundaryTemperature + IsTextBoxNumber(txtBC_HeatingBoundaryTemperature, "Please enter a number ( Heating Boundary Temperature )", result) + 'txtBC_CoolingBoundaryTemperature + IsTextBoxNumber(txtBC_CoolingBoundaryTemperature, "Please enter a number ( Cooling Boundary Temperature )", result) + 'txtBC_HighVentilation + IsTextBoxNumber(txtBC_HighVentilation, "Please enter a number ( High Ventilation )", result) + 'txtBC_lowVentilation + IsTextBoxNumber(txtBC_lowVentilation, "Please enter a number ( Low Ventilation )", result) + 'txtBC_High : Calculated + 'txtBC_Low : Calculated + 'txtBC_HighVentPowerW : Calculated + 'txtBC_LowVentPowerW : Calculated + 'txtBC_SpecificVentilationPower + IsTextBoxNumber(txtBC_SpecificVentilationPower, "Please enter a number ( Specific Ventilation Power )", result) + 'txtBC_COP + IsTextBoxNumber(txtAC_COP, "Please enter a number ( COP )", result) + 'txtBC_AuxHeaterEfficiency + IsTextBoxNumber(txtBC_AuxHeaterEfficiency, "Please enter a number ( Aux Heater Efficiency )", result) + 'txtBC_GCVDieselOrHeatingOil + IsTextBoxNumber(txtBC_GCVDieselOrHeatingOil, "Please enter a number ( GCV Diesel Or Heating Oil )", result) + 'txtBC_WindowAreaPerUnitBusLength : Calculated + 'txtBC_FrontRearWindowArea : Calculated + 'txtBC_MaxTemperatureDeltaForLowFloorBusses + IsTextBoxNumber(txtBC_MaxTemperatureDeltaForLowFloorBusses, + "Please enter a number ( Max Temp Delta For Low Floor Busses )", result) + 'txtBC_MaxPossibleBenefitFromTechnologyList + IsTextBoxNumber(txtBC_MaxPossibleBenefitFromTechnologyList, + "Please enter a number ( Max Benefit From Technology List )", result) + + 'Set Tab Color + UpdateTabStatus("tabGeneralInputsBC", result) + + Return result + End Function + + Public Function Validate_GeneralInputsOther() As Boolean + + Dim result As Boolean = True + + If (Not chkEC_BatchMode.Checked) Then + 'EnviromentalConditions + IsTextBoxNumber(txtEC_EnviromentalTemperature, "Please enter a number (Environmental Temperature)", result) + 'txtEC_Solar + IsTextBoxNumber(txtEC_Solar, "Please enter a number (Solar)", result) + End If + + + ''AC-system + 'chkAC_InCabinRoomAC_System : Selection + 'cboAC_CompressorType : Selection + 'txtAC_CompressorCapacitykW + IsTextBoxNumber(txtAC_CompressorCapacitykW, "Please enter a number ( Compressor Capacity )", result) + + ''Ventilation + 'chkVEN_VentilationOnDuringHeating : Selection + 'chkVEN_VentilationWhenBothHeatingAndACInactive : Selection + 'chkVEN_VentilationDuringAC : Selection + 'cboVEN_VentilationFlowSettingWhenHeatingAndACInactive : Selection + 'cboVEN_VentilationDuringHeating : Selection + 'cboVEN_VentilationDuringCooling : Selection + + ''Aux. Heater + 'txtAH_FuelFiredHeaterkW + IsTextBoxNumber(txtAH_FuelFiredHeaterkW, "Please enter a number ( Fuel fired heater )", result) + IsTextBoxNumber(txtAH_FuelEnergyHeatToCoolant, "Please enter a number ( Fuel Energy Heat To Coolant )", result) + IsTextBoxNumber(txtAH_CoolantHeatToAirCabinHeater, + "Please enter a number ( Coolant Heat Transfered To Air CabinHeater )", result) + + Try + Dim environmentalConditionsMap As IEnvironmentalConditionsMap = + New EnvironmentalConditionsMap(CType(txtEC_EnvironmentConditionsFilePath.Tag, String), fPATH(vectoFile)) + ErrorProvider1.SetError(txtEC_EnvironmentConditionsFilePath, String.Empty) + ssmTOOL.GenInputs.EC_EnviromentalConditions_BatchFile = CType(txtEC_EnvironmentConditionsFilePath.Tag, String) + Catch ex As Exception + ErrorProvider1.SetError(txtEC_EnvironmentConditionsFilePath, + "Error : The environment conditions file is invalid or cannot be found, please select a valid aenv file.") + result = False + End Try - End Function - Private Sub BindGrid() + 'Set Tab Color + UpdateTabStatus("tabGeneralInputsOther", result) - Dim gvTechListBinding As New BindingList(Of ITechListBenefitLine)(ssmTOOL.TechList.TechLines.OrderBy(Function(o) o.Category).ThenBy(Function(t) t.BenefitName).ToList()) - Me.gvTechBenefitLines.DataSource = gvTechListBinding + Return result + End Function - End Sub - Private Function GetCategories() As List(Of String) + Public Sub Validating_TechLineEdit(sender As Object, e As CancelEventArgs) _ +'Handles txtSemiLowFloorV.Validating, txtSemiLowFloorH.Validating, txtSemiLowFloorC.Validating, txtRaisedFloorV.Validating, txtRaisedFloorH.Validating, txtRaisedFloorC.Validating, txtLowFloorV.Validating, txtLowFloorH.Validating, txtLowFloorC.Validating, txtBenefitName.Validating, chkOnVehicle.Validating, chkActiveVV.Validating, chkActiveVH.Validating, chkActiveVC.Validating, cboUnits.Validating, cboLineType.Validating, cboCategory.Validating - If Not ssmTOOL Is Nothing AndAlso Not ssmTOOL.TechList Is Nothing AndAlso ssmTOOL.TechList.TechLines.Count > 0 Then + e.Cancel = Not Validate_TechLineEdit() + End Sub - 'Fuse Lists - Dim fusedList As List(Of String) = DefaultCategories.ToList() + Public Function Validate_TechLineEdit() As Boolean - For Each s As String In ssmTOOL.TechList.TechLines.Select(Function(sel) sel.Category) + Dim result As Boolean = True - If Not fusedList.Contains(s) Then - fusedList.Add(s) - End If + IsEmptyString(cboCategory.Text, cboCategory, "Please enter a valid category", result) + IsEmptyString(txtBenefitName.Text, txtBenefitName, "Please enter a valid Benefit Name", result) + IsEmptyString(cboUnits.Text, cboUnits, "Please enter valid units", result) + IsEmptyString(cboLineType.Text, cboLineType, "Please enter a valid line type", result) + IsTextBoxNumber(txtLowFloorH, "Please enter a valid number for this floor variable", result) + IsTextBoxNumber(txtLowFloorV, "Please enter a valid number for this floor variable", result) + IsTextBoxNumber(txtLowFloorC, "Please enter a valid number for this floor variable", result) + IsTextBoxNumber(txtSemiLowFloorH, "Please enter a valid number for this floor variable", result) + IsTextBoxNumber(txtSemiLowFloorV, "Please enter a valid number for this floor variable", result) + IsTextBoxNumber(txtSemiLowFloorC, "Please enter a valid number for this floor variable", result) + IsTextBoxNumber(txtRaisedFloorH, "Please enter a valid number for this floor variable", result) + IsTextBoxNumber(txtRaisedFloorV, "Please enter a valid number for this floor variable", result) + IsTextBoxNumber(txtRaisedFloorC, "Please enter a valid number for this floor variable", result) - Next - Return fusedList.OrderBy(Function(o) o.ToString()).ToList() + Return result + End Function - Else + 'Validation Helpers + Private Sub IsTextBoxNumber(control As TextBox, errorProviderMessage As String, ByRef result As Boolean) - Return New List(Of String)(DefaultCategories) + If Not IsNumeric(control.Text) Then + ErrorProvider1.SetError(control, errorProviderMessage) + result = False + Else + ErrorProvider1.SetError(control, String.Empty) - End If + End If + End Sub + Private Sub IsEmptyString(text As String, control As Control, errorProviderMessage As String, ByRef result As Boolean) - End Function + If String.IsNullOrEmpty(text) Then + ErrorProvider1.SetError(control, errorProviderMessage) + result = False + Else + ErrorProvider1.SetError(control, String.Empty) - 'Constructors - Public Sub New(busDatabasePath As String, ahsmFilePath As String, vectoFilePath As String, Optional useDefaults As Boolean = False) + End If + End Sub - ' This call is required by the designer. - InitializeComponent() + Private Function IsPostiveInteger(ByVal test As String) As Boolean - vectoFile = vectoFilePath - - 'Add any initialization after the InitializeComponent() call. - Me.busDatabasePath = busDatabasePath - Me.ahsmFilePath = ahsmFilePath - - ssmTOOL = New SSMTOOL(ahsmFilePath, New HVACConstants, False, useDefaults) - originalssmTOOL = New SSMTOOL(ahsmFilePath, New HVACConstants, False, useDefaults) + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - If IO.File.Exists(ahsmFilePath) Then - If ssmTOOL.Load(ahsmFilePath) AndAlso originalssmTOOL.Load(ahsmFilePath) Then - Timer1.Enabled = True - Else - MessageBox.Show("The file format for the Steady State Model (.AHSM) was corrupted or is an alpha version. Please refer to the documentation or help to discover more.") - Timer1.Enabled = False - End If - Else - Timer1.Enabled = True - End If + Dim number As Integer - setupBuses() - setupControls() - setupBindings() - - - End Sub - - 'Setup Methods - Private Sub setupBuses() - - 'Setup Buses - buses = New BusDatabase() - If Not buses.Initialise(busDatabasePath) Then - MessageBox.Show("Problems initialising the Bus Database, some buses may not appear") - End If + If Not Integer.TryParse(test, number) Then Return False - busesList = New BindingList(Of IBus)(buses.GetBuses(String.Empty, True)) + If number <= 0 Then Return False - cboBuses.DataSource = busesList - cboBuses.DisplayMember = "Model" - End Sub - Private Sub setupControls() - 'gvTechBenefitLines - gvTechBenefitLines.AutoGenerateColumns = False + Return True + End Function - Dim cIndex As Integer + Private Function IsPostiveNumber(ByVal test As String) As Boolean - 'Column - Category - cIndex = gvTechBenefitLines.Columns.Add("Category", "Category") - gvTechBenefitLines.Columns(cIndex).DataPropertyName = "Category" - gvTechBenefitLines.Columns(cIndex).Width = 70 - gvTechBenefitLines.Columns(cIndex).ReadOnly = True - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - 'Column - BenefitName - cIndex = gvTechBenefitLines.Columns.Add("BenefitName", "BenefitName") - gvTechBenefitLines.Columns(cIndex).DataPropertyName = "BenefitName" - gvTechBenefitLines.Columns(cIndex).Width = 330 - gvTechBenefitLines.Columns(cIndex).ReadOnly = True - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - - 'Column - H - cIndex = gvTechBenefitLines.Columns.Add("H", "H") - gvTechBenefitLines.Columns(cIndex).DataPropertyName = "H" - gvTechBenefitLines.Columns(cIndex).Width = 60 - gvTechBenefitLines.Columns(cIndex).ReadOnly = True - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - - 'Column - VH - cIndex = gvTechBenefitLines.Columns.Add("VH", "VH") - gvTechBenefitLines.Columns(cIndex).DataPropertyName = "VH" - gvTechBenefitLines.Columns(cIndex).Width = 60 - gvTechBenefitLines.Columns(cIndex).ReadOnly = True - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - - - 'Column - VV - cIndex = gvTechBenefitLines.Columns.Add("VV", "VV") - gvTechBenefitLines.Columns(cIndex).DataPropertyName = "VV" - gvTechBenefitLines.Columns(cIndex).Width = 60 - gvTechBenefitLines.Columns(cIndex).ReadOnly = True - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - - 'Column - VC - cIndex = gvTechBenefitLines.Columns.Add("VC", "VC") - gvTechBenefitLines.Columns(cIndex).DataPropertyName = "VC" - gvTechBenefitLines.Columns(cIndex).Width = 60 - gvTechBenefitLines.Columns(cIndex).ReadOnly = True - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - - 'Column - C - cIndex = gvTechBenefitLines.Columns.Add("C", "C") - gvTechBenefitLines.Columns(cIndex).DataPropertyName = "C" - gvTechBenefitLines.Columns(cIndex).Width = 60 - gvTechBenefitLines.Columns(cIndex).ReadOnly = True - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - - 'Column - OnVehicle - - Dim onV As New DataGridViewCheckBoxColumn() - - cIndex = gvTechBenefitLines.Columns.Add(onV) - gvTechBenefitLines.Columns(cIndex).Name = "OnVehicle" - gvTechBenefitLines.Columns(cIndex).DataPropertyName = "OnVehicle" - gvTechBenefitLines.Columns(cIndex).Width = 60 - gvTechBenefitLines.Columns(cIndex).ReadOnly = True - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Alignment = DataGridViewContentAlignment.TopCenter - gvTechBenefitLines.Columns(cIndex).HeaderCell.Style.Padding = New Padding(1, 2, 1, 1) - - - Dim deleteColumn As New DeleteColumn - With deleteColumn - .HeaderText = "" - .ToolTipText = "Delete this row" - .Name = "Delete" - .Width = 20 - .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter - End With - gvTechBenefitLines.Columns.Add(deleteColumn) - - 'Techlist Edit Panel - cboCategory.DataSource = GetCategories() - cboUnits.DataSource = {"Fraction"} - cboLineType.DataSource = {"Normal", "ActiveVentilation"} - - txtEC_EnvironmentConditionsFilePath.Tag = ssmTOOL.GenInputs.EC_EnviromentalConditions_BatchFile - txtEC_EnvironmentConditionsFilePath.Text = fFileWoDir(ssmTOOL.GenInputs.EC_EnviromentalConditions_BatchFile, fPATH(vectoFile)) - txtEC_EnvironmentConditionsFilePath.ReadOnly = True - btnEnvironmentConditionsSource.Enabled = False - btnOpenAenv.Enabled = False - - btnNewBus.Tag = "New" - btnEditBus.Tag = "Edit" - - BusParamGroupEdit.Location = New Point(30, 51) - End Sub - Private Sub setupBindings() - - UpdateButtonText() - - 'TechBenefitLines - BindGrid() - - 'Bus Parameterisation - txtBusModel.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusModel", False, DataSourceUpdateMode.OnPropertyChanged) - txtRegisteredPassengers.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_NumberOfPassengers", False, DataSourceUpdateMode.OnPropertyChanged) - cmbBusFloorType.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusFloorType", False, DataSourceUpdateMode.OnPropertyChanged) - chkIsDoubleDecker.DataBindings.Add("Checked", ssmTOOL.GenInputs, "BP_DoubleDecker", False, DataSourceUpdateMode.OnPropertyChanged) - txtBusLength.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusLength") - txtBusWidth.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusWidth") - txtBusHeight.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusHeight") - - txtBusFloorSurfaceArea.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusFloorSurfaceArea", False, DataSourceUpdateMode.OnPropertyChanged) - txtBusWindowSurfaceArea.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusWindowSurface") - txtBusSurfaceArea.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusSurfaceAreaM2") - txtBusVolume.DataBindings.Add("Text", ssmTOOL.GenInputs, "BP_BusVolume") - - 'Boundary Conditions - txtBC_GFactor.DataBindings.Add("Text", ssmTool.genInputs, "BC_GFactor") - txtBC_SolarClouding.DataBindings.Add("Text", ssmTool.genInputs, "BC_SolarClouding") - txtBC_HeatPerPassengerIntoCabinW.DataBindings.Add("Text", ssmTool.genInputs, "BC_HeatPerPassengerIntoCabinW") - txtBC_PassengerBoundaryTemperature.DataBindings.Add("Text", ssmTool.genInputs, "BC_PassengerBoundaryTemperature") - txtBC_PassengerDensityLowFloor.DataBindings.Add("Text", ssmTool.genInputs, "BC_PassengerDensityLowFloor") - txtBC_PassengerDensitySemiLowFloor.DataBindings.Add("Text", ssmTool.genInputs, "BC_PassengerDensitySemiLowFloor") - txtBC_PassengerDensityRaisedFloor.DataBindings.Add("Text", ssmTool.genInputs, "BC_PassengerDensityRaisedFloor") - txtBC_CalculatedPassengerNumber.DataBindings.Add("Text", ssmTool.genInputs, "BC_CalculatedPassengerNumber") - txtBC_UValues.DataBindings.Add("Text", ssmTool.genInputs, "BC_UValues") - txtBC_HeatingBoundaryTemperature.DataBindings.Add("Text", ssmTool.genInputs, "BC_HeatingBoundaryTemperature") - txtBC_CoolingBoundaryTemperature.DataBindings.Add("Text", ssmTool.genInputs, "BC_CoolingBoundaryTemperature") - txtBC_TemperatureCoolingOff.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_TemperatureCoolingTurnsOff") - txtBC_HighVentilation.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_HighVentilation") - txtBC_lowVentilation.DataBindings.Add("Text", ssmTool.genInputs, "BC_lowVentilation") - txtBC_High.DataBindings.Add("Text", ssmTool.genInputs, "BC_High") - txtBC_Low.DataBindings.Add("Text", ssmTool.genInputs, "BC_Low") - txtBC_HighVentPowerW.DataBindings.Add("Text", ssmTool.genInputs, "BC_HighVentPowerW") - txtBC_LowVentPowerW.DataBindings.Add("Text", ssmTool.genInputs, "BC_LowVentPowerW") - txtBC_SpecificVentilationPower.DataBindings.Add("Text", ssmTool.genInputs, "BC_SpecificVentilationPower") - txtBC_AuxHeaterEfficiency.DataBindings.Add("Text", ssmTool.genInputs, "BC_AuxHeaterEfficiency") - txtBC_GCVDieselOrHeatingOil.DataBindings.Add("Text", ssmTool.genInputs, "BC_GCVDieselOrHeatingOil") - txtBC_WindowAreaPerUnitBusLength.DataBindings.Add("Text", ssmTool.genInputs, "BC_WindowAreaPerUnitBusLength") - txtBC_FrontRearWindowArea.DataBindings.Add("Text", ssmTool.genInputs, "BC_FrontRearWindowArea") - txtBC_MaxTemperatureDeltaForLowFloorBusses.DataBindings.Add("Text", ssmTool.genInputs, "BC_MaxTemperatureDeltaForLowFloorBusses") - txtBC_MaxPossibleBenefitFromTechnologyList.DataBindings.Add("Text", ssmTOOL.GenInputs, "BC_MaxPossibleBenefitFromTechnologyList") - - 'EnviromentalConditions - txtEC_EnviromentalTemperature.DataBindings.Add("Text", ssmTool.genInputs, "EC_EnviromentalTemperature") - txtEC_Solar.DataBindings.Add("Text", ssmTOOL.GenInputs, "EC_Solar") - chkEC_BatchMode.DataBindings.Add("Checked", ssmTOOL.GenInputs, "EC_EnviromentalConditions_BatchEnabled", False, DataSourceUpdateMode.OnPropertyChanged) - - 'AC-system - cboAC_CompressorType.DataBindings.Add("Text", ssmTOOL.GenInputs, "AC_CompressorType", False, DataSourceUpdateMode.OnPropertyChanged) - txtAC_CompressorType.DataBindings.Add("Text", ssmTOOL.GenInputs, "AC_CompressorTypeDerived") - txtAC_CompressorCapacitykW.DataBindings.Add("Text", ssmTool.genInputs, "AC_CompressorCapacitykW") - txtAC_COP.DataBindings.Add("Text", ssmTOOL.GenInputs, "AC_COP") - - 'Ventilation - chkVEN_VentilationOnDuringHeating.DataBindings.Add("Checked", ssmTool.genInputs, "VEN_VentilationOnDuringHeating", False, DataSourceUpdateMode.OnPropertyChanged) - chkVEN_VentilationWhenBothHeatingAndACInactive.DataBindings.Add("Checked", ssmTool.genInputs, "VEN_VentilationWhenBothHeatingAndACInactive", False, DataSourceUpdateMode.OnPropertyChanged) - chkVEN_VentilationDuringAC.DataBindings.Add("Checked", ssmTool.genInputs, "VEN_VentilationDuringAC", False, DataSourceUpdateMode.OnPropertyChanged) - cboVEN_VentilationFlowSettingWhenHeatingAndACInactive.DataBindings.Add("Text", ssmTool.genInputs, "VEN_VentilationFlowSettingWhenHeatingAndACInactive") - cboVEN_VentilationDuringHeating.DataBindings.Add("Text", ssmTool.genInputs, "VEN_VentilationDuringHeating") - cboVEN_VentilationDuringCooling.DataBindings.Add("Text", ssmTool.genInputs, "VEN_VentilationDuringCooling") - - 'Aux. Heater - txtAH_FuelFiredHeaterkW.DataBindings.Add("Text", ssmTOOL.GenInputs, "AH_FuelFiredHeaterkW") - txtAH_FuelEnergyHeatToCoolant.DataBindings.Add("Text", ssmTOOL.GenInputs, "AH_FuelEnergyToHeatToCoolant") - txtAH_CoolantHeatToAirCabinHeater.DataBindings.Add("Text", ssmTOOL.GenInputs, "AH_CoolantHeatTransferredToAirCabinHeater") - - - End Sub - - 'GeneralInputControlEvents - Private Sub cboBuses_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboBuses.SelectedIndexChanged - - If cboBuses.SelectedIndex > 0 Then - - Dim bus As IBus = DirectCast(cboBuses.SelectedItem, IBus) - - ssmTOOL.GenInputs.BP_BusModel = bus.Model - ssmTOOL.GenInputs.BP_NumberOfPassengers = bus.RegisteredPassengers - ssmTOOL.GenInputs.BP_BusFloorType = bus.FloorType - ssmTOOL.GenInputs.BP_DoubleDecker = bus.IsDoubleDecker - ssmTOOL.GenInputs.BP_BusLength = bus.LengthInMetres - ssmTOOL.GenInputs.BP_BusWidth = bus.WidthInMetres - ssmTOOL.GenInputs.BP_BusHeight = bus.HeightInMetres - - txtBusModel.Text = bus.Model - txtRegisteredPassengers.Text = bus.RegisteredPassengers - cmbBusFloorType.Text = bus.FloorType - txtBusLength.Text = bus.LengthInMetres - txtBusWidth.Text = bus.WidthInMetres - txtBusHeight.Text = bus.HeightInMetres - chkIsDoubleDecker.Checked = bus.IsDoubleDecker - - txtBusFloorSurfaceArea.Text = ssmTOOL.GenInputs.BP_BusFloorSurfaceArea - txtBusWindowSurfaceArea.Text = ssmTOOL.GenInputs.BP_BusWindowSurface - txtBusSurfaceArea.Text = ssmTOOL.GenInputs.BP_BusSurfaceAreaM2 - txtBusVolume.Text = ssmTOOL.GenInputs.BP_BusVolume - - btnEditBus.Enabled = True - - Else - btnEditBus.Enabled = False - End If - - - End Sub - - 'Validators - Public Sub Validating_GeneralInputsBP(sender As Object, e As CancelEventArgs) Handles txtRegisteredPassengers.Validating, txtBusWidth.Validating, txtBusHeight.Validating, txtBusLength.Validating, txtBusModel.Validating - - e.Cancel = Not Validate_GeneralInputsBP() - - End Sub - Public Sub Validating_GeneralInputsBC(sender As Object, e As CancelEventArgs) Handles txtBC_GFactor.Validating, txtBC_SpecificVentilationPower.Validating, txtBC_MaxTemperatureDeltaForLowFloorBusses.Validating, txtBC_MaxPossibleBenefitFromTechnologyList.Validating, txtBC_lowVentilation.Validating, txtBC_HighVentilation.Validating, txtBC_HeatingBoundaryTemperature.Validating, txtBC_GCVDieselOrHeatingOil.Validating, txtBC_CoolingBoundaryTemperature.Validating, txtBC_AuxHeaterEfficiency.Validating, txtBC_PassengerBoundaryTemperature.Validating - - e.Cancel = Not Validate_GeneralInputsBC() - - End Sub - Public Sub Validating_GeneralInputsOther(sender As Object, e As CancelEventArgs) Handles txtEC_Solar.Validating, txtEC_EnviromentalTemperature.Validating, txtAH_FuelFiredHeaterkW.Validating, txtAC_CompressorCapacitykW.Validating, txtEC_EnvironmentConditionsFilePath.Validating, txtAH_FuelEnergyHeatToCoolant.Validating, txtAH_CoolantHeatToAirCabinHeater.Validating - - e.Cancel = Not Validate_GeneralInputsOther() - - End Sub - Public Function Validate_GeneralInputsBP() As Boolean - - Dim result As Boolean = True - - 'BUS PARAMETERISATION - '******************** - - 'txtBusModel - If txtBusModel.Text.Trim.Length = 0 Then - ErrorProvider1.SetError(txtBusModel, "Please enter a bus model") - result = False - Else - ErrorProvider1.SetError(txtBusModel, String.Empty) - End If - - - 'txtRegisteredPassengers - If Not IsNumberGreaterThanOne(txtRegisteredPassengers.Text) Then - ErrorProvider1.SetError(txtRegisteredPassengers, "Please enter an integer of one or higher ( Bus : Number of Passengers )") - result = False - Else - ErrorProvider1.SetError(txtRegisteredPassengers, String.Empty) - End If - - 'txtBusWidth - If Not IsPostiveNumber(txtBusWidth.Text) Then - ErrorProvider1.SetError(txtBusWidth, "Please enter a positive number ( BusWidth : linear metres )") - result = False - Else - ErrorProvider1.SetError(txtBusWidth, String.Empty) - End If - - 'txtBusHeight - If Not IsPostiveNumber(txtBusHeight.Text) Then - ErrorProvider1.SetError(txtBusHeight, "Please enter a positive number ( BusHeight : linear metres )") - result = False - Else - ErrorProvider1.SetError(txtBusHeight, String.Empty) - End If - - 'txtBusLength - If Not IsPostiveNumber(txtBusLength.Text) Then - ErrorProvider1.SetError(txtBusLength, "Please enter a positive number ( BusLength : linear metres )") - result = False - Else - ErrorProvider1.SetError(txtBusLength, String.Empty) - End If - - 'Set Tab Color - UpdateTabStatus("tabGeneralInputsBP", result) - - Return result - - End Function - Public Function Validate_GeneralInputsBPEdit() As Boolean - - Dim result As Boolean = True - - 'BUS PARAMETERISATION - '******************** - - 'txtBusModel - If txtEditBusModel.Text.Trim.Length = 0 Then - ErrorProvider1.SetError(txtEditBusModel, "Please enter a bus model") - result = False - Else - ErrorProvider1.SetError(txtEditBusModel, String.Empty) - End If - - 'cmbEditFloorType - If cmbEditFloorType.Text.Trim.Length = 0 Then - ErrorProvider1.SetError(cmbEditFloorType, "Please select a floor type") - result = False - Else - ErrorProvider1.SetError(cmbEditFloorType, String.Empty) - End If - - 'cmbEditEngineType - If cmbEditEngineType.Text.Trim.Length = 0 Then - ErrorProvider1.SetError(cmbEditEngineType, "Please select an engine type") - result = False - Else - ErrorProvider1.SetError(cmbEditEngineType, String.Empty) - End If - - 'txtRegisteredPassengers - If Not IsNumberGreaterThanOne(txtEditBusPassengers.Text) Then - ErrorProvider1.SetError(txtEditBusPassengers, "Please enter an integer of one or higher ( Bus : Number of Passengers )") - result = False - Else - ErrorProvider1.SetError(txtEditBusPassengers, String.Empty) - End If - - 'txtBusLength - If Not IsPostiveNumber(txtEditBusLength.Text) Then - ErrorProvider1.SetError(txtEditBusLength, "Please enter a positive number ( Buslength : linear metres )") - result = False - Else - ErrorProvider1.SetError(txtEditBusLength, String.Empty) - End If - - 'txtBusWidth - If Not IsPostiveNumber(txtEditBusWidth.Text) Then - ErrorProvider1.SetError(txtEditBusWidth, "Please enter a positive number ( BusWidth : linear metres )") - result = False - Else - ErrorProvider1.SetError(txtEditBusWidth, String.Empty) - End If - - 'txtBusHeight - If Not IsPostiveNumber(txtEditBusHeight.Text) Then - ErrorProvider1.SetError(txtEditBusHeight, "Please enter a positive number ( BusHeight : linear metres )") - result = False - Else - ErrorProvider1.SetError(txtEditBusHeight, String.Empty) - End If - - 'Set Tab Color - UpdateTabStatus("tabGeneralInputsBP", result) - - Return result - - End Function - Public Function Validate_GeneralInputsBC() As Boolean - - Dim result As Boolean = True - - 'BOUNDARY CONDITIONS - '******************* - - 'txtBC_GFactor - IsTextBoxNumber(txtBC_GFactor, "Please enter a number ( GFactor )", result) - 'BC_SolarClouding : Calculated - 'BC_HeatPerPassengerIntoCabinW : Calculated - 'txtBC_PassengerBoundaryTemperature - IsTextBoxNumber(txtBC_PassengerBoundaryTemperature, "Please enter a number ( Passenger Boundary Temperature )", result) - 'txtBC_PassengerDensityLowFloor : Calculated - 'txtBC_PassengerDensitySemiLowFloor : Calculated - 'txtBC_PassengerDensityRaisedFloor : Calculated - 'txtBC_CalculatedPassengerNumber : Calculated - 'txtBC_UValues : Calculated - 'txtBC_HeatingBoundaryTemperature - IsTextBoxNumber(txtBC_HeatingBoundaryTemperature, "Please enter a number ( Heating Boundary Temperature )", result) - 'txtBC_CoolingBoundaryTemperature - IsTextBoxNumber(txtBC_CoolingBoundaryTemperature, "Please enter a number ( Cooling Boundary Temperature )", result) - 'txtBC_HighVentilation - IsTextBoxNumber(txtBC_HighVentilation, "Please enter a number ( High Ventilation )", result) - 'txtBC_lowVentilation - IsTextBoxNumber(txtBC_lowVentilation, "Please enter a number ( Low Ventilation )", result) - 'txtBC_High : Calculated - 'txtBC_Low : Calculated - 'txtBC_HighVentPowerW : Calculated - 'txtBC_LowVentPowerW : Calculated - 'txtBC_SpecificVentilationPower - IsTextBoxNumber(txtBC_SpecificVentilationPower, "Please enter a number ( Specific Ventilation Power )", result) - 'txtBC_COP - IsTextBoxNumber(txtAC_COP, "Please enter a number ( COP )", result) - 'txtBC_AuxHeaterEfficiency - IsTextBoxNumber(txtBC_AuxHeaterEfficiency, "Please enter a number ( Aux Heater Efficiency )", result) - 'txtBC_GCVDieselOrHeatingOil - IsTextBoxNumber(txtBC_GCVDieselOrHeatingOil, "Please enter a number ( GCV Diesel Or Heating Oil )", result) - 'txtBC_WindowAreaPerUnitBusLength : Calculated - 'txtBC_FrontRearWindowArea : Calculated - 'txtBC_MaxTemperatureDeltaForLowFloorBusses - IsTextBoxNumber(txtBC_MaxTemperatureDeltaForLowFloorBusses, "Please enter a number ( Max Temp Delta For Low Floor Busses )", result) - 'txtBC_MaxPossibleBenefitFromTechnologyList - IsTextBoxNumber(txtBC_MaxPossibleBenefitFromTechnologyList, "Please enter a number ( Max Benefit From Technology List )", result) - - 'Set Tab Color - UpdateTabStatus("tabGeneralInputsBC", result) - - Return result - - End Function - Public Function Validate_GeneralInputsOther() As Boolean - - Dim result As Boolean = True - - If (Not chkEC_BatchMode.Checked) Then - 'EnviromentalConditions - IsTextBoxNumber(txtEC_EnviromentalTemperature, "Please enter a number (Environmental Temperature)", result) - 'txtEC_Solar - IsTextBoxNumber(txtEC_Solar, "Please enter a number (Solar)", result) - End If - - - ''AC-system - 'chkAC_InCabinRoomAC_System : Selection - 'cboAC_CompressorType : Selection - 'txtAC_CompressorCapacitykW - IsTextBoxNumber(txtAC_CompressorCapacitykW, "Please enter a number ( Compressor Capacity )", result) - - ''Ventilation - 'chkVEN_VentilationOnDuringHeating : Selection - 'chkVEN_VentilationWhenBothHeatingAndACInactive : Selection - 'chkVEN_VentilationDuringAC : Selection - 'cboVEN_VentilationFlowSettingWhenHeatingAndACInactive : Selection - 'cboVEN_VentilationDuringHeating : Selection - 'cboVEN_VentilationDuringCooling : Selection - - ''Aux. Heater - 'txtAH_FuelFiredHeaterkW - IsTextBoxNumber(txtAH_FuelFiredHeaterkW, "Please enter a number ( Fuel fired heater )", result) - IsTextBoxNumber(txtAH_FuelEnergyHeatToCoolant, "Please enter a number ( Fuel Energy Heat To Coolant )", result) - IsTextBoxNumber(txtAH_CoolantHeatToAirCabinHeater, "Please enter a number ( Coolant Heat Transfered To Air CabinHeater )", result) - - Try - Dim environmentalConditionsMap As IEnvironmentalConditionsMap = New EnvironmentalConditionsMap(txtEC_EnvironmentConditionsFilePath.Tag, fPATH(vectoFile)) - ErrorProvider1.SetError(txtEC_EnvironmentConditionsFilePath, String.Empty) - ssmTOOL.GenInputs.EC_EnviromentalConditions_BatchFile = txtEC_EnvironmentConditionsFilePath.Tag - Catch ex As Exception - ErrorProvider1.SetError(txtEC_EnvironmentConditionsFilePath, "Error : The environment conditions file is invalid or cannot be found, please select a valid aenv file.") - result = False - End Try + Dim number As Double - 'Set Tab Color - UpdateTabStatus("tabGeneralInputsOther", result) + If Not Double.TryParse(test, number) Then Return False - Return result + If number <= 0 Then Return False - End Function - Public Sub Validating_TechLineEdit(sender As Object, e As CancelEventArgs) 'Handles txtSemiLowFloorV.Validating, txtSemiLowFloorH.Validating, txtSemiLowFloorC.Validating, txtRaisedFloorV.Validating, txtRaisedFloorH.Validating, txtRaisedFloorC.Validating, txtLowFloorV.Validating, txtLowFloorH.Validating, txtLowFloorC.Validating, txtBenefitName.Validating, chkOnVehicle.Validating, chkActiveVV.Validating, chkActiveVH.Validating, chkActiveVC.Validating, cboUnits.Validating, cboLineType.Validating, cboCategory.Validating - e.Cancel = Not Validate_TechLineEdit() + Return True + End Function - End Sub - Public Function Validate_TechLineEdit() As Boolean + Private Function IsNumberGreaterThanOne(ByVal test As String) As Boolean - Dim result As Boolean = True + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - IsEmptyString(cboCategory.Text, cboCategory, "Please enter a valid category", result) - IsEmptyString(txtBenefitName.Text, txtBenefitName, "Please enter a valid Benefit Name", result) - IsEmptyString(cboUnits.Text, cboUnits, "Please enter valid units", result) - IsEmptyString(cboLineType.Text, cboLineType, "Please enter a valid line type", result) - IsTextBoxNumber(txtLowFloorH, "Please enter a valid number for this floor variable", result) - IsTextBoxNumber(txtLowFloorV, "Please enter a valid number for this floor variable", result) - IsTextBoxNumber(txtLowFloorC, "Please enter a valid number for this floor variable", result) - IsTextBoxNumber(txtSemiLowFloorH, "Please enter a valid number for this floor variable", result) - IsTextBoxNumber(txtSemiLowFloorV, "Please enter a valid number for this floor variable", result) - IsTextBoxNumber(txtSemiLowFloorC, "Please enter a valid number for this floor variable", result) - IsTextBoxNumber(txtRaisedFloorH, "Please enter a valid number for this floor variable", result) - IsTextBoxNumber(txtRaisedFloorV, "Please enter a valid number for this floor variable", result) - IsTextBoxNumber(txtRaisedFloorC, "Please enter a valid number for this floor variable", result) + Dim number As Double + If Not Double.TryParse(test, number) Then Return False - Return result + If number <= 1 Then Return False - End Function - 'Validation Helpers - Private Sub IsTextBoxNumber(control As TextBox, errorProviderMessage As String, ByRef result As Boolean) + Return True + End Function - If Not IsNumeric(control.Text) Then - ErrorProvider1.SetError(control, errorProviderMessage) - result = False - Else - ErrorProvider1.SetError(control, String.Empty) + Private Function IsZeroOrPostiveNumber(ByVal test As String) As Boolean - End If + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - End Sub - Private Sub IsEmptyString(text As String, control As Control, errorProviderMessage As String, ByRef result As Boolean) + Dim number As Double - If String.IsNullOrEmpty(text) Then - ErrorProvider1.SetError(control, errorProviderMessage) - result = False - Else - ErrorProvider1.SetError(control, String.Empty) + If Not Double.TryParse(test, number) Then Return False - End If + If number < 0 Then Return False - End Sub - Private Function IsPostiveInteger(ByVal test As String) As Boolean - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + Return True + End Function - Dim number As Single + Private Function IsNumberBetweenZeroandOne(test As String) As Boolean - If Not Integer.TryParse(test, number) Then Return False + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - If number <= 0 Then Return False + Dim number As Double + If Not Double.TryParse(test, number) Then Return False - Return True + If number < 0 OrElse number > 1 Then Return False - End Function - Private Function IsPostiveNumber(ByVal test As String) As Boolean + Return True + End Function - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + Private Function IsIntegerZeroOrPositiveNumber(test As String) As Boolean - Dim number As Single + 'Is this numeric sanity check. + If Not IsNumeric(test) Then Return False - If Not Double.TryParse(test, number) Then Return False + 'if not integer then return false - If number <= 0 Then Return False + Dim number As Integer + If Not Integer.TryParse(test, number) Then Return False - Return True + If number < 0 Then Return False - End Function - Private Function IsNumberGreaterThanOne(ByVal test As String) As Boolean + Return True + End Function - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + Private Function ValidateAll() As Boolean - Dim number As Single + Return Not IsAddingBus AndAlso + Not IsUpdatingBus AndAlso + Validate_GeneralInputsBC() AndAlso + Validate_GeneralInputsBP() AndAlso + Validate_GeneralInputsOther() + End Function - If Not Double.TryParse(test, number) Then Return False + 'Tab Colors + Private Sub UpdateTabStatus(pageName As String, resultGood As Boolean) - If number <= 1 Then Return False + Dim page As TabPage = tabMain.TabPages(pageName) + If Not resultGood Then - Return True + SetTabHeader(page, Color.Red) - End Function - Private Function IsZeroOrPostiveNumber(ByVal test As String) As Boolean + Else + SetTabHeader(page, Control.DefaultBackColor) - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + End If + End Sub - Dim number As Single + Private Sub SetTabHeader(page As TabPage, color As Color) - If Not Double.TryParse(test, number) Then Return False + TabColors(page) = color + tabMain.Invalidate() + End Sub - If number < 0 Then Return False + Private Sub tabMain_DrawItem(sender As Object, e As DrawItemEventArgs) + Dim br As Brush = New SolidBrush(TabColors(tabMain.TabPages(e.Index))) - Return True + Using (br) - End Function - Private Function IsNumberBetweenZeroandOne(test As String) As Boolean + e.Graphics.FillRectangle(br, e.Bounds) + Dim sz As SizeF = e.Graphics.MeasureString(tabMain.TabPages(e.Index).Text, e.Font) + e.Graphics.DrawString(tabMain.TabPages(e.Index).Text, e.Font, Brushes.Black, + e.Bounds.Left + (e.Bounds.Width - sz.Width)/2, e.Bounds.Top + (e.Bounds.Height - sz.Height)/2 + 1) - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + Dim rect As Rectangle = e.Bounds + rect.Offset(- 1, - 1) + rect.Inflate(1, 1) - Dim number As Single - If Not Double.TryParse(test, number) Then Return False + End Using + End Sub - If number < 0 OrElse number > 1 Then Return False + Private Sub EnsureBinding() + With tabMain + Dim lastSelectedTabIndex As Integer = .SelectedIndex + If lastSelectedTabIndex < 0 OrElse lastSelectedTabIndex > .TabCount Then lastSelectedTabIndex = 0 + For currentTab As Integer = 0 To .TabCount - 1 + .SelectedIndex = currentTab + Next + .SelectedIndex = 0 + End With + End Sub - Return True + 'Form/Control Events + Private Sub frmHVACTool_Load(sender As Object, e As EventArgs) Handles MyBase.Load - End Function - Private Function IsIntegerZeroOrPositiveNumber(test As String) As Boolean + 'Required for OwnerDraw, this is required in order to color the tabs when a validation error occurs to draw + 'The attention of the user to the fact that attention is required on a particlar tab. + TabColors.Add(tabGeneralInputsBP, Control.DefaultBackColor) + TabColors.Add(tabGeneralInputsBC, Control.DefaultBackColor) + TabColors.Add(tabGeneralInputsOther, Control.DefaultBackColor) + TabColors.Add(tabTechBenefits, Control.DefaultBackColor) + TabColors.Add(tabDiagnostics, Control.DefaultBackColor) - 'Is this numeric sanity check. - If Not IsNumeric(test) Then Return False + EnsureBinding() - 'if not integer then return false + 'Additional atatched events + 'For Tab Coloring, this is the place where the background will get filled on the tab when attention is required. + AddHandler tabMain.DrawItem, New System.Windows.Forms.DrawItemEventHandler(AddressOf tabMain_DrawItem) - Dim number As Integer + gvTechBenefitLines.ClearSelection() - If Not Integer.TryParse(test, number) Then Return False + Dim r As DialogResult = Me.DialogResult + End Sub - If number < 0 Then Return False + Private Sub frmHVACTool_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing - Return True + Dim result As DialogResult - End Function - Private Function ValidateAll() As Boolean + 'If UserHitCancel then bail + If UserHitCancel Then + DialogResult = Windows.Forms.DialogResult.Cancel + UserHitCancel = False + Return + End If - Return Not IsAddingBus AndAlso - Not IsUpdatingBus AndAlso - Validate_GeneralInputsBC() AndAlso - Validate_GeneralInputsBP() AndAlso - Validate_GeneralInputsOther() + 'UserHitSave + If UserHitSave Then + DialogResult = Windows.Forms.DialogResult.Cancel + If Not ssmTOOL.Save(ahsmFilePath) Then + MessageBox.Show("Unable to save file, aborting.") + e.Cancel = True + End If + DialogResult = Windows.Forms.DialogResult.OK + UserHitSave = False + Return + End If - End Function + 'This must be a close box event. If nothing changed, then bail, otherwise ask user if they wanna save + If Not ssmTOOL.IsEqualTo(originalssmTOOL) Then - 'Tab Colors - Private Sub UpdateTabStatus(pageName As String, resultGood As Boolean) + result = + (MessageBox.Show("Would you like to save changes before closing?", "Save Changes", MessageBoxButtons.YesNoCancel, + MessageBoxIcon.Question)) - Dim page As TabPage = tabMain.TabPages(pageName) - If Not resultGood Then + Select Case result - SetTabHeader(page, Color.Red) + Case DialogResult.Yes + 'save - Else - SetTabHeader(page, Control.DefaultBackColor) + If Not ssmTOOL.Save(ahsmFilePath) Then + e.Cancel = True + End If - End If + Case DialogResult.No + 'just allow the form to close + 'without saving + Me.DialogResult = Windows.Forms.DialogResult.Cancel - End Sub - Private Sub SetTabHeader(page As TabPage, color As Color) - TabColors(page) = color - tabMain.Invalidate() + Case DialogResult.Cancel + 'cancel the close + e.Cancel = True + Me.DialogResult = Windows.Forms.DialogResult.Cancel - End Sub - Private Sub tabMain_DrawItem(sender As Object, e As DrawItemEventArgs) - Dim br As Brush = New SolidBrush(TabColors(tabMain.TabPages(e.Index))) + End Select - Using (br) + End If - e.Graphics.FillRectangle(br, e.Bounds) - Dim sz As SizeF = e.Graphics.MeasureString(tabMain.TabPages(e.Index).Text, e.Font) - e.Graphics.DrawString(tabMain.TabPages(e.Index).Text, e.Font, Brushes.Black, e.Bounds.Left + (e.Bounds.Width - sz.Width) / 2, e.Bounds.Top + (e.Bounds.Height - sz.Height) / 2 + 1) + UserHitCancel = False + UserHitSave = False + End Sub - Dim rect As Rectangle = e.Bounds - rect.Offset(-1, -1) - rect.Inflate(1, 1) + 'Grid Events + Private Sub gvTechBenefitLines_DoubleClick(sender As Object, e As EventArgs) Handles gvTechBenefitLines.DoubleClick + If gvTechBenefitLines.SelectedCells.Count < 1 Then Return - End Using - End Sub - Private Sub EnsureBinding() - With tabMain - Dim lastSelectedTabIndex As Integer = .SelectedIndex - If lastSelectedTabIndex < 0 OrElse lastSelectedTabIndex > .TabCount Then lastSelectedTabIndex = 0 - For currentTab As Integer = 0 To .TabCount - 1 - .SelectedIndex = currentTab - Next - .SelectedIndex = 0 - End With - End Sub + Dim row As Integer = gvTechBenefitLines.SelectedCells(0).OwningRow.Index - 'Form/Control Events - Private Sub frmHVACTool_Load(sender As Object, e As EventArgs) Handles MyBase.Load + Dim benefitName, category As String + benefitName = CType(gvTechBenefitLines.Rows(row).Cells("BenefitName").Value, String) + category = CType(gvTechBenefitLines.Rows(row).Cells("Category").Value, String) - 'Required for OwnerDraw, this is required in order to color the tabs when a validation error occurs to draw - 'The attention of the user to the fact that attention is required on a particlar tab. - TabColors.Add(tabGeneralInputsBP, Control.DefaultBackColor) - TabColors.Add(tabGeneralInputsBC, Control.DefaultBackColor) - TabColors.Add(tabGeneralInputsOther, Control.DefaultBackColor) - TabColors.Add(tabTechBenefits, Control.DefaultBackColor) - TabColors.Add(tabDiagnostics, Control.DefaultBackColor) - EnsureBinding() + editTechLine = ssmTOOL.TechList.TechLines.First(Function(f) f.BenefitName = benefitName AndAlso f.Category = category) - 'Additional atatched events - 'For Tab Coloring, this is the place where the background will get filled on the tab when attention is required. - AddHandler tabMain.DrawItem, New System.Windows.Forms.DrawItemEventHandler(AddressOf tabMain_DrawItem) + If editTechLine.Units.ToLower = "kw" Then - gvTechBenefitLines.ClearSelection() + ClearEditPanel() + MessageBox.Show("KW Unit types not supported, any KW Units in list are for test purposes only") + Return - Dim r As DialogResult = Me.DialogResult + End If - End Sub - Private Sub frmHVACTool_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing + FillTechLineEditPanel(row) - Dim result As DialogResult + UpdateButtonText() + End Sub - 'If UserHitCancel then bail - If UserHitCancel Then - DialogResult = Windows.Forms.DialogResult.Cancel - UserHitCancel = False - Return - End If + Private Sub gvTechBenefitLines_CellClick(sender As Object, e As DataGridViewCellEventArgs) _ + Handles gvTechBenefitLines.CellClick - 'UserHitSave - If UserHitSave Then - DialogResult = Windows.Forms.DialogResult.Cancel - If Not ssmTOOL.Save(ahsmFilePath) Then - MessageBox.Show("Unable to save file, aborting.") - e.Cancel = True - End If - DialogResult = Windows.Forms.DialogResult.OK - UserHitSave = False - Return - End If + If e.ColumnIndex < 0 OrElse e.RowIndex < 0 Then Return - 'This must be a close box event. If nothing changed, then bail, otherwise ask user if they wanna save - If Not ssmTOOL.IsEqualTo(originalssmTOOL) Then + If _ + gvTechBenefitLines.Columns(e.ColumnIndex).Name = "Delete" OrElse + gvTechBenefitLines.Columns(e.ColumnIndex).Name = "OnVehicle" Then - result = (MessageBox.Show("Would you like to save changes before closing?", "Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) + Dim benefit As String = CType(gvTechBenefitLines.Rows(e.RowIndex).Cells(1).Value, String) + Dim category As String = CType(gvTechBenefitLines.Rows(e.RowIndex).Cells(0).Value, String) + Dim feedback As String = String.Empty - Select Case result + Select Case gvTechBenefitLines.Columns(e.ColumnIndex).Name - Case DialogResult.Yes - 'save - If Not ssmTOOL.Save(ahsmFilePath) Then - e.Cancel = True - End If + Case "Delete" + Dim dr As DialogResult = MessageBox.Show(String.Format("Do you want to delete benefit '{0}' ?", benefit), "", + MessageBoxButtons.YesNo) + If dr = Windows.Forms.DialogResult.Yes Then + If ssmTOOL.TechList.Delete(New TechListBenefitLine With {.BenefitName = benefit, .Category = category}, feedback) _ + Then + BindGrid() + End If + End If - Case DialogResult.No - 'just allow the form to close - 'without saving - Me.DialogResult = Windows.Forms.DialogResult.Cancel + Case "OnVehicle" + Dim onVehicle As Boolean = Not CType(gvTechBenefitLines.Rows(e.RowIndex).Cells(e.ColumnIndex).Value, Boolean) + Dim fi As ITechListBenefitLine = + ssmTOOL.TechList.TechLines.Find(Function(f) (f.Category = category) AndAlso f.BenefitName = benefit) + fi.OnVehicle = onVehicle + ' ssmTOOL.TechList.TechLines.First( Function(x) x.BenefitName= benefit AndAlso x.Category=category).OnVehicle=onVehicle + ' BindGrid + gvTechBenefitLines.Refresh() - Case DialogResult.Cancel - 'cancel the close - e.Cancel = True - Me.DialogResult = Windows.Forms.DialogResult.Cancel + End Select - End Select + End If + End Sub - End If + Private Sub gvTechBenefitLines_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) _ + Handles gvTechBenefitLines.CurrentCellDirtyStateChanged - UserHitCancel = False - UserHitSave = False - End Sub + If gvTechBenefitLines.IsCurrentCellDirty Then + gvTechBenefitLines.CommitEdit(DataGridViewDataErrorContexts.Commit) + End If + End Sub - 'Grid Events - Private Sub gvTechBenefitLines_DoubleClick(sender As Object, e As EventArgs) Handles gvTechBenefitLines.DoubleClick + 'Button Event Handlers + Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click - If gvTechBenefitLines.SelectedCells.Count < 1 Then Return + Dim feedback As String = String.Empty + If Not Validate_TechLineEdit() Then Return - Dim row As Integer = gvTechBenefitLines.SelectedCells(0).OwningRow.Index + If txtIndex.Text.Trim.Length = 0 Then + 'This is an Add + If Not ssmTOOL.TechList.Add(GetTechLineFromPanel(), feedback) Then + MessageBox.Show(feedback) + Else - Dim benefitName, category As String - benefitName = gvTechBenefitLines.Rows(row).Cells("BenefitName").Value - category = gvTechBenefitLines.Rows(row).Cells("Category").Value + BindGrid() - editTechLine = ssmTOOL.TechList.TechLines.First(Function(f) f.BenefitName = benefitName AndAlso f.Category = category) + 'find new row + Dim ol As List(Of ITechListBenefitLine) = + ssmTOOL.TechList.TechLines.OrderBy(Function(x) x.Category).ThenBy(Function(tb) tb.BenefitName).ToList() + Dim item As ITechListBenefitLine = + ol.First( + Function(x) _ + x.Category = GetTechLineFromPanel().Category AndAlso x.BenefitName = GetTechLineFromPanel().BenefitName) + Dim idx As Integer = ol.IndexOf(item) - If editTechLine.Units.ToLower = "kw" Then + gvTechBenefitLines.FirstDisplayedScrollingRowIndex = idx - ClearEditPanel() - MessageBox.Show("KW Unit types not supported, any KW Units in list are for test purposes only") - Return + cboCategory.DataSource = GetCategories() - End If + UpdateButtonText() + End If - FillTechLineEditPanel(row) + Else + 'This is an update + If Not ssmTOOL.TechList.Modify(editTechLine, GetTechLineFromPanel(), feedback) Then + MessageBox.Show(feedback) + Else + gvTechBenefitLines.Refresh() + ClearEditPanel() + UpdateButtonText() - UpdateButtonText() + End If + End If + End Sub + Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click - End Sub - Private Sub gvTechBenefitLines_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles gvTechBenefitLines.CellClick + If Not ValidateAll() Then Return - If e.ColumnIndex < 0 OrElse e.RowIndex < 0 Then Return + UserHitSave = True + Me.DialogResult = Windows.Forms.DialogResult.OK + Me.Close() + End Sub - If gvTechBenefitLines.Columns(e.ColumnIndex).Name = "Delete" OrElse gvTechBenefitLines.Columns(e.ColumnIndex).Name = "OnVehicle" Then + Private Sub btnClearForm_Click(sender As Object, e As EventArgs) Handles btnClearForm.Click - Dim benefit As String = gvTechBenefitLines.Rows(e.RowIndex).Cells(1).Value - Dim category As String = gvTechBenefitLines.Rows(e.RowIndex).Cells(0).Value - Dim feedback As String = String.Empty + ClearEditPanel() + UpdateButtonText() + End Sub + Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click - Select Case gvTechBenefitLines.Columns(e.ColumnIndex).Name + UserHitCancel = True + Me.Close() + End Sub + Private Sub btnNewBus_Click(sender As Object, e As EventArgs) Handles btnNewBus.Click - Case "Delete" - Dim dr As DialogResult = MessageBox.Show(String.Format("Do you want to delete benefit '{0}' ?", benefit), "", MessageBoxButtons.YesNo) - If dr = Windows.Forms.DialogResult.Yes Then - If ssmTOOL.TechList.Delete(New TechListBenefitLine With {.BenefitName = benefit, .Category = category}, feedback) Then - BindGrid() - End If - End If + If "New".Equals(btnNewBus.Tag) Then - Case "OnVehicle" - Dim onVehicle As Boolean = Not gvTechBenefitLines.Rows(e.RowIndex).Cells(e.ColumnIndex).Value + IsAddingBus = True - Dim fi As TechListBenefitLine = ssmTOOL.TechList.TechLines.Find(Function(f) (f.Category = category) AndAlso f.BenefitName = benefit) - fi.OnVehicle = onVehicle - ' ssmTOOL.TechList.TechLines.First( Function(x) x.BenefitName= benefit AndAlso x.Category=category).OnVehicle=onVehicle - ' BindGrid - gvTechBenefitLines.Refresh() + cboBuses.Enabled = False + btnUpdateBusDatabase.Enabled = False + btnEditBus.Enabled = False + btnCancelBus.Enabled = True + btnNewBus.Text = "Add" + btnNewBus.Tag = "Add" + BusParamGroupModel.Visible = False + BusParamGroupEdit.Visible = True - End Select + ElseIf "Add".Equals(btnNewBus.Tag) Then + If Validate_GeneralInputsBPEdit() Then + Dim newBus As IBus = New Bus(busesList.Count + 1, txtEditBusModel.Text, cmbEditFloorType.Text, + cmbEditEngineType.Text, Double.Parse(txtEditBusLength.Text, CultureInfo.InvariantCulture), + Double.Parse(txtEditBusWidth.Text, CultureInfo.InvariantCulture), + Double.Parse(txtEditBusHeight.Text, CultureInfo.InvariantCulture), + Convert.ToInt32(txtEditBusPassengers.Text), chkEditIsDoubleDecker.Checked) + buses.AddBus(newBus) + busesList.Add(newBus) - End If + cboBuses.Enabled = True + btnUpdateBusDatabase.Enabled = True + btnEditBus.Enabled = True + btnCancelBus.Enabled = False - End Sub - Private Sub gvTechBenefitLines_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles gvTechBenefitLines.CurrentCellDirtyStateChanged + BusParamGroupModel.Visible = True + BusParamGroupEdit.Visible = False + btnNewBus.Text = "New" + btnNewBus.Tag = "New" + cboBuses.SelectedIndex = busesList.Count - 1 - If gvTechBenefitLines.IsCurrentCellDirty Then - gvTechBenefitLines.CommitEdit(DataGridViewDataErrorContexts.Commit) - End If + IsAddingBus = False + End If + End If + End Sub + Private Sub btnUpdateBusDatabase_Click(sender As Object, e As EventArgs) Handles btnUpdateBusDatabase.Click - End Sub + If buses.Save(busDatabasePath) Then + MessageBox.Show("Buses database file saved successfully") + Else + MessageBox.Show("Failed to save buses database file") + End If + End Sub - 'Button Event Handlers - Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click + Private Sub btnEditBus_Click(sender As Object, e As EventArgs) Handles btnEditBus.Click - Dim feedback As String = String.Empty + If cboBuses.SelectedIndex > 0 Then - If Not Validate_TechLineEdit() Then Return + If "Edit".Equals(btnEditBus.Tag) Then - If txtIndex.Text.Trim.Length = 0 Then - 'This is an Add - If Not ssmTOOL.TechList.Add(GetTechLineFromPanel(), feedback) Then - MessageBox.Show(feedback) - Else + IsUpdatingBus = True + cboBuses.Enabled = False + btnUpdateBusDatabase.Enabled = False + btnNewBus.Enabled = False + btnCancelBus.Enabled = True - BindGrid() + btnEditBus.Text = "Save" + btnEditBus.Tag = "Save" - 'find new row - Dim ol As List(Of ITechListBenefitLine) = ssmTOOL.TechList.TechLines.OrderBy(Function(x) x.Category).ThenBy(Function(tb) tb.BenefitName).ToList() - Dim item As ITechListBenefitLine = ol.First(Function(x) x.Category = GetTechLineFromPanel().Category AndAlso x.BenefitName = GetTechLineFromPanel().BenefitName) - Dim idx As Integer = ol.IndexOf(item) + BusParamGroupModel.Visible = False + BusParamGroupEdit.Visible = True - gvTechBenefitLines.FirstDisplayedScrollingRowIndex = idx + Dim bus As IBus = DirectCast(cboBuses.SelectedItem, IBus) - cboCategory.DataSource = GetCategories() + txtEditBusModel.Text = bus.Model + cmbEditFloorType.Text = bus.FloorType + cmbEditEngineType.Text = bus.EngineType + txtEditBusLength.Text = String.Format(CultureInfo.InvariantCulture, "{0}", bus.LengthInMetres) + txtEditBusWidth.Text = String.Format(CultureInfo.InvariantCulture, "{0}", bus.WidthInMetres) + txtEditBusHeight.Text = String.Format(CultureInfo.InvariantCulture, "{0}", bus.HeightInMetres) + txtEditBusPassengers.Text = String.Format(CultureInfo.InvariantCulture, "{0}", bus.RegisteredPassengers) - UpdateButtonText() + ElseIf "Save".Equals(btnEditBus.Tag) Then - End If + If Validate_GeneralInputsBPEdit() Then - Else - 'This is an update - If Not ssmTOOL.TechList.Modify(editTechLine, GetTechLineFromPanel(), feedback) Then - MessageBox.Show(feedback) - Else - gvTechBenefitLines.Refresh() - ClearEditPanel() - UpdateButtonText() + Dim bus As IBus = DirectCast(cboBuses.SelectedItem, IBus) - End If + bus.Model = txtEditBusModel.Text + bus.FloorType = cmbEditFloorType.Text + bus.EngineType = cmbEditEngineType.Text + bus.LengthInMetres = Double.Parse(txtEditBusLength.Text, CultureInfo.InvariantCulture) + bus.WidthInMetres = Double.Parse(txtEditBusWidth.Text, CultureInfo.InvariantCulture) + bus.HeightInMetres = Double.Parse(txtEditBusHeight.Text, CultureInfo.InvariantCulture) + bus.RegisteredPassengers = Integer.Parse(txtEditBusPassengers.Text, CultureInfo.InvariantCulture) + bus.IsDoubleDecker = chkEditIsDoubleDecker.Checked - End If + buses.UpdateBus(bus.Id, bus) - End Sub - Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click + cboBuses.Enabled = True + btnUpdateBusDatabase.Enabled = True + btnNewBus.Enabled = True + btnCancelBus.Enabled = False - If Not ValidateAll() Then Return + BusParamGroupModel.Visible = True + BusParamGroupEdit.Visible = False - UserHitSave = True + btnEditBus.Text = "Edit" + btnEditBus.Tag = "Edit" - Me.DialogResult = Windows.Forms.DialogResult.OK - Me.Close() + Dim currentIndex As Integer = cboBuses.SelectedIndex + cboBuses.SelectedIndex = 0 + cboBuses.SelectedIndex = currentIndex - End Sub - Private Sub btnClearForm_Click(sender As Object, e As EventArgs) Handles btnClearForm.Click + IsUpdatingBus = False + End If - ClearEditPanel() - UpdateButtonText() + End If + End If + End Sub - End Sub - Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click + Private Sub btnCancelBus_Click(sender As Object, e As EventArgs) Handles btnCancelBus.Click + + IsUpdatingBus = False + IsAddingBus = False + + cboBuses.Enabled = True + btnUpdateBusDatabase.Enabled = True + btnNewBus.Enabled = True + btnCancelBus.Enabled = False + + If cboBuses.SelectedIndex > 0 Then + btnEditBus.Enabled = True + End If + + btnEditBus.Text = "Edit" + btnEditBus.Tag = "Edit" + + btnNewBus.Text = "New" + btnNewBus.Tag = "New" + + txtEditBusModel.Text = String.Empty + cmbEditFloorType.Text = String.Empty + cmbEditEngineType.Text = String.Empty + txtEditBusLength.Text = String.Empty + txtEditBusWidth.Text = String.Empty + txtEditBusHeight.Text = String.Empty + txtEditBusPassengers.Text = String.Empty + chkEditIsDoubleDecker.Checked = False + + BusParamGroupModel.Visible = True + BusParamGroupEdit.Visible = False + End Sub + + 'TechList Helpers + Private Sub FillTechLineEditPanel(index As Integer) + + Dim techline As ITechListBenefitLine + Dim benefitName, category As Object + benefitName = gvTechBenefitLines.Rows(index).Cells("BenefitName").Value + category = gvTechBenefitLines.Rows(index).Cells("Category").Value + + techline = + ssmTOOL.TechList.TechLines.First(Function(f) f.BenefitName.Equals(benefitName) AndAlso f.Category.Equals(category)) + + txtIndex.Text = index.ToString() + cboCategory.Text = techline.Category + txtBenefitName.Text = techline.BenefitName + cboUnits.Text = techline.Units + cboLineType.Text = If(techline.LineType = 0, "Normal", "ActiveVentilation") + txtLowFloorH.Text = String.Format(CultureInfo.InvariantCulture, "{0}", techline.LowFloorH) + txtLowFloorV.Text = String.Format(CultureInfo.InvariantCulture, "{0}", techline.LowFloorV) + txtLowFloorC.Text = String.Format(CultureInfo.InvariantCulture, "{0}", techline.LowFloorC) + txtSemiLowFloorH.Text = String.Format(CultureInfo.InvariantCulture, "{0}", techline.SemiLowFloorH) + txtSemiLowFloorV.Text = String.Format(CultureInfo.InvariantCulture, "{0}", techline.SemiLowFloorV) + txtSemiLowFloorC.Text = String.Format(CultureInfo.InvariantCulture, "{0}", techline.SemiLowFloorC) + txtRaisedFloorH.Text = String.Format(CultureInfo.InvariantCulture, "{0}", techline.RaisedFloorH) + txtRaisedFloorV.Text = String.Format(CultureInfo.InvariantCulture, "{0}", techline.RaisedFloorV) + txtRaisedFloorC.Text = String.Format(CultureInfo.InvariantCulture, "{0}", techline.RaisedFloorC) + chkActiveVH.Checked = techline.ActiveVH + chkActiveVV.Checked = techline.ActiveVV + chkActiveVC.Checked = techline.ActiveVC + chkOnVehicle.Checked = techline.OnVehicle + End Sub - UserHitCancel = True - Me.Close() + Private Function GetTechLineFromPanel() As ITechListBenefitLine + + Dim tl As ITechListBenefitLine = New TechListBenefitLine(ssmTOOL.GenInputs) - End Sub - Private Sub btnNewBus_Click(sender As Object, e As EventArgs) Handles btnNewBus.Click + tl.Category = StrConv(cboCategory.Text, vbProperCase) + tl.BenefitName = txtBenefitName.Text + tl.Units = cboUnits.Text + tl.LineType = If(cboLineType.Text = "Normal", TechLineType.Normal, TechLineType.HVCActiveSelection) + tl.LowFloorH = Double.Parse(txtLowFloorH.Text, CultureInfo.InvariantCulture) + tl.LowFloorV = Double.Parse(txtLowFloorV.Text, CultureInfo.InvariantCulture) + tl.LowFloorC = Double.Parse(txtLowFloorC.Text, CultureInfo.InvariantCulture) + tl.SemiLowFloorH = Double.Parse(txtSemiLowFloorH.Text, CultureInfo.InvariantCulture) + tl.SemiLowFloorV = Double.Parse(txtSemiLowFloorV.Text, CultureInfo.InvariantCulture) + tl.SemiLowFloorC = Double.Parse(txtSemiLowFloorC.Text, CultureInfo.InvariantCulture) + tl.RaisedFloorH = Double.Parse(txtRaisedFloorH.Text, CultureInfo.InvariantCulture) + tl.RaisedFloorV = Double.Parse(txtRaisedFloorV.Text, CultureInfo.InvariantCulture) + tl.RaisedFloorC = Double.Parse(txtRaisedFloorC.Text, CultureInfo.InvariantCulture) + tl.ActiveVH = chkActiveVH.Checked + tl.ActiveVV = chkActiveVV.Checked + tl.ActiveVC = chkActiveVC.Checked + tl.OnVehicle = chkOnVehicle.Checked + + + Return tl + End Function + + Private Sub ClearEditPanel() + + txtIndex.Text = String.Empty + cboCategory.SelectedIndex = 0 + txtBenefitName.Text = String.Empty + cboUnits.SelectedIndex = 0 + cboLineType.SelectedIndex = 0 + txtLowFloorH.Text = String.Empty + txtLowFloorV.Text = String.Empty + txtLowFloorC.Text = String.Empty + txtSemiLowFloorH.Text = String.Empty + txtSemiLowFloorV.Text = String.Empty + txtSemiLowFloorC.Text = String.Empty + txtRaisedFloorH.Text = String.Empty + txtRaisedFloorV.Text = String.Empty + txtRaisedFloorC.Text = String.Empty + chkActiveVH.Checked = False + chkActiveVV.Checked = False + chkActiveVC.Checked = False + chkOnVehicle.Checked = False + End Sub + + 'Tab Events + Private Sub tabMain_SelectedIndexChanged(sender As Object, e As EventArgs) Handles tabMain.SelectedIndexChanged + + If tabMain.SelectedIndex = 4 Then + captureDiagnostics = True + End If + End Sub + + 'Timer Events + Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick + + 'Enables the user to instantly see the results of the configuration changes + 'on the top right hand side of the form where it displays the main outputs. + 'The same information is also displayed in the Diagnostics tab where staging + 'results are also available, this is mainly used for testing but could also + 'be used as supporting documentation. + + Try + + If Not ssmTOOL Is Nothing Then + + txtBasElectrical.Text = ssmTOOL.ElectricalWBase.ToString("F4", CultureInfo.InvariantCulture) + txtBaseMechanical.Text = ssmTOOL.MechanicalWBase.ToString("F4", CultureInfo.InvariantCulture) + + txtAdjElectrical.Text = ssmTOOL.ElectricalWAdjusted.ToString("F4", CultureInfo.InvariantCulture) + txtAdjMechanical.Text = ssmTOOL.MechanicalWBaseAdjusted.ToString("F4", CultureInfo.InvariantCulture) + + If captureDiagnostics Then + + txtDiagnostics.Text = ssmTOOL.ToString() + + captureDiagnostics = False + + End If + + End If + + Catch Ex As SystemException + + MessageBox.Show("An unexpected error occured during the timer click recalculation.") + + End Try + End Sub + + Private Sub btnEnvironmentConditionsSource_Click(sender As Object, e As EventArgs) _ + Handles btnEnvironmentConditionsSource.Click + + Dim ecFileBrowser As New cFileBrowser("AAUXEnv", True, False) - If btnNewBus.Tag = "New" Then + ecFileBrowser.Extensions = New String() {"aenv"} - IsAddingBus = True + If ecFileBrowser.OpenDialog(fPATH(vectoFile)) Then - cboBuses.Enabled = False - btnUpdateBusDatabase.Enabled = False - btnEditBus.Enabled = False - btnCancelBus.Enabled = True + txtEC_EnvironmentConditionsFilePath.Tag = ecFileBrowser.Files(0) + txtEC_EnvironmentConditionsFilePath.Text = fFileWoDir(ecFileBrowser.Files(0), fPATH(vectoFile)) + + txtEC_EnvironmentConditionsFilePath.Focus() + txtAH_FuelFiredHeaterkW.Focus() + + End If + End Sub + + Private Sub chkEC_BatchMode_CheckedChanged(sender As Object, e As EventArgs) Handles chkEC_BatchMode.CheckedChanged + + If (chkEC_BatchMode.Checked) Then + txtEC_EnviromentalTemperature.ReadOnly = True + txtEC_Solar.ReadOnly = True + txtEC_EnvironmentConditionsFilePath.ReadOnly = False + btnEnvironmentConditionsSource.Enabled = True + btnOpenAenv.Enabled = True + Else + txtEC_EnviromentalTemperature.ReadOnly = False + txtEC_Solar.ReadOnly = False + txtEC_EnvironmentConditionsFilePath.ReadOnly = True + btnEnvironmentConditionsSource.Enabled = False + btnOpenAenv.Enabled = False + End If + End Sub - btnNewBus.Text = "Add" - btnNewBus.Tag = "Add" + ' File Helpers + Private cmFilesList As String() - BusParamGroupModel.Visible = False - BusParamGroupEdit.Visible = True + Private Sub btnOpenECDB_Click(sender As Object, e As EventArgs) Handles btnOpenAenv.Click + OpenFiles(fFileRepl(Me.txtEC_EnvironmentConditionsFilePath.Text, fPATH(vectoFile))) + End Sub - ElseIf btnNewBus.Tag = "Add" Then + Public Function FileOpenAlt(ByVal file As String) As Boolean + Dim PSI As New ProcessStartInfo - If Validate_GeneralInputsBPEdit() Then - Dim newBus As IBus = New Bus(busesList.Count + 1, txtEditBusModel.Text, cmbEditFloorType.Text, cmbEditEngineType.Text, txtEditBusLength.Text, txtEditBusWidth.Text, txtEditBusHeight.Text, Convert.ToInt32(txtEditBusPassengers.Text), chkEditIsDoubleDecker.Checked) + If Not IO.File.Exists(file) Then Return False - buses.AddBus(newBus) - busesList.Add(newBus) + PSI.FileName = "notepad.exe" + PSI.Arguments = ChrW(34) & file & ChrW(34) + Try + Process.Start(PSI) + Return True + Catch ex As Exception + Return False + End Try + End Function - cboBuses.Enabled = True - btnUpdateBusDatabase.Enabled = True - btnEditBus.Enabled = True - btnCancelBus.Enabled = False + Private Sub OpenFiles(ParamArray files() As String) - BusParamGroupModel.Visible = True - BusParamGroupEdit.Visible = False + If files.Length = 0 Then Exit Sub - btnNewBus.Text = "New" - btnNewBus.Tag = "New" + cmFilesList = files - cboBuses.SelectedIndex = busesList.Count - 1 + CMFiles.Show(Cursor.Position) + End Sub - IsAddingBus = False - End If + Private Sub OpenWithToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Handles OpenWithToolStripMenuItem.Click + If Not FileOpenAlt(cmFilesList(0)) Then MsgBox("Failed to open file!") + End Sub - End If - End Sub - Private Sub btnUpdateBusDatabase_Click(sender As Object, e As EventArgs) Handles btnUpdateBusDatabase.Click - - If buses.Save(busDatabasePath) Then - MessageBox.Show("Buses database file saved successfully") - Else - MessageBox.Show("Failed to save buses database file") - End If - - End Sub - Private Sub btnEditBus_Click(sender As Object, e As EventArgs) Handles btnEditBus.Click - - If cboBuses.SelectedIndex > 0 Then - - If btnEditBus.Tag = "Edit" Then - - IsUpdatingBus = True - - cboBuses.Enabled = False - btnUpdateBusDatabase.Enabled = False - btnNewBus.Enabled = False - btnCancelBus.Enabled = True - - btnEditBus.Text = "Save" - btnEditBus.Tag = "Save" - - BusParamGroupModel.Visible = False - BusParamGroupEdit.Visible = True - - Dim bus As IBus = DirectCast(cboBuses.SelectedItem, IBus) - - txtEditBusModel.Text = bus.Model - cmbEditFloorType.Text = bus.FloorType - cmbEditEngineType.Text = bus.EngineType - txtEditBusLength.Text = bus.LengthInMetres - txtEditBusWidth.Text = bus.WidthInMetres - txtEditBusHeight.Text = bus.HeightInMetres - txtEditBusPassengers.Text = bus.RegisteredPassengers - - ElseIf btnEditBus.Tag = "Save" Then - - If Validate_GeneralInputsBPEdit() Then - - Dim bus As IBus = DirectCast(cboBuses.SelectedItem, IBus) - - bus.Model = txtEditBusModel.Text - bus.FloorType = cmbEditFloorType.Text - bus.EngineType = cmbEditEngineType.Text - bus.LengthInMetres = txtEditBusLength.Text - bus.WidthInMetres = txtEditBusWidth.Text - bus.HeightInMetres = txtEditBusHeight.Text - bus.RegisteredPassengers = txtEditBusPassengers.Text - bus.IsDoubleDecker = chkEditIsDoubleDecker.Checked - - buses.UpdateBus(bus.Id, bus) - - cboBuses.Enabled = True - btnUpdateBusDatabase.Enabled = True - btnNewBus.Enabled = True - btnCancelBus.Enabled = False - - BusParamGroupModel.Visible = True - BusParamGroupEdit.Visible = False - - btnEditBus.Text = "Edit" - btnEditBus.Tag = "Edit" - - Dim currentIndex As Integer = cboBuses.SelectedIndex - cboBuses.SelectedIndex = 0 - cboBuses.SelectedIndex = currentIndex - - IsUpdatingBus = False - End If - - End If - - End If - - End Sub - Private Sub btnCancelBus_Click(sender As Object, e As EventArgs) Handles btnCancelBus.Click - - IsUpdatingBus = False - IsAddingBus = False - - cboBuses.Enabled = True - btnUpdateBusDatabase.Enabled = True - btnNewBus.Enabled = True - btnCancelBus.Enabled = False - - If cboBuses.SelectedIndex > 0 Then - btnEditBus.Enabled = True - End If - - btnEditBus.Text = "Edit" - btnEditBus.Tag = "Edit" - - btnNewBus.Text = "New" - btnNewBus.Tag = "New" - - txtEditBusModel.Text = String.Empty - cmbEditFloorType.Text = String.Empty - cmbEditEngineType.Text = String.Empty - txtEditBusLength.Text = String.Empty - txtEditBusWidth.Text = String.Empty - txtEditBusHeight.Text = String.Empty - txtEditBusPassengers.Text = String.Empty - chkEditIsDoubleDecker.Checked = False - - BusParamGroupModel.Visible = True - BusParamGroupEdit.Visible = False - - End Sub - - 'TechList Helpers - Private Sub FillTechLineEditPanel(index As Integer) - - Dim techline As ITechListBenefitLine - Dim benefitName, category As String - benefitName = gvTechBenefitLines.Rows(index).Cells("BenefitName").Value - category = gvTechBenefitLines.Rows(index).Cells("Category").Value - - techline = ssmTOOL.TechList.TechLines.First(Function(f) f.BenefitName = benefitName AndAlso f.Category = category) - - txtIndex.Text = index - cboCategory.Text = techline.Category - txtBenefitName.Text = techline.BenefitName - cboUnits.Text = techline.Units - cboLineType.Text = If(techline.LineType = 0, "Normal", "ActiveVentilation") - txtLowFloorH.Text = techline.LowFloorH - txtLowFloorV.Text = techline.LowFloorV - txtLowFloorC.Text = techline.LowFloorC - txtSemiLowFloorH.Text = techline.SemiLowFloorH - txtSemiLowFloorV.Text = techline.SemiLowFloorV - txtSemiLowFloorC.Text = techline.SemiLowFloorC - txtRaisedFloorH.Text = techline.RaisedFloorH - txtRaisedFloorV.Text = techline.RaisedFloorV - txtRaisedFloorC.Text = techline.RaisedFloorC - chkActiveVH.Checked = techline.ActiveVH - chkActiveVV.Checked = techline.ActiveVV - chkActiveVC.Checked = techline.ActiveVC - chkOnVehicle.Checked = techline.OnVehicle - - - - End Sub - Private Function GetTechLineFromPanel() As ITechListBenefitLine - - Dim tl As ITechListBenefitLine = New TechListBenefitLine(ssmTOOL.GenInputs) - - - tl.Category = StrConv(cboCategory.Text, vbProperCase) - tl.BenefitName = txtBenefitName.Text - tl.Units = cboUnits.Text - tl.LineType = If(cboLineType.Text = "Normal", 0, 1) - tl.LowFloorH = txtLowFloorH.Text - tl.LowFloorV = txtLowFloorV.Text - tl.LowFloorC = txtLowFloorC.Text - tl.SemiLowFloorH = txtSemiLowFloorH.Text - tl.SemiLowFloorV = txtSemiLowFloorV.Text - tl.SemiLowFloorC = txtSemiLowFloorC.Text - tl.RaisedFloorH = txtRaisedFloorH.Text - tl.RaisedFloorV = txtRaisedFloorV.Text - tl.RaisedFloorC = txtRaisedFloorC.Text - tl.ActiveVH = chkActiveVH.Checked - tl.ActiveVV = chkActiveVV.Checked - tl.ActiveVC = chkActiveVC.Checked - tl.OnVehicle = chkOnVehicle.Checked - - - Return tl - - End Function - Private Sub ClearEditPanel() - - txtIndex.Text = String.Empty - cboCategory.SelectedIndex = 0 - txtBenefitName.Text = String.Empty - cboUnits.SelectedIndex = 0 - cboLineType.SelectedIndex = 0 - txtLowFloorH.Text = String.Empty - txtLowFloorV.Text = String.Empty - txtLowFloorC.Text = String.Empty - txtSemiLowFloorH.Text = String.Empty - txtSemiLowFloorV.Text = String.Empty - txtSemiLowFloorC.Text = String.Empty - txtRaisedFloorH.Text = String.Empty - txtRaisedFloorV.Text = String.Empty - txtRaisedFloorC.Text = String.Empty - chkActiveVH.Checked = False - chkActiveVV.Checked = False - chkActiveVC.Checked = False - chkOnVehicle.Checked = False - - End Sub - - 'Tab Events - Private Sub tabMain_SelectedIndexChanged(sender As Object, e As EventArgs) Handles tabMain.SelectedIndexChanged - - If tabMain.SelectedIndex = 4 Then - captureDiagnostics = True - End If - - End Sub - - 'Timer Events - Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick - - 'Enables the user to instantly see the results of the configuration changes - 'on the top right hand side of the form where it displays the main outputs. - 'The same information is also displayed in the Diagnostics tab where staging - 'results are also available, this is mainly used for testing but could also - 'be used as supporting documentation. - - Try - - If Not ssmTOOL Is Nothing Then - - txtBasElectrical.Text = ssmTOOL.ElectricalWBase - txtBaseMechanical.Text = ssmTOOL.MechanicalWBase - - txtAdjElectrical.Text = ssmTOOL.ElectricalWAdjusted - txtAdjMechanical.Text = ssmTOOL.MechanicalWBaseAdjusted - - If captureDiagnostics Then - - txtDiagnostics.Text = ssmTOOL.ToString() - - captureDiagnostics = False - - End If - - End If - - Catch Ex As SystemException - - MessageBox.Show("An unexpected error occured during the timer click recalculation.") - - End Try - - - - - - - End Sub - - Private Sub btnEnvironmentConditionsSource_Click(sender As Object, e As EventArgs) Handles btnEnvironmentConditionsSource.Click - - Dim ecFileBrowser As New cFileBrowser(True, False) - - ecFileBrowser.Extensions = New String() {"aenv"} - - If ecFileBrowser.OpenDialog(fPATH(vectoFile)) Then - - txtEC_EnvironmentConditionsFilePath.Tag = ecFileBrowser.Files(0) - txtEC_EnvironmentConditionsFilePath.Text = fFileWoDir(ecFileBrowser.Files(0), fPATH(vectoFile)) - - txtEC_EnvironmentConditionsFilePath.Focus() - txtAH_FuelFiredHeaterkW.Focus() - - End If - - - End Sub - - Private Sub chkEC_BatchMode_CheckedChanged(sender As Object, e As EventArgs) Handles chkEC_BatchMode.CheckedChanged - - If (chkEC_BatchMode.Checked) Then - txtEC_EnviromentalTemperature.ReadOnly = True - txtEC_Solar.ReadOnly = True - txtEC_EnvironmentConditionsFilePath.ReadOnly = False - btnEnvironmentConditionsSource.Enabled = True - btnOpenAenv.Enabled = True - Else - txtEC_EnviromentalTemperature.ReadOnly = False - txtEC_Solar.ReadOnly = False - txtEC_EnvironmentConditionsFilePath.ReadOnly = True - btnEnvironmentConditionsSource.Enabled = False - btnOpenAenv.Enabled = False - End If - - End Sub - - ' File Helpers - Private cmFilesList As String() - - Private Sub btnOpenECDB_Click(sender As Object, e As EventArgs) Handles btnOpenAenv.Click - OpenFiles(fFileRepl(Me.txtEC_EnvironmentConditionsFilePath.Text, fPATH(vectoFile))) - End Sub - - Public Function FileOpenAlt(ByVal file As String) As Boolean - Dim PSI As New ProcessStartInfo - - If Not IO.File.Exists(file) Then Return False - - PSI.FileName = "notepad.exe" - PSI.Arguments = ChrW(34) & file & ChrW(34) - Try - Process.Start(PSI) - Return True - Catch ex As Exception - Return False - End Try - - End Function - - Private Sub OpenFiles(ParamArray files() As String) - - If files.Length = 0 Then Exit Sub - - cmFilesList = files - - CMFiles.Show(Cursor.Position) - - End Sub - - Private Sub OpenWithToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles OpenWithToolStripMenuItem.Click - If Not FileOpenAlt(cmFilesList(0)) Then MsgBox("Failed to open file!") - End Sub - Private Sub ShowInFolderToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ShowInFolderToolStripMenuItem.Click - If IO.File.Exists(cmFilesList(0)) Then - Try - System.Diagnostics.Process.Start("explorer", "/select,""" & cmFilesList(0) & "") - Catch ex As Exception - MsgBox("Failed to open file!") - End Try - Else - MsgBox("File not found!") - End If - End Sub - - + Private Sub ShowInFolderToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) _ + Handles ShowInFolderToolStripMenuItem.Click + If IO.File.Exists(cmFilesList(0)) Then + Try + System.Diagnostics.Process.Start("explorer", "/select,""" & cmFilesList(0) & "") + Catch ex As Exception + MsgBox("Failed to open file!") + End Try + Else + MsgBox("File not found!") + End If + End Sub End Class diff --git a/VECTOAux/VectoAuxiliaries/VectoAuxiliaries.vbproj b/VECTOAux/VectoAuxiliaries/VectoAuxiliaries.vbproj index dc3d8f96afc4b93b7c26ad600a0ce05f1da7c4fb..e61be0c184f832033912a46b7b71b0ad39ce91fa 100644 --- a/VECTOAux/VectoAuxiliaries/VectoAuxiliaries.vbproj +++ b/VECTOAux/VectoAuxiliaries/VectoAuxiliaries.vbproj @@ -10,7 +10,7 @@ <AssemblyName>BusAuxiliaries</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Windows</MyType> - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkProfile /> <SccProjectName>SAK</SccProjectName> <SccLocalPath>SAK</SccLocalPath> @@ -24,7 +24,10 @@ <DefineTrace>true</DefineTrace> <OutputPath>bin\Debug\</OutputPath> <DocumentationFile>BusAuxiliaries.xml</DocumentationFile> - <NoWarn>41999,42016,42017,42018,42019,42032,42036</NoWarn> + <NoWarn> + </NoWarn> + <WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors> + <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -33,7 +36,10 @@ <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DocumentationFile>BusAuxiliaries.xml</DocumentationFile> - <NoWarn>41999,42016,42017,42018,42019,42032,42036</NoWarn> + <NoWarn> + </NoWarn> + <WarningsAsErrors>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</WarningsAsErrors> + <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> @@ -42,7 +48,7 @@ <OptionCompare>Binary</OptionCompare> </PropertyGroup> <PropertyGroup> - <OptionStrict>Off</OptionStrict> + <OptionStrict>On</OptionStrict> </PropertyGroup> <PropertyGroup> <OptionInfer>Off</OptionInfer> @@ -289,6 +295,10 @@ <Project>{b4b9bd2f-fd8f-4bb8-82fa-e2154d2c7fbd}</Project> <Name>AdvancedAuxiliaryInterfaces</Name> </ProjectReference> + <ProjectReference Include="..\..\VectoCommon\VectoCommon\VectoCommon.csproj"> + <Project>{79a066ad-69a9-4223-90f6-6ed5d2d084f4}</Project> + <Name>VectoCommon</Name> + </ProjectReference> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. diff --git a/VECTOAux/VectoAuxiliaries/packages.config b/VECTOAux/VectoAuxiliaries/packages.config index c3b630348e6dc8748b8b841409bbf0574781c609..be681bd91116254cc7d9dcb27afb1ab1666a60fa 100644 --- a/VECTOAux/VectoAuxiliaries/packages.config +++ b/VECTOAux/VectoAuxiliaries/packages.config @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> + <packages> + <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net40" requireReinstallation="True" /> <package id="valueinjecter" version="2.3.3" targetFramework="net40" /> - <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net40" /> </packages> \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb b/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb index f22dc7e58f04f2a1ca9c129e5894cf80505316ac..51a3f030a2d3b6957c5785d6d41aeca604d4d8ef 100644 --- a/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb +++ b/VECTOAux/VectoAuxiliariesTests/IntegrationTests/AuxDemandTest.vb @@ -1,5 +1,6 @@ Imports System.IO Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries Namespace IntegrationTests @@ -11,16 +12,15 @@ Namespace IntegrationTests <TestCase(12000, 1256, -15, -50, 8954.1435)> <TestCase(15700, 1319, -35.79263, -144.0441, 9093.9511)> Public Sub AuxDemnadTest(vehicleWeight As Double, engineSpeed As Double, driveLinePower As Double, - internalPower As Double, - expectedPowerDemand As Double) + internalPower As Double, expectedPowerDemand As Double) Dim engineFCMapFilePath = "TestFiles\Integration\24t Coach.vmap" Dim auxFilePath = "TestFiles\Integration\AdvAuxTest.aaux" Dim aux As AdvancedAuxiliaries = New AdvancedAuxiliaries aux.VectoInputs.Cycle = "Coach" - aux.VectoInputs.VehicleWeightKG = vehicleWeight - aux.VectoInputs.FuelDensity = 0.832 + aux.VectoInputs.VehicleWeightKG = vehicleWeight.SI(Of Kilogram)() + aux.VectoInputs.FuelDensity = 832.SI(Of KilogramPerCubicMeter)() Dim fuelMap As cMAP = New cMAP() fuelMap.FilePath = engineFCMapFilePath fuelMap.ReadFile(False) @@ -30,25 +30,25 @@ Namespace IntegrationTests aux.Signals.TotalCycleTimeSeconds = 15000 - aux.Signals.EngineIdleSpeed = 560 + aux.Signals.EngineIdleSpeed = 560.RPMtoRad() aux.Initialise(Path.GetFileName(auxFilePath), Path.GetDirectoryName(Path.GetFullPath(auxFilePath)) + "\") aux.Signals.ClutchEngaged = True - aux.Signals.EngineDrivelinePower = driveLinePower 'kW - aux.Signals.EngineSpeed = engineSpeed 'rpm - aux.Signals.EngineDrivelineTorque = driveLinePower * 1000 / (engineSpeed * 2 * Math.PI / 60) - aux.Signals.EngineMotoringPower = 24 'kW - has to be positive + aux.Signals.EngineDrivelinePower = (driveLinePower * 1000).SI(Of Watt)() 'kW + aux.Signals.EngineSpeed = engineSpeed.RPMtoRad() 'rpm + aux.Signals.EngineDrivelineTorque = (driveLinePower * 1000).SI(Of Watt)() / (engineSpeed.RPMtoRad()) + aux.Signals.EngineMotoringPower = (24 * 1000).SI(Of Watt)() 'kW - has to be positive - aux.Signals.PreExistingAuxPower = 6.1 + aux.Signals.PreExistingAuxPower = (6.1 * 1000).SI(Of Watt)() aux.Signals.Idle = False aux.Signals.InNeutral = False aux.Signals.RunningCalc = True - aux.Signals.Internal_Engine_Power = internalPower 'kW + aux.Signals.InternalEnginePower = (internalPower * 1000).SI(Of Watt)() 'kW - Dim power As Single = aux.AuxiliaryPowerAtCrankWatts + Dim power As Watt = aux.AuxiliaryPowerAtCrankWatts() - Assert.AreEqual(expectedPowerDemand, power, 0.001) + Assert.AreEqual(expectedPowerDemand, power.Value(), 0.001) End Sub <Test> @@ -65,8 +65,8 @@ Namespace IntegrationTests Dim aux As AdvancedAuxiliaries = New AdvancedAuxiliaries aux.VectoInputs.Cycle = "Coach" - aux.VectoInputs.VehicleWeightKG = 12000 - aux.VectoInputs.FuelDensity = 0.832 + aux.VectoInputs.VehicleWeightKG = 12000.SI(Of Kilogram)() + aux.VectoInputs.FuelDensity = 832.SI(Of KilogramPerCubicMeter)() Dim fuelMap As cMAP = New cMAP() fuelMap.FilePath = engineFCMapFilePath fuelMap.ReadFile(False) @@ -76,51 +76,53 @@ Namespace IntegrationTests aux.Signals.TotalCycleTimeSeconds = 15000 - aux.Signals.EngineIdleSpeed = 560 + aux.Signals.EngineIdleSpeed = 560.RPMtoRad() aux.Initialise(Path.GetFileName(auxFilePath), Path.GetDirectoryName(Path.GetFullPath(auxFilePath)) + "\") aux.Signals.ClutchEngaged = True - aux.Signals.EngineDrivelinePower = driveLinePower 'kW - aux.Signals.EngineSpeed = engineSpeed 'rpm - aux.Signals.EngineDrivelineTorque = driveLinePower * 1000 / (1256 * 2 * Math.PI / 60) - aux.Signals.EngineMotoringPower = 24 'kW - has to be positive + aux.Signals.EngineDrivelinePower = (driveLinePower * 1000).SI(Of Watt)() 'kW + aux.Signals.EngineSpeed = engineSpeed.RPMtoRad() 'rpm + aux.Signals.EngineDrivelineTorque = (driveLinePower * 1000).SI(Of Watt)() / (1256.RPMtoRad()) + aux.Signals.EngineMotoringPower = (24 * 1000).SI(Of Watt)() 'kW - has to be positive - aux.Signals.PreExistingAuxPower = 0 + aux.Signals.PreExistingAuxPower = 0.SI(Of Watt)() aux.Signals.Idle = False aux.Signals.InNeutral = False aux.Signals.RunningCalc = True - aux.Signals.Internal_Engine_Power = internalPower 'kW + aux.Signals.InternalEnginePower = (internalPower * 1000).SI(Of Watt)() 'kW Dim msg As String = String.Empty For i As Integer = 0 To 9 - Assert.AreEqual(6087.0317, aux.AuxiliaryPowerAtCrankWatts, 0.001) - aux.CycleStep(1, msg) + Assert.AreEqual(6087.0317, aux.AuxiliaryPowerAtCrankWatts().Value(), 0.001) + aux.CycleStep(1.SI(Of Second), msg) + Debug.Print("{0}", aux.AA_TotalCycleFC_Grams) Next - Assert.AreEqual(79.303, aux.AA_TotalCycleFC_Grams, 0.0001) + Assert.AreEqual(79.303.SI().Gramm.Value(), aux.AA_TotalCycleFC_Grams().Value(), 0.0001) - aux.Signals.EngineDrivelinePower = -15 - aux.Signals.EngineDrivelineTorque = aux.Signals.EngineDrivelinePower * 1000 / (1256 * 2 * Math.PI / 60) - aux.Signals.Internal_Engine_Power = -50 + aux.Signals.EngineDrivelinePower = (-15 * 1000).SI(Of Watt)() + aux.Signals.EngineDrivelineTorque = aux.Signals.EngineDrivelinePower / (1256.RPMtoRad()) + aux.Signals.InternalEnginePower = (-50 * 1000).SI(Of Watt)() For i As Integer = 0 To 9 - Assert.AreEqual(8954.1435, aux.AuxiliaryPowerAtCrankWatts, 0.001) - aux.CycleStep(1, msg) + Assert.AreEqual(8954.1435, aux.AuxiliaryPowerAtCrankWatts().Value(), 0.001) + aux.CycleStep(1.SI(Of Second), msg) + Debug.Print("{0}", aux.AA_TotalCycleFC_Grams) Next - Assert.AreEqual(82.5783, aux.AA_TotalCycleFC_Grams, 0.0001) + Assert.AreEqual(82.5783.SI().Gramm.Value(), aux.AA_TotalCycleFC_Grams().Value(), 0.0001) - aux.Signals.EngineDrivelinePower = driveLinePower - aux.Signals.EngineDrivelineTorque = aux.Signals.EngineDrivelinePower * 1000 / (1256 * 2 * Math.PI / 60) - aux.Signals.Internal_Engine_Power = internalPower + aux.Signals.EngineDrivelinePower = (driveLinePower * 1000).SI(Of Watt)() + aux.Signals.EngineDrivelineTorque = aux.Signals.EngineDrivelinePower / (1256.RPMtoRad()) + aux.Signals.InternalEnginePower = (internalPower * 1000).SI(Of Watt)() 'kW For i As Integer = 0 To 9 - Assert.AreEqual(6087.0317, aux.AuxiliaryPowerAtCrankWatts, 0.001) - aux.CycleStep(1, msg) + Assert.AreEqual(6087.0317, aux.AuxiliaryPowerAtCrankWatts().Value(), 0.001) + aux.CycleStep(1.SI(Of Second), msg) Next - Assert.AreEqual(162.4655, aux.AA_TotalCycleFC_Grams, 0.0001) + Assert.AreEqual(162.4655.SI().Gramm.Value(), aux.AA_TotalCycleFC_Grams().Value(), 0.0001) End Sub End Class End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/AlternatorMapMock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/AlternatorMapMock.vb index d94cd72e60793fe5d28f3a8459788d8ed6e55da8..99df79b2500a3a5dbbf232c825d41352bce00469 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/AlternatorMapMock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/AlternatorMapMock.vb @@ -1,35 +1,36 @@ -Imports VectoAuxiliaries.Electrics +Imports TUGraz.VectoCommon.Utils +Imports VectoAuxiliaries.Electrics Namespace Mocks - Public Class AlternatorMapMock - Implements IAlternatorMap + Public Class AlternatorMapMock + Implements IAlternatorMap - Dim failing As Boolean + Dim failing As Boolean - Public Sub New(ByVal isFailing As Boolean) - failing = isFailing - End Sub + Public Sub New(ByVal isFailing As Boolean) + failing = isFailing + End Sub - Public Function Initialise() As Boolean Implements IAlternatorMap.Initialise - If failing Then - Throw New ArgumentException - Else - Return True - End If - End Function + Public Function Initialise() As Boolean Implements IAlternatorMap.Initialise + If failing Then + Throw New ArgumentException + Else + Return True + End If + End Function - Public Function GetEfficiency(ByVal rpm As single, ByVal amps As single) As AlternatorMapValues Implements IAlternatorMap.GetEfficiency - Return New AlternatorMapValues() - End Function + Public Function GetEfficiency(rpm1 As Double, amps1 As Ampere) As AlternatorMapValues Implements IAlternatorMap.GetEfficiency + Return New AlternatorMapValues() + End Function - Public Event AuxiliaryEvent(ByRef sender As Object, message As String, messageType As VectoAuxiliaries.AdvancedAuxiliaryMessageType) Implements VectoAuxiliaries.IAuxiliaryEvent.AuxiliaryEvent + Public Event AuxiliaryEvent(ByRef sender As Object, message As String, messageType As VectoAuxiliaries.AdvancedAuxiliaryMessageType) Implements VectoAuxiliaries.IAuxiliaryEvent.AuxiliaryEvent - End Class + End Class End Namespace diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/CompressorMapMock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/CompressorMapMock.vb index f726848898c80af4d0d48d2b373103182d4d0bce..f78f43a9a8a8b659be61479230e4ef11a94b7db1 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/CompressorMapMock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/CompressorMapMock.vb @@ -1,4 +1,5 @@ -Imports VectoAuxiliaries +Imports TUGraz.VectoCommon.Utils +Imports VectoAuxiliaries Imports VectoAuxiliaries.Pneumatics Namespace Mocks @@ -19,20 +20,20 @@ Namespace Mocks End If End Function - Public Function GetFlowRate(ByVal rpm As Double) As Single Implements ICompressorMap.GetFlowRate - Return 2.0 + Public Function GetFlowRate(ByVal rpm As Double) As NormLiterPerSecond Implements ICompressorMap.GetFlowRate + Return 2.0.SI(Of NormLiterPerSecond)() End Function - Public Function GetPowerCompressorOn(ByVal rpm As Double) As Single Implements ICompressorMap.GetPowerCompressorOn - Return 8.0 + Public Function GetPowerCompressorOn(ByVal rpm As Double) As Watt Implements ICompressorMap.GetPowerCompressorOn + Return 8.0.SI(Of Watt)() End Function - Public Function GetPowerCompressorOff(ByVal rpm As Double) As Single Implements ICompressorMap.GetPowerCompressorOff - Return 5.0 + Public Function GetPowerCompressorOff(ByVal rpm As Double) As Watt Implements ICompressorMap.GetPowerCompressorOff + Return 5.0.SI(Of Watt)() End Function - Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Single _ + Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Double _ Implements ICompressorMap.GetAveragePowerDemandPerCompressorUnitFlowRate Return 0.01 diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/ElectricalConsumerMock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/ElectricalConsumerMock.vb index 9fbc70024211845da23629d900dcaba60802e1c1..ac0e67d58b37ef2c83ba6ac07679bf4283f404e8 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/ElectricalConsumerMock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/ElectricalConsumerMock.vb @@ -1,48 +1,47 @@ Imports VectoAuxiliaries.Electrics Imports System.ComponentModel +Imports TUGraz.VectoCommon.Utils Namespace Mocks + Public Class ElectricalConsumerMock + Implements IElectricalConsumer - Public Class ElectricalConsumerMock - Implements IElectricalConsumer + Public Property AvgConsumptionAmps As Double Implements IElectricalConsumer.AvgConsumptionAmps - Public Property AvgConsumptionAmps As Single Implements IElectricalConsumer.AvgConsumptionAmps + Public Property BaseVehicle As Boolean Implements IElectricalConsumer.BaseVehicle - Public Property BaseVehicle As Boolean Implements IElectricalConsumer.BaseVehicle + Public Property Category As String Implements IElectricalConsumer.Category - Public Property Category As String Implements IElectricalConsumer.Category + Public Property ConsumerName As String Implements IElectricalConsumer.ConsumerName - Public Property ConsumerName As String Implements IElectricalConsumer.ConsumerName + Public Property NominalConsumptionAmps As Double Implements IElectricalConsumer.NominalConsumptionAmps - Public Property NominalConsumptionAmps As Single Implements IElectricalConsumer.NominalConsumptionAmps + Public Property NumberInActualVehicle As Integer Implements IElectricalConsumer.NumberInActualVehicle - Public Property NumberInActualVehicle As Integer Implements IElectricalConsumer.NumberInActualVehicle + Public Property PhaseIdle_TractionOn As Double Implements IElectricalConsumer.PhaseIdle_TractionOn - Public Property PhaseIdle_TractionOn As Single Implements IElectricalConsumer.PhaseIdle_TractionOn + Public Property PowerNetVoltage As Double Implements IElectricalConsumer.PowerNetVoltage - Public Property PowerNetVoltage As Single Implements IElectricalConsumer.PowerNetVoltage + Public Function TotalAvgConumptionAmps(Optional PhaseIdle_TractionOnBasedOnCycle As Double = Nothing) As Ampere _ + Implements IElectricalConsumer.TotalAvgConumptionAmps + Return 9.SI(Of Ampere)() + End Function - Public Function TotalAvgConumptionAmps(Optional PhaseIdle_TractionOnBasedOnCycle As Single = 0.0) As Single Implements IElectricalConsumer.TotalAvgConumptionAmps - Return 9 - End Function + Public Function TotalAvgConsumptionInWatts(Optional PhaseIdle_TractionOnBasedOnCycle As Double = 0.0) As Watt _ + Implements IElectricalConsumer.TotalAvgConsumptionInWatts - Public Function TotalAvgConsumptionInWatts(Optional PhaseIdle_TractionOnBasedOnCycle As Single = 0.0) As Single Implements IElectricalConsumer.TotalAvgConsumptionInWatts + Return (9 * 26.3).SI(Of Watt)() + End Function - Return 9 * 26.3 - End Function + Public Property Info As String Implements IElectricalConsumer.Info + Public Event PropertyChanged As PropertyChangedEventHandler _ + Implements INotifyPropertyChanged.PropertyChanged - Public Property Info As String Implements IElectricalConsumer.Info - - Public Event PropertyChanged As PropertyChangedEventHandler _ - Implements INotifyPropertyChanged.PropertyChanged - - Private Sub NotifyPropertyChanged(p As String) - RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(p)) - End Sub - - End Class - + Private Sub NotifyPropertyChanged(p As String) + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(p)) + End Sub + End Class End Namespace diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/M1_Mock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/M1_Mock.vb index ec7cfd4ad555f92aa2e69858a0f0939618995cbd..c5e3815812e9a90deef961d7a280c544876b7fa9 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/M1_Mock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/M1_Mock.vb @@ -1,4 +1,5 @@  +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac @@ -6,51 +7,49 @@ Imports VectoAuxiliaries.DownstreamModules Public Class M1_Mock -Implements IM1_AverageHVACLoadDemand - -Public _AveragePowerDemandAtAlternatorFromHVACElectricsWatts As Single -public _AveragePowerDemandAtCrankFromHVACElectricsWatts As single -Public _AveragePowerDemandAtCrankFromHVACMechanicalsWatts As Single -Public _HVACFuelingLitresPerHour As single - - Public Function AveragePowerDemandAtAlternatorFromHVACElectricsWatts() As Single Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtAlternatorFromHVACElectricsWatts - Return _AveragePowerDemandAtAlternatorFromHVACElectricsWatts - End Function - - Public Function AveragePowerDemandAtCrankFromHVACElectricsWatts() As Single Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtCrankFromHVACElectricsWatts - Return _AveragePowerDemandAtCrankFromHVACElectricsWatts - End Function - - Public Function AveragePowerDemandAtCrankFromHVACMechanicalsWatts() As Single Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtCrankFromHVACMechanicalsWatts - Return _AveragePowerDemandAtCrankFromHVACMechanicalsWatts - End Function - - Public Function HVACFuelingLitresPerHour() As Single Implements IM1_AverageHVACLoadDemand.HVACFuelingLitresPerHour - Return _HVACFuelingLitresPerHour - End Function - - - -Public Sub new() - -End Sub - -Public Sub new ( AveragePowerDemandAtAlternatorFromHVACElectricsWatts As Single, _ - AveragePowerDemandAtCrankFromHVACElectricsWatts As single, _ - AveragePowerDemandAtCrankFromHVACMechanicalsWatts As Single, _ - HVACFuelingLitresPerHour As single) - - 'Assign Values - _AveragePowerDemandAtAlternatorFromHVACElectricsWatts = AveragePowerDemandAtAlternatorFromHVACElectricsWatts - _AveragePowerDemandAtCrankFromHVACElectricsWatts = AveragePowerDemandAtCrankFromHVACElectricsWatts - _AveragePowerDemandAtCrankFromHVACMechanicalsWatts = AveragePowerDemandAtCrankFromHVACMechanicalsWatts - _HVACFuelingLitresPerHour = HVACFuelingLitresPerHour - - -End Sub - - - - + Implements IM1_AverageHVACLoadDemand + + Public _AveragePowerDemandAtAlternatorFromHVACElectricsWatts As Watt + Public _AveragePowerDemandAtCrankFromHVACElectricsWatts As Watt + Public _AveragePowerDemandAtCrankFromHVACMechanicalsWatts As Watt + Public _HVACFuelingLitresPerHour As LiterPerSecond + + Public Function AveragePowerDemandAtAlternatorFromHVACElectricsWatts() As Watt _ + Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtAlternatorFromHVACElectricsWatts + Return _AveragePowerDemandAtAlternatorFromHVACElectricsWatts + End Function + + Public Function AveragePowerDemandAtCrankFromHVACElectricsWatts() As Watt _ + Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtCrankFromHVACElectricsWatts + Return _AveragePowerDemandAtCrankFromHVACElectricsWatts + End Function + + Public Function AveragePowerDemandAtCrankFromHVACMechanicalsWatts() As Watt _ + Implements IM1_AverageHVACLoadDemand.AveragePowerDemandAtCrankFromHVACMechanicalsWatts + Return _AveragePowerDemandAtCrankFromHVACMechanicalsWatts + End Function + + Public Function HVACFuelingLitresPerHour() As LiterPerSecond _ + Implements IM1_AverageHVACLoadDemand.HVACFuelingLitresPerHour + Return _HVACFuelingLitresPerHour + End Function + + + Public Sub New() + End Sub + + Public Sub New(AveragePowerDemandAtAlternatorFromHVACElectricsWatts As Double, + AveragePowerDemandAtCrankFromHVACElectricsWatts As Double, + AveragePowerDemandAtCrankFromHVACMechanicalsWatts As Double, + HVACFuelingLitresPerHour As Double) + + 'Assign Values + _AveragePowerDemandAtAlternatorFromHVACElectricsWatts = + AveragePowerDemandAtAlternatorFromHVACElectricsWatts.SI(Of Watt)() + _AveragePowerDemandAtCrankFromHVACElectricsWatts = AveragePowerDemandAtCrankFromHVACElectricsWatts.SI(Of Watt)() + _AveragePowerDemandAtCrankFromHVACMechanicalsWatts = AveragePowerDemandAtCrankFromHVACMechanicalsWatts.SI(Of Watt)() + _HVACFuelingLitresPerHour = HVACFuelingLitresPerHour.SI().Liter.Per.Hour.Cast(Of LiterPerSecond)() _ + '(Of LiterPerHour)() + End Sub End Class diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/M2_Mock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/M2_Mock.vb index 14b4ad5464967d7eeba82beadc6830af0ad1c83f..e555250bf37b42e723a7985e69793943ef09084d 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/M2_Mock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/M2_Mock.vb @@ -1,39 +1,36 @@ -Imports VectoAuxiliaries.Electrics +Imports TUGraz.VectoCommon.Utils +Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Imports VectoAuxiliaries.DownstreamModules Public Class M2_Mock -Implements IM2_AverageElectricalLoadDemand + Implements IM2_AverageElectricalLoadDemand + Public _GetAveragePowerAtCrankFromElectrics As Watt + Public _GetAveragePowerDemandAtAlternator As Watt -Public _GetAveragePowerAtCrankFromElectrics As Single -Public _GetAveragePowerDemandAtAlternator As Single + Public Function GetAveragePowerAtCrankFromElectrics() As Watt _ + Implements IM2_AverageElectricalLoadDemand.GetAveragePowerAtCrankFromElectrics + Return _GetAveragePowerAtCrankFromElectrics + End Function + Public Function GetAveragePowerDemandAtAlternator() As Watt _ + Implements IM2_AverageElectricalLoadDemand.GetAveragePowerDemandAtAlternator + Return _GetAveragePowerDemandAtAlternator + End Function - Public Function GetAveragePowerAtCrankFromElectrics() As Single Implements IM2_AverageElectricalLoadDemand.GetAveragePowerAtCrankFromElectrics - Return _GetAveragePowerAtCrankFromElectrics - End Function - Public Function GetAveragePowerDemandAtAlternator() As Single Implements IM2_AverageElectricalLoadDemand.GetAveragePowerDemandAtAlternator - Return _GetAveragePowerDemandAtAlternator - End Function + Public Sub New() + End Sub -Public Sub new() - -End Sub - - -Public Sub new ( GetAveragePowerAtCrankFromElectrics As Single,GetAveragePowerDemandAtAlternator As single ) - - - _GetAveragePowerAtCrankFromElectrics = GetAveragePowerAtCrankFromElectrics - _GetAveragePowerDemandAtAlternator = GetAveragePowerDemandAtAlternator - -End Sub + Public Sub New(GetAveragePowerAtCrankFromElectrics As Double, GetAveragePowerDemandAtAlternator As Double) + _GetAveragePowerAtCrankFromElectrics = GetAveragePowerAtCrankFromElectrics.SI(Of Watt)() + _GetAveragePowerDemandAtAlternator = GetAveragePowerDemandAtAlternator.SI(Of Watt)() + End Sub End Class diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/M3_Mock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/M3_Mock.vb index 9067cef65a1e26932b9c6d9930e7a65a0d71b7c6..c7d3bd5e9f70bb10c5985934395ffb2808729113 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/M3_Mock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/M3_Mock.vb @@ -1,37 +1,34 @@ -Imports VectoAuxiliaries.Electrics +Imports TUGraz.VectoCommon.Utils +Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Imports VectoAuxiliaries.DownstreamModules Public Class M3_Mock - Implements IM3_AveragePneumaticLoadDemand + Implements IM3_AveragePneumaticLoadDemand - public _GetAveragePowerDemandAtCrankFromPneumatics as single - public _TotalAirConsumedPerCycle as single + Public _GetAveragePowerDemandAtCrankFromPneumatics As Watt + Public _TotalAirConsumedPerCycle As NormLiterPerSecond - Public Function GetAveragePowerDemandAtCrankFromPneumatics() As Single Implements IM3_AveragePneumaticLoadDemand.GetAveragePowerDemandAtCrankFromPneumatics - Return _GetAveragePowerDemandAtCrankFromPneumatics - End Function + Public Function GetAveragePowerDemandAtCrankFromPneumatics() As Watt _ + Implements IM3_AveragePneumaticLoadDemand.GetAveragePowerDemandAtCrankFromPneumatics + Return _GetAveragePowerDemandAtCrankFromPneumatics + End Function - Public Function TotalAirConsumedPerCycle() As Single Implements IM3_AveragePneumaticLoadDemand.AverageAirConsumedPerSecondLitre - Return _TotalAirConsumedPerCycle - End Function + Public Function TotalAirConsumedPerCycle() As NormLiterPerSecond _ + Implements IM3_AveragePneumaticLoadDemand.AverageAirConsumedPerSecondLitre + Return _TotalAirConsumedPerCycle + End Function + Public Sub New() + End Sub -Public Sub new() - -End Sub - -Public Sub new ( GetAveragePowerDemandAtCrankFromPneumatics As Single,TotalAirConsumedPerCycle As single ) - -_GetAveragePowerDemandAtCrankFromPneumatics= GetAveragePowerDemandAtCrankFromPneumatics -_TotalAirConsumedPerCycle = TotalAirConsumedPerCycle - -End Sub - - + Public Sub New(GetAveragePowerDemandAtCrankFromPneumatics As Double, TotalAirConsumedPerCycle As Double) + _GetAveragePowerDemandAtCrankFromPneumatics = GetAveragePowerDemandAtCrankFromPneumatics.SI(Of Watt)() + _TotalAirConsumedPerCycle = TotalAirConsumedPerCycle.SI(Of NormLiterPerSecond)() + End Sub End Class diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/M4_Mock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/M4_Mock.vb index 513ec0a8d06017c1b5fed1832e99e1cb3a2afba7..7eb7e8e7447dfd252a0d14a980b5a6f6f8565227 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/M4_Mock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/M4_Mock.vb @@ -1,65 +1,66 @@ -Imports VectoAuxiliaries.Electrics +Imports TUGraz.VectoCommon.Utils +Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Imports VectoAuxiliaries.DownstreamModules Public Class M4_Mock - Implements IM4_AirCompressor - - -Public Property _AveragePowerDemandPerCompressorUnitFlowRate As Single -Public Property _FlowRate As Single -Public Property _PowerCompressorOff As single -Public Property _PowerCompressorOn As Single -Public Property _PowerDifference As single - - Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As Single Implements IM4_AirCompressor.GetAveragePowerDemandPerCompressorUnitFlowRate - Return _AveragePowerDemandPerCompressorUnitFlowRate - End Function - - Public Function GetFlowRate() As Single Implements IM4_AirCompressor.GetFlowRate - Return _FlowRate - End Function - - Public Function GetPowerCompressorOff() As Single Implements IM4_AirCompressor.GetPowerCompressorOff - Return _PowerCompressorOff - End Function - - Public Function PowerCompressorOn() As Single Implements IM4_AirCompressor.GetPowerCompressorOn - Return _PowerCompressorOn - End Function - - Public Function GetPowerDifference() As Single Implements IM4_AirCompressor.GetPowerDifference - Return _PowerDifference - End Function - - - Public Sub new() - - End Sub - - Public Sub new(AveragePowerDemandPerCompressorUnitFlowRate as single , _ - FlowRate As single, _ - PowerCompressorOff As Single, _ - PowerCompressorOn As Single, _ - PowerDifference As Single) - - _AveragePowerDemandPerCompressorUnitFlowRate = AveragePowerDemandPerCompressorUnitFlowRate - _FlowRate = FlowRate - _PowerCompressorOff = PowerCompressorOff - _PowerCompressorOn = PowerCompressorOn - _PowerDifference = PowerDifference - - End Sub - - - 'Non Essential - Public Function Initialise() As Boolean Implements IM4_AirCompressor.Initialise - Return true - End Function - - Public Property PulleyGearEfficiency As Single Implements IM4_AirCompressor.PulleyGearEfficiency - Public Property PulleyGearRatio As Single Implements IM4_AirCompressor.PulleyGearRatio + Implements IM4_AirCompressor + + + Public Property _AveragePowerDemandPerCompressorUnitFlowRate As SI + Public Property _FlowRate As NormLiterPerSecond + Public Property _PowerCompressorOff As Watt + Public Property _PowerCompressorOn As Watt + Public Property _PowerDifference As Watt + + Public Function GetAveragePowerDemandPerCompressorUnitFlowRate() As SI Implements IM4_AirCompressor.GetAveragePowerDemandPerCompressorUnitFlowRate + Return _AveragePowerDemandPerCompressorUnitFlowRate + End Function + + Public Function GetFlowRate() As NormLiterPerSecond Implements IM4_AirCompressor.GetFlowRate + Return _FlowRate + End Function + + Public Function GetPowerCompressorOff() As Watt Implements IM4_AirCompressor.GetPowerCompressorOff + Return _PowerCompressorOff + End Function + + Public Function PowerCompressorOn() As Watt Implements IM4_AirCompressor.GetPowerCompressorOn + Return _PowerCompressorOn + End Function + + Public Function GetPowerDifference() As Watt Implements IM4_AirCompressor.GetPowerDifference + Return _PowerDifference + End Function + + + Public Sub New() + + End Sub + + Public Sub New(AveragePowerDemandPerCompressorUnitFlowRate As Double, _ + FlowRate As Double, _ + PowerCompressorOff As Double, _ + PowerCompressorOn As Double, _ + PowerDifference As Double) + + _AveragePowerDemandPerCompressorUnitFlowRate = AveragePowerDemandPerCompressorUnitFlowRate.SI() + _FlowRate = FlowRate.SI(Of NormLiterPerSecond)() + _PowerCompressorOff = PowerCompressorOff.SI(Of Watt)() + _PowerCompressorOn = PowerCompressorOn.SI(Of Watt)() + _PowerDifference = PowerDifference.SI(Of Watt)() + + End Sub + + + 'Non Essential + Public Function Initialise() As Boolean Implements IM4_AirCompressor.Initialise + Return True + End Function + + Public Property PulleyGearEfficiency As Double Implements IM4_AirCompressor.PulleyGearEfficiency + Public Property PulleyGearRatio As Double Implements IM4_AirCompressor.PulleyGearRatio diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/M5_Mock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/M5_Mock.vb index 93b90a035b7c95410a9e7a4694f1263f75c1ae02..1b53fb739f6a5c3722772ab834fac0a3f8f69021 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/M5_Mock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/M5_Mock.vb @@ -1,46 +1,44 @@ -Imports VectoAuxiliaries.Electrics +Imports TUGraz.VectoCommon.Utils +Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Imports VectoAuxiliaries.DownstreamModules Public Class M5_Mock - Implements IM5_SmartAlternatorSetGeneration + Implements IM5_SmartAlternatorSetGeneration + Public Property _AlternatorsGenerationPowerAtCrankIdleWatts As Watt + Public Property _AlternatorsGenerationPowerAtCrankOverrunWatts As Watt + Public Property _AlternatorsGenerationPowerAtCrankTractionOnWatts As Watt - public property _AlternatorsGenerationPowerAtCrankIdleWatts as single - public property _AlternatorsGenerationPowerAtCrankOverrunWatts as single - public property _AlternatorsGenerationPowerAtCrankTractionOnWatts as single + Public Function AlternatorsGenerationPowerAtCrankIdleWatts() As Watt _ + Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankIdleWatts + Return _AlternatorsGenerationPowerAtCrankIdleWatts + End Function - Public Function AlternatorsGenerationPowerAtCrankIdleWatts() As Single Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankIdleWatts - Return _AlternatorsGenerationPowerAtCrankIdleWatts - End Function + Public Function AlternatorsGenerationPowerAtCrankOverrunWatts() As Watt _ + Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankOverrunWatts + Return _AlternatorsGenerationPowerAtCrankOverrunWatts + End Function - Public Function AlternatorsGenerationPowerAtCrankOverrunWatts() As Single Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankOverrunWatts - Return _AlternatorsGenerationPowerAtCrankOverrunWatts - End Function + Public Function AlternatorsGenerationPowerAtCrankTractionOnWatts() As Watt _ + Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankTractionOnWatts + Return _AlternatorsGenerationPowerAtCrankTractionOnWatts + End Function - Public Function AlternatorsGenerationPowerAtCrankTractionOnWatts() As Single Implements IM5_SmartAlternatorSetGeneration.AlternatorsGenerationPowerAtCrankTractionOnWatts - Return _AlternatorsGenerationPowerAtCrankTractionOnWatts - End Function + Public Sub New() + End Sub - Public Sub new () - - End Sub - - - Public Sub new ( AlternatorsGenerationPowerAtCrankIdleWatts as single, - AlternatorsGenerationPowerAtCrankOverrunWatts as single, - AlternatorsGenerationPowerAtCrankTractionOnWatts as single) - - _AlternatorsGenerationPowerAtCrankIdleWatts = AlternatorsGenerationPowerAtCrankIdleWatts - _AlternatorsGenerationPowerAtCrankOverrunWatts = AlternatorsGenerationPowerAtCrankOverrunWatts - _AlternatorsGenerationPowerAtCrankTractionOnWatts = AlternatorsGenerationPowerAtCrankTractionOnWatts - - - End Sub + Public Sub New(AlternatorsGenerationPowerAtCrankIdleWatts As Double, + AlternatorsGenerationPowerAtCrankOverrunWatts As Double, + AlternatorsGenerationPowerAtCrankTractionOnWatts As Double) + _AlternatorsGenerationPowerAtCrankIdleWatts = AlternatorsGenerationPowerAtCrankIdleWatts.SI(Of Watt)() + _AlternatorsGenerationPowerAtCrankOverrunWatts = AlternatorsGenerationPowerAtCrankOverrunWatts.SI(Of Watt)() + _AlternatorsGenerationPowerAtCrankTractionOnWatts = AlternatorsGenerationPowerAtCrankTractionOnWatts.SI(Of Watt)() + End Sub End Class diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/M6_Mock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/M6_Mock.vb index 70621c1a9c5ba1d3ca6d7f98bee190c75de51a06..3ccbc1173173cd1b75825a336202bb0001bbefad 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/M6_Mock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/M6_Mock.vb @@ -1,4 +1,5 @@  +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac @@ -6,97 +7,103 @@ Imports VectoAuxiliaries.DownstreamModules Public Class M6_Mock - Implements IM6 - - -Public Property _AveragePowerDemandAtCrankFromPneumatics As Single -public property _AvgPowerDemandAtCrankFromElectricsIncHVAC As single -public property _OverrunFlag As integer -public property _SmartElecAndPneumaticAirCompPowerGenAtCrank As single -public property _SmartElecAndPneumaticAltPowerGenAtCrank As single -public property _SmartElecAndPneumaticsCompressorFlag As integer -public property _SmartElecOnlyAltPowerGenAtCrank As single -public property _SmartPneumaticOnlyAirCompPowerGenAtCrank As single -public property _SmartPneumaticsOnlyCompressorFlag As integer - - - Public ReadOnly Property AveragePowerDemandAtCrankFromPneumatics As Single Implements IM6.AveragePowerDemandAtCrankFromPneumatics - Get - Return _AveragePowerDemandAtCrankFromPneumatics - End Get - - End Property - Public ReadOnly Property AvgPowerDemandAtCrankFromElectricsIncHVAC As Single Implements IM6.AvgPowerDemandAtCrankFromElectricsIncHVAC - Get - Return _AvgPowerDemandAtCrankFromElectricsIncHVAC - End Get - End Property - Public ReadOnly Property OverrunFlag As Integer Implements IM6.OverrunFlag - Get - Return _OverrunFlag - End Get - End Property - Public ReadOnly Property SmartElecAndPneumaticAirCompPowerGenAtCrank As Single Implements IM6.SmartElecAndPneumaticAirCompPowerGenAtCrank - Get - Return _SmartElecAndPneumaticAirCompPowerGenAtCrank - End Get - End Property - Public ReadOnly Property SmartElecAndPneumaticAltPowerGenAtCrank As Single Implements IM6.SmartElecAndPneumaticAltPowerGenAtCrank - Get - Return _SmartElecAndPneumaticAltPowerGenAtCrank - End Get - End Property - Public ReadOnly Property SmartElecAndPneumaticsCompressorFlag As Integer Implements IM6.SmartElecAndPneumaticsCompressorFlag - Get - Return _SmartElecAndPneumaticsCompressorFlag - End Get - End Property - Public ReadOnly Property SmartElecOnlyAltPowerGenAtCrank As Single Implements IM6.SmartElecOnlyAltPowerGenAtCrank - Get - Return _SmartElecOnlyAltPowerGenAtCrank - End Get - End Property - Public ReadOnly Property SmartPneumaticOnlyAirCompPowerGenAtCrank As Single Implements IM6.SmartPneumaticOnlyAirCompPowerGenAtCrank - Get - return _SmartPneumaticOnlyAirCompPowerGenAtCrank - End Get - End Property - Public ReadOnly Property SmartPneumaticsOnlyCompressorFlag As Integer Implements IM6.SmartPneumaticsOnlyCompressorFlag - Get - Return _SmartPneumaticsOnlyCompressorFlag - End Get - End Property - - - Public Sub new() - - End Sub - - Public Sub new(_AveragePowerDemandAtCrankFromPneumatics As Single , _ - _AvgPowerDemandAtCrankFromElectricsIncHVAC As single , _ - _OverrunFlag As integer, _ - _SmartElecAndPneumaticAirCompPowerGenAtCrank As single , _ - _SmartElecAndPneumaticAltPowerGenAtCrank As single , _ - _SmartElecAndPneumaticsCompressorFlag As integer, _ - _SmartElecOnlyAltPowerGenAtCrank As single , _ - _SmartPneumaticOnlyAirCompPowerGenAtCrank As single , _ - _SmartPneumaticsOnlyCompressorFlag As integer) - - - _AveragePowerDemandAtCrankFromPneumatics = AveragePowerDemandAtCrankFromPneumatics - _AvgPowerDemandAtCrankFromElectricsIncHVAC = AvgPowerDemandAtCrankFromElectricsIncHVAC - _OverrunFlag = OverrunFlag - _SmartElecAndPneumaticAirCompPowerGenAtCrank = SmartElecAndPneumaticAirCompPowerGenAtCrank - _SmartElecAndPneumaticAltPowerGenAtCrank = SmartElecAndPneumaticAltPowerGenAtCrank - _SmartElecAndPneumaticsCompressorFlag = SmartElecAndPneumaticsCompressorFlag - _SmartElecOnlyAltPowerGenAtCrank = SmartElecOnlyAltPowerGenAtCrank - _SmartPneumaticOnlyAirCompPowerGenAtCrank = SmartPneumaticOnlyAirCompPowerGenAtCrank - _SmartPneumaticsOnlyCompressorFlag = SmartPneumaticsOnlyCompressorFlag - - - - End Sub - + Implements IM6 + Public Property _AveragePowerDemandAtCrankFromPneumatics As Watt + Public Property _AvgPowerDemandAtCrankFromElectricsIncHVAC As Watt + Public Property _OverrunFlag As Integer + Public Property _SmartElecAndPneumaticAirCompPowerGenAtCrank As Watt + Public Property _SmartElecAndPneumaticAltPowerGenAtCrank As Watt + Public Property _SmartElecAndPneumaticsCompressorFlag As Integer + Public Property _SmartElecOnlyAltPowerGenAtCrank As Watt + Public Property _SmartPneumaticOnlyAirCompPowerGenAtCrank As Watt + Public Property _SmartPneumaticsOnlyCompressorFlag As Integer + + + Public ReadOnly Property AveragePowerDemandAtCrankFromPneumatics As Watt _ + Implements IM6.AveragePowerDemandAtCrankFromPneumatics + Get + Return _AveragePowerDemandAtCrankFromPneumatics + End Get + End Property + + Public ReadOnly Property AvgPowerDemandAtCrankFromElectricsIncHVAC As Watt _ + Implements IM6.AvgPowerDemandAtCrankFromElectricsIncHVAC + Get + Return _AvgPowerDemandAtCrankFromElectricsIncHVAC + End Get + End Property + + Public ReadOnly Property OverrunFlag As Boolean Implements IM6.OverrunFlag + Get + Return _OverrunFlag + End Get + End Property + + Public ReadOnly Property SmartElecAndPneumaticAirCompPowerGenAtCrank As Watt _ + Implements IM6.SmartElecAndPneumaticAirCompPowerGenAtCrank + Get + Return _SmartElecAndPneumaticAirCompPowerGenAtCrank + End Get + End Property + + Public ReadOnly Property SmartElecAndPneumaticAltPowerGenAtCrank As Watt _ + Implements IM6.SmartElecAndPneumaticAltPowerGenAtCrank + Get + Return _SmartElecAndPneumaticAltPowerGenAtCrank + End Get + End Property + + Public ReadOnly Property SmartElecAndPneumaticsCompressorFlag As Boolean _ + Implements IM6.SmartElecAndPneumaticsCompressorFlag + Get + Return _SmartElecAndPneumaticsCompressorFlag + End Get + End Property + + Public ReadOnly Property SmartElecOnlyAltPowerGenAtCrank As Watt Implements IM6.SmartElecOnlyAltPowerGenAtCrank + Get + Return _SmartElecOnlyAltPowerGenAtCrank + End Get + End Property + + Public ReadOnly Property SmartPneumaticOnlyAirCompPowerGenAtCrank As Watt _ + Implements IM6.SmartPneumaticOnlyAirCompPowerGenAtCrank + Get + Return _SmartPneumaticOnlyAirCompPowerGenAtCrank + End Get + End Property + + Public ReadOnly Property SmartPneumaticsOnlyCompressorFlag As Boolean Implements IM6.SmartPneumaticsOnlyCompressorFlag + Get + Return _SmartPneumaticsOnlyCompressorFlag + End Get + End Property + + + Public Sub New() + End Sub + + Public Sub New(AveragePowerDemandAtCrankFromPneumatics As Double, + AvgPowerDemandAtCrankFromElectricsIncHVAC As Double, + OverrunFlag As Boolean, + SmartElecAndPneumaticAirCompPowerGenAtCrank As Double, + SmartElecAndPneumaticAltPowerGenAtCrank As Double, + SmartElecAndPneumaticsCompressorFlag As Boolean, + SmartElecOnlyAltPowerGenAtCrank As Double, + SmartPneumaticOnlyAirCompPowerGenAtCrank As Double, + SmartPneumaticsOnlyCompressorFlag As Boolean) + + + _AveragePowerDemandAtCrankFromPneumatics = AveragePowerDemandAtCrankFromPneumatics.SI(Of Watt)() + _AvgPowerDemandAtCrankFromElectricsIncHVAC = AvgPowerDemandAtCrankFromElectricsIncHVAC.SI(Of Watt)() + _OverrunFlag = OverrunFlag + _SmartElecAndPneumaticAirCompPowerGenAtCrank = SmartElecAndPneumaticAirCompPowerGenAtCrank.SI(Of Watt)() + _SmartElecAndPneumaticAltPowerGenAtCrank = SmartElecAndPneumaticAltPowerGenAtCrank.SI(Of Watt)() + _SmartElecAndPneumaticsCompressorFlag = SmartElecAndPneumaticsCompressorFlag + _SmartElecOnlyAltPowerGenAtCrank = SmartElecOnlyAltPowerGenAtCrank.SI(Of Watt)() + _SmartPneumaticOnlyAirCompPowerGenAtCrank = SmartPneumaticOnlyAirCompPowerGenAtCrank.SI(Of Watt)() + _SmartPneumaticsOnlyCompressorFlag = SmartPneumaticsOnlyCompressorFlag + End Sub End Class diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/M7_Mock.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/M7_Mock.vb index c9df44ed5de1084af6d7e5437df4b4f2b2d37cca..4bae96687221cf91fe6828d1d4268ecb05a85976 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/M7_Mock.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/M7_Mock.vb @@ -1,4 +1,5 @@  +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac @@ -6,56 +7,54 @@ Imports VectoAuxiliaries.DownstreamModules Public Class M7_Mock - Implements IM7 - - Private _SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Single - Private _SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Single - Private _SmartElectricalOnlyAuxAltPowerGenAtCrank As Single - Private _SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Single - - Public ReadOnly Property SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Single Implements IM7.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank - Get - Return _SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank - End Get - End Property - - Public ReadOnly Property SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Single Implements IM7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank - Get - Return _SmartElectricalAndPneumaticAuxAltPowerGenAtCrank - End Get - End Property - - Public ReadOnly Property SmartElectricalOnlyAuxAltPowerGenAtCrank As Single Implements IM7.SmartElectricalOnlyAuxAltPowerGenAtCrank - Get - Return _SmartElectricalOnlyAuxAltPowerGenAtCrank - End Get - End Property - - Public ReadOnly Property SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Single Implements IM7.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank - Get - Return _SmartPneumaticOnlyAuxAirCompPowerGenAtCrank - End Get - End Property - - - - 'Constructors - public Sub new() - - End Sub - - Public Sub new (SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Single, - SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Single, - SmartElectricalOnlyAuxAltPowerGenAtCrank As Single, - SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Single) - - _SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank = SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank - _SmartElectricalAndPneumaticAuxAltPowerGenAtCrank = SmartElectricalAndPneumaticAuxAltPowerGenAtCrank - _SmartElectricalOnlyAuxAltPowerGenAtCrank = SmartElectricalOnlyAuxAltPowerGenAtCrank - _SmartPneumaticOnlyAuxAirCompPowerGenAtCrank = SmartPneumaticOnlyAuxAirCompPowerGenAtCrank - - - End Sub - - -End Class \ No newline at end of file + Implements IM7 + + Private _SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Watt + Private _SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Watt + Private _SmartElectricalOnlyAuxAltPowerGenAtCrank As Watt + Private _SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Watt + + Public ReadOnly Property SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Watt _ + Implements IM7.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank + Get + Return _SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank + End Get + End Property + + Public ReadOnly Property SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Watt _ + Implements IM7.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank + Get + Return _SmartElectricalAndPneumaticAuxAltPowerGenAtCrank + End Get + End Property + + Public ReadOnly Property SmartElectricalOnlyAuxAltPowerGenAtCrank As Watt _ + Implements IM7.SmartElectricalOnlyAuxAltPowerGenAtCrank + Get + Return _SmartElectricalOnlyAuxAltPowerGenAtCrank + End Get + End Property + + Public ReadOnly Property SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Watt _ + Implements IM7.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank + Get + Return _SmartPneumaticOnlyAuxAirCompPowerGenAtCrank + End Get + End Property + + + 'Constructors + Public Sub New() + End Sub + + Public Sub New(SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank As Watt, + SmartElectricalAndPneumaticAuxAltPowerGenAtCrank As Watt, + SmartElectricalOnlyAuxAltPowerGenAtCrank As Watt, + SmartPneumaticOnlyAuxAirCompPowerGenAtCrank As Watt) + + _SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank = SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank + _SmartElectricalAndPneumaticAuxAltPowerGenAtCrank = SmartElectricalAndPneumaticAuxAltPowerGenAtCrank + _SmartElectricalOnlyAuxAltPowerGenAtCrank = SmartElectricalOnlyAuxAltPowerGenAtCrank + _SmartPneumaticOnlyAuxAirCompPowerGenAtCrank = SmartPneumaticOnlyAuxAirCompPowerGenAtCrank + End Sub +End Class \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliariesTests/Mocks/MockFuel50PC.vb b/VECTOAux/VectoAuxiliariesTests/Mocks/MockFuel50PC.vb index a98fdff1bda4334ecfbbeb5ee3a600bfaca5bed3..0c46f104e4bd1bb1d10426391ed241842553ee99 100644 --- a/VECTOAux/VectoAuxiliariesTests/Mocks/MockFuel50PC.vb +++ b/VECTOAux/VectoAuxiliariesTests/Mocks/MockFuel50PC.vb @@ -3,20 +3,21 @@ Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries -public class MockFuel50PC +Public Class MockFuel50PC Implements IFuelConsumptionMap - Public Function fFCdelaunay_Intp(nU As Single, Tq As Single) As Single + Public Function fFCdelaunay_Intp(nU As Double, Tq As Double) As Double Return (nU + Tq) * 0.5 End Function - Public Function GetFuelConsumption(torque As Double, angularVelocity As Double) As Double _ + Public Function GetFuelConsumption(torque As NewtonMeter, angularVelocity As PerSecond) As KilogramPerSecond _ Implements IFuelConsumptionMap.GetFuelConsumption - Return fFCdelaunay_Intp(angularVelocity, torque) + Return (fFCdelaunay_Intp(angularVelocity.AsRPM, torque.Value()) / 3600 / 1000).SI(Of KilogramPerSecond)() End Function End Class diff --git a/VECTOAux/VectoAuxiliariesTests/My Project/Application.Designer.vb b/VECTOAux/VectoAuxiliariesTests/My Project/Application.Designer.vb index 0aecefe6649856e7f2f1917454c1aa12737d11a2..8ab460ba03644d647f67a62136b9e8f010a0d561 100644 --- a/VECTOAux/VectoAuxiliariesTests/My Project/Application.Designer.vb +++ b/VECTOAux/VectoAuxiliariesTests/My Project/Application.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' <auto-generated> -' This code was generated by a tool. -' Runtime Version:4.0.30319.18444 +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 ' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. ' </auto-generated> '------------------------------------------------------------------------------ diff --git a/VECTOAux/VectoAuxiliariesTests/My Project/Resources.Designer.vb b/VECTOAux/VectoAuxiliariesTests/My Project/Resources.Designer.vb index 12ad5ab8305b8c54da0383b339dedbc081981c3f..1d5344126ac3f53250286b2a06eb565859f05b2c 100644 --- a/VECTOAux/VectoAuxiliariesTests/My Project/Resources.Designer.vb +++ b/VECTOAux/VectoAuxiliariesTests/My Project/Resources.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' <auto-generated> -' This code was generated by a tool. -' Runtime Version:4.0.30319.18444 +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 ' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. ' </auto-generated> '------------------------------------------------------------------------------ @@ -15,12 +15,12 @@ Imports System Namespace My.Resources - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. '''<summary> - ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. '''</summary> <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ @@ -33,7 +33,7 @@ Namespace My.Resources Private resourceCulture As Global.System.Globalization.CultureInfo '''<summary> - ''' Returns the cached ResourceManager instance used by this class. + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. '''</summary> <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager @@ -47,8 +47,8 @@ Namespace My.Resources End Property '''<summary> - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. '''</summary> <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ Friend Property Culture() As Global.System.Globalization.CultureInfo diff --git a/VECTOAux/VectoAuxiliariesTests/My Project/Settings.Designer.vb b/VECTOAux/VectoAuxiliariesTests/My Project/Settings.Designer.vb index 4587b0e408bb44cfe1033f77c5c0e2f68138750a..4d52204690298f79e59bfe2f03516bb9f0b4eb25 100644 --- a/VECTOAux/VectoAuxiliariesTests/My Project/Settings.Designer.vb +++ b/VECTOAux/VectoAuxiliariesTests/My Project/Settings.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' <auto-generated> -' This code was generated by a tool. -' Runtime Version:4.0.30319.18444 +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 ' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. ' </auto-generated> '------------------------------------------------------------------------------ @@ -22,7 +22,7 @@ Namespace My Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) -#Region "My.Settings Auto-Save Functionality" +#Region "Funktion zum automatischen Speichern von My.Settings" #If _MyType = "WindowsForms" Then Private Shared addedHandler As Boolean diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/AirCompressorTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/AirCompressorTests.vb index c3e3a0c855c867344cee9f8ca1831f5365ccf285..d001e7c1ede54fc76758b484351f8cee1c0705ad 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/AirCompressorTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/AirCompressorTests.vb @@ -1,182 +1,177 @@ Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliariesTests.Mocks Imports VectoAuxiliaries Namespace UnitTests + <TestFixture()> + Public Class M4_AirCompressorTests - <TestFixture()> - Public Class M4_AirCompressorTests #Region "Test Constants" - Private Const GoodEfficiency As Single = 0.7 - Private Const TooLowEfficiency As Single = -1 - Private Const TooHighEfficiency As Single = 1.1 - Private Const GoodRatio As Single = 1 - Private Const TooLowRatio As Single = -1 - Private Const TooHighRatio As Single = 12 + Private Const GoodEfficiency As Single = 0.7 + Private Const TooLowEfficiency As Single = -1 + Private Const TooHighEfficiency As Single = 1.1 -#End Region - - -Private _signals As ISignals = New Signals + Private Const GoodRatio As Single = 1 + Private Const TooLowRatio As Single = -1 + Private Const TooHighRatio As Single = 12 +#End Region -Public Sub new() -_signals.EngineSpeed=100 + Private _signals As ISignals = New Signals -End Sub + Public Sub New() + _signals.EngineSpeed = 100.RPMtoRad() + End Sub #Region "Factory Methods" - Private Function GetNonFailingCompressorMapMock() As ICompressorMap - Return New CompressorMapMock(False) - End Function + Private Function GetNonFailingCompressorMapMock() As ICompressorMap + Return New CompressorMapMock(False) + End Function + + Private Function GetFailingCompressorMapMock() As ICompressorMap + Return New CompressorMapMock(True) + End Function - Private Function GetFailingCompressorMapMock() As ICompressorMap - Return New CompressorMapMock(True) - End Function + Private Function GetGoodCompressor() As M4_AirCompressor + Dim map As ICompressorMap = GetNonFailingCompressorMapMock() + Dim target As M4_AirCompressor = New M4_AirCompressor(map, GoodRatio, GoodEfficiency, _signals) + Return target + End Function - Private Function GetGoodCompressor() As M4_AirCompressor - Dim map As ICompressorMap = GetNonFailingCompressorMapMock() - Dim target As M4_AirCompressor = New M4_AirCompressor(map, GoodRatio, GoodEfficiency, _signals) - Return target - End Function #End Region - <Test()> - Public Sub CreateNewJustPathTest() - Dim map As ICompressorMap = GetNonFailingCompressorMapMock() - _signals.EngineSpeed=100 - Dim target As M4_AirCompressor = New M4_AirCompressor(map,2,0.8,_signals) - Assert.IsNotNull(target) - End Sub - - <Test()> - Public Sub CreateNewAllParametersTest() - Dim map As ICompressorMap = GetNonFailingCompressorMapMock() - Dim target As M4_AirCompressor = New M4_AirCompressor(map, GoodRatio, GoodEfficiency,_signals) - Assert.IsNotNull(target) - End Sub - - - <Test()> - Public Sub InitialiseTest() - Dim map As ICompressorMap = GetNonFailingCompressorMapMock() - _signals.EngineSpeed=100 - Dim target As M4_AirCompressor = New M4_AirCompressor(map,2,0.8,_signals) - Assert.IsTrue(target.Initialise()) - End Sub - - <Test(), ExpectedException("System.ArgumentException")> - Public Sub InitialiseInvalidMapTest() - Dim map As ICompressorMap = GetFailingCompressorMapMock() - _signals.EngineSpeed=100 - Dim target As M4_AirCompressor = New M4_AirCompressor(map,2,0.8,_signals) - target.Initialise() - End Sub - - <Test()> - Public Sub GetEfficiencyTest() - Dim comp As M4_AirCompressor = GetGoodCompressor() - Dim target = comp.PulleyGearEfficiency - Assert.AreEqual(target, GoodEfficiency) - End Sub - - <Test()> - Public Sub SetEfficiencyTest() - Dim comp As M4_AirCompressor = GetGoodCompressor() - Dim target As Single = 0.3 - comp.PulleyGearEfficiency = target - Dim actual As Single = comp.PulleyGearEfficiency - Assert.AreEqual(target, actual) - End Sub - - <TestCase(TooLowEfficiency)> _ - <TestCase(TooHighEfficiency)> _ - <ExpectedException("System.ArgumentOutOfRangeException")> - Public Sub SetEfficiencyOutOfRangeTest(ByVal efficiency As Single) - Dim comp As M4_AirCompressor = GetGoodCompressor() - comp.PulleyGearEfficiency = efficiency - End Sub - - - <Test()> - Public Sub GetRatioTest() - Dim comp As M4_AirCompressor = GetGoodCompressor() - Dim target = comp.PulleyGearRatio - Assert.AreEqual(target, GoodRatio) - End Sub - - <Test()> - Public Sub SetRatioTest() - Dim comp As M4_AirCompressor = GetGoodCompressor() - Dim target As Single = 3 - comp.PulleyGearRatio = target - Dim actual As Single = comp.PulleyGearRatio - Assert.AreEqual(target, actual) - End Sub - - <TestCase(TooLowRatio)> _ - <TestCase(TooHighRatio)> _ - <ExpectedException("System.ArgumentOutOfRangeException")> - Public Sub SetRatioOutOfRangeTest(ByVal ratio As Single) - Dim comp As M4_AirCompressor = GetGoodCompressor() - comp.PulleyGearRatio = ratio - End Sub - - <Test()> - Public Sub GetCompressorFlowRateTest() - Dim comp As M4_AirCompressor = GetGoodCompressor() - Dim expected As Single = 0.0333333351f - Dim actual = comp.GetFlowRate() - Assert.AreEqual(expected, actual) - End Sub - - <Test()> - Public Sub GetPowerCompressorOffTest() - Dim comp As M4_AirCompressor = GetGoodCompressor() - Dim expected As Single = 5.0 - Dim actual = comp.GetPowerCompressorOff() - Assert.AreEqual(expected, actual) - End Sub - - - <Test()> - Public Sub GetPowerCompressorOnTest() - Dim comp As M4_AirCompressor = GetGoodCompressor() - Dim expected As Single = 8.0 - Dim actual = comp.GetPowerCompressorOn() - Assert.AreEqual(expected, actual) - End Sub - - - <Test()> - Public Sub GetPowerDifferenceTest() - Dim comp As M4_AirCompressor = GetGoodCompressor() - Dim expected As Single = 3.0 - Dim actual = comp.GetPowerDifference() - Assert.AreEqual(expected, actual) - End Sub - - - <Test> - Public Sub GetAveragePowerDemandPerCompressorUnitFlowRate() - - Dim comp As M4_AirCompressor = GetGoodCompressor() - - Dim expected As Single = 0.01 - Dim actual As Single = comp.GetAveragePowerDemandPerCompressorUnitFlowRate - Assert.AreEqual(actual, expected) - - - End Sub - - - - End Class + <Test()> + Public Sub CreateNewJustPathTest() + Dim map As ICompressorMap = GetNonFailingCompressorMapMock() + _signals.EngineSpeed = 100.RPMtoRad() + Dim target As M4_AirCompressor = New M4_AirCompressor(map, 2, 0.8, _signals) + Assert.IsNotNull(target) + End Sub + + <Test()> + Public Sub CreateNewAllParametersTest() + Dim map As ICompressorMap = GetNonFailingCompressorMapMock() + Dim target As M4_AirCompressor = New M4_AirCompressor(map, GoodRatio, GoodEfficiency, _signals) + Assert.IsNotNull(target) + End Sub + + + <Test()> + Public Sub InitialiseTest() + Dim map As ICompressorMap = GetNonFailingCompressorMapMock() + _signals.EngineSpeed = 100.RPMtoRad() + Dim target As M4_AirCompressor = New M4_AirCompressor(map, 2, 0.8, _signals) + Assert.IsTrue(target.Initialise()) + End Sub + + <Test(), ExpectedException("System.ArgumentException")> + Public Sub InitialiseInvalidMapTest() + Dim map As ICompressorMap = GetFailingCompressorMapMock() + _signals.EngineSpeed = 100.RPMtoRad() + Dim target As M4_AirCompressor = New M4_AirCompressor(map, 2, 0.8, _signals) + target.Initialise() + End Sub + + <Test()> + Public Sub GetEfficiencyTest() + Dim comp As M4_AirCompressor = GetGoodCompressor() + Dim target = comp.PulleyGearEfficiency + Assert.AreEqual(target, GoodEfficiency) + End Sub + + <Test()> + Public Sub SetEfficiencyTest() + Dim comp As M4_AirCompressor = GetGoodCompressor() + Dim target As Single = 0.3 + comp.PulleyGearEfficiency = target + Dim actual As Single = comp.PulleyGearEfficiency + Assert.AreEqual(target, actual) + End Sub + + <TestCase(TooLowEfficiency)> _ + <TestCase(TooHighEfficiency)> _ + <ExpectedException("System.ArgumentOutOfRangeException")> + Public Sub SetEfficiencyOutOfRangeTest(ByVal efficiency As Single) + Dim comp As M4_AirCompressor = GetGoodCompressor() + comp.PulleyGearEfficiency = efficiency + End Sub + + + <Test()> + Public Sub GetRatioTest() + Dim comp As M4_AirCompressor = GetGoodCompressor() + Dim target = comp.PulleyGearRatio + Assert.AreEqual(target, GoodRatio) + End Sub + + <Test()> + Public Sub SetRatioTest() + Dim comp As M4_AirCompressor = GetGoodCompressor() + Dim target As Single = 3 + comp.PulleyGearRatio = target + Dim actual As Single = comp.PulleyGearRatio + Assert.AreEqual(target, actual) + End Sub + + <TestCase(TooLowRatio)> _ + <TestCase(TooHighRatio)> _ + <ExpectedException("System.ArgumentOutOfRangeException")> + Public Sub SetRatioOutOfRangeTest(ByVal ratio As Single) + Dim comp As M4_AirCompressor = GetGoodCompressor() + comp.PulleyGearRatio = ratio + End Sub + + <Test()> + Public Sub GetCompressorFlowRateTest() + Dim comp As M4_AirCompressor = GetGoodCompressor() + Dim expected As Double = 0.0333333351 + Dim actual = comp.GetFlowRate() + Assert.AreEqual(expected, actual.Value(), 0.00000001) + End Sub + + <Test()> + Public Sub GetPowerCompressorOffTest() + Dim comp As M4_AirCompressor = GetGoodCompressor() + Dim expected As Double = 5.0 + Dim actual = comp.GetPowerCompressorOff() + Assert.AreEqual(expected, actual.Value(), 0.00000001) + End Sub + + + <Test()> + Public Sub GetPowerCompressorOnTest() + Dim comp As M4_AirCompressor = GetGoodCompressor() + Dim expected As Double = 8.0 + Dim actual = comp.GetPowerCompressorOn() + Assert.AreEqual(expected, actual.Value(), 0.00000001) + End Sub + + + <Test()> + Public Sub GetPowerDifferenceTest() + Dim comp As M4_AirCompressor = GetGoodCompressor() + Dim expected As Double = 3.0 + Dim actual = comp.GetPowerDifference() + Assert.AreEqual(expected, actual.Value(), 0.00000001) + End Sub + + + <Test> + Public Sub GetAveragePowerDemandPerCompressorUnitFlowRate() + + Dim comp As M4_AirCompressor = GetGoodCompressor() + + Dim expected As Single = 0.01 + Dim actual As SI = comp.GetAveragePowerDemandPerCompressorUnitFlowRate + Assert.AreEqual(actual.Value(), expected, 0.001) + End Sub + End Class End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/AlternatorMapTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/AlternatorMapTests.vb index b67ce159b5c2b96f1c4eecf9f4ef4245affe50f0..082bfb8ec092f7b402eb49b3ae2b2cb18ae0f992 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/AlternatorMapTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/AlternatorMapTests.vb @@ -1,5 +1,6 @@ Imports VectoAuxiliaries.Electrics Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries @@ -31,7 +32,7 @@ Namespace UnitTests Dim map As IAlternatorMap = GetInitialisedMap() Dim target As IAlternatorMap = GetInitialisedMap() - Dim actual As Single = map.GetEfficiency(rpm, amps).Efficiency + Dim actual As Single = map.GetEfficiency(rpm, amps.SI(Of Ampere)).Efficiency Assert.AreEqual(expected, actual) End Sub @@ -44,7 +45,7 @@ Namespace UnitTests Dim map As IAlternatorMap = GetInitialisedMap() Dim target As IAlternatorMap = GetInitialisedMap() - Dim actual As Single = map.GetEfficiency(rpm, amps).Efficiency + Dim actual As Single = map.GetEfficiency(rpm, amps.SI(Of Ampere)).Efficiency Assert.AreEqual(expected, actual) End Sub @@ -58,7 +59,7 @@ Namespace UnitTests Dim map As IAlternatorMap = GetInitialisedMap() Dim target As IAlternatorMap = GetInitialisedMap() - Dim actual As Single = map.GetEfficiency(rpm, amps).Efficiency + Dim actual As Single = map.GetEfficiency(rpm, amps.SI(Of Ampere)).Efficiency Assert.AreEqual(expected, actual) End Sub @@ -95,7 +96,7 @@ Namespace UnitTests Dim map As IAlternatorMap = GetInitialisedMap() Dim target As IAlternatorMap = GetInitialisedMap() - Dim actual As Single = map.GetEfficiency(rpm, amps).Efficiency + Dim actual As Single = map.GetEfficiency(rpm, amps.SI(Of Ampere)).Efficiency Assert.AreEqual(expected, CType(Math.Round(actual, 6), Single)) End Sub diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentComparisonTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentComparisonTests.vb index 8ea31566d7c82f089d6394143f6e4852b89e5469..89291cbd1aeac1ae6531010cd76960e1ede9b9ae 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentComparisonTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/AuxiliaryEnvironmentComparisonTests.vb @@ -1,856 +1,846 @@ Imports System.Text Imports NUnit.Framework Imports NUnit +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Namespace UnitTests + <TestFixture()> + Public Class AuxiliaryComparisonTests + <Test()> + Public Sub BasicEqualCompareTest() -<TestFixture()> -Public Class AuxiliaryComparisonTests + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") 'auxFresh.ShallowCopy() + Dim compareResult As Boolean + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - <Test()> - Public Sub BasicEqualCompareTest() + Assert.AreEqual(True, compareResult) + End Sub - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("")'auxFresh.ShallowCopy() - Dim compareResult As Boolean - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) - - Assert.AreEqual( True,compareResult ) + <Test()> + Public Sub BasicUnequalTest() - End Sub + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + + 'Act + auxNow.PneumaticUserInputsConfig.SmartRegeneration = Not auxNow.PneumaticUserInputsConfig.SmartRegeneration + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub - <Test()> - Public Sub BasicUnequalTest() +#Region "ElectricalUserConfig" - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - - 'Act - auxNow.PneumaticUserInputsConfig.SmartRegeneration= Not auxNow.PneumaticUserInputsConfig.SmartRegeneration - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) - - Assert.AreEqual( false,compareResult ) + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_AlternatorGearEfficiency_UnequalTest() - End Sub + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.AlternatorGearEfficiency = + If _ + (auxNow.ElectricalUserInputsConfig.AlternatorGearEfficiency + 0.1 > 1, 1, + auxNow.ElectricalUserInputsConfig.AlternatorGearEfficiency + 0.1) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_AlternatorMap_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.AlternatorMap = auxNow.ElectricalUserInputsConfig.AlternatorMap & "X" + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_DoorActuationTimeSecond_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.DoorActuationTimeSecond += 1 + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Consumers_Unequal_Count_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items.RemoveAt(0) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_Consumers_AvgConsumptionAmps_UnequalTest() - #Region "ElectricalUserConfig" + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).AvgConsumptionAmps += 1 + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_Consumers_BaseVehicle_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).BaseVehicle = + Not auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).BaseVehicle + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_Consumers_Category_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + Dim cat As String = auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).Category + auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).Category = cat & "x" + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_Consumers_ConsumerName_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + Dim cname As String = auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).ConsumerName + auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).ConsumerName = cname & "x" + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_Consumers_NominalConsumptionAmps_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).NominalConsumptionAmps += 1 + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_Consumers_NumberInActualVehicle_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + Dim cname As Single = auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).NumberInActualVehicle + auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).NumberInActualVehicle += 1 + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_Consumers_PhaseIdle_TractionOn_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + Dim cname As Single = auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).PhaseIdle_TractionOn + auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).PhaseIdle_TractionOn += 1 + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardIdle_UnequalCount_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(50, 49)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardTraction_UnequalCount_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.ResultCardTraction.Results.Add(New SmartResult(50, 49)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardOverrun_UnequalCount_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add(New SmartResult(50, 49)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardIdle_AMPS_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(50, 49)) + auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(49, 49)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardIdle_UnEqualAMPS_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(49, 49)) + auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(50, 49)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardIdle_UnEqualSMARTAMPS_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(49, 51)) + auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(49, 50)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardTraction_AMPS_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxFresh.ElectricalUserInputsConfig.ResultCardTraction.Results.Add(New SmartResult(50, 49)) + auxNow.ElectricalUserInputsConfig.ResultCardTraction.Results.Add(New SmartResult(51, 49)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardTraction_UnEqualAMPS_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(49, 49)) + auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(50, 49)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardTraction_UnEqualSMARTAMPS_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(49, 49)) + auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add(New SmartResult(49, 50)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardOverrun_AMPS_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxFresh.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add(New SmartResult(50, 49)) + auxNow.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add(New SmartResult(50, 48)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardOverrun_UnEqualAMPS_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxFresh.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add(New SmartResult(49, 49)) + auxNow.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add(New SmartResult(50, 49)) + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_ResultCardOverrun_UnEqualSMARTAMPS_UnequalTest() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxFresh.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add(New SmartResult(49, 49)) + auxNow.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add(New SmartResult(49, 50)) - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_AlternatorGearEfficiency_UnequalTest() + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.AlternatorGearEfficiency= If( auxNow.ElectricalUserInputsConfig.AlternatorGearEfficiency+0.1>1, 1, auxNow.ElectricalUserInputsConfig.AlternatorGearEfficiency+0.1) + Assert.AreEqual(False, compareResult) + End Sub - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_PowernetVoltage_UnEqualSMARTAMPS_UnequalTest() - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.PowerNetVoltage += 1 - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_AlternatorMap_UnequalTest() + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.AlternatorMap = auxNow.ElectricalUserInputsConfig.AlternatorMap & "X" - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) + Assert.AreEqual(False, compareResult) + End Sub - Assert.AreEqual( false,compareResult ) + <Test()> + <Category("ElectricalUserConfig")> + Public Sub ElectricalUserConfig_Unequal_SmarElectrics_UnEqualSMARTAMPS_UnequalTest() - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_DoorActuationTimeSecond_UnequalTest() + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.ElectricalUserInputsConfig.SmartElectrical = Not auxNow.ElectricalUserInputsConfig.SmartElectrical - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.DoorActuationTimeSecond+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - Assert.AreEqual( false,compareResult ) + Assert.AreEqual(False, compareResult) + End Sub - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Consumers_Unequal_Count_UnequalTest() +#End Region - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items.RemoveAt(0) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) +#Region "PneumaticAuxiliariesConfig" - Assert.AreEqual( false,compareResult ) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_AdBlueNIperMinute_Enequal() - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_Consumers_AvgConsumptionAmps_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).AvgConsumptionAmps+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_Consumers_BaseVehicle_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).BaseVehicle= NOT auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).BaseVehicle - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.AdBlueNIperMinute += 1 - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_Consumers_Category_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - Dim cat As String = auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).Category - auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).Category= cat & "x" - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - Assert.AreEqual( false,compareResult ) + Assert.AreEqual(False, compareResult) + End Sub - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_Consumers_ConsumerName_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - Dim cname As String = auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).ConsumerName - auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).ConsumerName= cName & "x" - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_AirControlledSuspensionNIperMinute_Enequal() - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_Consumers_NominalConsumptionAmps_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - Dim cname As single = auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).NominalConsumptionAmps - auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).NominalConsumptionAmps+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_Consumers_NumberInActualVehicle_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - Dim cname As single = auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).NumberInActualVehicle - auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).NumberInActualVehicle+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_Consumers_PhaseIdle_TractionOn_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - Dim cname As single = auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).PhaseIdle_TractionOn - auxNow.ElectricalUserInputsConfig.ElectricalConsumers.Items(0).PhaseIdle_TractionOn+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardIdle_UnequalCount_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(50,49)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardTraction_UnequalCount_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.ResultCardTraction.Results.Add( New SmartResult(50,49)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardOverrun_UnequalCount_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add( New SmartResult(50,49)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardIdle_AMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(50,49)) - auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(49,49)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardIdle_UnEqualAMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(49,49)) - auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(50,49)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardIdle_UnEqualSMARTAMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(49,51)) - auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(49,50)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardTraction_AMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxFresh.ElectricalUserInputsConfig.ResultCardTraction.Results.Add( New SmartResult(50,49)) - auxNow.ElectricalUserInputsConfig.ResultCardTraction.Results.Add( New SmartResult(51,49)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardTraction_UnEqualAMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(49,49)) - auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(50,49)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardTraction_UnEqualSMARTAMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxFresh.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(49,49)) - auxNow.ElectricalUserInputsConfig.ResultCardIdle.Results.Add( New SmartResult(49,50)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardOverrun_AMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxFresh.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add( New SmartResult(50,49)) - auxNow.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add( New SmartResult(50,48)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardOverrun_UnEqualAMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxFresh.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add( New SmartResult(49,49)) - auxNow.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add( New SmartResult(50,49)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_ResultCardOverrun_UnEqualSMARTAMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxFresh.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add( New SmartResult(49,49)) - auxNow.ElectricalUserInputsConfig.ResultCardOverrun.Results.Add( New SmartResult(49,50)) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_PowernetVoltage_UnEqualSMARTAMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.PowerNetVoltage+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("ElectricalUserConfig")> _ - Public Sub ElectricalUserConfig_Unequal_SmarElectrics_UnEqualSMARTAMPS_UnequalTest() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.ElectricalUserInputsConfig.SmartElectrical= Not auxNow.ElectricalUserInputsConfig.SmartElectrical - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - - #End Region - - #Region "PneumaticAuxiliariesConfig" - - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_AdBlueNIperMinute_Enequal() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.AdBlueNIperMinute+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_AirControlledSuspensionNIperMinute_Enequal() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.AirControlledSuspensionNIperMinute+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_BrakingNoRetarderNIperKG_Enequal() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.BrakingNoRetarderNIperKG+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_BrakingWithRetarderNIperKG_Enequal() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.BrakingWithRetarderNIperKG+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) - - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_BreakingPerKneelingNIperKGinMM_Enequal() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.BreakingPerKneelingNIperKGinMM+=1 + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.AirControlledSuspensionNIperMinute += 1 - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_DeadVolBlowOutsPerLitresperHour_Enequal() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.DeadVolBlowOutsPerLitresperHour+=1 + Assert.AreEqual(False, compareResult) + End Sub - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_BrakingNoRetarderNIperKG_Enequal() - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.BrakingNoRetarderNIperKG += 1 - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_DeadVolumeLitres_Enequal() + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.DeadVolumeLitres+=1 + Assert.AreEqual(False, compareResult) + End Sub - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_BrakingWithRetarderNIperKG_Enequal() - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.BrakingWithRetarderNIperKG += 1 - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_NonSmartRegenFractionTotalAirDemand_Enequal() + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.NonSmartRegenFractionTotalAirDemand+=1 + Assert.AreEqual(False, compareResult) + End Sub - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_BreakingPerKneelingNIperKGinMM_Enequal() - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.BreakingPerKneelingNIperKGinMM += 1 - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_OverrunUtilisationForCompressionFraction_Enequal() + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.OverrunUtilisationForCompressionFraction+=1 + Assert.AreEqual(False, compareResult) + End Sub - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow ) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_DeadVolBlowOutsPerLitresperHour_Enequal() - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.DeadVolBlowOutsPerLitresperHour += 1 - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_PerDoorOpeningNI_Enequal() + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.PerDoorOpeningNI+=1 + Assert.AreEqual(False, compareResult) + End Sub - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_DeadVolumeLitres_Enequal() - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.DeadVolumeLitres += 1 - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsAuxuiliaryConfig_PerStopBrakeActuationNIperKG_Enequal() + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.PerStopBrakeActuationNIperKG+=1 + Assert.AreEqual(False, compareResult) + End Sub - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_NonSmartRegenFractionTotalAirDemand_Enequal() - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.NonSmartRegenFractionTotalAirDemand += 1 - End Sub - <Test()> - <Category("PneumaticAuxiliariesConfig")> _ - Public Sub PneumaticsUserInputsConfig_SmartRegenFractionTotalAirDemand_Enequal() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticAuxillariesConfig.SmartRegenFractionTotalAirDemand+=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - Assert.AreEqual( false,compareResult ) + Assert.AreEqual(False, compareResult) + End Sub - End Sub + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_OverrunUtilisationForCompressionFraction_Enequal() - #End Region + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.OverrunUtilisationForCompressionFraction += 1 - #Region "PneumaticUserInputsConfig" + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_ActuationsMap_Enequal() + Assert.AreEqual(False, compareResult) + End Sub - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.ActuationsMap = auxNow.PneumaticUserInputsConfig.ActuationsMap & "x" + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_PerDoorOpeningNI_Enequal() - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.PerDoorOpeningNI += 1 - Assert.AreEqual( false,compareResult ) + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_AdBlueDosing_Enequal() + Assert.AreEqual(False, compareResult) + End Sub - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.AdBlueDosing = auxNow.PneumaticUserInputsConfig.AdBlueDosing & "x" - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsAuxuiliaryConfig_PerStopBrakeActuationNIperKG_Enequal() - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.PerStopBrakeActuationNIperKG += 1 - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_AirSuspensionControl_Enequal() + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.AirSuspensionControl = auxNow.PneumaticUserInputsConfig.AirSuspensionControl & "x" + Assert.AreEqual(False, compareResult) + End Sub - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + <Test()> + <Category("PneumaticAuxiliariesConfig")> + Public Sub PneumaticsUserInputsConfig_SmartRegenFractionTotalAirDemand_Enequal() - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_CompressorGearEfficiency_Enequal() - - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.CompressorGearEfficiency = If( auxNow.PneumaticUserInputsConfig.CompressorGearEfficiency-0.1<0,0,auxNow.PneumaticUserInputsConfig.CompressorGearEfficiency-0.1) - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticAuxillariesConfig.SmartRegenFractionTotalAirDemand += 1 + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - Assert.AreEqual( false,compareResult ) + Assert.AreEqual(False, compareResult) + End Sub - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_CompressorGearRatio_Enequal() +#End Region - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.CompressorGearRatio +=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) - Assert.AreEqual( false,compareResult ) - - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_CompressorMap_Enequal() +#Region "PneumaticUserInputsConfig" - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_ActuationsMap_Enequal() - auxNow.PneumaticUserInputsConfig.CompressorMap = auxNow.PneumaticUserInputsConfig.CompressorMap & "x" - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.ActuationsMap = auxNow.PneumaticUserInputsConfig.ActuationsMap & "x" + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + Assert.AreEqual(False, compareResult) + End Sub - Assert.AreEqual( false,compareResult ) + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_AdBlueDosing_Enequal() - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_Doors_Enequal() + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.AdBlueDosing = auxNow.PneumaticUserInputsConfig.AdBlueDosing & "x" - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.Doors = auxNow.PneumaticUserInputsConfig.Doors & "x" + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + Assert.AreEqual(False, compareResult) + End Sub + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_AirSuspensionControl_Enequal() - Assert.AreEqual( false,compareResult ) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.AirSuspensionControl = auxNow.PneumaticUserInputsConfig.AirSuspensionControl & "x" - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_KneelingHeightMillimeters_Enequal() + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.KneelingHeightMillimeters +=1 - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) - Assert.AreEqual( false,compareResult ) + Assert.AreEqual(False, compareResult) + End Sub - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_RetarderBrake_Enequal() + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_CompressorGearEfficiency_Enequal() - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.RetarderBrake = Not auxNow.PneumaticUserInputsConfig.RetarderBrake + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.CompressorGearEfficiency = + If _ + (auxNow.PneumaticUserInputsConfig.CompressorGearEfficiency - 0.1 < 0, 0, + auxNow.PneumaticUserInputsConfig.CompressorGearEfficiency - 0.1) - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) - Assert.AreEqual( false,compareResult ) + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_SmartAirCompression_Enequal() - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.SmartAirCompression = Not auxNow.PneumaticUserInputsConfig.SmartAirCompression + Assert.AreEqual(False, compareResult) + End Sub - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_CompressorGearRatio_Enequal() + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.CompressorGearRatio += 1 - Assert.AreEqual( false,compareResult ) + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + Assert.AreEqual(False, compareResult) + End Sub - End Sub - <Test()> - <Category("PneumaticUserInputsConfig")> _ - Public Sub PneumaticUserInputsConfig_SmartRegeneration_Enequal() + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_CompressorMap_Enequal() - 'Arrange - Dim auxFresh = New AuxiliaryConfig("") - Dim auxNow = New AuxiliaryConfig("") - Dim compareResult As Boolean - auxNow.PneumaticUserInputsConfig.SmartRegeneration = Not auxNow.PneumaticUserInputsConfig.SmartRegeneration - - 'Act - compareResult = auxFresh.ConfigValuesAreTheSameAs( auxNow) + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean - Assert.AreEqual( false,compareResult ) - End Sub + auxNow.PneumaticUserInputsConfig.CompressorMap = auxNow.PneumaticUserInputsConfig.CompressorMap & "x" + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) - #End Region + Assert.AreEqual(False, compareResult) + End Sub + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_Doors_Enequal() + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.Doors = auxNow.PneumaticUserInputsConfig.Doors & "x" + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) -End Class + Assert.AreEqual(False, compareResult) + End Sub + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_KneelingHeightMillimeters_Enequal() + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.KneelingHeightMillimeters += 1 + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_RetarderBrake_Enequal() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.RetarderBrake = Not auxNow.PneumaticUserInputsConfig.RetarderBrake + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_SmartAirCompression_Enequal() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.SmartAirCompression = Not auxNow.PneumaticUserInputsConfig.SmartAirCompression + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + + Assert.AreEqual(False, compareResult) + End Sub + + <Test()> + <Category("PneumaticUserInputsConfig")> + Public Sub PneumaticUserInputsConfig_SmartRegeneration_Enequal() + + 'Arrange + Dim auxFresh = New AuxiliaryConfig("") + Dim auxNow = New AuxiliaryConfig("") + Dim compareResult As Boolean + auxNow.PneumaticUserInputsConfig.SmartRegeneration = Not auxNow.PneumaticUserInputsConfig.SmartRegeneration + + 'Act + compareResult = auxFresh.ConfigValuesAreTheSameAs(auxNow) + + Assert.AreEqual(False, compareResult) + End Sub + +#End Region + End Class End Namespace diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb index 4d3c8681a669155a3e47395c53940ebc475a2f5d..f21248343a08496c1201f51952d344b8ba921688 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/AveragePneumaticLoadDemandTests.vb @@ -1,6 +1,7 @@  Imports VectoAuxiliaries.Pneumatics Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliariesTests.Mocks Imports VectoAuxiliaries @@ -46,7 +47,7 @@ Namespace UnitTests _Signals.TotalCycleTimeSeconds = 3114 - _Signals.EngineSpeed = 3000 + _Signals.EngineSpeed = 3000.RPMtoRad() End Sub @@ -67,8 +68,8 @@ Namespace UnitTests psCompressorMap.Initialise() Dim _ target As _ - New M3_AveragePneumaticLoadDemand(psUserInputsConfig, psAuxConfig, psActuationsMap, psCompressorMap, _vehicleMassKG, - "Urban", _signals) + New M3_AveragePneumaticLoadDemand(psUserInputsConfig, psAuxConfig, psActuationsMap, psCompressorMap, + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) Assert.IsNotNull(target) @@ -88,12 +89,12 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _signals) + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) - Dim expected As Single = 7947.684 - Dim actual As Single = target.TotalAirDemand() + Dim expected As Double = 7947.684 + Dim actual As NormLiter = target.TotalAirDemand() - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, actual.Value(), 0.000001) End Sub <Test()> @@ -110,12 +111,12 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _signals) + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) Dim expected As Single = 5832.091 - Dim actual As Single = target.GetAveragePowerDemandAtCrankFromPneumatics() + Dim actual As Watt = target.GetAveragePowerDemandAtCrankFromPneumatics() - Assert.AreEqual(expected, actual, 0.001) + Assert.AreEqual(expected, actual.Value(), 0.001) End Sub @@ -135,12 +136,11 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _signals) + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) Dim expected As Single = 5832.091 - Dim actual As Single = target.GetAveragePowerDemandAtCrankFromPneumatics() - Assert.AreEqual(expected, actual, 0.001) + Assert.AreEqual(expected, target.GetAveragePowerDemandAtCrankFromPneumatics().Value(), 0.001) End Sub <Test()> @@ -157,12 +157,11 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _signals) + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) - Dim expected As Single = Math.Round(7947.55127 / _Signals.TotalCycleTimeSeconds, 4) - Dim actual As Single = Math.Round(target.AverageAirConsumedPerSecondLitre(), 4) + Dim expected As Single = 7947.55127 / _Signals.TotalCycleTimeSeconds - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, target.AverageAirConsumedPerSecondLitre().Value(), 0.001) End Sub 'SmartRegeneration = False @@ -182,12 +181,11 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _Signals) + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) - Dim expected As Single = Math.Round(8863.378 / _Signals.TotalCycleTimeSeconds, 4) - Dim actual As Single = Math.Round(target.AverageAirConsumedPerSecondLitre(), 4) + Dim expected As Double = 8863.378 / _Signals.TotalCycleTimeSeconds - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, target.AverageAirConsumedPerSecondLitre().Value(), 0.001) End Sub 'RetarderBrake = False @@ -207,13 +205,12 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _Signals) + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) - Dim expected As Single = Math.Round(8541.45 / _Signals.TotalCycleTimeSeconds, 4) + Dim expected As Double = 8541.45 / _Signals.TotalCycleTimeSeconds - Dim actual As Single = Math.Round(target.AverageAirConsumedPerSecondLitre(), 4) - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, target.AverageAirConsumedPerSecondLitre().Value(), 0.001) End Sub 'KneelingHeightMilimeters = 100 @@ -233,13 +230,11 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _Signals) + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) - Dim expected As Single = 8557.524 / _Signals.TotalCycleTimeSeconds + Dim expected As Double = 8557.524 / _Signals.TotalCycleTimeSeconds - Dim actual As Single = Math.Round(target.AverageAirConsumedPerSecondLitre(), 8) - - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, target.AverageAirConsumedPerSecondLitre().Value(), 0.001) End Sub 'AirSuspensionControl = "mechanically" @@ -259,13 +254,11 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _Signals) - - Dim expected As Single = 7947.68457 / _Signals.TotalCycleTimeSeconds + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) - Dim actual As Single = Math.Round(target.AverageAirConsumedPerSecondLitre(), 6) + Dim expected As Double = 7947.68457 / _Signals.TotalCycleTimeSeconds - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, target.AverageAirConsumedPerSecondLitre().Value(), 0.001) End Sub 'AdBlueDosing = "electric" @@ -285,13 +278,11 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _Signals) + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) - Dim expected As Single = 7947.68457 / _Signals.TotalCycleTimeSeconds + Dim expected As Double = 7947.68457 / _Signals.TotalCycleTimeSeconds - Dim actual As Single = Math.Round(target.AverageAirConsumedPerSecondLitre(), 6) - - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, target.AverageAirConsumedPerSecondLitre().Value(), 0.001) End Sub 'Doors = "Electric" @@ -311,13 +302,11 @@ Namespace UnitTests Dim _ target As _ New M3_AveragePneumaticLoadDemand(_defaultInputConfig, psAuxConfig, psActuationsMap, psCompressorMap, - _vehicleMassKG, "Urban", _Signals) - - Dim expected As Single = 6880.88428 / _Signals.TotalCycleTimeSeconds + _vehicleMassKG.SI(Of Kilogram), "Urban", _Signals) - Dim actual As Single = Math.Round(target.AverageAirConsumedPerSecondLitre(), 6) + Dim expected As Double = 6880.88428 / _Signals.TotalCycleTimeSeconds - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, target.AverageAirConsumedPerSecondLitre().Value(), 0.001) End Sub End Class End Namespace diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb index 1e057d583fbd38f2dda66358033addae4c70a219..f6e3167d3c8145f212a3fcadf89140f7eb71c14b 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/CombinedAlternatorTests.vb @@ -1,6 +1,7 @@ Option Strict On Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics Imports VectoAuxiliariesTests.Mocks Imports VectoAuxiliaries @@ -8,133 +9,133 @@ Imports VectoAuxiliaries.Hvac Namespace UnitTests - <TestFixture()> - Public Class CombinedAlternatorTests - - Private Alt1ExpectedTable2000 As New List(Of AltUserInput) - Private Alt1ExpectedTable4000 As New List(Of AltUserInput) - Private Alt1ExpectedTable6000 As New List(Of AltUserInput) - Private Alt2ExpectedTable2000 As New List(Of AltUserInput) - Private Alt2ExpectedTable4000 As New List(Of AltUserInput) - Private Alt2ExpectedTable6000 As New List(Of AltUserInput) - Private Alt3ExpectedTable2000 As New List(Of AltUserInput) - Private Alt3ExpectedTable4000 As New List(Of AltUserInput) - Private Alt3ExpectedTable6000 As New List(Of AltUserInput) - Private Alt4ExpectedTable2000 As New List(Of AltUserInput) - Private Alt4ExpectedTable4000 As New List(Of AltUserInput) - Private Alt4ExpectedTable6000 As New List(Of AltUserInput) - Private RangeTableExpected As New List(Of AltUserInput) - - - - Private Const COMBINEDALT_GOODMAP = "testfiles\testCombinedAlternatorMap.aalt" - - - Sub New() - - Alt1ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 50), _ - New AltUserInput(10, 50), _ - New AltUserInput(40, 50), _ - New AltUserInput(60, 50), _ - New AltUserInput(61, 50), _ - New AltUserInput(200, 50)} - - Alt1ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 70), _ - New AltUserInput(10, 70), _ - New AltUserInput(40, 70), _ - New AltUserInput(60, 70), _ - New AltUserInput(61, 70), _ - New AltUserInput(200, 70)} + <TestFixture()> + Public Class CombinedAlternatorTests + + Private Alt1ExpectedTable2000 As New List(Of AltUserInput) + Private Alt1ExpectedTable4000 As New List(Of AltUserInput) + Private Alt1ExpectedTable6000 As New List(Of AltUserInput) + Private Alt2ExpectedTable2000 As New List(Of AltUserInput) + Private Alt2ExpectedTable4000 As New List(Of AltUserInput) + Private Alt2ExpectedTable6000 As New List(Of AltUserInput) + Private Alt3ExpectedTable2000 As New List(Of AltUserInput) + Private Alt3ExpectedTable4000 As New List(Of AltUserInput) + Private Alt3ExpectedTable6000 As New List(Of AltUserInput) + Private Alt4ExpectedTable2000 As New List(Of AltUserInput) + Private Alt4ExpectedTable4000 As New List(Of AltUserInput) + Private Alt4ExpectedTable6000 As New List(Of AltUserInput) + Private RangeTableExpected As New List(Of AltUserInput) + + + + Private Const COMBINEDALT_GOODMAP = "testfiles\testCombinedAlternatorMap.aalt" + + + Sub New() + + Alt1ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 50), _ + New AltUserInput(10, 50), _ + New AltUserInput(40, 50), _ + New AltUserInput(60, 50), _ + New AltUserInput(61, 50), _ + New AltUserInput(200, 50)} + + Alt1ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 70), _ + New AltUserInput(10, 70), _ + New AltUserInput(40, 70), _ + New AltUserInput(60, 70), _ + New AltUserInput(61, 70), _ + New AltUserInput(200, 70)} - Alt1ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 60), _ - New AltUserInput(10, 60), _ - New AltUserInput(40, 60), _ - New AltUserInput(60, 60), _ - New AltUserInput(61, 60), _ - New AltUserInput(200, 60)} + Alt1ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 60), _ + New AltUserInput(10, 60), _ + New AltUserInput(40, 60), _ + New AltUserInput(60, 60), _ + New AltUserInput(61, 60), _ + New AltUserInput(200, 60)} - 'ALT 2 - Alt2ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 80), _ - New AltUserInput(10, 80), _ - New AltUserInput(40, 80), _ - New AltUserInput(60, 80), _ - New AltUserInput(61, 80), _ - New AltUserInput(200, 80)} + 'ALT 2 + Alt2ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 80), _ + New AltUserInput(10, 80), _ + New AltUserInput(40, 80), _ + New AltUserInput(60, 80), _ + New AltUserInput(61, 80), _ + New AltUserInput(200, 80)} - Alt2ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 40), _ - New AltUserInput(10, 40), _ - New AltUserInput(40, 40), _ - New AltUserInput(60, 40), _ - New AltUserInput(61, 40), _ - New AltUserInput(200, 40)} + Alt2ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 40), _ + New AltUserInput(10, 40), _ + New AltUserInput(40, 40), _ + New AltUserInput(60, 40), _ + New AltUserInput(61, 40), _ + New AltUserInput(200, 40)} - Alt2ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 60), _ - New AltUserInput(10, 60), _ - New AltUserInput(40, 60), _ - New AltUserInput(60, 60), _ - New AltUserInput(61, 60), _ - New AltUserInput(200, 60)} + Alt2ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 60), _ + New AltUserInput(10, 60), _ + New AltUserInput(40, 60), _ + New AltUserInput(60, 60), _ + New AltUserInput(61, 60), _ + New AltUserInput(200, 60)} - 'ALT 3 - Alt3ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 95), _ - New AltUserInput(10, 95), _ - New AltUserInput(40, 50), _ - New AltUserInput(60, 90), _ - New AltUserInput(62.5, 95), _ - New AltUserInput(200, 95)} + 'ALT 3 + Alt3ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 95), _ + New AltUserInput(10, 95), _ + New AltUserInput(40, 50), _ + New AltUserInput(60, 90), _ + New AltUserInput(62.5, 95), _ + New AltUserInput(200, 95)} - Alt3ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 99), _ - New AltUserInput(10, 99), _ - New AltUserInput(40, 1), _ - New AltUserInput(60, 55), _ - New AltUserInput(76.2962963, 99), _ - New AltUserInput(200, 99)} + Alt3ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 99), _ + New AltUserInput(10, 99), _ + New AltUserInput(40, 1), _ + New AltUserInput(60, 55), _ + New AltUserInput(76.2962963, 99), _ + New AltUserInput(200, 99)} - Alt3ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 94), _ - New AltUserInput(10, 94), _ - New AltUserInput(40, 86), _ - New AltUserInput(60, 13), _ - New AltUserInput(63.5616438, 0), _ - New AltUserInput(200, 0)} + Alt3ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 94), _ + New AltUserInput(10, 94), _ + New AltUserInput(40, 86), _ + New AltUserInput(60, 13), _ + New AltUserInput(63.5616438, 0), _ + New AltUserInput(200, 0)} - 'ALT 4 - Alt4ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 55), _ - New AltUserInput(10, 55), _ - New AltUserInput(40, 45), _ - New AltUserInput(60, 67), _ - New AltUserInput(61, 67), _ - New AltUserInput(200, 67)} + 'ALT 4 + Alt4ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 55), _ + New AltUserInput(10, 55), _ + New AltUserInput(40, 45), _ + New AltUserInput(60, 67), _ + New AltUserInput(61, 67), _ + New AltUserInput(200, 67)} - Alt4ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 77), _ - New AltUserInput(10, 77), _ - New AltUserInput(40, 39), _ - New AltUserInput(60, 23), _ - New AltUserInput(88.75, 0), _ - New AltUserInput(200, 0)} + Alt4ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 77), _ + New AltUserInput(10, 77), _ + New AltUserInput(40, 39), _ + New AltUserInput(60, 23), _ + New AltUserInput(88.75, 0), _ + New AltUserInput(200, 0)} - Alt4ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 34), _ - New AltUserInput(10, 34), _ - New AltUserInput(40, 67), _ - New AltUserInput(60, 35), _ - New AltUserInput(81.875, 0), _ - New AltUserInput(200, 0)} + Alt4ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 34), _ + New AltUserInput(10, 34), _ + New AltUserInput(40, 67), _ + New AltUserInput(60, 35), _ + New AltUserInput(81.875, 0), _ + New AltUserInput(200, 0)} - 'RangeTable - RangeTableExpected = New List(Of AltUserInput)() From {New AltUserInput(-3001, 0), _ - New AltUserInput(-3000, 0), _ - New AltUserInput(2000, 50), _ - New AltUserInput(4000, 70), _ - New AltUserInput(6000, 60), _ - New AltUserInput(18000, 0), _ - New AltUserInput(18001, 0)} + 'RangeTable + RangeTableExpected = New List(Of AltUserInput)() From {New AltUserInput(-3001, 0), _ + New AltUserInput(-3000, 0), _ + New AltUserInput(2000, 50), _ + New AltUserInput(4000, 70), _ + New AltUserInput(6000, 60), _ + New AltUserInput(18000, 0), _ + New AltUserInput(18001, 0)} @@ -144,371 +145,371 @@ Namespace UnitTests - End Sub + End Sub - <Test()> _ - <TestCase(1, 2, 50.0F)> _ - <TestCase(1, 4, 70)> _ - <TestCase(1, 6, 60)> _ - <TestCase(2, 2, 80)> _ - <TestCase(2, 4, 40)> _ - <TestCase(2, 6, 60)> _ - <TestCase(3, 2, 55)> _ - <TestCase(3, 4, 7.75F)> _ - <TestCase(3, 6, 76.875F)> _ - <TestCase(4, 2, 47.75F)> _ - <TestCase(4, 4, 37)> _ - <TestCase(4, 6, 63)> - Public Sub Interpolate4Table4(alt As Integer, rpmK As Integer, expected As Single) + <Test()> _ + <TestCase(1, 2, 50.0F)> _ + <TestCase(1, 4, 70)> _ + <TestCase(1, 6, 60)> _ + <TestCase(2, 2, 80)> _ + <TestCase(2, 4, 40)> _ + <TestCase(2, 6, 60)> _ + <TestCase(3, 2, 55)> _ + <TestCase(3, 4, 7.75F)> _ + <TestCase(3, 6, 76.875F)> _ + <TestCase(4, 2, 47.75F)> _ + <TestCase(4, 4, 37)> _ + <TestCase(4, 6, 63)> + Public Sub Interpolate4Table4(alt As Integer, rpmK As Integer, expected As Single) - Dim interpValue As Single + Dim interpValue As Double - Select Case alt + Select Case alt - Case 1 + Case 1 - Select Case rpmK + Select Case rpmK - Case 2 - interpValue = Alternator.Iterpolate(Alt1ExpectedTable2000, 42.5) - Case 4 - interpValue = Alternator.Iterpolate(Alt1ExpectedTable4000, 42.5) - Case 6 - interpValue = Alternator.Iterpolate(Alt1ExpectedTable6000, 42.5) + Case 2 + interpValue = Alternator.Iterpolate(Alt1ExpectedTable2000, 42.5) + Case 4 + interpValue = Alternator.Iterpolate(Alt1ExpectedTable4000, 42.5) + Case 6 + interpValue = Alternator.Iterpolate(Alt1ExpectedTable6000, 42.5) - End Select + End Select - Case 2 + Case 2 - Select Case rpmK + Select Case rpmK - Case 2 - interpValue = Alternator.Iterpolate(Alt2ExpectedTable2000, 42.5) - Case 4 - interpValue = Alternator.Iterpolate(Alt2ExpectedTable4000, 42.5) - Case 6 - interpValue = Alternator.Iterpolate(Alt2ExpectedTable6000, 42.5) + Case 2 + interpValue = Alternator.Iterpolate(Alt2ExpectedTable2000, 42.5) + Case 4 + interpValue = Alternator.Iterpolate(Alt2ExpectedTable4000, 42.5) + Case 6 + interpValue = Alternator.Iterpolate(Alt2ExpectedTable6000, 42.5) - End Select + End Select - Case 3 + Case 3 - Select Case rpmK + Select Case rpmK - Case 2 - interpValue = Alternator.Iterpolate(Alt3ExpectedTable2000, 42.5) - Case 4 - interpValue = Alternator.Iterpolate(Alt3ExpectedTable4000, 42.5) - Case 6 - interpValue = Alternator.Iterpolate(Alt3ExpectedTable6000, 42.5) + Case 2 + interpValue = Alternator.Iterpolate(Alt3ExpectedTable2000, 42.5) + Case 4 + interpValue = Alternator.Iterpolate(Alt3ExpectedTable4000, 42.5) + Case 6 + interpValue = Alternator.Iterpolate(Alt3ExpectedTable6000, 42.5) - End Select + End Select - Case 4 + Case 4 - Select Case rpmK + Select Case rpmK - Case 2 - interpValue = Alternator.Iterpolate(Alt4ExpectedTable2000, 42.5) - Case 4 - interpValue = Alternator.Iterpolate(Alt4ExpectedTable4000, 42.5) - Case 6 - interpValue = Alternator.Iterpolate(Alt4ExpectedTable6000, 42.5) + Case 2 + interpValue = Alternator.Iterpolate(Alt4ExpectedTable2000, 42.5) + Case 4 + interpValue = Alternator.Iterpolate(Alt4ExpectedTable4000, 42.5) + Case 6 + interpValue = Alternator.Iterpolate(Alt4ExpectedTable6000, 42.5) - End Select + End Select - End Select + End Select - Assert.AreEqual(interpValue, expected) + Assert.AreEqual(interpValue, expected, 0.001) - End Sub + End Sub - <Test()> - Public Sub Alt1TableConstructTest() + <Test()> + Public Sub Alt1TableConstructTest() - 'Arrange - Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals + 'Arrange + Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals - 'Act - Dim alt As New CombinedAlternator(COMBINEDALT_GOODMAP) + 'Act + Dim alt As New CombinedAlternator(COMBINEDALT_GOODMAP) - Dim idx As Integer + Dim idx As Integer - For idx = 0 To alt.Alternators(0).InputTable2000.Count - 1 - Assert.IsTrue(alt.Alternators(0).InputTable2000(idx).IsEqual(Alt1ExpectedTable2000(idx))) - Next + For idx = 0 To alt.Alternators(0).InputTable2000.Count - 1 + Assert.IsTrue(alt.Alternators(0).InputTable2000(idx).IsEqual(Alt1ExpectedTable2000(idx))) + Next - For idx = 0 To alt.Alternators(0).InputTable4000.Count - 1 - Assert.IsTrue(alt.Alternators(0).InputTable4000(idx).IsEqual(Alt1ExpectedTable4000(idx))) - Next + For idx = 0 To alt.Alternators(0).InputTable4000.Count - 1 + Assert.IsTrue(alt.Alternators(0).InputTable4000(idx).IsEqual(Alt1ExpectedTable4000(idx))) + Next - For idx = 0 To alt.Alternators(0).InputTable6000.Count - 1 - Assert.IsTrue(alt.Alternators(0).InputTable6000(idx).IsEqual(Alt1ExpectedTable6000(idx))) - Next + For idx = 0 To alt.Alternators(0).InputTable6000.Count - 1 + Assert.IsTrue(alt.Alternators(0).InputTable6000(idx).IsEqual(Alt1ExpectedTable6000(idx))) + Next - End Sub + End Sub - <Test()> - Public Sub Alt2TableConstructTest() + <Test()> + Public Sub Alt2TableConstructTest() - 'Arrange + 'Arrange - 'Act - Dim alt As New CombinedAlternator(COMBINEDALT_GOODMAP) + 'Act + Dim alt As New CombinedAlternator(COMBINEDALT_GOODMAP) - Dim idx As Integer + Dim idx As Integer - For idx = 0 To alt.Alternators(1).InputTable2000.Count - 1 - Assert.IsTrue(alt.Alternators(1).InputTable2000(idx).IsEqual(Alt2ExpectedTable2000(idx))) - Next + For idx = 0 To alt.Alternators(1).InputTable2000.Count - 1 + Assert.IsTrue(alt.Alternators(1).InputTable2000(idx).IsEqual(Alt2ExpectedTable2000(idx))) + Next - For idx = 0 To alt.Alternators(1).InputTable4000.Count - 1 - Assert.IsTrue(alt.Alternators(1).InputTable4000(idx).IsEqual(Alt2ExpectedTable4000(idx))) - Next + For idx = 0 To alt.Alternators(1).InputTable4000.Count - 1 + Assert.IsTrue(alt.Alternators(1).InputTable4000(idx).IsEqual(Alt2ExpectedTable4000(idx))) + Next - For idx = 0 To alt.Alternators(1).InputTable6000.Count - 1 - Assert.IsTrue(alt.Alternators(1).InputTable6000(idx).IsEqual(Alt2ExpectedTable6000(idx))) - Next + For idx = 0 To alt.Alternators(1).InputTable6000.Count - 1 + Assert.IsTrue(alt.Alternators(1).InputTable6000(idx).IsEqual(Alt2ExpectedTable6000(idx))) + Next - End Sub - <Test()> - Public Sub Alt3TableConstructTest() + End Sub + <Test()> + Public Sub Alt3TableConstructTest() - 'Arrange - Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals + 'Arrange + Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals - 'Act - Dim alt As New CombinedAlternator(COMBINEDALT_GOODMAP) + 'Act + Dim alt As New CombinedAlternator(COMBINEDALT_GOODMAP) - Dim idx As Integer + Dim idx As Integer - For idx = 0 To alt.Alternators(2).InputTable2000.Count - 1 - Assert.IsTrue(alt.Alternators(2).InputTable2000(idx).IsEqual(Alt3ExpectedTable2000(idx))) - Next + For idx = 0 To alt.Alternators(2).InputTable2000.Count - 1 + Assert.IsTrue(alt.Alternators(2).InputTable2000(idx).IsEqual(Alt3ExpectedTable2000(idx))) + Next - For idx = 0 To alt.Alternators(2).InputTable4000.Count - 1 - Assert.IsTrue(alt.Alternators(2).InputTable4000(idx).IsEqual(Alt3ExpectedTable4000(idx), 3)) - Next + For idx = 0 To alt.Alternators(2).InputTable4000.Count - 1 + Assert.IsTrue(alt.Alternators(2).InputTable4000(idx).IsEqual(Alt3ExpectedTable4000(idx), 3)) + Next - For idx = 0 To alt.Alternators(2).InputTable6000.Count - 1 - Assert.IsTrue(alt.Alternators(2).InputTable6000(idx).IsEqual(Alt3ExpectedTable6000(idx), 3)) - Next + For idx = 0 To alt.Alternators(2).InputTable6000.Count - 1 + Assert.IsTrue(alt.Alternators(2).InputTable6000(idx).IsEqual(Alt3ExpectedTable6000(idx), 3)) + Next - End Sub - <Test()> - Public Sub Alt4TableConstructTest() + End Sub + <Test()> + Public Sub Alt4TableConstructTest() - 'Arrange - Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals + 'Arrange + Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals - 'Act - Dim alt As New CombinedAlternator(COMBINEDALT_GOODMAP) + 'Act + Dim alt As New CombinedAlternator(COMBINEDALT_GOODMAP) - Dim idx As Integer + Dim idx As Integer - For idx = 0 To alt.Alternators(3).InputTable2000.Count - 1 - Assert.IsTrue(alt.Alternators(3).InputTable2000(idx).IsEqual(Alt4ExpectedTable2000(idx))) - Next + For idx = 0 To alt.Alternators(3).InputTable2000.Count - 1 + Assert.IsTrue(alt.Alternators(3).InputTable2000(idx).IsEqual(Alt4ExpectedTable2000(idx))) + Next - For idx = 0 To alt.Alternators(3).InputTable4000.Count - 1 - Assert.IsTrue(alt.Alternators(3).InputTable4000(idx).IsEqual(Alt4ExpectedTable4000(idx), 3)) - Next + For idx = 0 To alt.Alternators(3).InputTable4000.Count - 1 + Assert.IsTrue(alt.Alternators(3).InputTable4000(idx).IsEqual(Alt4ExpectedTable4000(idx), 3)) + Next - For idx = 0 To alt.Alternators(3).InputTable6000.Count - 1 - Assert.IsTrue(alt.Alternators(3).InputTable6000(idx).IsEqual(Alt4ExpectedTable6000(idx), 3)) - Next + For idx = 0 To alt.Alternators(3).InputTable6000.Count - 1 + Assert.IsTrue(alt.Alternators(3).InputTable6000(idx).IsEqual(Alt4ExpectedTable6000(idx), 3)) + Next - End Sub + End Sub - 'testCombinedAlternatorMap - <Test()> - Public Sub InitialiseCombinedAlternatorMapFromFile() + 'testCombinedAlternatorMap + <Test()> + Public Sub InitialiseCombinedAlternatorMapFromFile() - 'Arrange - Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals + 'Arrange + Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals - 'Act - Dim target As New CombinedAlternator(COMBINEDALT_GOODMAP) + 'Act + Dim target As New CombinedAlternator(COMBINEDALT_GOODMAP) - 'Assert + 'Assert - Assert.AreEqual(target.Alternators.Count, 4) + Assert.AreEqual(target.Alternators.Count, 4) - End Sub + End Sub - <Test()> - Public Sub InitialiseCombinedAlternatorMapFromDefault() + <Test()> + Public Sub InitialiseCombinedAlternatorMapFromDefault() - 'Arrange - Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals + 'Arrange + Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals - 'Act - Dim target As New CombinedAlternator("123.aalt") + 'Act + Dim target As New CombinedAlternator("123.aalt") - 'Assert - Assert.AreEqual(target.Alternators.Count, 2) + 'Assert + Assert.AreEqual(target.Alternators.Count, 2) - End Sub + End Sub - <Test()> - Public Sub AveragedEfficiency() + <Test()> + Public Sub AveragedEfficiency() - ' Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals() With {.CrankRPM=1750, .CurrentDemandAmps=170} + ' Dim signals As ICombinedAlternatorSignals = New CombinedAlternatorSignals() With {.CrankRPM=1750, .CurrentDemandAmps=170} - Dim ca As New CombinedAlternator("abc.aalt") + Dim ca As New CombinedAlternator("abc.aalt") - ca.Initialise() + ca.Initialise() - Dim actual As AlternatorMapValues = ca.GetEfficiency(1750, 170) + Dim actual As AlternatorMapValues = ca.GetEfficiency(1750, 170.SI(Of Ampere)) - Assert.AreEqual(0.684354842F, actual.Efficiency) + Assert.AreEqual(0.684354842F, actual.Efficiency) - End Sub + End Sub - '<Test()> - Public Sub Performance() + '<Test()> + Public Sub Performance() - Dim ca As New CombinedAlternator("abc.aalt") + Dim ca As New CombinedAlternator("abc.aalt") - ca.Initialise() + ca.Initialise() - Dim startDT As DateTime = DateTime.Now - Dim endDateDT As DateTime - Dim crank As Single - Dim demand As Single - Dim rand As New Random(50) + Dim startDT As DateTime = DateTime.Now + Dim endDateDT As DateTime + Dim crank As Single + Dim demand As Single + Dim rand As New Random(50) - Dim min As Single = 0.1 - Dim max As Single = 0.1 + Dim min As Double = 0.1 + Dim max As Double = 0.1 - For x = 1 To 500000 + For x = 1 To 500000 - 'crank = rand.Next(500,3000) - 'demand = rand.Next(1,200) + 'crank = rand.Next(500,3000) + 'demand = rand.Next(1,200) - crank = rand.Next(0, 0) - demand = rand.Next(0, 0) + crank = rand.Next(0, 0) + demand = rand.Next(0, 0) - Dim actual As AlternatorMapValues = ca.GetEfficiency(crank, demand) + Dim actual As AlternatorMapValues = ca.GetEfficiency(crank, demand.SI(Of Ampere)) - If actual.Efficiency < min Then min = actual.Efficiency + If actual.Efficiency < min Then min = actual.Efficiency - If actual.Efficiency > max Then max = actual.Efficiency + If actual.Efficiency > max Then max = actual.Efficiency - Next + Next - endDateDT = DateTime.Now + endDateDT = DateTime.Now - Dim secs As Single = (endDateDT - startDT).Seconds + Dim secs As Single = (endDateDT - startDT).Seconds - End Sub + End Sub - <Test()> - Public Sub AlternatorsAreEqual() + <Test()> + Public Sub AlternatorsAreEqual() - Dim ca As ICombinedAlternator = New CombinedAlternator("abc.aalt") - Dim original As ICombinedAlternator = New CombinedAlternator("abc.aalt") + Dim ca As ICombinedAlternator = New CombinedAlternator("abc.aalt") + Dim original As ICombinedAlternator = New CombinedAlternator("abc.aalt") - Assert.IsTrue(ca.IsEqualTo(original)) + Assert.IsTrue(ca.IsEqualTo(original)) - End Sub + End Sub - <Test()> - Public Sub AlternatorsUnequalName() + <Test()> + Public Sub AlternatorsUnequalName() - Dim ca As New CombinedAlternator("abc.aalt") - Dim original As New CombinedAlternator("abc.aalt") + Dim ca As New CombinedAlternator("abc.aalt") + Dim original As New CombinedAlternator("abc.aalt") - ca.Alternators(0).AlternatorName = "ZCZZCZCZCZCXXXYYY" + ca.Alternators(0).AlternatorName = "ZCZZCZCZCZCXXXYYY" - Assert.IsFalse(ca.IsEqualTo(original)) + Assert.IsFalse(ca.IsEqualTo(original)) - End Sub + End Sub - <Test()> - Public Sub AlternatorsUnequalPulley() + <Test()> + Public Sub AlternatorsUnequalPulley() - Dim ca As New CombinedAlternator("abc.aalt") - Dim original As New CombinedAlternator("abc.aalt") + Dim ca As New CombinedAlternator("abc.aalt") + Dim original As New CombinedAlternator("abc.aalt") - ca.Alternators(0).PulleyRatio = 9 + ca.Alternators(0).PulleyRatio = 9 - Assert.IsFalse(ca.IsEqualTo(original)) + Assert.IsFalse(ca.IsEqualTo(original)) - End Sub + End Sub - '<Test()> - ' Public Sub AlternatorsUnequalEfficiency() + '<Test()> + ' Public Sub AlternatorsUnequalEfficiency() - ' Dim ca As new CombinedAlternator("abc.aalt") - ' Dim original As new CombinedAlternator("abc.aalt") + ' Dim ca As new CombinedAlternator("abc.aalt") + ' Dim original As new CombinedAlternator("abc.aalt") - ' ca.Alternators(0).InputTable2000(1).Eff=0.99999 + ' ca.Alternators(0).InputTable2000(1).Eff=0.99999 - ' 'Only tests efficiency values table row 1-3 - ' Assert.IsFalse(ca.IsEqualTo( original)) + ' 'Only tests efficiency values table row 1-3 + ' Assert.IsFalse(ca.IsEqualTo( original)) - ' End Sub + ' End Sub - <Test()> - Public Sub AlternatorsUnequalEfficiency() + <Test()> + Public Sub AlternatorsUnequalEfficiency() - Dim ca As New CombinedAlternator("abc.aalt") - Dim original As New CombinedAlternator("abc.aalt") + Dim ca As New CombinedAlternator("abc.aalt") + Dim original As New CombinedAlternator("abc.aalt") - ca.Alternators(0).InputTable2000(1).Eff = 0.99999 + ca.Alternators(0).InputTable2000(1).Eff = 0.99999 - 'Only tests efficiency values table row 1-3 - Assert.IsFalse(ca.IsEqualTo(original)) + 'Only tests efficiency values table row 1-3 + Assert.IsFalse(ca.IsEqualTo(original)) - End Sub + End Sub - End Class + End Class End Namespace diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/CompressorMapTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/CompressorMapTests.vb index d0f3fbf06ae2bd0d444f1d3e437091e92364d4ff..d899a1c627ef52b26d8af96f0d1b0efc47fe204c 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/CompressorMapTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/CompressorMapTests.vb @@ -1,153 +1,142 @@ Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Pneumatics Namespace UnitTests - - <TestFixture()> - Public Class CompressorMapTests - - Private Const GOODMAP As String = "TestFiles\testCompressorMap.acmp" - Private Const INVALIDPOWERCOMPRESSORONMAP As String = "TestFiles\testCompressorMapInvalidOnPower.acmp" - Private Const INVALIDPOWERCOMPRESSOROFFMAP As String = "TestFiles\testCompressorMapInvalidOffPower.acmp" - Private Const INVALIDFLOWRATEMAP As String = "TestFiles\testCompressorMapInvalidFlow.acmp" - Private Const INSSUFICIENTROWSMAP As String = "TestFiles\testCompressorMapNotEnoughRows.acmp" - Private Const INVALIDRPMMAP As String = "TestFiles\testCompressorMapInvalidRpm.acmp" - Private Const INVALIDNUMBEROFCOLUMNS As String = "TestFiles\testCompressorMapWrongNumberOfColumns.acmp" + <TestFixture()> + Public Class CompressorMapTests + Private Const GOODMAP As String = "TestFiles\testCompressorMap.acmp" + Private Const INVALIDPOWERCOMPRESSORONMAP As String = "TestFiles\testCompressorMapInvalidOnPower.acmp" + Private Const INVALIDPOWERCOMPRESSOROFFMAP As String = "TestFiles\testCompressorMapInvalidOffPower.acmp" + Private Const INVALIDFLOWRATEMAP As String = "TestFiles\testCompressorMapInvalidFlow.acmp" + Private Const INSSUFICIENTROWSMAP As String = "TestFiles\testCompressorMapNotEnoughRows.acmp" + Private Const INVALIDRPMMAP As String = "TestFiles\testCompressorMapInvalidRpm.acmp" + Private Const INVALIDNUMBEROFCOLUMNS As String = "TestFiles\testCompressorMapWrongNumberOfColumns.acmp" #Region "Helpers" - Private Function GetInitialiseMap() As CompressorMap - Dim target As CompressorMap = GetMap() - target.Initialise() - Return target - End Function + Private Function GetInitialiseMap() As CompressorMap + Dim target As CompressorMap = GetMap() + target.Initialise() + Return target + End Function - Private Function GetMap() As CompressorMap - Dim path As String = GOODMAP - Dim target As CompressorMap = New CompressorMap(path) - Return target - End Function + Private Function GetMap() As CompressorMap + Dim path As String = GOODMAP + Dim target As CompressorMap = New CompressorMap(path) + Return target + End Function #End Region - <Test()> - Public Sub CreateNewCompressorMapInstanceTest() - Dim pat As String = "test" - Dim target As CompressorMap = New CompressorMap(pat) - End Sub - - - <Test()> - Public Sub InitialisationTest() - Dim target As CompressorMap = GetMap() - Assert.IsTrue(target.Initialise()) - End Sub - - <Test(), ExpectedException("System.ArgumentException")> - Public Sub InitialisationNoFileSuppliedThrowsExceptionTest() - Dim path As String = "" - Dim target As CompressorMap = New CompressorMap(path) - Assert.IsTrue(target.Initialise()) - End Sub - - <Test(), ExpectedException("System.ArgumentException")> - Public Sub InitialisationWrongNumberOfColumnsThrowsExceptionTest() - Dim path As String = INVALIDNUMBEROFCOLUMNS - Dim target As CompressorMap = New CompressorMap(path) - target.Initialise() - End Sub - - <Test(), ExpectedException("System.InvalidCastException")> - Public Sub InitialisationInvalidRpmThrowsExceptionTest() - Dim path As String = INVALIDRPMMAP - Dim target As CompressorMap = New CompressorMap(path) - target.Initialise() - End Sub - - <Test(), ExpectedException("System.InvalidCastException")> - Public Sub InitialisationInvalidFlowRateThrowsExceptionTest() - Dim path As String = INVALIDFLOWRATEMAP - Dim target As CompressorMap = New CompressorMap(path) - target.Initialise() - End Sub - - <Test(), ExpectedException("System.InvalidCastException")> - Public Sub InitialisationInvalidPowerCompressorOnThrowsExceptionTest() - Dim path As String = INVALIDPOWERCOMPRESSORONMAP - Dim target As CompressorMap = New CompressorMap(path) - target.Initialise() - End Sub - - <Test(), ExpectedException("System.InvalidCastException")> - Public Sub InitialisationInvalidPowerCompressorOffThrowsExceptionTest() - Dim path As String = INVALIDPOWERCOMPRESSOROFFMAP - Dim target As CompressorMap = New CompressorMap(path) - target.Initialise() - End Sub - - <Test(), ExpectedException("System.ArgumentException")> - Public Sub InitialisationInsufficientRowsThrowsExceptionTest() - Dim path As String = INSSUFICIENTROWSMAP - Dim target As CompressorMap = New CompressorMap(path) - target.Initialise() - End Sub - - - <Test()> - Public Sub GetFlowRateKeyPassedTest() - Dim target As CompressorMap = GetInitialiseMap() - Dim expected As Single = 400 - Dim value As Single = target.GetFlowRate(2000) - Assert.AreEqual(expected, value) - End Sub - - <Test()> - Public Sub GetFlowRateInterpolaitionTest() - Dim target As CompressorMap = GetInitialiseMap() - Dim expected As Single = 500 - Dim value As Single = target.GetFlowRate(2500) - Assert.AreEqual(expected, value) - End Sub - - - - - - <Test()> - Public Sub GetPowerCompressorOnInterpolaitionTest() - Dim target As CompressorMap = GetInitialiseMap() - Dim expected As Single = 5000 - Dim value As Single = target.GetPowerCompressorOn(2500) - Assert.AreEqual(expected, value) - End Sub - - - - - <Test()> - Public Sub GetPowerCompressorOffInterpolaitionTest() - Dim target As CompressorMap = GetInitialiseMap() - Dim expected As Single = 2500 - Dim value As Single = target.GetPowerCompressorOff(2500) - Assert.AreEqual(expected, value) - End Sub - - - - <Test()> - Public Sub InterpMiddle() - - Dim target As CompressorMap = New CompressorMap(GOODMAP) - Assert.IsTrue(target.Initialise()) - - Dim actual = target.GetFlowRate(1750) - - Assert.AreEqual( actual,300) - - End Sub - - - End Class - + <Test()> + Public Sub CreateNewCompressorMapInstanceTest() + Dim pat As String = "test" + Dim target As CompressorMap = New CompressorMap(pat) + End Sub + + + <Test()> + Public Sub InitialisationTest() + Dim target As CompressorMap = GetMap() + Assert.IsTrue(target.Initialise()) + End Sub + + <Test(), ExpectedException("System.ArgumentException")> + Public Sub InitialisationNoFileSuppliedThrowsExceptionTest() + Dim path As String = "" + Dim target As CompressorMap = New CompressorMap(path) + Assert.IsTrue(target.Initialise()) + End Sub + + <Test(), ExpectedException("System.ArgumentException")> + Public Sub InitialisationWrongNumberOfColumnsThrowsExceptionTest() + Dim path As String = INVALIDNUMBEROFCOLUMNS + Dim target As CompressorMap = New CompressorMap(path) + target.Initialise() + End Sub + + <Test(), ExpectedException("System.InvalidCastException")> + Public Sub InitialisationInvalidRpmThrowsExceptionTest() + Dim path As String = INVALIDRPMMAP + Dim target As CompressorMap = New CompressorMap(path) + target.Initialise() + End Sub + + <Test(), ExpectedException("System.InvalidCastException")> + Public Sub InitialisationInvalidFlowRateThrowsExceptionTest() + Dim path As String = INVALIDFLOWRATEMAP + Dim target As CompressorMap = New CompressorMap(path) + target.Initialise() + End Sub + + <Test(), ExpectedException("System.InvalidCastException")> + Public Sub InitialisationInvalidPowerCompressorOnThrowsExceptionTest() + Dim path As String = INVALIDPOWERCOMPRESSORONMAP + Dim target As CompressorMap = New CompressorMap(path) + target.Initialise() + End Sub + + <Test(), ExpectedException("System.InvalidCastException")> + Public Sub InitialisationInvalidPowerCompressorOffThrowsExceptionTest() + Dim path As String = INVALIDPOWERCOMPRESSOROFFMAP + Dim target As CompressorMap = New CompressorMap(path) + target.Initialise() + End Sub + + <Test(), ExpectedException("System.ArgumentException")> + Public Sub InitialisationInsufficientRowsThrowsExceptionTest() + Dim path As String = INSSUFICIENTROWSMAP + Dim target As CompressorMap = New CompressorMap(path) + target.Initialise() + End Sub + + + <Test()> + Public Sub GetFlowRateKeyPassedTest() + Dim target As CompressorMap = GetInitialiseMap() + Dim expected As Single = 400 + Dim value As NormLiterPerSecond = target.GetFlowRate(2000) + Assert.AreEqual(expected, value.Value(), 0.001) + End Sub + + <Test()> + Public Sub GetFlowRateInterpolaitionTest() + Dim target As CompressorMap = GetInitialiseMap() + Dim expected As Single = 500 + Dim value As NormLiterPerSecond = target.GetFlowRate(2500) + Assert.AreEqual(expected, value.Value(), 0.001) + End Sub + + + <Test()> + Public Sub GetPowerCompressorOnInterpolaitionTest() + Dim target As CompressorMap = GetInitialiseMap() + Dim expected As Single = 5000 + Dim value As Watt = target.GetPowerCompressorOn(2500) + Assert.AreEqual(expected, value.Value(), 0.001) + End Sub + + + <Test()> + Public Sub GetPowerCompressorOffInterpolaitionTest() + Dim target As CompressorMap = GetInitialiseMap() + Dim expected As Single = 2500 + Dim value As Watt = target.GetPowerCompressorOff(2500) + Assert.AreEqual(expected, value.Value(), 0.001) + End Sub + + + <Test()> + Public Sub InterpMiddle() + + Dim target As CompressorMap = New CompressorMap(GOODMAP) + Assert.IsTrue(target.Initialise()) + + Dim actual = target.GetFlowRate(1750) + + Assert.AreEqual(300, actual.Value(), 0.001) + End Sub + End Class End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerListTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerListTests.vb index c72c90a42a043617f64fd338f05a4ee2dd7a9af0..76d9d1b63ac8bd686def9db4836dd0e466bb4bac 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerListTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerListTests.vb @@ -1,65 +1,57 @@ Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics <TestFixture()> Public Class ElectricalConsumerListTests + Private TestConsumerList As ElectricalConsumerList = New ElectricalConsumerList(26.3, 0.096, True) -Private TestConsumerList As ElectricalConsumerList = New ElectricalConsumerList(26.3,0.096,True) + Sub New() + End Sub -Sub New() -End Sub + <Test()> + Public Sub CreateNewTest() + Dim target As New ElectricalConsumerList(26.3, 0.096, True) -<Test()> -Public Sub CreateNewTest() + Assert.IsNotNull(target) + End Sub - Dim target As New ElectricalConsumerList(26.3,0.096, True) - Assert.IsNotNull(target) + <Test()> + Public Sub SumAllConsumersTest() -End Sub + TestConsumerList.Items.First(Function(item) item.ConsumerName = "Controllers,Valves etc").NumberInActualVehicle = 1 + Dim actual As Ampere = TestConsumerList.GetTotalAverageDemandAmps(False) -<Test()> -Public Sub SumAllConsumersTest() + TestConsumerList.Items.First(Function(item) item.ConsumerName = "Controllers,Valves etc").NumberInActualVehicle = 0 - TestConsumerList.Items.First(Function(item) item.ConsumerName= "Controllers,Valves etc").NumberInActualVehicle=1 + Dim expected = 60.63 - Dim actual As Single = TestConsumerList.GetTotalAverageDemandAmps( False) + Assert.AreEqual(expected, actual.Value(), 0.01) + End Sub - TestConsumerList.Items.First(Function(item) item.ConsumerName= "Controllers,Valves etc").NumberInActualVehicle=0 + <Test()> + Public Sub SumNonExcludedConsumersTest() - Dim expected = 60.63 - - Assert.AreEqual(expected, Math.Round(actual,2)) - -End Sub - -<Test()> -Public Sub SumNonExcludedConsumersTest() - - TestConsumerList.Items.First(Function(item) item.ConsumerName= "Controllers,Valves etc").NumberInActualVehicle=1 - Dim actual As Single = TestConsumerList.GetTotalAverageDemandAmps(True) - TestConsumerList.Items.First(Function(item) item.ConsumerName= "Controllers,Valves etc").NumberInActualVehicle=0 - Dim expected = 35.63 - Assert.AreEqual(expected, Math.Round(actual,2)) - -End Sub - - -<Test()> -<ExpectedException("System.ArgumentException")> _ -Public Sub DuplicateConsumersTest_ThrowsArgumentException() - - Dim target As New ElectricalConsumerList(0.096,26.3) - 'Add two OnBaseVehicle consumers - target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1,"")) - target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1,"")) - -End Sub + TestConsumerList.Items.First(Function(item) item.ConsumerName = "Controllers,Valves etc").NumberInActualVehicle = 1 + Dim actual As Ampere = TestConsumerList.GetTotalAverageDemandAmps(True) + TestConsumerList.Items.First(Function(item) item.ConsumerName = "Controllers,Valves etc").NumberInActualVehicle = 0 + Dim expected = 35.63 + Assert.AreEqual(expected, actual.Value(), 0.01) + End Sub + <Test()> + <ExpectedException("System.ArgumentException")> + Public Sub DuplicateConsumersTest_ThrowsArgumentException() + Dim target As New ElectricalConsumerList(0.096, 26.3) + 'Add two OnBaseVehicle consumers + target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1, "")) + target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1, "")) + End Sub End Class diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerTests.vb index e227cfb538b46a9e19e48896df46f5a8a46b809e..23c1fd81af72910b6d4517d94c347ed12a773f06 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/ElectricalConsumerTests.vb @@ -1,75 +1,82 @@ Imports VectoAuxiliaries.Electrics Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Namespace UnitTests - - <TestFixture()> - Public Class ElectricalConsumerTests + <TestFixture()> + Public Class ElectricalConsumerTests #Region "Helpers" - - - Public Function GetGoodConsumer() As ElectricalConsumer - Return New ElectricalConsumer(False, "Doors", "Doors per Door", 20, 0.5, 26.3, 1,"") - End Function + Public Function GetGoodConsumer() As ElectricalConsumer + Return New ElectricalConsumer(False, "Doors", "Doors per Door", 20, 0.5, 26.3, 1, "") + End Function #End Region - <Test()> - Public Sub CreateNewTest() - Dim target As ElectricalConsumer = GetGoodConsumer() - Assert.IsNotNull(target) - End Sub - - ' <Test(), ExpectedException("System.ArgumentException")> - - <Test(), ExpectedException("System.ArgumentException")> - Public Sub ZeroLengthConsumerNameTest() - - Dim target As New ElectricalConsumer(False, "Doors", "", 20, 0.5, 26.3, 1,"") + <Test()> + Public Sub CreateNewTest() + Dim target As ElectricalConsumer = GetGoodConsumer() + Assert.IsNotNull(target) + End Sub - End Sub + ' <Test(), ExpectedException("System.ArgumentException")> - <Test(), ExpectedException("System.ArgumentException")> - Public Sub ZeroLengthCategoryNameTest_ThrowsArgumentException() + <Test(), ExpectedException("System.ArgumentException")> + Public Sub ZeroLengthConsumerNameTest() - Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, 26.3, 1,"") + Dim target As New ElectricalConsumer(False, "Doors", "", 20, 0.5, 26.3, 1, "") + End Sub - End Sub + <Test(), ExpectedException("System.ArgumentException")> + Public Sub ZeroLengthCategoryNameTest_ThrowsArgumentException() + Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, 26.3, 1, "") + End Sub - 'TooLow NominalConsumption - 'TooHigh NominalConsumption + 'TooLow NominalConsumption + 'TooHigh NominalConsumption - <Test(), ExpectedException("System.ArgumentException")> - Public Sub ToLow_PhaseIdleTractionOn_ThrowsArgumentException() - Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, ElectricConstants.PhaseIdleTractionOnMin - 1, 26.3, 1,"") - End Sub - <Test(), ExpectedException("System.ArgumentException")> - Public Sub ToHigh_PhaseIdleTractionOn_ThrowsArgumentException() - Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, ElectricConstants.PhaseIdleTractionMax + 1, 26.3, 1,"") - End Sub + <Test(), ExpectedException("System.ArgumentException")> + Public Sub ToLow_PhaseIdleTractionOn_ThrowsArgumentException() + Dim _ + target As _ + New ElectricalConsumer(False, "", "Doors per Door", 20, ElectricConstants.PhaseIdleTractionOnMin - 1, + 26.3, 1, "") + End Sub + <Test(), ExpectedException("System.ArgumentException")> + Public Sub ToHigh_PhaseIdleTractionOn_ThrowsArgumentException() + Dim _ + target As _ + New ElectricalConsumer(False, "", "Doors per Door", 20, ElectricConstants.PhaseIdleTractionMax + 1, + 26.3, 1, "") + End Sub - <Test(), ExpectedException("System.ArgumentException")> - Public Sub ToLowNumberInVehicle_ThrowsArgumentException() - Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, 26.3, -1,"") - End Sub - 'TooLow PowerNetVoltage - <Test(), ExpectedException("System.ArgumentException")> - Public Sub ToLowPowerNetVoltageTest_ThrowsArgumentException() - Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, ElectricConstants.PowenetVoltageMin - 1, 1,"") - End Sub + <Test(), ExpectedException("System.ArgumentException")> + Public Sub ToLowNumberInVehicle_ThrowsArgumentException() + Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, 26.3, -1, "") + End Sub - 'TooHigh PowerNetVoltage - Public Sub ToHighPowerNetVoltageTest_ThrowsArgumentException() - Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, ElectricConstants.PowenetVoltageMax + 1, 1,"") - End Sub + 'TooLow PowerNetVoltage + <Test(), ExpectedException("System.ArgumentException")> + Public Sub ToLowPowerNetVoltageTest_ThrowsArgumentException() + Dim _ + target As _ + New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, + (ElectricConstants.PowenetVoltageMin - 1), 1, "") + End Sub - End Class + 'TooHigh PowerNetVoltage + Public Sub ToHighPowerNetVoltageTest_ThrowsArgumentException() + Dim _ + target As _ + New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, + (ElectricConstants.PowenetVoltageMax + 1), 1, "") + End Sub + End Class End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_5_SmartAlternatorSetEfficiencyTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_5_SmartAlternatorSetEfficiencyTests.vb index 6e23f9ad6e1621f1eb891e68fe429f7ac3084fd3..c8bb4610d3731cae15c7d1756ffd1ad56faf3c03 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_5_SmartAlternatorSetEfficiencyTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_5_SmartAlternatorSetEfficiencyTests.vb @@ -2,137 +2,122 @@ Imports VectoAuxiliaries.Hvac Imports VectoAuxiliaries Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Namespace UnitTests + <TestFixture()> + Public Class M0_5_SmartAlternatorSetEfficiencyTests + Private target As M0_5_SmartAlternatorSetEfficiency + Private signals = New Signals -<TestFixture()> -Public Class M0_5_SmartAlternatorSetEfficiencyTests + Public Sub New() -Private target As M0_5_SmartAlternatorSetEfficiency -Private signals = New Signals + Initialise() + End Sub -Public Sub new() -Initialise() + Private Function GetSSM() As ISSMTOOL -End Sub - -Private Function GetSSM() As ISSMTOOL - - - Const _SSMMAP As String = "TestFiles\ssm.Ahsm + Const _SSMMAP As String = "TestFiles\ssm.Ahsm" 'Const _BusDatabase As String ="TestFiles\BusDatabase.abdb - Dim ssm As ISSMTOOL = New SSMTOOL(_SSMMAP, New HVACConstants()) - - - ssm.Load( _SSMMAP) - - - Return ssm - + Dim ssm As ISSMTOOL = New SSMTOOL(_SSMMAP, New HVACConstants()) -End Function -Private sub Initialise() + ssm.Load(_SSMMAP) -Dim ssm As ISSMTOOL = GetSSM() -Dim elecConsumers As New ElectricalConsumerList(26.3,0.096,True) + Return ssm + End Function -'Dim hvacMap As New HVACMap("testFiles\TestHvacMap.csv") -'hvacMap.Initialise() -Dim alternatoMap As New AlternatorMap("testFiles\testAlternatormap.aalt") -alternatoMap.Initialise() + Private Sub Initialise() -Dim signals = New Signals() -signals.EngineSpeed=2000 -Dim m0 As New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers,alternatoMap,26.3,signals,ssm) + Dim ssm As ISSMTOOL = GetSSM() + Dim elecConsumers As New ElectricalConsumerList(26.3, 0.096, True) -'Results Cards -Dim readings = new List(of SmartResult) -readings.Add(new SmartResult(10,8)) -readings.Add(New SmartResult(70,63)) + 'Dim hvacMap As New HVACMap("testFiles\TestHvacMap.csv") + 'hvacMap.Initialise() + Dim alternatoMap As New AlternatorMap("testFiles\testAlternatormap.aalt") + alternatoMap.Initialise() -Dim idleResult As New ResultCard(readings) -Dim tractionResult As New ResultCard(readings) -Dim overrunResult As New ResultCard(readings) + Dim signals = New Signals() + signals.EngineSpeed = 2000.RPMtoRad() + Dim m0 As New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, alternatoMap, 26.3.SI(Of Volt), signals, ssm) - signals.EngineSpeed=2000 - target = New M0_5_SmartAlternatorSetEfficiency(m0,elecConsumers,alternatoMap,idleResult,tractionResult,overrunResult, signals) + 'Results Cards + Dim readings = New List(Of SmartResult) + readings.Add(New SmartResult(10, 8)) + readings.Add(New SmartResult(70, 63)) -End Sub + Dim idleResult As New ResultCard(readings) + Dim tractionResult As New ResultCard(readings) + Dim overrunResult As New ResultCard(readings) -<Test()> _ -Public Sub CreateNewTest() - Initialise() - Assert.IsNotNull( target) -End Sub -<Test()> _ -Public Sub SmartIdleCurrentTest() - Initialise() - Assert.IsNotNull( target) -End Sub + signals.EngineSpeed = 2000.RPMtoRad() + target = New M0_5_SmartAlternatorSetEfficiency(m0, elecConsumers, alternatoMap, idleResult, tractionResult, + overrunResult, signals) + End Sub -<Test()> _ -Public Sub SmartTractionCurrentTest() - Initialise() - Assert.IsNotNull( target) -End Sub + <Test()> + Public Sub CreateNewTest() + Initialise() + Assert.IsNotNull(target) + End Sub -<Test()> _ -Public Sub SmartOverrunCurrentTest() - Initialise() - Assert.IsNotNull( target) -End Sub + <Test()> + Public Sub SmartIdleCurrentTest() + Initialise() + Assert.IsNotNull(target) + End Sub -<Test()> _ -Public Sub AlternatorsEfficiencyIdle2000rpmTest() - Initialise() + <Test()> + Public Sub SmartTractionCurrentTest() + Initialise() + Assert.IsNotNull(target) + End Sub - Dim expected As Single = 0.6308339 - Dim actual As Single = target.AlternatorsEfficiencyIdleResultCard() + <Test()> + Public Sub SmartOverrunCurrentTest() + Initialise() + Assert.IsNotNull(target) + End Sub - Assert.AreEqual(expected, actual) - + <Test()> + Public Sub AlternatorsEfficiencyIdle2000rpmTest() + Initialise() -End Sub + Dim expected As Double = 0.6308339 + Dim actual As Double = target.AlternatorsEfficiencyIdleResultCard() + Assert.AreEqual(expected, actual, 0.000001) + End Sub -<Test()> _ -Public Sub AlternatorsEfficiencyTraction2000rpmTest() - Initialise() - Dim expected As Single = 0.6308339 - Dim actual As Single = target.AlternatorsEfficiencyTractionOnResultCard() + <Test()> + Public Sub AlternatorsEfficiencyTraction2000rpmTest() + Initialise() - Assert.AreEqual(expected, actual) + Dim expected As Double = 0.6308339 + Dim actual As Double = target.AlternatorsEfficiencyTractionOnResultCard() -End Sub + Assert.AreEqual(expected, actual, 0.000001) + End Sub -<Test()> _ -Public Sub AlternatorsEfficiencyOverrun2000rpmTest() - Initialise() - - Dim expected As Single = 0.6308339 - Dim actual As Single = target.AlternatorsEfficiencyOverrunResultCard() - - Assert.AreEqual(expected, actual) - -End Sub - - - -End Class + <Test()> + Public Sub AlternatorsEfficiencyOverrun2000rpmTest() + Initialise() + Dim expected As Double = 0.6308339 + Dim actual As Double = target.AlternatorsEfficiencyOverrunResultCard() + Assert.AreEqual(expected, actual, 0.000001) + End Sub + End Class End Namespace - - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_NonSmart_AlternatorsSetEfficiencyTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_NonSmart_AlternatorsSetEfficiencyTests.vb index 11112d24edb081c46b5a11629ef5c2d49a6066d1..d4a8990c6523d47000ad8cf13958fda2ac2bf4e0 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_NonSmart_AlternatorsSetEfficiencyTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M0_NonSmart_AlternatorsSetEfficiencyTests.vb @@ -1,4 +1,5 @@ Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliariesTests.Mocks @@ -6,94 +7,90 @@ Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Hvac Namespace UnitTests + <TestFixture()> + Public Class M0_NonSmart_AlternatorsSetEfficiencyTests + Private Const cstrAlternatorsEfficiencyMapLocation As String = "tests\testAlternatorMap.aalt" + Private Const cstrHVACMapLocation As String = "TestFiles\TestHvacMap.csv" + Private Const cstrAlternatorMap As String = "TestFiles\testAlternatorMap.aalt" - <TestFixture()> - Public Class M0_NonSmart_AlternatorsSetEfficiencyTests + Private elecConsumers As IElectricalConsumerList - Private Const cstrAlternatorsEfficiencyMapLocation As String = "tests\testAlternatorMap.aalt" - Private Const cstrHVACMapLocation As String = "TestFiles\TestHvacMap.csv" - Private Const cstrAlternatorMap As String = "TestFiles\testAlternatorMap.aalt" + Private alternatorMap As IAlternatorMap + Private signals As Signals = New Signals + Private powernetVoltage As Volt = 26.3.SI(Of Volt)() + Private ssm As IHVACSteadyStateModel = New HVACSteadyStateModel(100, 100, 100) - Private elecConsumers As IElectricalConsumerList + Private Function GetSSM() As ISSMTOOL - Private alternatorMap As IAlternatorMap - Private signals As Signals = New Signals - Private powernetVoltage As Single = 26.3 - Private ssm As IHVACSteadyStateModel = New HVACSteadyStateModel(100, 100, 100) + Const _SSMMAP As String = "TestFiles\ssm.Ahsm" - Private Function GetSSM() As ISSMTOOL + Dim ssm As ISSMTOOL = New SSMTOOL(_SSMMAP, New HVACConstants()) + ssm.Load(_SSMMAP) - Const _SSMMAP As String = "TestFiles\ssm.Ahsm" + Return ssm + End Function - Dim ssm As ISSMTOOL = New SSMTOOL(_SSMMAP, New HVACConstants()) - ssm.Load(_SSMMAP) + Public Sub New() - Return ssm + signals.EngineSpeed = 2000.RPMtoRad() - End Function + 'Setup consumers and HVAC ( 1 Consumer in Test Category ) + elecConsumers = CType(New ElectricalConsumerList(0.096, 26.3), IElectricalConsumerList) + elecConsumers.AddConsumer(New ElectricalConsumer(False, "TEST", "CONSUMER1", 20, 0.5, + 26.3, 1, "")) - Public Sub New() + 'Alternator Map + alternatorMap = CType(New AlternatorMap(cstrAlternatorMap), IAlternatorMap) + alternatorMap.Initialise() + End Sub - signals.EngineSpeed = 2000 + <Test()> + Public Sub CreateNewTest() + Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, + alternatorMap, powernetVoltage, signals, GetSSM()) + Assert.IsNotNull(target) + End Sub - 'Setup consumers and HVAC ( 1 Consumer in Test Category ) - elecConsumers = CType(New ElectricalConsumerList(0.096, 26.3), IElectricalConsumerList) - elecConsumers.AddConsumer(New ElectricalConsumer(False, "TEST", "CONSUMER1", 20, 0.5, 26.3, 1, "")) + <Test()> + <ExpectedException("System.ArgumentException")> + Public Sub CreateNew_MissingElecConsumers_ThrowArgumentExceptionTest() + Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(Nothing, alternatorMap, + powernetVoltage, signals, GetSSM()) + End Sub - 'Alternator Map - alternatorMap = CType(New AlternatorMap(cstrAlternatorMap), IAlternatorMap) - alternatorMap.Initialise() + <Test()> + <ExpectedException("System.ArgumentException")> + Public Sub CreateNew_MissingAlternatorMap_ThrowArgumentExceptionTest() + Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, Nothing, + powernetVoltage, signals, GetSSM()) + End Sub - End Sub + <Test()> + Public Sub EfficiencyValueTest() + Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, + alternatorMap, powernetVoltage, signals, GetSSM()) - <Test()> - Public Sub CreateNewTest() - Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, alternatorMap, powernetVoltage, signals, GetSSM()) - Assert.IsNotNull(target) - End Sub + Dim actual As Single = target.AlternatorsEfficiency - <Test()> - <ExpectedException("System.ArgumentException")> - Public Sub CreateNew_MissingElecConsumers_ThrowArgumentExceptionTest() - Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(Nothing, alternatorMap, powernetVoltage, signals, GetSSM()) - End Sub + Dim expected As Single = 0.62 - <Test()> - <ExpectedException("System.ArgumentException")> - Public Sub CreateNew_MissingAlternatorMap_ThrowArgumentExceptionTest() - Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, Nothing, powernetVoltage, signals, GetSSM()) - End Sub + Assert.AreEqual(expected, actual, 0.001) + End Sub - <Test()> - Public Sub EfficiencyValueTest() - Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, alternatorMap, powernetVoltage, signals, GetSSM()) + <Test()> + Public Sub HVAC_PowerDemandAmpsTest() - Dim actual As Single = target.AlternatorsEfficiency + Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, + alternatorMap, powernetVoltage, signals, GetSSM()) - Dim expected As Single = 0.62 + Dim actual As Ampere + Dim expected As Single = 0 - Assert.AreEqual(expected, actual) - - - End Sub - - <Test()> - Public Sub HVAC_PowerDemandAmpsTest() - - Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, alternatorMap, powernetVoltage, signals, GetSSM()) - - Dim actual As Single - Dim expected As Single = 0 - - actual = target.GetHVACElectricalPowerDemandAmps() - - Assert.AreEqual(expected, actual) - - End Sub - - End Class + actual = target.GetHVACElectricalPowerDemandAmps() + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M10Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M10Tests.vb index 83b135530344c7dd1966f943296932f3d8e8247d..c637132d749fef1318dfd3dec09e7dda28fcc1be 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M10Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M10Tests.vb @@ -5,47 +5,37 @@ Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework Imports VectoAuxiliaries Imports Moq +Imports TUGraz.VectoCommon.Utils Namespace UnitTests - -<TestFixture()> -Public Class M10Test - - - -<Test()> _ -<TestCase(8,8,0,2,4,2,5,5.75f,3.5f)> _ -Public Sub InterpolationTests( x1 As Single ,y1 As Single ,x2 As single,y2 As single,x3 As single,y3 As single,xTAir As single, out1 As single, out2 as single) - -Dim m3 As new Mock( Of IM3_AveragePneumaticLoadDemand) -Dim m9 As new Mock( Of IM9) -Dim signals As New Signals() ' Not required , here for expansion only. - -m3.Setup( Function(x) x.AverageAirConsumedPerSecondLitre).Returns( xTAir ) -m9.Setup( Function(x) x.LitresOfAirCompressorOnContinually).Returns(x1) -m9.Setup( Function(x) x.TotalCycleFuelConsumptionCompressorOnContinuously).Returns(y1) -'x2 is not an output of m9, an is allways zero, but to keep in line with schematic, is represented anyway although it is a constant. -m9.Setup( Function(x) x.TotalCycleFuelConsumptionCompressorOffContinuously).Returns( y2) -m9.Setup( Function(x) x.LitresOfAirCompressorOnOnlyInOverrun).Returns( x3) -m9.Setup( Function(x) x.TotalCycleFuelConsumptionCompressorOffContinuously).Returns(y3) - - -Dim target As IM10 = New M10(m3.Object,m9.Object,Signals) - -target.CycleStep(1) - -Assert.AreEqual(out1, target.AverageLoadsFuelConsumptionInterpolatedForPneumatics ) -Assert.AreEqual(out2, target.FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand ) - - - - -End Sub - - -End Class - + <TestFixture()> + Public Class M10Test + <Test()> _ + <TestCase(8, 8, 0, 2, 4, 2, 5, 5.75, 3.5)> + Public Sub InterpolationTests(x1 As Double, y1 As Double, x2 As Double, y2 As Double, x3 As Double, y3 As Double, + xTAir As Double, out1 As Double, out2 As Double) + + Dim m3 As New Mock(Of IM3_AveragePneumaticLoadDemand) + Dim m9 As New Mock(Of IM9) + Dim signals As New Signals() ' Not required , here for expansion only. + + m3.Setup(Function(x) x.AverageAirConsumedPerSecondLitre).Returns(xTAir.SI(Of NormLiterPerSecond)) + m9.Setup(Function(x) x.LitresOfAirCompressorOnContinually).Returns(x1.SI(Of NormLiter)) + m9.Setup(Function(x) x.TotalCycleFuelConsumptionCompressorOnContinuously).Returns((y1 / 1000).SI(Of Kilogram)) + 'x2 is not an output of m9, an is allways zero, but to keep in line with schematic, is represented anyway although it is a constant. + m9.Setup(Function(x) x.TotalCycleFuelConsumptionCompressorOffContinuously).Returns((y2 / 1000).SI(Of Kilogram)) + m9.Setup(Function(x) x.LitresOfAirCompressorOnOnlyInOverrun).Returns(x3.SI(Of NormLiter)) + m9.Setup(Function(x) x.TotalCycleFuelConsumptionCompressorOffContinuously).Returns((y3 / 1000).SI(Of Kilogram)) + + + Dim target As IM10 = New M10(m3.Object, m9.Object, signals) + + target.CycleStep(1.SI(Of Second)) + + Assert.AreEqual(out1.SI().Gramm.Value(), target.AverageLoadsFuelConsumptionInterpolatedForPneumatics.Value(), 0.001) + Assert.AreEqual(out2.SI().Gramm.Value(), target.FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand.Value(), 0.001) + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M11Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M11Tests.vb index 1791559c2412d3f7e95ea4fde71d7c772f114c4c..349ad34dfb3110030d042cc90b08fe14163dd2da 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M11Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M11Tests.vb @@ -5,139 +5,125 @@ Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework Imports VectoAuxiliaries Imports Moq +Imports TUGraz.VectoCommon.Utils Namespace UnitTests -<TestFixture()> _ -Public Class M11Tests - -<Test()> _ -<TestCase(0,50,60,70,80,90,1500,False , 0,50,60,0.2182501f,0.2182059f,60)> _ -<TestCase(1,50,60,70,80,90,1500,False ,50,50,60,0.2182501f,0.2182059f,60)> _ -<TestCase(1,50,60,70,80,90,1500,True , 0, 0,60,0 ,0 ,0)> _ -Public Sub InputOutputValues( IP1 As single, - IP2 As single, - IP3 As single, - IP4 As single, - IP5 As single, - IP6 As single, - IP7 As single, - IP8 As Boolean, - OUT1 As single, - OUT2 As single, - OUT3 As single, - OUT4 As single, - OUT5 As single, - OUT6 As single) - -'Arrange - - Dim m1Mock As New Mock(Of IM1_AverageHVACLoadDemand) - Dim m3Mock As New Mock(Of IM3_AveragePneumaticLoadDemand) - - - Dim m6Mock As New Mock(Of IM6) - Dim m8Mock As New Mock(Of IM8) - Dim sgnlsMock As New Mock(Of ISignals) - Dim fmap As New MockFuel50pc - - - - - m6Mock .Setup( Function(x) x.OverrunFlag) .Returns( IP1 ) - m8Mock .Setup( Function(x) x.SmartElectricalAlternatorPowerGenAtCrank) .Returns( IP2 ) - m6Mock .Setup( Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC) .Returns( IP3 ) - sgnlsMock.Setup( Function(x) x.EngineDrivelineTorque) .Returns( IP4 ) - m3Mock .Setup( Function(x) x.GetAveragePowerDemandAtCrankFromPneumatics) .Returns( IP5 ) - m1Mock .Setup( Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts) .Returns( IP6 ) - sgnlsMock.Setup( Function(x) x.EngineSpeed) .Returns( IP7 ) - sgnlsMock.Setup( Function(x) x.EngineStopped) .Returns( IP8 ) - - - 'Act - Dim target = New M11( m1Mock.Object,m3Mock.Object, m6Mock.Object,m8Mock.Object,fmap ,sgnlsMock.Object)',m3Mock.Object,m6Mock.Object,m8Mock.Object,fmap,sgnlsMock.Object) - - 'Add Current Calculation to Internal Aggregates ( Accesseed by public output properties which are external interface ) - target.CycleStep(1) - - - 'Assert - Assert.AreEqual( target.SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly,OUT1) - Assert.AreEqual( target.SmartElectricalTotalCycleEletricalEnergyGenerated,OUT2) - Assert.AreEqual( target.TotalCycleElectricalDemand,OUT3) - Assert.AreEqual( Math.Round(CType(target.TotalCycleFuelConsumptionSmartElectricalLoad,Decimal),7),OUT4) - Assert.AreEqual( Math.Round(CType(target.TotalCycleFuelConsumptionZeroElectricalLoad,Decimal),7),OUT5) - Assert.AreEqual( Math.Round(CType(target.StopStartSensitiveTotalCycleElectricalDemand,Decimal),7),OUT6) - - - -End Sub - - -<Test()> _ -<TestCase(1,50,60,70,80,90,1500,True , 0, 0,60,0 ,0 ,0)> -Public Sub UnaggregatedInputOutputValues( IP1 As single, - IP2 As single, - IP3 As single, - IP4 As single, - IP5 As single, - IP6 As single, - IP7 As single, - IP8 As Boolean, - OUT1 As single, - OUT2 As single, - OUT3 As single, - OUT4 As single, - OUT5 As single, - OUT6 As single) - -'Arrange - - Dim m1Mock As New Mock(Of IM1_AverageHVACLoadDemand) - Dim m3Mock As New Mock(Of IM3_AveragePneumaticLoadDemand) - - - Dim m6Mock As New Mock(Of IM6) - Dim m8Mock As New Mock(Of IM8) - Dim sgnlsMock As New Mock(Of ISignals) - Dim fmap As New MockFuel50pc - - - - - m6Mock .Setup( Function(x) x.OverrunFlag) .Returns( IP1 ) - m8Mock .Setup( Function(x) x.SmartElectricalAlternatorPowerGenAtCrank) .Returns( IP2 ) - m6Mock .Setup( Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC) .Returns( IP3 ) - sgnlsMock.Setup( Function(x) x.EngineDrivelineTorque) .Returns( IP4 ) - m3Mock .Setup( Function(x) x.GetAveragePowerDemandAtCrankFromPneumatics) .Returns( IP5 ) - m1Mock .Setup( Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts) .Returns( IP6 ) - sgnlsMock.Setup( Function(x) x.EngineSpeed) .Returns( IP7 ) - sgnlsMock.Setup( Function(x) x.EngineStopped) .Returns( IP8 ) - - - 'Act - Dim target = New M11( m1Mock.Object,m3Mock.Object, m6Mock.Object,m8Mock.Object,fmap ,sgnlsMock.Object)',m3Mock.Object,m6Mock.Object,m8Mock.Object,fmap,sgnlsMock.Object) - - - target.CycleStep(1) - - 'Assert - Assert.AreEqual( target.SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly,OUT1) - Assert.AreEqual( target.SmartElectricalTotalCycleEletricalEnergyGenerated,OUT2) - Assert.AreEqual( target.TotalCycleElectricalDemand,OUT3) - Assert.AreEqual( Math.Round(CType(target.TotalCycleFuelConsumptionSmartElectricalLoad,Decimal),7),OUT4) - Assert.AreEqual( Math.Round(CType(target.TotalCycleFuelConsumptionZeroElectricalLoad,Decimal),7),OUT5) - Assert.AreEqual( Math.Round(CType(target.StopStartSensitiveTotalCycleElectricalDemand,Decimal),7),OUT6) - - - -End Sub - - -End Class - - - + <TestFixture()> + Public Class M11Tests + <Test()> _ + <TestCase(0, 50, 60, 70, 80, 90, 1500, False, 0, 50, 60, 0.2182501F, 0.2182059, 60)> _ + <TestCase(1, 50, 60, 70, 80, 90, 1500, False, 50, 50, 60, 0.2182501F, 0.2182059, 60)> _ + <TestCase(1, 50, 60, 70, 80, 90, 1500, True, 0, 0, 60, 0, 0, 0)> + Public Sub InputOutputValues(IP1 As Double, + IP2 As Double, + IP3 As Double, + IP4 As Double, + IP5 As Double, + IP6 As Double, + IP7 As Double, + IP8 As Boolean, + OUT1 As Double, + OUT2 As Double, + OUT3 As Double, + OUT4 As Double, + OUT5 As Double, + OUT6 As Double) + + 'Arrange + + Dim m1Mock As New Mock(Of IM1_AverageHVACLoadDemand) + Dim m3Mock As New Mock(Of IM3_AveragePneumaticLoadDemand) + + + Dim m6Mock As New Mock(Of IM6) + Dim m8Mock As New Mock(Of IM8) + Dim sgnlsMock As New Mock(Of ISignals) + Dim fmap As New MockFuel50PC + + + m6Mock.Setup(Function(x) x.OverrunFlag).Returns(IP1) + m8Mock.Setup(Function(x) x.SmartElectricalAlternatorPowerGenAtCrank).Returns(IP2.SI(Of Watt)) + m6Mock.Setup(Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC).Returns(IP3.SI(Of Watt)) + sgnlsMock.Setup(Function(x) x.EngineDrivelineTorque).Returns(IP4.SI(Of NewtonMeter)) + sgnlsMock.Setup(Function(x) x.PreExistingAuxPower).Returns(0.SI(Of Watt)) + m3Mock.Setup(Function(x) x.GetAveragePowerDemandAtCrankFromPneumatics).Returns(IP5.SI(Of Watt)) + m1Mock.Setup(Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts).Returns(IP6.SI(Of Watt)) + sgnlsMock.Setup(Function(x) x.EngineSpeed).Returns(IP7.RPMtoRad()) + sgnlsMock.Setup(Function(x) x.EngineStopped).Returns(IP8) + + + 'Act + Dim target = New M11(m1Mock.Object, m3Mock.Object, m6Mock.Object, m8Mock.Object, fmap, sgnlsMock.Object) _ + ',m3Mock.Object,m6Mock.Object,m8Mock.Object,fmap,sgnlsMock.Object) + + 'Add Current Calculation to Internal Aggregates ( Accesseed by public output properties which are external interface ) + target.CycleStep(1.SI(Of Second)) + + + 'Assert + Assert.AreEqual(target.SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly.Value(), OUT1, 0.00001) + Assert.AreEqual(target.SmartElectricalTotalCycleEletricalEnergyGenerated.Value(), OUT2, 0.00001) + Assert.AreEqual(target.TotalCycleElectricalDemand.Value(), OUT3, 0.00001) + Assert.AreEqual(target.TotalCycleFuelConsumptionSmartElectricalLoad.ConvertTo().Gramm.Value(), OUT4, 0.00001) + Assert.AreEqual(target.TotalCycleFuelConsumptionZeroElectricalLoad.Value(), OUT5.SI().Gramm.Value(), 0.00001) + Assert.AreEqual(target.StopStartSensitiveTotalCycleElectricalDemand.Value(), OUT6, 0.00001) + End Sub + + + <Test()> _ + <TestCase(1, 50, 60, 70, 80, 90, 1500, True, 0, 0, 60, 0, 0, 0)> + Public Sub UnaggregatedInputOutputValues(IP1 As Double, + IP2 As Double, + IP3 As Double, + IP4 As Double, + IP5 As Double, + IP6 As Double, + IP7 As Double, + IP8 As Boolean, + OUT1 As Double, + OUT2 As Double, + OUT3 As Double, + OUT4 As Double, + OUT5 As Double, + OUT6 As Double) + + 'Arrange + + Dim m1Mock As New Mock(Of IM1_AverageHVACLoadDemand) + Dim m3Mock As New Mock(Of IM3_AveragePneumaticLoadDemand) + + + Dim m6Mock As New Mock(Of IM6) + Dim m8Mock As New Mock(Of IM8) + Dim sgnlsMock As New Mock(Of ISignals) + Dim fmap As New MockFuel50PC + + m6Mock.Setup(Function(x) x.OverrunFlag).Returns(IP1) + m8Mock.Setup(Function(x) x.SmartElectricalAlternatorPowerGenAtCrank).Returns(IP2.SI(Of Watt)) + m6Mock.Setup(Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC).Returns(IP3.SI(Of Watt)) + sgnlsMock.Setup(Function(x) x.EngineDrivelineTorque).Returns(IP4.SI(Of NewtonMeter)) + m3Mock.Setup(Function(x) x.GetAveragePowerDemandAtCrankFromPneumatics).Returns(IP5.SI(Of Watt)) + m1Mock.Setup(Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts).Returns(IP6.SI(Of Watt)) + sgnlsMock.Setup(Function(x) x.EngineSpeed).Returns(IP7.RPMtoRad()) + sgnlsMock.Setup(Function(x) x.EngineStopped).Returns(IP8) + + + 'Act + Dim target = New M11(m1Mock.Object, m3Mock.Object, m6Mock.Object, m8Mock.Object, fmap, sgnlsMock.Object) _ + ',m3Mock.Object,m6Mock.Object,m8Mock.Object,fmap,sgnlsMock.Object) + + + target.CycleStep(1.SI(Of Second)) + + 'Assert + Assert.AreEqual(target.SmartElectricalTotalCycleElectricalEnergyGeneratedDuringOverrunOnly.Value(), OUT1, 0.00001) + Assert.AreEqual(target.SmartElectricalTotalCycleEletricalEnergyGenerated.Value(), OUT2, 0.00001) + Assert.AreEqual(target.TotalCycleElectricalDemand.Value(), OUT3, 0.00001) + Assert.AreEqual(target.TotalCycleFuelConsumptionSmartElectricalLoad.Value(), OUT4, 0.00001) + Assert.AreEqual(target.TotalCycleFuelConsumptionZeroElectricalLoad.Value(), OUT5, 0.00001) + Assert.AreEqual(target.StopStartSensitiveTotalCycleElectricalDemand.Value(), OUT6, 0.00001) + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M12Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M12Tests.vb index 5e1c7332a4ff919a32dd4c02ea06452045f30393..bc46d489552919a60ff9250a6acc7e809928f7a2 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M12Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M12Tests.vb @@ -5,57 +5,48 @@ Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework Imports VectoAuxiliaries Imports Moq +Imports TUGraz.VectoCommon.Utils Namespace UnitTests -<TestFixture()> _ -Public Class M12Tests - -<Test()> _ -<TestCase(2,8,6,5,8,6,4.67379665f,4.5f)> _ -Public Sub InputOutputValues( IP2 As single, - IP3 As single, - IP4 As single, - IP5 As single, - IP6 As Single, - IP7 As Single, - OUT1 As single, - OUT2 As single - ) - -'Arrange - Dim M10Mock As New Mock(Of IM10) - Dim m11Mock As New Mock(Of IM11) - - Dim sgnlsMock As New Mock(Of ISignals) - - - sgnlsMock.Setup(Function(x) x.StoredEnergyEfficiency).Returns(0.935) - -m11Mock.Setup( Function(x) x.TotalCycleFuelConsumptionZeroElectricalLoad) .Returns( IP2 ) -m11Mock.Setup( Function(x) x.SmartElectricalTotalCycleEletricalEnergyGenerated) .Returns( IP3 ) -m11Mock.Setup( Function(x) x.TotalCycleFuelConsumptionSmartElectricalLoad) .Returns( IP4 ) -m11Mock.Setup( Function(x) x.TotalCycleElectricalDemand) .Returns( IP5 ) -m11Mock.Setup( Function(x) x.StopStartSensitiveTotalCycleElectricalDemand) .Returns( IP6 ) -M10Mock.Setup( Function(x) x.AverageLoadsFuelConsumptionInterpolatedForPneumatics) .Returns( IP7 ) - - 'Act - Dim target = New M12(M10Mock.Object, m11Mock.Object ,sgnlsMock.Object ) - - 'Assert - Assert.AreEqual( target.FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand, OUT1 ) - Assert.AreEqual( target.BaseFuelConsumptionWithTrueAuxiliaryLoads, OUT2 ) - -End Sub - - - - - -End Class - - - + <TestFixture()> + Public Class M12Tests + <Test()> _ + <TestCase(2, 8, 6, 5, 8, 6, 4.67379665, 4.5)> + Public Sub InputOutputValues(IP2 As Double, + IP3 As Double, + IP4 As Double, + IP5 As Double, + IP6 As Double, + IP7 As Double, + OUT1 As Double, + OUT2 As Double + ) + + 'Arrange + Dim M10Mock As New Mock(Of IM10) + Dim m11Mock As New Mock(Of IM11) + + Dim sgnlsMock As New Mock(Of ISignals) + + + sgnlsMock.Setup(Function(x) x.StoredEnergyEfficiency).Returns(0.935) + + m11Mock.Setup(Function(x) x.TotalCycleFuelConsumptionZeroElectricalLoad).Returns((IP2 / 1000).SI(Of Kilogram)) + m11Mock.Setup(Function(x) x.SmartElectricalTotalCycleEletricalEnergyGenerated).Returns(IP3.SI(Of Joule)) + m11Mock.Setup(Function(x) x.TotalCycleFuelConsumptionSmartElectricalLoad).Returns((IP4 / 1000).SI(Of Kilogram)) + m11Mock.Setup(Function(x) x.TotalCycleElectricalDemand).Returns(IP5.SI(Of Joule)) + m11Mock.Setup(Function(x) x.StopStartSensitiveTotalCycleElectricalDemand).Returns(IP6.SI(Of Joule)) + M10Mock.Setup(Function(x) x.AverageLoadsFuelConsumptionInterpolatedForPneumatics).Returns((IP7 / 1000).SI(Of Kilogram)) + + 'Act + Dim target = New M12(M10Mock.Object, m11Mock.Object, sgnlsMock.Object) + + 'Assert + Assert.AreEqual(target.FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand().Value(), + OUT1.SI().Gramm.Value(), 0.001) + Assert.AreEqual(target.BaseFuelConsumptionWithTrueAuxiliaryLoads().Value(), OUT2.SI().Gramm.Value(), 0.001) + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M13Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M13Tests.vb index 671e30bd533b3d654af2baa08ab15e6a41780429..a5be740128f5a252576b27ab22366c4172ab94b6 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M13Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M13Tests.vb @@ -5,60 +5,60 @@ Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework Imports VectoAuxiliaries Imports Moq +Imports TUGraz.VectoCommon.Utils Namespace UnitTests - <TestFixture()> _ - Public Class M13Tests - - Private Const FUEL_DENSITY_percm3 As Single = 0.835 - - - '<TestCase(50, 60, 70, TRUE, TRUE ,100, 1,False, 72287.5f , 86.57185629f )> _ - - <Test()> _ - <TestCase(50, 60, 70, False, False, 100, 1, False, 60.0F)> _ - <TestCase(50, 60, 70, False, True, 100, 1, False, 110.0F)> _ - <TestCase(50, 60, 70, True, False, 100, 1, False, 0.0F)> _ - <TestCase(50, 60, 70, True, True, 100, 1, False, 110.0F)> _ - <TestCase(50, 60, 70, True, True, 100, 2, True, 220.0F)> _ - Public Sub InputOutputValues(IP1 As Single, - IP2 As Single, - IP3 As Single, - IP4 As Boolean, - IP5 As Boolean, - IP6 As Single, - IP7 As Single, - IP8 As Boolean, - OUT1 As Single) - - 'Arrange - Dim m10 As New Mock(Of IM10) - Dim m11 As New Mock(Of IM11) - Dim m12 As New Mock(Of IM12) - Dim Signals As New Mock(Of ISignals) - - m12.Setup(Function(x) x.FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand).Returns(IP1) - m12.Setup(Function(x) x.BaseFuelConsumptionWithTrueAuxiliaryLoads).Returns(IP2) - m10.Setup(Function(x) x.FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand).Returns(IP3) - Signals.Setup(Function(x) x.SmartPneumatics).Returns(IP4) - Signals.Setup(Function(x) x.SmartElectrics).Returns(IP5) - Signals.Setup(Function(x) x.WHTC).Returns(IP7) - Signals.Setup(Function(x) x.DeclarationMode).Returns(IP8) - Signals.Setup(Function(x) x.TotalCycleTimeSeconds).Returns(3114) - Signals.Setup(Function(x) x.CurrentCycleTimeInSeconds).Returns(3114) - - 'Act - Dim target = New M13(m10.Object, m11.Object, m12.Object, Signals.Object) - - 'Assert - Assert.AreEqual(OUT1, target.WHTCTotalCycleFuelConsumptionGrams) - - End Sub - - End Class - + <TestFixture()> + Public Class M13Tests + Private Const FUEL_DENSITY_percm3 As Single = 0.835 + + + '<TestCase(50, 60, 70, TRUE, TRUE ,100, 1,False, 72287.5f , 86.57185629f )> _ + + <Test()> _ + <TestCase(50, 60, 70, False, False, 100, 1, False, 60.0)> _ + <TestCase(50, 60, 70, False, True, 100, 1, False, 110.0)> _ + <TestCase(50, 60, 70, True, False, 100, 1, False, 0.0)> _ + <TestCase(50, 60, 70, True, True, 100, 1, False, 110.0)> _ + <TestCase(50, 60, 70, True, True, 100, 2, True, 220.0)> + Public Sub InputOutputValues(IP1 As Double, + IP2 As Double, + IP3 As Double, + IP4 As Boolean, + IP5 As Boolean, + IP6 As Double, + IP7 As Double, + IP8 As Boolean, + OUT1 As Double) + + 'Arrange + Dim m10 As New Mock(Of IM10) + Dim m11 As New Mock(Of IM11) + Dim m12 As New Mock(Of IM12) + Dim Signals As New Mock(Of ISignals) + + m12.Setup(Function(x) x.FuelconsumptionwithsmartElectricsandAveragePneumaticPowerDemand()).Returns( + (IP1 / 1000).SI(Of Kilogram)) + m12.Setup(Function(x) x.BaseFuelConsumptionWithTrueAuxiliaryLoads()).Returns((IP2 / 1000).SI(Of Kilogram)) + m10.Setup(Function(x) x.AverageLoadsFuelConsumptionInterpolatedForPneumatics).Returns((0 / 1000).SI(Of Kilogram)) + m10.Setup(Function(x) x.FuelConsumptionSmartPneumaticsAndAverageElectricalPowerDemand).Returns( + (IP3 / 1000).SI(Of Kilogram)) + m11.Setup(Function(x) x.TotalCycleFuelConsuptionAverageLoads).Returns((0 / 1000).SI(Of Kilogram)) + Signals.Setup(Function(x) x.SmartPneumatics).Returns(IP4) + Signals.Setup(Function(x) x.SmartElectrics).Returns(IP5) + Signals.Setup(Function(x) x.WHTC).Returns(IP7) + Signals.Setup(Function(x) x.DeclarationMode).Returns(IP8) + Signals.Setup(Function(x) x.TotalCycleTimeSeconds).Returns(3114) + Signals.Setup(Function(x) x.CurrentCycleTimeInSeconds).Returns(3114) + + 'Act + Dim target = New M13(m10.Object, m11.Object, m12.Object, Signals.Object) + + 'Assert + Assert.AreEqual(OUT1.SI().Gramm.Value(), target.WHTCTotalCycleFuelConsumptionGrams.Value(), 0.001) + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M14Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M14Tests.vb index 4b7d086a7c7cc995430ccf9056ac5f84179b7a7a..f5f7f3ad65a1c03005cd74d36d83e0fd9b2ccf5c 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M14Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M14Tests.vb @@ -5,6 +5,7 @@ Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework Imports VectoAuxiliaries Imports Moq +Imports TUGraz.VectoCommon.Utils Namespace UnitTests @@ -20,31 +21,31 @@ Namespace UnitTests Public Sub Clone(from As ISSMTOOL) Implements ISSMTOOL.Clone End Sub - Public ReadOnly Property ElectricalWAdjusted As Single Implements ISSMTOOL.ElectricalWAdjusted + Public ReadOnly Property ElectricalWAdjusted As Double Implements ISSMTOOL.ElectricalWAdjusted Get Throw New NotImplementedException End Get End Property - Public ReadOnly Property ElectricalWBase As Single Implements ISSMTOOL.ElectricalWBase + Public ReadOnly Property ElectricalWBase As Double Implements ISSMTOOL.ElectricalWBase Get Throw New NotImplementedException End Get End Property - Public ReadOnly Property FuelPerHBase As Single Implements ISSMTOOL.FuelPerHBase + Public ReadOnly Property FuelPerHBase As Double Implements ISSMTOOL.FuelPerHBase Get Throw New NotImplementedException End Get End Property - Public ReadOnly Property FuelPerHBaseAdjusted As Single Implements ISSMTOOL.FuelPerHBaseAdjusted + Public ReadOnly Property FuelPerHBaseAdjusted As Double Implements ISSMTOOL.FuelPerHBaseAdjusted Get Throw New NotImplementedException End Get End Property - Public Function FuelPerHBaseAsjusted(AverageUseableEngineWasteHeatKW As Single) As Single _ + Public Function FuelPerHBaseAsjusted(AverageUseableEngineWasteHeatKW As Double) As Double _ Implements ISSMTOOL.FuelPerHBaseAsjusted Return 0.5 * AverageUseableEngineWasteHeatKW @@ -67,13 +68,13 @@ Namespace UnitTests Throw New NotImplementedException End Function - Public ReadOnly Property MechanicalWBase As Single Implements ISSMTOOL.MechanicalWBase + Public ReadOnly Property MechanicalWBase As Double Implements ISSMTOOL.MechanicalWBase Get Throw New NotImplementedException End Get End Property - Public ReadOnly Property MechanicalWBaseAdjusted As Single Implements ISSMTOOL.MechanicalWBaseAdjusted + Public ReadOnly Property MechanicalWBaseAdjusted As Double Implements ISSMTOOL.MechanicalWBaseAdjusted Get Throw New NotImplementedException End Get @@ -96,21 +97,20 @@ Namespace UnitTests Public Sub ValuesTest() 'Arrange - Dim ip1 As Single = 1000.0F - Dim ip5 As Single = 3114 - Dim ip6 As Single = 3114 + Dim ip1 As Double = 1000.0 + Dim ip5 As Double = 3114 - Dim expectedOut1 As Single = 780333.4F - Dim expectedOut2 As Single = 0.934531F + Dim expectedOut1 As Double = 1799.3334 ' 780333.4 + Dim expectedOut2 As Double = 2.13093 Dim m13 As New Mock(Of IM13) Dim hvacSSM As New Mock(Of ISSMTOOL) Dim signals As New Mock(Of ISignals) Dim ssmMock As ISSMTOOL = New SSMToolMock() - Dim constants As IHVACConstants = New HVACConstants(835) + Dim constants As IHVACConstants = New HVACConstants(835.SI(Of KilogramPerCubicMeter)) 'Moq' Arrangements - m13.Setup(Function(x) x.WHTCTotalCycleFuelConsumptionGrams).Returns(ip1) + m13.Setup(Function(x) x.WHTCTotalCycleFuelConsumptionGrams).Returns((ip1 / 1000).SI(Of Kilogram)) signals.Setup(Function(x) x.CurrentCycleTimeInSeconds).Returns(ip5) @@ -118,8 +118,8 @@ Namespace UnitTests Dim m14 As New M14(m13.Object, ssmMock, constants, signals.Object) 'Assert - Assert.AreEqual(expectedOut1, m14.TotalCycleFCGrams) - Assert.AreEqual(expectedOut2, m14.TotalCycleFCLitres) + Assert.AreEqual(expectedOut1.SI().Gramm.Value(), m14.TotalCycleFCGrams.Value(), 0.1) + Assert.AreEqual(expectedOut2.SI().Liter.Value(), m14.TotalCycleFCLitres.Value(), 0.00001) End Sub End Class End Namespace diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M1_AverageHVACLoadDemandTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M1_AverageHVACLoadDemandTests.vb index 1647a7a614d5a2da58896d0ea42c7848da0699bc..02251b0ee0c4d5e00c763385c5da3df17519c670 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M1_AverageHVACLoadDemandTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M1_AverageHVACLoadDemandTests.vb @@ -1,4 +1,5 @@ Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Pneumatics @@ -6,113 +7,99 @@ Imports VectoAuxiliaries.Hvac Namespace UnitTests + <TestFixture()> + Public Class M1_AverageHVACLoadDemandTests + Private Const _GOODMAP As String = "TestFiles\testAlternatorMap.aalt" + Private Const _SSMMAP As String = "TestFiles\ssm.Ahsm" + Private Const _BusDatabase As String = "TestFiles\BusDatabase.abdb" -<TestFixture()> -Public Class M1_AverageHVACLoadDemandTests + Private signals As ISignals = New Signals With {.EngineSpeed = 2000.RPMtoRad()} + Private powernetVoltage As Double = 26.3 + Private ssm As ISSMTOOL = New SSMTOOL(_SSMMAP, New HVACConstants()) - Private Const _GOODMAP As String = "TestFiles\testAlternatorMap.aalt" - Private Const _SSMMAP As String = "TestFiles\ssm.Ahsm - Private Const _BusDatabase As String ="TestFiles\BusDatabase.abdb -Private signals As ISignals = New Signals With {.EngineSpeed=2000} -Private powernetVoltage As Single = 26.3 - Private ssm As ISSMTOOL = New SSMTOOL(_SSMMAP, New HVACConstants()) + Private m0 As IM0_NonSmart_AlternatorsSetEfficiency + Private alternatorMap As IAlternatorMap = New AlternatorMap(_GOODMAP) + Private alternatorGearEfficiency As Single = 0.8 + Private compressorGrearEfficiency As Single = 0.8 -Private m0 As IM0_NonSmart_AlternatorsSetEfficiency -Private alternatorMap As IAlternatorMap = New AlternatorMap(_GOODMAP) -Private alternatorGearEfficiency As Single = 0.8 -Private compressorGrearEfficiency As Single = 0.8 + Public Sub New() + alternatorMap.Initialise() -Public Sub new() + ssm.Load(_SSMMAP) -alternatorMap.Initialise() + m0 = New M0_NonSmart_AlternatorsSetEfficiency(New ElectricalConsumerList(powernetVoltage, 0.096, True), + alternatorMap, powernetVoltage.SI(Of Volt), signals, ssm) + End Sub - ssm.Load( _SSMMAP ) + Private Function GETM1Instance() As IM1_AverageHVACLoadDemand - m0 = New M0_NonSmart_AlternatorsSetEfficiency(New ElectricalConsumerList(powernetVoltage,0.096,True),alternatorMap,powernetVoltage,signals,ssm ) + ssm.Load(_SSMMAP) + Return New M1_AverageHVACLoadDemand(m0, + alternatorGearEfficiency, + compressorGrearEfficiency, + powernetVoltage.SI(Of Volt), + signals, + ssm) + End Function -End Sub -Private function GETM1Instance() As IM1_AverageHVACLoadDemand + <Test()> + Public Sub CreateNew() -ssm.Load( _SSMMAP ) + Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() -return New M1_AverageHVACLoadDemand( m0, - alternatorGearEfficiency, - compressorGrearEfficiency, - powernetVoltage, - signals, - ssm) -End Function + Assert.NotNull(target) + End Sub + <Test()> + Public Sub GetAveragePowerDemandAtCrankFromHVACMechanicsWattsTest() -<Test()> -Public Sub CreateNew() - Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() + Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() + Dim expected As Single = 1580.276 + Dim actual As Watt = target.AveragePowerDemandAtCrankFromHVACMechanicalsWatts - Assert.NotNull(target) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -End Sub + <Test()> + Public Sub AveragePowerDemandAtCrankFromHVACElectricsWattsTest() + Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() + Dim expected As Single = 0 + Dim actual As Watt = target.AveragePowerDemandAtCrankFromHVACElectricsWatts -<Test()> -Public Sub GetAveragePowerDemandAtCrankFromHVACMechanicsWattsTest() + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub + <Test()> + Public Sub AveragePowerDemandAtAlternatorFromHVACElectricsWattsTest() - Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() - Dim expected As Single = 1580.276 - dim actual as Single = target.AveragePowerDemandAtCrankFromHVACMechanicalsWatts - Assert.AreEqual( expected , actual) + Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() + Dim expected As Single = 0 + Dim actual As Watt = target.AveragePowerDemandAtAlternatorFromHVACElectricsWatts -End Sub + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -<Test()> -Public Sub AveragePowerDemandAtCrankFromHVACElectricsWattsTest() + <Test()> + Public Sub HVACFuelingLitresPerHourTest() - Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() - Dim expected As Single = 0 - dim actual as Single = target.AveragePowerDemandAtCrankFromHVACElectricsWatts - - Assert.AreEqual( expected , actual) - -End Sub - -<Test()> -Public Sub AveragePowerDemandAtAlternatorFromHVACElectricsWattsTest() - - - Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() - Dim expected As Single = 0 - dim actual as Single = target.AveragePowerDemandAtAlternatorFromHVACElectricsWatts - - Assert.AreEqual( expected , actual) - -End Sub - -<Test()> -Public Sub HVACFuelingLitresPerHourTest() - - - Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() - Dim expected As Single = 0 - dim actual as Single = target.HVACFuelingLitresPerHour - - Assert.AreEqual( expected , actual) - -End Sub - -End Class - + Dim target As IM1_AverageHVACLoadDemand = GETM1Instance() + Dim expected As Single = 0 + Dim actual As LiterPerSecond = target.HVACFuelingLitresPerHour() + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M2_AverageElectricalLoadTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M2_AverageElectricalLoadTests.vb index 199bd699fd44f4b37019faea86b4cf32e9c7703a..4aba3ace562def96f5a1c8d23dc12f7eafe5e290 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M2_AverageElectricalLoadTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M2_AverageElectricalLoadTests.vb @@ -1,6 +1,7 @@ Imports VectoAuxiliaries.Electrics Imports VectoAuxiliaries.Hvac Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliariesTests.Mocks Imports VectoAuxiliaries @@ -32,7 +33,7 @@ Namespace UnitTests Private Function GetAverageElectricalDemandInstance() As M2_AverageElectricalLoadDemand - signals.EngineSpeed = 2000 + signals.EngineSpeed = 2000.RPMtoRad() Dim consumers As IElectricalConsumerList = CType(New ElectricalConsumerList(26.3, 0.096, True), @@ -40,12 +41,12 @@ Namespace UnitTests Dim altMap As IAlternatorMap = CType(New AlternatorMap("testfiles\testAlternatorMap.aalt"), IAlternatorMap) altMap.Initialise() - Dim m0 As New M0_NonSmart_AlternatorsSetEfficiency(consumers, altMap, 26.3, signals, GetSSM()) + Dim m0 As New M0_NonSmart_AlternatorsSetEfficiency(consumers, altMap, 26.3.SI(Of Volt), signals, GetSSM()) 'Get Consumers. - Return New M2_AverageElectricalLoadDemand(consumers, m0, 0.8, 26.3, signals) + Return New M2_AverageElectricalLoadDemand(consumers, m0, 0.8, 26.3.SI(Of Volt), signals) End Function #End Region @@ -63,16 +64,16 @@ Namespace UnitTests Dim expected As Single = 1594.61572 Dim target As M2_AverageElectricalLoadDemand = GetAverageElectricalDemandInstance() - Dim actual As Single = target.GetAveragePowerDemandAtAlternator() - Assert.AreEqual(expected, actual) + Dim actual As Watt = target.GetAveragePowerDemandAtAlternator() + Assert.AreEqual(expected, actual.Value(), 0.001) End Sub <Test()> Public Sub GetAveragePowerAtCrankTest() Dim target As M2_AverageElectricalLoadDemand = GetAverageElectricalDemandInstance() Dim expected As Single = 10914.6543 - Dim actual As Single = target.GetAveragePowerAtCrankFromElectrics() - Assert.AreEqual(expected, actual) + Dim actual As Watt = target.GetAveragePowerAtCrankFromElectrics() + Assert.AreEqual(expected, actual.Value(), 0.001) End Sub End Class End Namespace \ No newline at end of file diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M5_SmartAlternatorSetGenerationTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M5_SmartAlternatorSetGenerationTests.vb index f4ebc85e01dcfa04c99e11760a84a339f4b35288..42fe64dcda9c37dd5e04504b1aef96ddf016d2e7 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M5_SmartAlternatorSetGenerationTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M5_SmartAlternatorSetGenerationTests.vb @@ -1,4 +1,5 @@ Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliariesTests.Mocks Imports VectoAuxiliaries.Electrics @@ -39,13 +40,16 @@ Namespace UnitTests Private Sub Initialise() - _signals.EngineSpeed = 2000 + _signals.EngineSpeed = 2000.RPMtoRad() Dim elecConsumers As New ElectricalConsumerList(_powerNetVoltage, 0.096, True) Dim alternatoMap As New AlternatorMap(_altMap) alternatoMap.Initialise() - Dim m0 As New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, alternatoMap, _powerNetVoltage, _signals, GetSSM()) + Dim _ + m0 As _ + New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, alternatoMap, _powerNetVoltage.SI(Of Volt), _signals, + GetSSM()) 'Results Cards Dim readings = New List(Of SmartResult) @@ -57,7 +61,7 @@ Namespace UnitTests Dim overrunResult As New ResultCard(readings) Dim signals As ISignals = New Signals - signals.EngineSpeed = 2000 + signals.EngineSpeed = 2000.RPMtoRad() _m05 = New M0_5_SmartAlternatorSetEfficiency(m0, elecConsumers, alternatoMap, idleResult, tractionResult, overrunResult, signals) @@ -67,7 +71,7 @@ Namespace UnitTests Public Sub CreateNewTest() Initialise() - _target = New M5__SmartAlternatorSetGeneration(_m05, _powerNetVoltage, _altGearPullyEfficiency) + _target = New M5__SmartAlternatorSetGeneration(_m05, _powerNetVoltage.SI(Of Volt), _altGearPullyEfficiency) Assert.IsNotNull(_target) End Sub @@ -75,34 +79,34 @@ Namespace UnitTests Public Sub PowerAtCrankIdleWatts() Initialise() - _target = New M5__SmartAlternatorSetGeneration(_m05, _powerNetVoltage, _altGearPullyEfficiency) + _target = New M5__SmartAlternatorSetGeneration(_m05, _powerNetVoltage.SI(Of Volt), _altGearPullyEfficiency) Dim expected As Single = 1641.35791 - Dim actual As Single = _target.AlternatorsGenerationPowerAtCrankIdleWatts() + Dim actual As Watt = _target.AlternatorsGenerationPowerAtCrankIdleWatts() - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, actual.Value(), 0.001) End Sub <Test()> Public Sub PowerAtCrankTractionWatts() Initialise() - _target = New M5__SmartAlternatorSetGeneration(_m05, _powerNetVoltage, _altGearPullyEfficiency) + _target = New M5__SmartAlternatorSetGeneration(_m05, _powerNetVoltage.SI(Of Volt), _altGearPullyEfficiency) Dim expected As Single = 1641.35791 - Dim actual As Single = _target.AlternatorsGenerationPowerAtCrankTractionOnWatts() + Dim actual As Watt = _target.AlternatorsGenerationPowerAtCrankTractionOnWatts() - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, actual.Value(), 0.001) End Sub <Test()> Public Sub PowerAtCrankOverrunWatts() Initialise() - _target = New M5__SmartAlternatorSetGeneration(_m05, _powerNetVoltage, _altGearPullyEfficiency) + _target = New M5__SmartAlternatorSetGeneration(_m05, _powerNetVoltage.SI(Of Volt), _altGearPullyEfficiency) Dim expected As Single = 1641.35791F - Dim actual As Single = _target.AlternatorsGenerationPowerAtCrankOverrunWatts() + Dim actual As Watt = _target.AlternatorsGenerationPowerAtCrankOverrunWatts() - Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, actual.Value(), 0.001) End Sub End Class End Namespace diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M6Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M6Tests.vb index 832e3de2a651c1d92abf4f7a027afe51b4978135..b3dc1caa4129040d077e3beaa3eb9cef74ea9374 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M6Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M6Tests.vb @@ -5,128 +5,117 @@ Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework Imports VectoAuxiliaries Imports Moq +Imports TUGraz.VectoCommon.Utils 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 = 100000.SI(Of Watt)() + Signals.EngineDrivelinePower = 150000.SI(Of Watt)() + Signals.PreExistingAuxPower = 30000.SI(Of Watt)() + 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.55, False, False, False, 0, 20, 0, 100, 20, 200, False)> _ + < + TestCase _ + (100, 100, 100, 100, 20, 20, 40, 100, 100, 100, 100, -550, True, False, False, 0, 20, 0, 100, 20, 200, False)> + Public Sub MikesConditionsTest(M1_1 As Double, + M1_2 As Double, + M2_1 As Double, + M3_1 As Double, + M4_1 As Double, + M4_2 As Double, + M4_3 As Double, + M5_1 As Double, + M5_2 As Double, + AUX As Double, + EMP As Double, + EDP As Double, + SM As Boolean, + OUT1 As Boolean, + OUT2 As Boolean, + OUT3 As Double, + OUT4 As Double, + OUT5 As Double, + OUT6 As Double, + OUT7 As Double, + OUT8 As Double, + OUT9 As Boolean) + + + 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.SI(Of Watt)() + M1._AveragePowerDemandAtCrankFromHVACElectricsWatts = M1_2.SI(Of Watt)() + M2._GetAveragePowerAtCrankFromElectrics = M2_1.SI(Of Watt)() + M3._GetAveragePowerDemandAtCrankFromPneumatics = M3_1.SI(Of Watt)() + M4._PowerCompressorOff = M4_1.SI(Of Watt)() + M4._PowerDifference = M4_2.SI(Of Watt)() + M4._PowerCompressorOn = M4_3.SI(Of Watt)() + M5._AlternatorsGenerationPowerAtCrankTractionOnWatts = M5_1.SI(Of Watt)() + M5._AlternatorsGenerationPowerAtCrankOverrunWatts = M5_2.SI(Of Watt)() + + + signals.EngineMotoringPower = (EMP * 1000).SI(Of Watt)() + signals.InternalEnginePower = 0.SI(Of Watt)() + signals.PreExistingAuxPower = (AUX * 1000).SI(Of Watt)() + signals.EngineDrivelinePower = (EDP * 1000).SI(Of Watt)() + 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.Value(), 0.001) + Assert.AreEqual(OUT4, target.SmartElecAndPneumaticAirCompPowerGenAtCrank.Value(), 0.001) + Assert.AreEqual(OUT5, target.SmartElecOnlyAltPowerGenAtCrank.Value(), 0.001) + Assert.AreEqual(OUT6, target.AveragePowerDemandAtCrankFromPneumatics.Value(), 0.001) + Assert.AreEqual(OUT7, target.SmartElecAndPneumaticAirCompPowerGenAtCrank.Value(), 0.001) + Assert.AreEqual(OUT8, target.AvgPowerDemandAtCrankFromElectricsIncHVAC.Value(), 0.001) + Assert.AreEqual(OUT9, target.SmartPneumaticsOnlyCompressorFlag) + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M7Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M7Tests.vb index 42aa22d2168b1360bd9dbbdcf83e4ddd03c61efe..a984dacfe80db2fdb52f0d0c8197fffc5f4b4ed6 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M7Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M7Tests.vb @@ -3,109 +3,102 @@ Imports VectoAuxiliaries.Pneumatics Imports VectoAuxiliaries.Hvac Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries Namespace UnitTests - -<TestFixture()> _ -Public Class M7Test - -private M5 As M5_Mock -Private M6 As M6_MOCK -Private Signals As ISignals - -Public Sub new () - -M5 = New M5_Mock( 100,110,120) -M6 = New M6_Mock(100,0,0,110,120,0,130,140,150) -Signals = New Signals() - -End Sub - -<Test()> -Public Sub CreateNew_M7InstanceTest() - Dim target As IM7 = New M7(M5,M6,Signals) - Assert.IsNotNull(target) -End Sub - -'IP1 M5 : Alternators Generation Power At Crank (Traction ) (Single ) -'IP2 M5 : Alternators Generation Power At Crank (Idle ) (Single ) -'IP3 Signals : IDLE (Boolean ) -'IP4 M6 :Overrun Flag (Integer ) -'IP5 Signals : Clutch engaged (Boolean ) -'IP6 Signals : InNuetral (Boolean ) -'IP7 M6 : SmartElectricalAndPneumatic:AlternatorPowerGen@Crank -'IP8 M6 : SmartElectricalAndPneumatic:AirCompPowerGen@Crank -'IP9 M6 : SmartElectricalOnly:AlternatorPowerGen@Crank -'IP10 M6 : AveragePowerDemand@CrankFromPneumatics -'IP11 M6 : SmartPneumaticsOnly:AirComprPowerGen@Crank -'OP1 Op1 :Smart Electrical & Pneumatic Aux : Alternator power gen @ Crank -'OP2 OP2 :Smart Electrical & Pneumatic Aux : Air comp power gen @ Crank -'OP3 OP3 :Smart Electrical Aux : Alternator Power Gen @ Crank -'OP4 OP4 :Smart Electrical Aux : Ait Compressor Power Gen @ Crank -<Test()> _ -<TestCase(100,200,false,0,false,true,300,400,500,600,700,200,600,200,600)> _ -<TestCase(100,200,true,0,false,true,300,400,500,600,700,200,600,200,600)> _ -<TestCase(100,200,false,1,true,false,300,400,500,600,700,300,400,500,700)> _ -Public Sub InputOutputTests(byval IP1 As Single, _ - byval IP2 As Single, _ - byval IP3 As Boolean, _ - byval IP4 As Single, _ - byval IP5 As Boolean, _ - byval IP6 As Boolean, _ - byval IP7 As Single, _ - byval IP8 As Single, _ - byval IP9 As single, _ - byval IP10 As Single, _ - byval IP11 As Single, _ - byval OP1 As Single, _ - byval OP2 As Single, _ - byval OP3 As Single, _ - byval OP4 As Single ) - - 'Instantiate new mocks. - M5 = New M5_Mock() - M6 = New M6_Mock() - Signals = New Signals() - - 'Assign from TestCaseValues - M5._AlternatorsGenerationPowerAtCrankTractionOnWatts=IP1 - M5._AlternatorsGenerationPowerAtCrankIdleWatts=IP2 - Signals.Idle=IP3 - M6._OverrunFlag=IP4 - Signals.ClutchEngaged=IP5 - Signals.InNeutral=IP6 - M6._SmartElecAndPneumaticAltPowerGenAtCrank=IP7 - M6._SmartElecAndPneumaticAirCompPowerGenAtCrank=IP8 - M6._SmartElecOnlyAltPowerGenAtCrank=IP9 - M6._AveragePowerDemandAtCrankFromPneumatics=IP10 - M6._SmartPneumaticOnlyAirCompPowerGenAtCrank=IP11 - - - 'Create Instance of M7 from - Dim target As IM7 = New M7(M5,M6,Signals) - - Dim OP1act As Single = target.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank - Dim OP2act As Single = target.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank - Dim OP3act As Single = target.SmartElectricalOnlyAuxAltPowerGenAtCrank - Dim OP4act As Single = target.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank - - Assert.AreEqual(OP1, OP1act) - Assert.AreEqual(OP2, OP2act) - Assert.AreEqual(OP3, OP3act) - Assert.AreEqual(OP4, OP4act) - - - Assert.IsNotNull(target) - -End Sub - - -End Class - - - + <TestFixture()> + Public Class M7Test + Private M5 As M5_Mock + Private M6 As M6_Mock + Private Signals As ISignals + + Public Sub New() + + M5 = New M5_Mock(100, 110, 120) + M6 = New M6_Mock(100, 0, 0, 110, 120, 0, 130, 140, 150) + Signals = New Signals() + End Sub + + <Test()> + Public Sub CreateNew_M7InstanceTest() + Dim target As IM7 = New M7(M5, M6, Signals) + Assert.IsNotNull(target) + End Sub + + 'IP1 M5 : Alternators Generation Power At Crank (Traction ) (Single ) + 'IP2 M5 : Alternators Generation Power At Crank (Idle ) (Single ) + 'IP3 Signals : IDLE (Boolean ) + 'IP4 M6 :Overrun Flag (Integer ) + 'IP5 Signals : Clutch engaged (Boolean ) + 'IP6 Signals : InNuetral (Boolean ) + 'IP7 M6 : SmartElectricalAndPneumatic:AlternatorPowerGen@Crank + 'IP8 M6 : SmartElectricalAndPneumatic:AirCompPowerGen@Crank + 'IP9 M6 : SmartElectricalOnly:AlternatorPowerGen@Crank + 'IP10 M6 : AveragePowerDemand@CrankFromPneumatics + 'IP11 M6 : SmartPneumaticsOnly:AirComprPowerGen@Crank + 'OP1 Op1 :Smart Electrical & Pneumatic Aux : Alternator power gen @ Crank + 'OP2 OP2 :Smart Electrical & Pneumatic Aux : Air comp power gen @ Crank + 'OP3 OP3 :Smart Electrical Aux : Alternator Power Gen @ Crank + 'OP4 OP4 :Smart Electrical Aux : Ait Compressor Power Gen @ Crank + <Test()> _ + <TestCase(100, 200, False, 0, False, True, 300, 400, 500, 600, 700, 200, 600, 200, 600)> _ + <TestCase(100, 200, True, 0, False, True, 300, 400, 500, 600, 700, 200, 600, 200, 600)> _ + <TestCase(100, 200, False, 1, True, False, 300, 400, 500, 600, 700, 300, 400, 500, 700)> + Public Sub InputOutputTests(ByVal IP1 As Double, + ByVal IP2 As Double, + ByVal IP3 As Boolean, + ByVal IP4 As Double, + ByVal IP5 As Boolean, + ByVal IP6 As Boolean, + ByVal IP7 As Double, + ByVal IP8 As Double, + ByVal IP9 As Double, + ByVal IP10 As Double, + ByVal IP11 As Double, + ByVal OP1 As Double, + ByVal OP2 As Double, + ByVal OP3 As Double, + ByVal OP4 As Double) + + 'Instantiate new mocks. + M5 = New M5_Mock() + M6 = New M6_Mock() + Signals = New Signals() + + 'Assign from TestCaseValues + M5._AlternatorsGenerationPowerAtCrankTractionOnWatts = IP1.SI(Of Watt)() + M5._AlternatorsGenerationPowerAtCrankIdleWatts = IP2.SI(Of Watt)() + Signals.Idle = IP3 + M6._OverrunFlag = IP4 + Signals.ClutchEngaged = IP5 + Signals.InNeutral = IP6 + Signals.EngineSpeed = 0.RPMtoRad() + Signals.EngineIdleSpeed = 0.RPMtoRad() + M6._SmartElecAndPneumaticAltPowerGenAtCrank = IP7.SI(Of Watt)() + M6._SmartElecAndPneumaticAirCompPowerGenAtCrank = IP8.SI(Of Watt)() + M6._SmartElecOnlyAltPowerGenAtCrank = IP9.SI(Of Watt)() + M6._AveragePowerDemandAtCrankFromPneumatics = IP10.SI(Of Watt)() + M6._SmartPneumaticOnlyAirCompPowerGenAtCrank = IP11.SI(Of Watt)() + + + 'Create Instance of M7 from + Dim target As IM7 = New M7(M5, M6, Signals) + + Dim OP1act As Double = target.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank().Value() + Dim OP2act As Double = target.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank().Value() + Dim OP3act As Double = target.SmartElectricalOnlyAuxAltPowerGenAtCrank().Value() + Dim OP4act As Double = target.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank.Value() + + Assert.AreEqual(OP1, OP1act, 0.001) + Assert.AreEqual(OP2, OP2act, 0.001) + Assert.AreEqual(OP3, OP3act, 0.001) + Assert.AreEqual(OP4, OP4act, 0.001) + + + Assert.IsNotNull(target) + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M8Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M8Tests.vb index f411f0e07777532f558858039f0c6d36a012eac9..6f180ab8bf72a75c4dfcfcc7af65748030945f64 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M8Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M8Tests.vb @@ -5,132 +5,123 @@ Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework Imports VectoAuxiliaries Imports Moq +Imports TUGraz.VectoCommon.Utils Namespace UnitTests - -<TestFixture()> _ -Public Class M8Tests - -<Test()> _ -Public Sub CreateInstanceTest() - - 'Arrange - Dim m1MOCK = New Mock(Of IM1_AverageHVACLoadDemand )() - Dim m6Mock = new Mock(Of IM6 )() - Dim m7MOCK = New Mock(Of IM7 )() - Dim sigsMock = New Mock(Of ISignals)() - - 'Act - Dim target As IM8 = New M8(m1MOCK.Object, m6Mock.Object, m7MOCK.Object, sigsMock.Object) - - 'Assert - Assert.IsNotNull( target ) - -End Sub - - -<Test()> _ -<TestCase(10,20,30,40,50,60,70,0,1,FALSE,FALSE,140 ,40 ,1 )> _ -<TestCase(10,20,30,40,50,60,70,1,0,FALSE,TRUE ,120 ,40 ,1 )> _ -<TestCase(10,20,30,40,50,60,70,1,0,TRUE,FALSE ,120 ,20 ,0 )> _ -<TestCase(10,20,30,40,50,60,70,0,1,TRUE,TRUE , 60 ,20 ,0 )> _ -Public sub ValueInOutTest( IP1 As Single, - IP2 As Single, - IP3 As Single, - IP4 As Single, - IP5 As Single, - IP6 As Single, - IP7 As Single, - IP8 as Integer, - IP9 as Integer, - IP10 As Boolean, - IP11 As Boolean, - OUT1 As Single, - OUT2 As Single, - OUT3 As Single) - - 'Arrange - Dim m1MOCK = New Mock(Of IM1_AverageHVACLoadDemand )() - Dim m6Mock = new Mock(Of IM6 )() - Dim m7MOCK = New Mock(Of IM7 )() - Dim sigsMock = New Mock(Of ISignals)() - - m1MOCK.Setup ( Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts ).Returns(IP1 ) - m7MOCK.Setup ( Function(x) x.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank ).Returns(IP2 ) - m7MOCK.Setup ( Function(x) x.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank ).Returns(IP3 ) - m7MOCK.Setup ( Function(x) x.SmartElectricalOnlyAuxAltPowerGenAtCrank ).Returns(IP4 ) - m7MOCK.Setup ( Function(x) x.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank ).Returns(IP5 ) - m6Mock.Setup ( Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC ).Returns(IP6 ) - m6Mock.Setup ( Function(x) x.AveragePowerDemandAtCrankFromPneumatics ).Returns(IP7 ) - m6Mock.Setup ( Function(x) x.SmartElecAndPneumaticsCompressorFlag ).Returns(IP8 ) - m6Mock.Setup ( Function(x) x.SmartPneumaticsOnlyCompressorFlag ).Returns(IP9 ) - sigsMock.Setup ( Function(x) x.SmartPneumatics ).Returns(IP10) - sigsMock.Setup ( Function(x) x.SmartElectrics ).Returns(IP11) - - 'Act - Dim target As IM8 = New M8(m1MOCK.Object, m6Mock.Object, m7MOCK.Object, sigsMock.Object) - -'Assert - Assert.AreEqual(OUT1, target.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries ) - Assert.AreEqual(OUT2, target.SmartElectricalAlternatorPowerGenAtCrank ) - Assert.AreEqual(OUT3, target.CompressorFlag ) - -End Sub - -<Test()> _ -<TestCase(10,20,30,40,50,60,70,0,1,FALSE,FALSE,TRUE,0 ,40 ,1 )> _ -<TestCase(10,20,30,40,50,60,70,0,1,FALSE,FALSE,FALSE,140 ,40 ,1 )> _ -Public sub TestIdlingFunction( IP1 As Single, - IP2 As Single, - IP3 As Single, - IP4 As Single, - IP5 As Single, - IP6 As Single, - IP7 As Single, - IP8 as Integer, - IP9 as Integer, - IP10 As Boolean, - IP11 As Boolean, - IP12 As Boolean, - OUT1 As Single, - OUT2 As Single, - OUT3 As Single) - - 'Arrange - Dim m1MOCK = New Mock(Of IM1_AverageHVACLoadDemand )() - Dim m6Mock = new Mock(Of IM6 )() - Dim m7MOCK = New Mock(Of IM7 )() - Dim sigsMock = New Mock(Of ISignals)() - - m1MOCK.Setup ( Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts ).Returns(IP1 ) - m7MOCK.Setup ( Function(x) x.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank ).Returns(IP2 ) - m7MOCK.Setup ( Function(x) x.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank ).Returns(IP3 ) - m7MOCK.Setup ( Function(x) x.SmartElectricalOnlyAuxAltPowerGenAtCrank ).Returns(IP4 ) - m7MOCK.Setup ( Function(x) x.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank ).Returns(IP5 ) - m6Mock.Setup ( Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC ).Returns(IP6 ) - m6Mock.Setup ( Function(x) x.AveragePowerDemandAtCrankFromPneumatics ).Returns(IP7 ) - m6Mock.Setup ( Function(x) x.SmartElecAndPneumaticsCompressorFlag ).Returns(IP8 ) - m6Mock.Setup ( Function(x) x.SmartPneumaticsOnlyCompressorFlag ).Returns(IP9 ) - sigsMock.Setup ( Function(x) x.SmartPneumatics ).Returns(IP10) - sigsMock.Setup ( Function(x) x.SmartElectrics ).Returns(IP11) - sigsMock.Setup ( Function(x) x.EngineStopped ).Returns(IP12) - - - 'Act - Dim target As IM8 = New M8(m1MOCK.Object, m6Mock.Object, m7MOCK.Object, sigsMock.Object) - -'Assert - Assert.AreEqual(OUT1, target.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries ) - Assert.AreEqual(OUT2, target.SmartElectricalAlternatorPowerGenAtCrank ) - Assert.AreEqual(OUT3, target.CompressorFlag ) - -End Sub - - - -End Class - + <TestFixture()> + Public Class M8Tests + <Test()> + Public Sub CreateInstanceTest() + + 'Arrange + Dim m1MOCK = New Mock(Of IM1_AverageHVACLoadDemand)() + Dim m6Mock = New Mock(Of IM6)() + Dim m7MOCK = New Mock(Of IM7)() + Dim sigsMock = New Mock(Of ISignals)() + + 'Act + Dim target As IM8 = New M8(m1MOCK.Object, m6Mock.Object, m7MOCK.Object, sigsMock.Object) + + 'Assert + Assert.IsNotNull(target) + End Sub + + + <Test()> _ + <TestCase(10, 20, 30, 40, 50, 60, 70, 0, 1, False, False, 140, 40, True)> _ + <TestCase(10, 20, 30, 40, 50, 60, 70, 1, 0, False, True, 120, 40, True)> _ + <TestCase(10, 20, 30, 40, 50, 60, 70, 1, 0, True, False, 120, 20, False)> _ + <TestCase(10, 20, 30, 40, 50, 60, 70, 0, 1, True, True, 60, 20, False)> + Public Sub ValueInOutTest(IP1 As Double, + IP2 As Double, + IP3 As Double, + IP4 As Double, + IP5 As Double, + IP6 As Double, + IP7 As Double, + IP8 As Integer, + IP9 As Integer, + IP10 As Boolean, + IP11 As Boolean, + OUT1 As Double, + OUT2 As Double, + OUT3 As Boolean) + + 'Arrange + Dim m1MOCK = New Mock(Of IM1_AverageHVACLoadDemand)() + Dim m6Mock = New Mock(Of IM6)() + Dim m7MOCK = New Mock(Of IM7)() + Dim sigsMock = New Mock(Of ISignals)() + + m1MOCK.Setup(Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts).Returns(IP1.SI(Of Watt)) + m7MOCK.Setup(Function(x) x.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank()).Returns(IP2.SI(Of Watt)) + m7MOCK.Setup(Function(x) x.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank()).Returns(IP3.SI(Of Watt)) + m7MOCK.Setup(Function(x) x.SmartElectricalOnlyAuxAltPowerGenAtCrank()).Returns(IP4.SI(Of Watt)) + m7MOCK.Setup(Function(x) x.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank).Returns(IP5.SI(Of Watt)) + m6Mock.Setup(Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC).Returns(IP6.SI(Of Watt)) + m6Mock.Setup(Function(x) x.AveragePowerDemandAtCrankFromPneumatics).Returns(IP7.SI(Of Watt)) + m6Mock.Setup(Function(x) x.SmartElecAndPneumaticsCompressorFlag).Returns(IP8) + m6Mock.Setup(Function(x) x.SmartPneumaticsOnlyCompressorFlag).Returns(IP9) + sigsMock.Setup(Function(x) x.SmartPneumatics).Returns(IP10) + sigsMock.Setup(Function(x) x.SmartElectrics).Returns(IP11) + + 'Act + Dim target As IM8 = New M8(m1MOCK.Object, m6Mock.Object, m7MOCK.Object, sigsMock.Object) + + 'Assert + Assert.AreEqual(OUT1, target.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries.Value(), 0.001) + Assert.AreEqual(OUT2, target.SmartElectricalAlternatorPowerGenAtCrank.Value(), 0.001) + Assert.AreEqual(OUT3, target.CompressorFlag) + End Sub + + <Test()> _ + <TestCase(10, 20, 30, 40, 50, 60, 70, 0, 1, False, False, True, 0, 40, True)> _ + <TestCase(10, 20, 30, 40, 50, 60, 70, 0, 1, False, False, False, 140, 40, True)> + Public Sub TestIdlingFunction(IP1 As Double, + IP2 As Double, + IP3 As Double, + IP4 As Double, + IP5 As Double, + IP6 As Double, + IP7 As Double, + IP8 As Integer, + IP9 As Integer, + IP10 As Boolean, + IP11 As Boolean, + IP12 As Boolean, + OUT1 As Double, + OUT2 As Double, + OUT3 As Boolean) + + 'Arrange + Dim m1MOCK = New Mock(Of IM1_AverageHVACLoadDemand)() + Dim m6Mock = New Mock(Of IM6)() + Dim m7MOCK = New Mock(Of IM7)() + Dim sigsMock = New Mock(Of ISignals)() + + m1MOCK.Setup(Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts).Returns(IP1.SI(Of Watt)) + m7MOCK.Setup(Function(x) x.SmartElectricalAndPneumaticAuxAltPowerGenAtCrank()).Returns(IP2.SI(Of Watt)) + m7MOCK.Setup(Function(x) x.SmartElectricalAndPneumaticAuxAirCompPowerGenAtCrank()).Returns(IP3.SI(Of Watt)) + m7MOCK.Setup(Function(x) x.SmartElectricalOnlyAuxAltPowerGenAtCrank()).Returns(IP4.SI(Of Watt)) + m7MOCK.Setup(Function(x) x.SmartPneumaticOnlyAuxAirCompPowerGenAtCrank).Returns(IP5.SI(Of Watt)) + m6Mock.Setup(Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC).Returns(IP6.SI(Of Watt)) + m6Mock.Setup(Function(x) x.AveragePowerDemandAtCrankFromPneumatics).Returns(IP7.SI(Of Watt)) + m6Mock.Setup(Function(x) x.SmartElecAndPneumaticsCompressorFlag).Returns(IP8) + m6Mock.Setup(Function(x) x.SmartPneumaticsOnlyCompressorFlag).Returns(IP9) + sigsMock.Setup(Function(x) x.SmartPneumatics).Returns(IP10) + sigsMock.Setup(Function(x) x.SmartElectrics).Returns(IP11) + sigsMock.Setup(Function(x) x.EngineStopped).Returns(IP12) + + + 'Act + Dim target As IM8 = New M8(m1MOCK.Object, m6Mock.Object, m7MOCK.Object, sigsMock.Object) + + 'Assert + Assert.AreEqual(OUT1, target.AuxPowerAtCrankFromElectricalHVACAndPneumaticsAncillaries.Value(), 0.001) + Assert.AreEqual(OUT2, target.SmartElectricalAlternatorPowerGenAtCrank.Value(), 0.001) + Assert.AreEqual(OUT3, target.CompressorFlag) + End Sub + End Class End Namespace - diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/M9Tests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/M9Tests.vb index 4af64fab9ac161bd9342a6ccd5c6c2905a812783..9a6c23400a93ffbc1b2044909ce96d85ced4872e 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/M9Tests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/M9Tests.vb @@ -5,31 +5,32 @@ Imports VectoAuxiliaries.DownstreamModules Imports NUnit.Framework Imports VectoAuxiliaries Imports Moq +Imports TUGraz.VectoCommon.Utils Namespace UnitTests <TestFixture()> Public Class M9Tests <Test()> _ - <TestCase(50, 50, 400, 200, 100, 1200, 50, 0, 0, 0.5F, False, 50.0F, 0, 0.181108221F, 0.180887148F)> _ - <TestCase(50, 50, 400, 200, 100, 1200, 50, 1, 0, 0.5F, False, 50.0F, 0, 0.181108221F, 0.180887148F)> _ - <TestCase(50, 50, 400, 200, 100, 1200, 50, 0, 1, 0.5F, False, 50.0F, 0, 0.181108221F, 0.180887148F)> _ - <TestCase(50, 50, 400, 200, 100, 1200, 50, 1, 1, 0.5F, False, 50.0F, 0, 0.181108221F, 0.180887148F)> _ - <TestCase(50, 50, 400, 200, 100, 1200, 50, 1, 1, 0.5F, True, 0, 0, 0, 0)> - Public Sub ValuesInOutTests(IP1 As Single, - IP2 As Single, - IP3 As Single, - IP4 As Single, - IP5 As Single, - IP6 As Single, - IP7 As Single, - IP8 As Single, - IP9 As Single, - IP10 As Single, + <TestCase(50, 50, 400, 200, 100, 1200, 50, 0, 0, 0.5, False, 50.0F, 0, 0.181108221, 0.180887148)> _ + <TestCase(50, 50, 400, 200, 100, 1200, 50, 1, 0, 0.5, False, 50.0F, 0, 0.181108221, 0.180887148)> _ + <TestCase(50, 50, 400, 200, 100, 1200, 50, 0, 1, 0.5, False, 50.0F, 0, 0.181108221, 0.180887148)> _ + <TestCase(50, 50, 400, 200, 100, 1200, 50, 1, 1, 0.5, False, 50.0F, 0, 0.181108221, 0.180887148)> _ + <TestCase(50, 50, 400, 200, 100, 1200, 50, 1, 1, 0.5, True, 0, 0, 0, 0)> + Public Sub ValuesInOutTests(IP1 As Double, + IP2 As Double, + IP3 As Double, + IP4 As Double, + IP5 As Double, + IP6 As Double, + IP7 As Double, + IP8 As Double, + IP9 As Double, + IP10 As Double, IP11 As Boolean, - AG1 As Single, - AG2 As Single, - AG3 As Single, - AG4 As Single) + AG1 As Double, + AG2 As Double, + AG3 As Double, + AG4 As Double) Dim m1Mock As New Mock(Of IM1_AverageHVACLoadDemand) Dim m4Mock As New Mock(Of IM4_AirCompressor) @@ -39,13 +40,14 @@ Namespace UnitTests Dim sgnlsMock As New Mock(Of ISignals) Dim psac As New Mock(Of IPneumaticsAuxilliariesConfig) - m6Mock.Setup(Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC).Returns(IP1) - m1Mock.Setup(Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts).Returns(IP2) - m4Mock.Setup(Function(x) x.GetPowerCompressorOn).Returns(IP3) - m4Mock.Setup(Function(x) x.GetPowerCompressorOff).Returns(IP4) - sgnlsMock.Setup(Function(x) x.EngineDrivelineTorque).Returns(IP5) - sgnlsMock.Setup(Function(x) x.EngineSpeed).Returns(IP6) - m4Mock.Setup(Function(x) x.GetFlowRate).Returns(IP7) + m6Mock.Setup(Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC).Returns(IP1.SI(Of Watt)) + m1Mock.Setup(Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts).Returns(IP2.SI(Of Watt)) + m4Mock.Setup(Function(x) x.GetPowerCompressorOn).Returns(IP3.SI(Of Watt)) + m4Mock.Setup(Function(x) x.GetPowerCompressorOff).Returns(IP4.SI(Of Watt)) + sgnlsMock.Setup(Function(x) x.EngineDrivelineTorque).Returns(IP5.SI(Of NewtonMeter)) + sgnlsMock.Setup(Function(x) x.EngineSpeed).Returns(IP6.RPMtoRad()) + sgnlsMock.Setup(Function(x) x.PreExistingAuxPower).Returns(0.SI(Of Watt)) + m4Mock.Setup(Function(x) x.GetFlowRate).Returns(IP7.SI(Of NormLiterPerSecond)) m6Mock.Setup(Function(x) x.OverrunFlag).Returns(IP8) m8Mock.Setup(Function(x) x.CompressorFlag).Returns(IP9) psac.Setup(Function(x) x.OverrunUtilisationForCompressionFraction).Returns(IP10) @@ -55,32 +57,32 @@ Namespace UnitTests target As _ New M9(m1Mock.Object, m4Mock.Object, m6Mock.Object, m8Mock.Object, fMapMock, psac.Object, sgnlsMock.Object) - target.CycleStep(1) + target.CycleStep(1.SI(Of Second)) - Assert.AreEqual(target.LitresOfAirCompressorOnContinually, AG1) - Assert.AreEqual(target.LitresOfAirCompressorOnOnlyInOverrun, AG2) - Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOnContinuously, AG3, 0.000001) - Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOffContinuously, AG4, 0.000001) + Assert.AreEqual(target.LitresOfAirCompressorOnContinually.Value(), AG1, 0.000001) + Assert.AreEqual(target.LitresOfAirCompressorOnOnlyInOverrun.Value(), AG2, 0.000001) + Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOnContinuously.Value(), AG3.SI().Gramm.Value(), 0.000001) + Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOffContinuously.Value(), AG4.SI().Gramm.Value(), 0.000001) End Sub <Test()> _ <TestCase(50, 50, 400, 200, 100, 1200, 50, 0, 0, 0.5F, False, 50.0F, 0, 0.181108221F, 0.180887148F)> - Public Sub NEGATIVEINTERPADJUSTMENTValuesInOutTests(IP1 As Single, - IP2 As Single, - IP3 As Single, - IP4 As Single, - IP5 As Single, - IP6 As Single, - IP7 As Single, - IP8 As Single, - IP9 As Single, - IP10 As Single, + Public Sub NEGATIVEINTERPADJUSTMENTValuesInOutTests(IP1 As Double, + IP2 As Double, + IP3 As Double, + IP4 As Double, + IP5 As Double, + IP6 As Double, + IP7 As Double, + IP8 As Double, + IP9 As Double, + IP10 As Double, IP11 As Boolean, - AG1 As Single, - AG2 As Single, - AG3 As Single, - AG4 As Single) + AG1 As Double, + AG2 As Double, + AG3 As Double, + AG4 As Double) Dim m1Mock As New Mock(Of IM1_AverageHVACLoadDemand) Dim m4Mock As New Mock(Of IM4_AirCompressor) @@ -90,14 +92,16 @@ Namespace UnitTests Dim sgnlsMock As New Mock(Of ISignals) Dim psac As New Mock(Of IPneumaticsAuxilliariesConfig) - fMapMock.Setup(Function(x) x.GetFuelConsumption(1, 1)).Returns(-1) - m6Mock.Setup(Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC).Returns(IP1) - m1Mock.Setup(Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts).Returns(IP2) - m4Mock.Setup(Function(x) x.GetPowerCompressorOn).Returns(IP3) - m4Mock.Setup(Function(x) x.GetPowerCompressorOff).Returns(IP4) - sgnlsMock.Setup(Function(x) x.EngineDrivelineTorque).Returns(IP5) - sgnlsMock.Setup(Function(x) x.EngineSpeed).Returns(IP6) - m4Mock.Setup(Function(x) x.GetFlowRate).Returns(IP7) + fMapMock.Setup(Function(x) x.GetFuelConsumption(1.SI(Of NewtonMeter), 1.RPMtoRad())).Returns( + (-1 / 1000).SI(Of KilogramPerSecond)()) + m6Mock.Setup(Function(x) x.AvgPowerDemandAtCrankFromElectricsIncHVAC).Returns(IP1.SI(Of Watt)) + m1Mock.Setup(Function(x) x.AveragePowerDemandAtCrankFromHVACMechanicalsWatts).Returns(IP2.SI(Of Watt)) + m4Mock.Setup(Function(x) x.GetPowerCompressorOn).Returns(IP3.SI(Of Watt)) + m4Mock.Setup(Function(x) x.GetPowerCompressorOff).Returns(IP4.SI(Of Watt)) + sgnlsMock.Setup(Function(x) x.EngineDrivelineTorque).Returns(IP5.SI(Of NewtonMeter)) + sgnlsMock.Setup(Function(x) x.EngineSpeed).Returns(IP6.RPMtoRad()) + sgnlsMock.Setup(Function(x) x.PreExistingAuxPower).Returns(0.SI(Of Watt)) + m4Mock.Setup(Function(x) x.GetFlowRate).Returns(IP7.SI(Of NormLiterPerSecond)) m6Mock.Setup(Function(x) x.OverrunFlag).Returns(IP8) m8Mock.Setup(Function(x) x.CompressorFlag).Returns(IP9) psac.Setup(Function(x) x.OverrunUtilisationForCompressionFraction).Returns(IP10) @@ -107,12 +111,12 @@ Namespace UnitTests target As _ New M9(m1Mock.Object, m4Mock.Object, m6Mock.Object, m8Mock.Object, fMapMock.Object, psac.Object, sgnlsMock.Object) - target.CycleStep(1) + target.CycleStep(1.SI(Of Second)) - Assert.AreEqual(target.LitresOfAirCompressorOnContinually, AG1) - Assert.AreEqual(target.LitresOfAirCompressorOnOnlyInOverrun, AG2) - Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOnContinuously, 0) - Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOffContinuously, 0) + Assert.AreEqual(target.LitresOfAirCompressorOnContinually.Value(), AG1, 0.000001) + Assert.AreEqual(target.LitresOfAirCompressorOnOnlyInOverrun.Value(), AG2, 0.000001) + Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOnContinuously.Value(), 0, 0.000001) + Assert.AreEqual(target.TotalCycleFuelConsumptionCompressorOffContinuously.Value(), 0, 0.000001) End Sub End Class End Namespace diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/ResultCardTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/ResultCardTests.vb index 4cca39803600142e174364ebb10e97d50eb0a79a..130b56579f0528ab1382a38c53d220ec51f97bf7 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/ResultCardTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/ResultCardTests.vb @@ -1,202 +1,178 @@ Imports NUnit.Framework +Imports TUGraz.VectoCommon.Utils Imports VectoAuxiliaries.Electrics <TestFixture()> Public Class ResultCardTests + Private results As New List(Of SmartResult) + Private unorderedResults As New List(Of SmartResult) -Private results As New List(Of SmartResult) -Private unorderedResults As New List(of SmartResult) + Private resultCard As ResultCard + Private unorderedResultCard As ResultCard -Private resultCard As ResultCard -Private unorderedResultCard As ResultCard + Public Sub New() -Public Sub New() + results.Add(New SmartResult(20, 18)) + results.Add(New SmartResult(30, 27)) + results.Add(New SmartResult(40, 36)) + results.Add(New SmartResult(50, 45)) -results.Add(new SmartResult(20, 18)) -results.Add(new SmartResult(30, 27)) -results.Add(new SmartResult(40, 36)) -results.Add(new SmartResult(50, 45)) + unorderedResults.Add(New SmartResult(40, 36)) + unorderedResults.Add(New SmartResult(30, 27)) + unorderedResults.Add(New SmartResult(50, 45)) + unorderedResults.Add(New SmartResult(20, 18)) -unorderedResults.Add(new SmartResult(40, 36)) -unorderedResults.Add(new SmartResult(30, 27)) -unorderedResults.Add(new SmartResult(50, 45)) -unorderedResults.Add(new SmartResult(20, 18)) + 'results.Add(60, 54) -'results.Add(60, 54) + resultCard = New ResultCard(results) -resultCard = New ResultCard(results) + unorderedResultCard = New ResultCard(unorderedResults) + End Sub -unorderedResultCard = New ResultCard( unorderedResults) + <Test()> + Public Sub CreateNewResultsOKTest() + Dim target As New ResultCard(results) -End Sub + Assert.IsNotNull(target) + End Sub + <Test()> + <ExpectedException("System.ArgumentException")> + Public Sub CreateNewBanResultsNullTest() -<Test()> -Public Sub CreateNewResultsOKTest() + Dim target As New ResultCard(Nothing) - Dim target As New ResultCard(results) + Assert.IsNotNull(target) + End Sub - Assert.IsNotNull(target) -End Sub + <Test()> + Public Sub GetBotomBoundryValueTest() -<Test()> -<ExpectedException("System.ArgumentException")> -Public Sub CreateNewBanResultsNullTest() + Dim expected As Single = 18 + Dim actual As Ampere = resultCard.GetSmartCurrentResult(20.SI(Of Ampere)) - Dim target As New ResultCard(Nothing) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub - Assert.IsNotNull(target) -End Sub + <Test()> + Public Sub UnorderedGetBotomBoundryValueTest() + Dim expected As Single = 18 + Dim actual As Ampere = unorderedResultCard.GetSmartCurrentResult(20.SI(Of Ampere)) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -<Test()> -Public Sub GetBotomBoundryValueTest() + <Test()> + Public Sub GetCentreBoundayValueTest() -Dim expected As Single = 18 -Dim actual As Single = resultCard.GetSmartCurrentResult(20) + Dim expected As Single = 36 + Dim actual As Ampere = resultCard.GetSmartCurrentResult(40.SI(Of Ampere)) -Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -End Sub + <Test()> + Public Sub UnorderedGetCentreBoundayValueTest() -<Test()> -Public Sub UnorderedGetBotomBoundryValueTest() + Dim expected As Single = 36 + Dim actual As Ampere = unorderedResultCard.GetSmartCurrentResult(40.SI(Of Ampere)) -Dim expected As Single = 18 -Dim actual As Single = unorderedResultCard.GetSmartCurrentResult(20) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -Assert.AreEqual(expected, actual) -End Sub + <Test()> + Public Sub GetTopBoundaryValueTest() + Dim expected As Single = 45 + Dim actual As Ampere = resultCard.GetSmartCurrentResult(50.SI(Of Ampere)) -<Test()> -Public Sub GetCentreBoundayValueTest() + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -Dim expected As Single = 36 -Dim actual As Single = resultCard.GetSmartCurrentResult(40) + <Test()> + Public Sub UnorderedGetTopBoundaryValueTest() -Assert.AreEqual(expected, actual) + Dim expected As Single = 45 + Dim actual As Ampere = unorderedResultCard.GetSmartCurrentResult(50.SI(Of Ampere)) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -End Sub + <Test()> + Public Sub GetInterpolatedValue35AmpsTest() -<Test()> -Public Sub UnorderedGetCentreBoundayValueTest() + Dim expected As Single = 31.5 + Dim actual As Ampere = resultCard.GetSmartCurrentResult(35.SI(Of Ampere)) -Dim expected As Single = 36 -Dim actual As Single = unorderedResultCard.GetSmartCurrentResult(40) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -Assert.AreEqual(expected, actual) + <Test()> + Public Sub UnorderedGetInterpolatedValue35AmpsTest() -End Sub + Dim expected As Single = 31.5 + Dim actual As Ampere = unorderedResultCard.GetSmartCurrentResult(35.SI(Of Ampere)) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -<Test()> -Public Sub GetTopBoundaryValueTest() + <Test()> + Public Sub GetExtrapolatedValue60AmpsTest() -Dim expected As Single = 45 -Dim actual As Single = resultCard.GetSmartCurrentResult(50) + Dim expected As Single = 54 + Dim actual As Ampere = resultCard.GetSmartCurrentResult(60.SI(Of Ampere)) -Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -End Sub + <Test()> + Public Sub UnorderedGetExtrapolatedValue60AmpsTest() -<Test()> -Public Sub UnorderedGetTopBoundaryValueTest() + Dim expected As Single = 54 + Dim actual As Ampere = unorderedResultCard.GetSmartCurrentResult(60.SI(Of Ampere)) -Dim expected As Single = 45 -Dim actual As Single = unorderedResultCard.GetSmartCurrentResult(50) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -Assert.AreEqual(expected, actual) + <Test()> + Public Sub GetExtrapolatedValue10AmpsTest() -End Sub + Dim expected As Single = 9 + Dim actual As Ampere = resultCard.GetSmartCurrentResult(10.SI(Of Ampere)) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -<Test()> -Public Sub GetInterpolatedValue35AmpsTest() + <Test()> + Public Sub UnorderedGetExtrapolatedValue10AmpsTest() -Dim expected As Single = 31.5 -Dim actual As Single = resultCard.GetSmartCurrentResult(35) + Dim expected As Single = 9 + Dim actual As Ampere = unorderedResultCard.GetSmartCurrentResult(10.SI(Of Ampere)) -Assert.AreEqual(expected, actual) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub -End Sub + <Test()> + Public Sub EmptyOrInsufficientResultsTest() -<Test()> -Public Sub UnorderedGetInterpolatedValue35AmpsTest() - -Dim expected As Single = 31.5 -Dim actual As Single = unorderedResultCard.GetSmartCurrentResult(35) - -Assert.AreEqual(expected, actual) - -End Sub - -<Test()> -Public Sub GetExtrapolatedValue60AmpsTest() - -Dim expected As Single = 54 -Dim actual As Single = resultCard.GetSmartCurrentResult(60) - -Assert.AreEqual(expected, actual) - -End Sub - -<Test()> -Public Sub UnorderedGetExtrapolatedValue60AmpsTest() - -Dim expected As Single = 54 -Dim actual As Single = unorderedResultCard.GetSmartCurrentResult(60) - -Assert.AreEqual(expected, actual) - -End Sub - -<Test()> -Public Sub GetExtrapolatedValue10AmpsTest() - -Dim expected As Single = 9 -Dim actual As Single = resultCard.GetSmartCurrentResult(10) - -Assert.AreEqual(expected, actual) - -End Sub - -<Test()> -Public Sub UnorderedGetExtrapolatedValue10AmpsTest() - -Dim expected As Single = 9 -Dim actual As Single = unorderedResultCard.GetSmartCurrentResult(10) - -Assert.AreEqual(expected, actual) - -End Sub - - -<Test()> -Public Sub EmptyOrInsufficientResultsTest() - -Dim resultSet As new List(Of SmartResult) - -Dim expected As Single = 10 -Dim actual As Single = (New ResultCard(resultSet)).GetSmartCurrentResult(10) - -Assert.AreEqual(expected, actual) - -End Sub + Dim resultSet As New List(Of SmartResult) + Dim expected As Single = 10 + Dim actual As Ampere = (New ResultCard(resultSet)).GetSmartCurrentResult(10.SI(Of Ampere)) + Assert.AreEqual(expected, actual.Value(), 0.001) + End Sub End Class diff --git a/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj b/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj index 1e5bdb1f7b575229560ac92889f5fac11184e893..58f507916fa3315dca31e11cfaee077a04add5f3 100644 --- a/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj +++ b/VECTOAux/VectoAuxiliariesTests/VectoAuxiliariesTests.vbproj @@ -9,7 +9,7 @@ <AssemblyName>VectoAuxiliariesTests</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Windows</MyType> - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> @@ -30,6 +30,7 @@ <OutputPath>bin\Debug\</OutputPath> <DocumentationFile>VectoAuxiliariesTests.xml</DocumentationFile> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> + <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -39,6 +40,7 @@ <OutputPath>bin\Release\</OutputPath> <DocumentationFile>VectoAuxiliariesTests.xml</DocumentationFile> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> + <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> @@ -390,6 +392,10 @@ <Project>{b4b9bd2f-fd8f-4bb8-82fa-e2154d2c7fbd}</Project> <Name>AdvancedAuxiliaryInterfaces</Name> </ProjectReference> + <ProjectReference Include="..\..\VectoCommon\VectoCommon\VectoCommon.csproj"> + <Project>{79a066ad-69a9-4223-90f6-6ed5d2d084f4}</Project> + <Name>VectoCommon</Name> + </ProjectReference> <ProjectReference Include="..\VectoAuxiliaries\VectoAuxiliaries.vbproj"> <Project>{fdeee460-0b8a-4ef6-8d9e-72f203a50f65}</Project> <Name>VectoAuxiliaries</Name> diff --git a/VECTOAux/VectoAuxiliariesTests/packages.config b/VECTOAux/VectoAuxiliariesTests/packages.config index d533166308e45574854ff7d661d724597ea43d0e..ea7681609886e7fd9fb3529c8f8128d2f727363d 100644 --- a/VECTOAux/VectoAuxiliariesTests/packages.config +++ b/VECTOAux/VectoAuxiliariesTests/packages.config @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Moq" version="4.2.1510.2205" targetFramework="net40" /> - <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net40" /> + <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net40" requireReinstallation="True" /> <package id="NUnit" version="2.6.2" targetFramework="net45" /> </packages> \ No newline at end of file diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/AdvancedAuxiliaryInterfaces.vbproj b/VectoCommon/AdvancedAuxiliaryInterfaces/AdvancedAuxiliaryInterfaces.vbproj index 60e5c7ee61a08385ebd4b0eadb682d65df8872a5..e4a61b496fda7765b2ed2f2ccde22818fb6a8d0c 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/AdvancedAuxiliaryInterfaces.vbproj +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/AdvancedAuxiliaryInterfaces.vbproj @@ -10,7 +10,7 @@ <AssemblyName>AdvancedAuxiliaryInterfaces</AssemblyName> <FileAlignment>512</FileAlignment> <MyType>Windows</MyType> - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <SccProjectName>SAK</SccProjectName> <SccLocalPath>SAK</SccLocalPath> <SccAuxPath>SAK</SccAuxPath> @@ -25,6 +25,7 @@ <OutputPath>bin\Debug\</OutputPath> <DocumentationFile>AdvancedAuxiliaryInterfaces.xml</DocumentationFile> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> + <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -34,6 +35,7 @@ <OutputPath>bin\Release\</OutputPath> <DocumentationFile>AdvancedAuxiliaryInterfaces.xml</DocumentationFile> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> + <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <PropertyGroup> <OptionExplicit>On</OptionExplicit> @@ -115,6 +117,12 @@ </None> <None Include="packages.config" /> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\VectoCommon\VectoCommon.csproj"> + <Project>{79a066ad-69a9-4223-90f6-6ed5d2d084f4}</Project> + <Name>VectoCommon</Name> + </ProjectReference> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/IAdvancedAuxiliaries.vb b/VectoCommon/AdvancedAuxiliaryInterfaces/IAdvancedAuxiliaries.vb index 4cc3a55f3e21c5729d8c8eca40f0f3e3f0991fd3..4b8a27b5c980ca826fa3ad3024166e289fb53b8a 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/IAdvancedAuxiliaries.vb +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/IAdvancedAuxiliaries.vb @@ -8,6 +8,7 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Public Interface IAdvancedAuxiliaries ' Inherits IAuxiliaryEvent @@ -23,36 +24,36 @@ Public Interface IAdvancedAuxiliaries 'Diagnostic Only - Remove when beta over. - ReadOnly Property AA_D_M12_P1X As Single - ReadOnly Property AA_D_M12_P1Y As Single - ReadOnly Property AA_D_M12_P2X As Single - ReadOnly Property AA_D_M12_P2Y As Single - ReadOnly Property AA_D_M12_P3X As Single - ReadOnly Property AA_D_M12_P3Y As Single - ReadOnly Property AA_D_M12_XTAIN As Single - ReadOnly Property AA_D_M12_INTERP1 As Single - ReadOnly Property AA_D_M12_INTERP2 As Single + ReadOnly Property AA_D_M12_P1X As Joule + ReadOnly Property AA_D_M12_P1Y As Kilogram + ReadOnly Property AA_D_M12_P2X As Joule + ReadOnly Property AA_D_M12_P2Y As Kilogram + ReadOnly Property AA_D_M12_P3X As Joule + ReadOnly Property AA_D_M12_P3Y As Kilogram + ReadOnly Property AA_D_M12_XTAIN As Joule + ReadOnly Property AA_D_M12_INTERP1 As Kilogram + ReadOnly Property AA_D_M12_INTERP2 As Kilogram 'Additional Permenent Monitoring Signals - Required by engineering - ReadOnly Property AA_NonSmartAlternatorsEfficiency As Single? - ReadOnly Property AA_SmartIdleCurrent_Amps As Single? - ReadOnly Property AA_SmartIdleAlternatorsEfficiency As Single? - ReadOnly Property AA_SmartTractionCurrent_Amps As Single? - ReadOnly Property AA_SmartTractionAlternatorEfficiency As Single? - ReadOnly Property AA_SmartOverrunCurrent_Amps As Single? - ReadOnly Property AA_SmartOverrunAlternatorEfficiency As Single? - ReadOnly Property AA_CompressorFlowRate_LitrePerSec As Single? - ReadOnly Property AA_OverrunFlag As Integer? + ReadOnly Property AA_NonSmartAlternatorsEfficiency As Double + ReadOnly Property AA_SmartIdleCurrent_Amps As Ampere + ReadOnly Property AA_SmartIdleAlternatorsEfficiency As Double + ReadOnly Property AA_SmartTractionCurrent_Amps As Ampere + ReadOnly Property AA_SmartTractionAlternatorEfficiency As Double + ReadOnly Property AA_SmartOverrunCurrent_Amps As Ampere + ReadOnly Property AA_SmartOverrunAlternatorEfficiency As Double + ReadOnly Property AA_CompressorFlowRate_LitrePerSec As NormLiterPerSecond + ReadOnly Property AA_OverrunFlag As Boolean ReadOnly Property AA_EngineIdleFlag As Integer? - ReadOnly Property AA_CompressorFlag As Integer? - ReadOnly Property AA_TotalCycleFC_Grams As Single? - ReadOnly Property AA_TotalCycleFC_Litres As Single? - ReadOnly Property AA_AveragePowerDemandCrankHVACMechanicals As Single? - ReadOnly Property AA_AveragePowerDemandCrankHVACElectricals As Single? - ReadOnly Property AA_AveragePowerDemandCrankElectrics As Single? - ReadOnly Property AA_AveragePowerDemandCrankPneumatics As Single? - ReadOnly Property AA_TotalCycleFuelConsumptionCompressorOff As Single? - ReadOnly Property AA_TotalCycleFuelConsumptionCompressorOn As Single? + ReadOnly Property AA_CompressorFlag As Boolean + ReadOnly Property AA_TotalCycleFC_Grams As Kilogram + ReadOnly Property AA_TotalCycleFC_Litres As Liter + ReadOnly Property AA_AveragePowerDemandCrankHVACMechanicals As Watt + ReadOnly Property AA_AveragePowerDemandCrankHVACElectricals As Watt + ReadOnly Property AA_AveragePowerDemandCrankElectrics As Watt + ReadOnly Property AA_AveragePowerDemandCrankPneumatics As Watt + ReadOnly Property AA_TotalCycleFuelConsumptionCompressorOff As Kilogram + ReadOnly Property AA_TotalCycleFuelConsumptionCompressorOn As Kilogram ''' <summary> ''' Total Cycle Fuel In Grams @@ -60,7 +61,7 @@ Public Interface IAdvancedAuxiliaries ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property TotalFuelGRAMS As Single + ReadOnly Property TotalFuelGRAMS As Kilogram ''' <summary> ''' Total Cycle Fuel in Litres @@ -68,7 +69,7 @@ Public Interface IAdvancedAuxiliaries ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property TotalFuelLITRES As Single + ReadOnly Property TotalFuelLITRES As Liter ''' <summary> ''' Total Power Demans At Crank From Auxuliaries (W) @@ -76,7 +77,7 @@ Public Interface IAdvancedAuxiliaries ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - ReadOnly Property AuxiliaryPowerAtCrankWatts As Single + ReadOnly Property AuxiliaryPowerAtCrankWatts As Watt ''' <summary> @@ -121,7 +122,7 @@ Public Interface IAdvancedAuxiliaries ''' <param name="message"></param> ''' <returns></returns> ''' <remarks></remarks> - Function CycleStep(seconds As Double, ByRef message As String) As Boolean + Function CycleStep(seconds As Second, ByRef message As String) As Boolean ''' <summary> ''' Initialises AAUX Environment ( Begin Processs ) diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/IFuelConsumptionMap.vb b/VectoCommon/AdvancedAuxiliaryInterfaces/IFuelConsumptionMap.vb index e14b1c7f47a63c94e7863d11067fb74a0ea6a48b..3d5d0a3e3e2e64748680372c98ac37128e6804b1 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/IFuelConsumptionMap.vb +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/IFuelConsumptionMap.vb @@ -1,4 +1,6 @@ -Public Interface IFuelConsumptionMap +Imports TUGraz.VectoCommon.Utils + +Public Interface IFuelConsumptionMap ''' <summary> ''' ''' </summary> @@ -6,5 +8,5 @@ ''' <param name="angularVelocity"></param> ''' <returns></returns> ''' <remarks></remarks> - Function GetFuelConsumption(torque As Double, angularVelocity As Double) As Double + Function GetFuelConsumption(torque As NewtonMeter, angularVelocity As PerSecond) As KilogramPerSecond End Interface \ No newline at end of file diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/ISignals.vb b/VectoCommon/AdvancedAuxiliaryInterfaces/ISignals.vb index 76e513745b5afacaa25fef44889a0f4feeb1eaea..c1c6f361faaf10d2d4025b100b1e49f919a2d86a 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/ISignals.vb +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/ISignals.vb @@ -8,6 +8,7 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Public Interface ISignals ''' <summary> @@ -16,7 +17,7 @@ Public Interface ISignals ''' <value></value> ''' <returns></returns> ''' <remarks>Vecto Input</remarks> - Property PreExistingAuxPower As Single + Property PreExistingAuxPower As Watt ''' <summary> ''' Engine Motoring Power (KW) @@ -24,7 +25,7 @@ Public Interface ISignals ''' <value></value> ''' <returns></returns> ''' <remarks>Vecto Input</remarks> - Property EngineMotoringPower As Single + Property EngineMotoringPower As Watt ''' <summary> ''' Engine Driveline Power (KW) @@ -32,7 +33,7 @@ Public Interface ISignals ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Property EngineDrivelinePower As Single + Property EngineDrivelinePower As Watt ''' <summary> ''' Smart Electrics @@ -55,8 +56,8 @@ Public Interface ISignals ''' </summary> ''' <value></value> ''' <returns></returns> - ''' <remarks>RPM in old money - Vecto Input</remarks> - Property EngineSpeed As Double + ''' + Property EngineSpeed As PerSecond ''' <summary> ''' Smart Pneumatics @@ -88,7 +89,7 @@ Public Interface ISignals ''' <value></value> ''' <returns></returns> ''' <remarks>Vecto Input</remarks> - Property EngineDrivelineTorque As Single + Property EngineDrivelineTorque As NewtonMeter ''' <summary> ''' Engine Idle @@ -128,7 +129,7 @@ Public Interface ISignals ''' <value></value> ''' <returns></returns> ''' <remarks>'Vecto Input</remarks> - Property WHTC As Single + Property WHTC As Double ''' <summary> ''' Declaration Mode @@ -144,7 +145,7 @@ Public Interface ISignals ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Property EngineIdleSpeed As Single + Property EngineIdleSpeed As PerSecond ''' <summary> ''' Pneumatic Overrun Utilisation @@ -152,7 +153,7 @@ Public Interface ISignals ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Property PneumaticOverrunUtilisation As Single + Property PneumaticOverrunUtilisation As Double ''' <summary> ''' Stored Energy Efficiency @@ -160,7 +161,7 @@ Public Interface ISignals ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Property StoredEnergyEfficiency As Single + Property StoredEnergyEfficiency As Double ''' <summary> ''' Running Calc @@ -176,5 +177,5 @@ Public Interface ISignals ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Property Internal_Engine_Power As Single + Property InternalEnginePower As Watt End Interface diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/IVectoInputs.vb b/VectoCommon/AdvancedAuxiliaryInterfaces/IVectoInputs.vb index 4f31f2b45b341f28111e562bf3bc015216952e4c..11e637ce9ef92dd4a6b0b111de163955cc0690f6 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/IVectoInputs.vb +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/IVectoInputs.vb @@ -8,6 +8,7 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports TUGraz.VectoCommon.Utils Public Interface IVectoInputs ''' <summary> @@ -16,7 +17,7 @@ Public Interface IVectoInputs ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Property VehicleWeightKG As Single + Property VehicleWeightKG As Kilogram ''' <summary> ''' Cycle ( Urban, Interurban etc ) @@ -32,7 +33,7 @@ Public Interface IVectoInputs ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Property PowerNetVoltage As Single + Property PowerNetVoltage As Volt ''' <summary> ''' Fuel Map Used in Vecto. @@ -50,5 +51,5 @@ Public Interface IVectoInputs ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Property FuelDensity As Double + Property FuelDensity As KilogramPerCubicMeter End Interface diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Application.Designer.vb b/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Application.Designer.vb index 0aecefe6649856e7f2f1917454c1aa12737d11a2..8ab460ba03644d647f67a62136b9e8f010a0d561 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Application.Designer.vb +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Application.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' <auto-generated> -' This code was generated by a tool. -' Runtime Version:4.0.30319.18444 +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 ' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. ' </auto-generated> '------------------------------------------------------------------------------ diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Resources.Designer.vb b/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Resources.Designer.vb index 88b7755261c42ef2bb625d7e5e360914990afa1b..0b266d4e9cfcd30bd01867faccb0b7e472138e7d 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Resources.Designer.vb +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Resources.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' <auto-generated> -' This code was generated by a tool. -' Runtime Version:4.0.30319.18444 +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 ' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. ' </auto-generated> '------------------------------------------------------------------------------ @@ -15,12 +15,12 @@ Imports System Namespace My.Resources - 'This class was auto-generated by the StronglyTypedResourceBuilder - 'class via a tool like ResGen or Visual Studio. - 'To add or remove a member, edit your .ResX file then rerun ResGen - 'with the /str option, or rebuild your VS project. + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. '''<summary> - ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. '''</summary> <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ @@ -33,7 +33,7 @@ Namespace My.Resources Private resourceCulture As Global.System.Globalization.CultureInfo '''<summary> - ''' Returns the cached ResourceManager instance used by this class. + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. '''</summary> <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager @@ -47,8 +47,8 @@ Namespace My.Resources End Property '''<summary> - ''' Overrides the current thread's CurrentUICulture property for all - ''' resource lookups using this strongly typed resource class. + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. '''</summary> <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _ Friend Property Culture() As Global.System.Globalization.CultureInfo diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Settings.Designer.vb b/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Settings.Designer.vb index 14e244d9bbf3a3c5dfd44f61f996fe1661a78895..950881703c2b39c67a8cc31aaeef5425505c0b26 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Settings.Designer.vb +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/My Project/Settings.Designer.vb @@ -1,10 +1,10 @@ '------------------------------------------------------------------------------ ' <auto-generated> -' This code was generated by a tool. -' Runtime Version:4.0.30319.18444 +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 ' -' Changes to this file may cause incorrect behavior and will be lost if -' the code is regenerated. +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. ' </auto-generated> '------------------------------------------------------------------------------ @@ -22,7 +22,7 @@ Namespace My Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) -#Region "My.Settings Auto-Save Functionality" +#Region "Funktion zum automatischen Speichern von My.Settings" #If _MyType = "WindowsForms" Then Private Shared addedHandler As Boolean diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/Signals.vb b/VectoCommon/AdvancedAuxiliaryInterfaces/Signals.vb index 0cada55b0331cbddbb0da75ab9ef30fbe058c778..e90d59cb8b4ec87dc85bef713914994adae1b7c4 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/Signals.vb +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/Signals.vb @@ -8,7 +8,7 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. - +Imports TUGraz.VectoCommon.Utils Public Class Signals Implements ISignals @@ -18,10 +18,10 @@ Public Class Signals Private _smartElectrics As Boolean Public Property ClutchEngaged As Boolean Implements ISignals.ClutchEngaged - Public Property EngineDrivelinePower As Single Implements ISignals.EngineDrivelinePower - Public Property EngineDrivelineTorque As Single Implements ISignals.EngineDrivelineTorque - Public Property EngineMotoringPower As Single Implements ISignals.EngineMotoringPower - Public Property EngineSpeed As Double Implements ISignals.EngineSpeed + Public Property EngineDrivelinePower As Watt Implements ISignals.EngineDrivelinePower + Public Property EngineDrivelineTorque As NewtonMeter Implements ISignals.EngineDrivelineTorque + Public Property EngineMotoringPower As Watt Implements ISignals.EngineMotoringPower + Public Property EngineSpeed As PerSecond Implements ISignals.EngineSpeed Public Property SmartElectrics As Boolean Implements ISignals.SmartElectrics Get @@ -35,7 +35,7 @@ Public Class Signals Public Property SmartPneumatics As Boolean Implements ISignals.SmartPneumatics Public Property TotalCycleTimeSeconds As Integer Implements ISignals.TotalCycleTimeSeconds Public Property CurrentCycleTimeInSeconds As Double Implements ISignals.CurrentCycleTimeInSeconds - Public Property PreExistingAuxPower As Single Implements ISignals.PreExistingAuxPower + Public Property PreExistingAuxPower As Watt Implements ISignals.PreExistingAuxPower Public Property Idle As Boolean Implements ISignals.Idle Public Property InNeutral As Boolean Implements ISignals.InNeutral @@ -45,8 +45,8 @@ Public Class Signals Public Property EngineStopped As Boolean Implements ISignals.EngineStopped Public Property DeclarationMode As Boolean Implements ISignals.DeclarationMode - Public Property WHTC As Single Implements ISignals.WHTC - Set(value As Single) + Public Property WHTC As Double Implements ISignals.WHTC + Set(value As Double) _WHTCCorretion = value End Set Get @@ -54,11 +54,11 @@ Public Class Signals End Get End Property - Public Property EngineIdleSpeed As Single Implements ISignals.EngineIdleSpeed - Public Property PneumaticOverrunUtilisation As Single Implements ISignals.PneumaticOverrunUtilisation - Public Property StoredEnergyEfficiency As Single Implements ISignals.StoredEnergyEfficiency + Public Property EngineIdleSpeed As PerSecond Implements ISignals.EngineIdleSpeed + Public Property PneumaticOverrunUtilisation As Double Implements ISignals.PneumaticOverrunUtilisation + Public Property StoredEnergyEfficiency As Double Implements ISignals.StoredEnergyEfficiency Public Property RunningCalc As Boolean Implements ISignals.RunningCalc - Public Property Internal_Engine_Power As Single Implements ISignals.Internal_Engine_Power + Public Property InternalEnginePower As Watt Implements ISignals.InternalEnginePower End Class diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/VectoInputs.vb b/VectoCommon/AdvancedAuxiliaryInterfaces/VectoInputs.vb index e0b5b0459671531efc14dfeae6fa136ebab592a2..bf8f81c84d29c764ff0e7f974fbf9549092d1c11 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/VectoInputs.vb +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/VectoInputs.vb @@ -9,6 +9,7 @@ ' ' See the LICENSE.txt for the specific language governing permissions and limitations. Imports Newtonsoft.Json +Imports TUGraz.VectoCommon.Utils Public Class VectoInputs Implements IVectoInputs @@ -27,7 +28,17 @@ Public Class VectoInputs ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Public Property VehicleWeightKG As Single Implements IVectoInputs.VehicleWeightKG + <JsonIgnore> + Public Property VehicleWeightKG As Kilogram Implements IVectoInputs.VehicleWeightKG + Get + Return _vehicleWeight.SI(Of Kilogram)() + End Get + Set(value As Kilogram) + _vehicleWeight = value.Value() + End Set + End Property + + <JsonProperty("VehicleWeightKG")> Dim _vehicleWeight As Double ''' <summary> ''' Powernet Voltage (V) @@ -35,7 +46,17 @@ Public Class VectoInputs ''' <value></value> ''' <returns></returns> ''' <remarks>This is the power voltage available in the bus - usually 26.3 Volts</remarks> - Public Property PowerNetVoltage As Single Implements IVectoInputs.PowerNetVoltage + <JsonIgnore> + Public Property PowerNetVoltage As Volt Implements IVectoInputs.PowerNetVoltage + Get + Return _powerNetVoltage.SI(Of Volt)() + End Get + Set(value As Volt) + _powerNetVoltage = value.Value() + End Set + End Property + + <JsonProperty("PowerNetVoltage")> Dim _powerNetVoltage As Double ''' <summary> ''' Fuel Map Same One as used in Vecto. @@ -55,6 +76,16 @@ Public Class VectoInputs ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> - Public Property FuelDensity As Double Implements IVectoInputs.FuelDensity + <JsonIgnore> + Public Property FuelDensity As KilogramPerCubicMeter Implements IVectoInputs.FuelDensity + Get + Return _fuelDensity.SI(Of KilogramPerCubicMeter)() + End Get + Set(value As KilogramPerCubicMeter) + _fuelDensity = value.Value() + End Set + End Property + + <JsonProperty("FuelDensity")> Dim _fuelDensity As Double End Class diff --git a/VectoCommon/AdvancedAuxiliaryInterfaces/packages.config b/VectoCommon/AdvancedAuxiliaryInterfaces/packages.config index 2c6c3f124c11e64130ecedfed95f3a7462b4966b..6b50e260edc83ddef1ec196b286e143c4e2867d9 100644 --- a/VectoCommon/AdvancedAuxiliaryInterfaces/packages.config +++ b/VectoCommon/AdvancedAuxiliaryInterfaces/packages.config @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net40" /> + <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net40" requireReinstallation="True" /> </packages> \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs index 2829377e57687f7ddfb4482b0cabbd24b2d9ded3..d9329db771fad24a1dabeba6bb63b7ffcc72de10 100644 --- a/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/DoubleExtensionMethods.cs @@ -152,6 +152,16 @@ namespace TUGraz.VectoCommon.Utils return SI<PerSecond>(self * 2 * Math.PI / 60.0); } + /// <summary> + /// Converts the double-value from RPM (rounds per minute) to the SI Unit PerSecond. + /// </summary> + /// <param name="self"></param> + /// <returns></returns> + public static PerSecond RPMtoRad(this float self) + { + return SI<PerSecond>(self * 2 * Math.PI / 60.0); + } + /// <summary> /// Converts the value from rounds per minute to the SI Unit PerSecond /// </summary> diff --git a/VectoCommon/VectoCommon/Utils/SI.cs b/VectoCommon/VectoCommon/Utils/SI.cs index c40df194cfc0f2f4cf768d977a67b5dea0c4f618..6005ad2e8760f5289a10b59bb032b364b698570a 100644 --- a/VectoCommon/VectoCommon/Utils/SI.cs +++ b/VectoCommon/VectoCommon/Utils/SI.cs @@ -248,6 +248,47 @@ namespace TUGraz.VectoCommon.Utils private KilogramPerMeter(double val) : base(val, NumeratorDefault, DenominatorDefault) {} } + ///// <summary> + ///// SI Class for Gram + ///// </summary> + //public class Gram : SIBase<Gram> + //{ + // private static readonly Unit[] NumeratorDefault = { Unit.g }; + + // [DebuggerHidden] + // private Gram(double val) : base(val, NumeratorDefault) {} + //} + + + //public class GramPerSecond : SIBase<GramPerSecond> + //{ + // private static readonly Unit[] NumeratorDefault = { Unit.g }; + // private static readonly Unit[] DenominatorDefault = { Unit.s }; + + // private GramPerSecond(double val) : base(val, NumeratorDefault, DenominatorDefault) { } + + // public static Gram operator *(GramPerSecond gps, Second s) + // { + // return SIBase<Gram>.Create(gps.Val * s.Value()); + // } + //} + + //public class GramPerLiter : SIBase<GramPerLiter> + //{ + // private static readonly Unit[] NumeratorDefault = { Unit.g }; + // private static readonly Unit[] DenominatorDefault = { Unit.liter }; + + // private GramPerLiter(double val) : base(val, NumeratorDefault, DenominatorDefault) {} + //} + + public class LiterPerSecond : SIBase<LiterPerSecond> + { + private static readonly Unit[] NumeratorDefault = { Unit.liter }; + private static readonly Unit[] DenominatorDefault = { Unit.s }; + + private LiterPerSecond(double val) : base(val, NumeratorDefault, DenominatorDefault) {} + } + /// <summary> /// SI Class for Kilogram [kg]. /// </summary> @@ -275,6 +316,63 @@ namespace TUGraz.VectoCommon.Utils { return SIBase<Newton>.Create(kg.Val * m.Value()); } + + public static Liter operator /(Kilogram kilogram, KilogramPerCubicMeter kilogramPerCubicMeter) + { + return SIBase<Liter>.Create(kilogram.Value() / kilogramPerCubicMeter.Value() * 1000); + } + } + + + public class Liter : SIBase<Liter> + { + private static readonly Unit[] NumeratorDefault = { Unit.liter }; + + [DebuggerHidden] + private Liter(double val) : base(val, NumeratorDefault) {} + + public static Kilogram operator *(Liter liter, KilogramPerCubicMeter kilogramPerCubicMeter) + { + return SIBase<Kilogram>.Create(liter.Val / 1000 * kilogramPerCubicMeter.Value()); + } + } + + /// <summary> + /// + /// </summary> + public class NormLiter : SIBase<NormLiter> + { + private static readonly Unit[] NumeratorDefault = { Unit.NI }; + + [DebuggerHidden] + private NormLiter(double val) : base(val, NumeratorDefault) {} + + public static NormLiterPerSecond operator /(NormLiter nl, Second s) + { + return SIBase<NormLiterPerSecond>.Create(nl.Val / s.Value()); + } + } + + /// <summary> + /// + /// </summary> + public class NormLiterPerSecond : SIBase<NormLiterPerSecond> + { + private static readonly Unit[] NumeratorDefault = { Unit.NI }; + private static readonly Unit[] DenominatorDefault = { Unit.s }; + + [DebuggerHidden] + private NormLiterPerSecond(double val) : base(val, NumeratorDefault, DenominatorDefault) {} + + public static NormLiter operator *(NormLiterPerSecond nips, Second s) + { + return SIBase<NormLiter>.Create(nips.Val * s.Value()); + } + + public static NormLiterPerSecond operator *(NormLiterPerSecond nps, double val) + { + return Create(nps.Val * val); + } } /// <summary> @@ -335,6 +433,34 @@ namespace TUGraz.VectoCommon.Utils } } + /// <summary> + /// SI Class for Kilogram Square Meter [kgm^2]. + /// </summary> + public class KilogramPerCubicMeter : SIBase<KilogramPerCubicMeter> + { + private static readonly Unit[] NumeratorDefault = { Unit.k, Unit.g }; + private static readonly Unit[] DenominatorDefault = { Unit.m, Unit.m, Unit.m }; + + [DebuggerHidden] + private KilogramPerCubicMeter(double value) : base(value, NumeratorDefault, DenominatorDefault) {} + + [DebuggerHidden] + public static Kilogram operator *(KilogramPerCubicMeter kilogramPerCubicMeter, CubicMeter cubicMeter) + { + return SIBase<Kilogram>.Create(kilogramPerCubicMeter.Val * cubicMeter.Value()); + } + + public static Kilogram operator *(KilogramPerCubicMeter kilogramPerCubicMeter, Liter liter) + { + return SIBase<Kilogram>.Create(kilogramPerCubicMeter.Val * liter.Value() / 1000); + } + + //public static CubicMeter operator /(Kilogram kg, KilogramPerCubicMeter kgm3) + //{ + // return SIBase<CubicMeter>.Create(kg.Value() / kgm3.Val); + //} + } + /// <summary> /// SI Class for Kilogramm per watt second [kg/Ws]. /// </summary> @@ -413,8 +539,51 @@ namespace TUGraz.VectoCommon.Utils { return SIBase<WattSecond>.Create(watt.Val * second.Value()); } + + [DebuggerHidden] + public static Watt operator *(Watt watt, double val) + { + return Create(watt.Val * val); + } + } + + public class Joule : SIBase<Joule> + { + private static readonly Unit[] NumeratorDefault = { Unit.W, Unit.s }; + + [DebuggerHidden] + private Joule(double val) : base(val, NumeratorDefault) {} + + public static implicit operator Joule(WattSecond self) + { + return Create(self.Value()); + } + + public static Joule operator +(Joule joule, WattSecond ws) + { + return Create(joule.Val + ws.Value()); + } + + public static Watt operator /(Joule joule, Second s) + { + return SIBase<Watt>.Create(joule.Val / s.Value()); + } } + public class JoulePerKilogramm : SIBase<JoulePerKilogramm> + { + private static readonly Unit[] NumeratorDefault = { Unit.J }; + private static readonly Unit[] DenominatorDefault = { Unit.k, Unit.g }; + + private JoulePerKilogramm(double val) : base(val, NumeratorDefault, DenominatorDefault) {} + + public static Joule operator *(Kilogram kg, JoulePerKilogramm jpg) + { + return SIBase<Joule>.Create(kg.Value() * jpg.Val); + } + } + + /// <summary> /// SI Class for one per second [1/s]. /// </summary> @@ -425,6 +594,11 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private PerSecond(double val) : base(val, new Unit[0], DenominatorDefault) {} + + public double AsRPM + { + get { return Val * 60 / (2 * Math.PI); } + } } /// <summary> @@ -553,10 +727,52 @@ namespace TUGraz.VectoCommon.Utils private NewtonMeterSecond(double val) : base(val, NumeratorDefault) {} } + /// <summary> + /// + /// </summary> public class Ampere : SIBase<Ampere> { private static readonly Unit[] NumeratorDefault = { Unit.Ampere }; private Ampere(double val) : base(val, NumeratorDefault) {} + + public static Watt operator *(Ampere ampere, Volt volt) + { + return SIBase<Watt>.Create(volt.Value() * ampere.Val); + } + + public static Ampere operator *(Ampere ampere, double val) + { + return Create(ampere.Val * val); + } + + public static Volt operator /(Watt watt, Ampere ampere) + { + return SIBase<Volt>.Create(watt.Value() / ampere.Value()); + } + + public static Watt operator /(Volt volt, Ampere ampere) + { + return SIBase<Watt>.Create(volt.Value() * ampere.Value()); + } + } + + /// <summary> + /// + /// </summary> + public class Volt : SIBase<Volt> + { + private static readonly Unit[] NumeratorDefault = { Unit.Volt }; + private Volt(double val) : base(val, NumeratorDefault) {} + + public static Watt operator *(Volt volt, Ampere ampere) + { + return SIBase<Watt>.Create(volt.Val * ampere.Value()); + } + + public static Ampere operator /(Watt watt, Volt volt) + { + return SIBase<Ampere>.Create(watt.Value() / volt.Value()); + } } /// <summary> @@ -828,7 +1044,11 @@ namespace TUGraz.VectoCommon.Utils h, milli, t, - Ampere + J, + Ampere, + NI, // norm liter + liter, + Volt } /// <summary> @@ -982,12 +1202,13 @@ namespace TUGraz.VectoCommon.Utils /// Casts the SI Unit to the concrete unit type (if the units allow such an cast). /// </summary> /// <typeparam name="T">the specialized SI unit. e.g. Watt, NewtonMeter, Second</typeparam> - [DebuggerHidden] + //[DebuggerHidden] public T Cast<T>() where T : SIBase<T> { - var t = SIBase<T>.Create(Val); - if (!HasEqualUnit(t)) { - throw new VectoException("SI Unit Conversion failed: From {0} to {1}", this, t); + var si = ToBasicUnits(); + var t = SIBase<T>.Create(si.Val); + if (!si.HasEqualUnit(t)) { + throw new VectoException("SI Unit Conversion failed: From {0} to {1}", si, t); } return t; } @@ -1039,6 +1260,14 @@ namespace TUGraz.VectoCommon.Utils numerator.Add(Unit.k); numerator.Add(Unit.g); break; + case Unit.J: + numerator.Add(Unit.k); + numerator.Add(Unit.g); + numerator.Add(Unit.m); + numerator.Add(Unit.m); + denominator.Add(Unit.s); + denominator.Add(Unit.s); + break; case Unit.min: factor *= 60; numerator.Add(Unit.s); @@ -1163,6 +1392,18 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] get { return new SI(new SI(this, toUnit: Unit.k), 0.001, Unit.g, Unit.g); } } + [DebuggerHidden] + public SI Liter + { + [DebuggerHidden] get { return new SI(this, fromUnit: Unit.liter, toUnit: Unit.liter); } + } + + [DebuggerHidden] + public SI Joule + { + [DebuggerHidden] get { return new SI(this, fromUnit: Unit.J, toUnit: Unit.J); } + } + /// <summary> /// [t] (to basic unit: [kg]) /// </summary> diff --git a/VectoCore/VectoCore/Utils/VectoMath.cs b/VectoCommon/VectoCommon/Utils/VectoMath.cs similarity index 100% rename from VectoCore/VectoCore/Utils/VectoMath.cs rename to VectoCommon/VectoCommon/Utils/VectoMath.cs diff --git a/VectoCommon/VectoCommon/VectoCommon.csproj b/VectoCommon/VectoCommon/VectoCommon.csproj index 8fafefd6fde69cac5ec0ac3bd48275e39e439dcb..9465f3d28f9f5906953c34438d9fb402cebf280e 100644 --- a/VectoCommon/VectoCommon/VectoCommon.csproj +++ b/VectoCommon/VectoCommon/VectoCommon.csproj @@ -67,6 +67,7 @@ <Compile Include="Utils\IntExtensionMethods.cs" /> <Compile Include="Utils\SI.cs" /> <Compile Include="Utils\StringExtensionMethods.cs" /> + <Compile Include="Utils\VectoMath.cs" /> </ItemGroup> <ItemGroup> <None Include="packages.config" /> diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs index 0968285e11bf72a469a6af6c6b3780e35e097b99..5022dc43883e4df637c491b45cdc75f58c8fa8ee 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs @@ -43,7 +43,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine public class FuelConsumptionMap : SimulationComponentData, IDisposable { [Required, ValidateObject] private readonly DelaunayMap _fuelMap = new DelaunayMap("FuelConsumptionMap"); - + private FuelConsumptionMap() {} public static FuelConsumptionMap ReadFromFile(string fileName) @@ -126,7 +126,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine { // delaunay map needs is initialised with rpm, therefore the angularVelocity has to be converted. return - _fuelMap.Interpolate(torque.Value(), angularVelocity.ConvertTo().Rounds.Per.Minute.Value(), allowExtrapolation) + _fuelMap.Interpolate(torque.Value(), angularVelocity.AsRPM, allowExtrapolation) .SI().Kilo.Gramm.Per.Second.Cast<KilogramPerSecond>(); } @@ -235,8 +235,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine protected virtual void Dispose(bool disposing) { - if (disposing) + if (disposing) { _fuelMap.Dispose(); + } } #endregion diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs index 5988322470655ff2f94bfa213bf7f283d1d207cc..a170bb82787c1d6526bea6173927398c75ff2bce 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/BusAuxiliariesAdapter.cs @@ -62,13 +62,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl // 'Set Statics tmpAux.VectoInputs.Cycle = DetermineCycle(cycleName, tmpAux.Signals); - tmpAux.VectoInputs.VehicleWeightKG = (float)vehicleWeight.Value(); + tmpAux.VectoInputs.VehicleWeightKG = vehicleWeight; _fcMapAdapter = new FuelConsumptionAdapter() { FcMap = fcMap }; tmpAux.VectoInputs.FuelMap = _fcMapAdapter; - tmpAux.VectoInputs.FuelDensity = Physics.FuelDensity.Value(); + tmpAux.VectoInputs.FuelDensity = Physics.FuelDensity; //'Set Signals - tmpAux.Signals.EngineIdleSpeed = (float)(engineIdleSpeed.Value() / Constants.RPMToRad); + tmpAux.Signals.EngineIdleSpeed = engineIdleSpeed; tmpAux.Initialise(Path.GetFileName(aauxFile), Path.GetDirectoryName(Path.GetFullPath(aauxFile)) + @"\"); Auxiliaries = tmpAux; @@ -137,60 +137,60 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _fcMapAdapter.AllowExtrapolation = true; // cycleStep has to be called here and not in DoCommit, write is called before Commit! var message = String.Empty; - Auxiliaries.CycleStep(CurrentState.dt.Value(), ref message); + Auxiliaries.CycleStep(CurrentState.dt, ref message); Log.Warn(message); container[ModalResultField.P_aux] = CurrentState.PowerDemand; container[ModalResultField.AA_NonSmartAlternatorsEfficiency] = Auxiliaries.AA_NonSmartAlternatorsEfficiency; if (Auxiliaries.AA_SmartIdleCurrent_Amps != null) { - container[ModalResultField.AA_SmartIdleCurrent_Amps] = Auxiliaries.AA_SmartIdleCurrent_Amps.Value.SI<Ampere>(); + container[ModalResultField.AA_SmartIdleCurrent_Amps] = Auxiliaries.AA_SmartIdleCurrent_Amps; } container[ModalResultField.AA_SmartIdleAlternatorsEfficiency] = Auxiliaries.AA_SmartIdleAlternatorsEfficiency; if (Auxiliaries.AA_SmartTractionCurrent_Amps != null) { container[ModalResultField.AA_SmartTractionCurrent_Amps] = - Auxiliaries.AA_SmartTractionCurrent_Amps.Value.SI<Ampere>(); + Auxiliaries.AA_SmartTractionCurrent_Amps; } container[ModalResultField.AA_SmartTractionAlternatorEfficiency] = Auxiliaries.AA_SmartTractionAlternatorEfficiency; if (Auxiliaries.AA_SmartOverrunCurrent_Amps != null) { - container[ModalResultField.AA_SmartOverrunCurrent_Amps] = Auxiliaries.AA_SmartOverrunCurrent_Amps.Value.SI<Ampere>(); + container[ModalResultField.AA_SmartOverrunCurrent_Amps] = Auxiliaries.AA_SmartOverrunCurrent_Amps; } container[ModalResultField.AA_SmartOverrunAlternatorEfficiency] = Auxiliaries.AA_SmartOverrunAlternatorEfficiency; if (Auxiliaries.AA_CompressorFlowRate_LitrePerSec != null) { container[ModalResultField.AA_CompressorFlowRate_LitrePerSec] = - new SI(Auxiliaries.AA_CompressorFlowRate_LitrePerSec.Value); + Auxiliaries.AA_CompressorFlowRate_LitrePerSec; } container[ModalResultField.AA_OverrunFlag] = Auxiliaries.AA_OverrunFlag; container[ModalResultField.AA_EngineIdleFlag] = Auxiliaries.AA_EngineIdleFlag; container[ModalResultField.AA_CompressorFlag] = Auxiliaries.AA_CompressorFlag; if (Auxiliaries.AA_TotalCycleFC_Grams != null) { - container[ModalResultField.AA_TotalCycleFC_Grams] = new SI(Auxiliaries.AA_TotalCycleFC_Grams.Value); + container[ModalResultField.AA_TotalCycleFC_Grams] = Auxiliaries.AA_TotalCycleFC_Grams; } if (Auxiliaries.AA_TotalCycleFC_Litres != null) { - container[ModalResultField.AA_TotalCycleFC_Litres] = new SI(Auxiliaries.AA_TotalCycleFC_Litres.Value); + container[ModalResultField.AA_TotalCycleFC_Litres] = Auxiliaries.AA_TotalCycleFC_Litres; } if (Auxiliaries.AA_AveragePowerDemandCrankHVACMechanicals != null) { container[ModalResultField.AA_AveragePowerDemandCrankHVACMechanicals] = - new SI(Auxiliaries.AA_AveragePowerDemandCrankHVACMechanicals.Value); + Auxiliaries.AA_AveragePowerDemandCrankHVACMechanicals; } if (Auxiliaries.AA_AveragePowerDemandCrankHVACElectricals != null) { container[ModalResultField.AA_AveragePowerDemandCrankHVACElectricals] = - new SI(Auxiliaries.AA_AveragePowerDemandCrankHVACElectricals.Value); + Auxiliaries.AA_AveragePowerDemandCrankHVACElectricals; } if (Auxiliaries.AA_AveragePowerDemandCrankElectrics != null) { container[ModalResultField.AA_AveragePowerDemandCrankElectrics] = - new SI(Auxiliaries.AA_AveragePowerDemandCrankElectrics.Value); + Auxiliaries.AA_AveragePowerDemandCrankElectrics; } if (Auxiliaries.AA_AveragePowerDemandCrankPneumatics != null) { container[ModalResultField.AA_AveragePowerDemandCrankPneumatics] = - new SI(Auxiliaries.AA_AveragePowerDemandCrankPneumatics.Value); + Auxiliaries.AA_AveragePowerDemandCrankPneumatics; } if (Auxiliaries.AA_TotalCycleFuelConsumptionCompressorOff != null) { container[ModalResultField.AA_TotalCycleFuelConsumptionCompressorOff] = - new SI(Auxiliaries.AA_TotalCycleFuelConsumptionCompressorOff.Value); + Auxiliaries.AA_TotalCycleFuelConsumptionCompressorOff; } container[ModalResultField.AA_TotalCycleFuelConsumptionCompressorOn] = - new SI(Auxiliaries.AA_TotalCycleFuelConsumptionCompressorOn.Value); + Auxiliaries.AA_TotalCycleFuelConsumptionCompressorOn; } protected override void DoCommitSimulationStep() @@ -205,29 +205,27 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _fcMapAdapter.AllowExtrapolation = true; Auxiliaries.Signals.ClutchEngaged = DataBus.ClutchClosed(absTime); - Auxiliaries.Signals.EngineDrivelinePower = (float)(torquePowerTrain * angularSpeed / 1000).Value(); - Auxiliaries.Signals.EngineDrivelineTorque = (float)torquePowerTrain.Value(); - Auxiliaries.Signals.Internal_Engine_Power = - (float)((torqueEngine * angularSpeed - DataBus.BrakePower) / 1000).Value(); + Auxiliaries.Signals.EngineDrivelinePower = torquePowerTrain * angularSpeed; + Auxiliaries.Signals.EngineDrivelineTorque = torquePowerTrain; + Auxiliaries.Signals.InternalEnginePower = torqueEngine * angularSpeed - DataBus.BrakePower; if (DataBus.DriverBehavior == DrivingBehavior.Coasting) { // make sure smart aux are _not_ enabled for now // set internal_engine_power a little bit lower so there is no excessive power for smart aux - Auxiliaries.Signals.Internal_Engine_Power = - (float)((0.9 * torqueEngine * angularSpeed /*- DataBus.BrakePower*/) / 1000).Value(); + Auxiliaries.Signals.InternalEnginePower = 0.9 * torqueEngine * angularSpeed /*- DataBus.BrakePower*/; // if smart aux should be on during coasting use the following line // set internal_engine_power to a large value (*10) so that there's excessive power for smart aux (alreadin during search operating point) //(float)DataBus.EngineDragPower(angularSpeed).Value() / 100; } else { if (DataBus.DriverBehavior != DrivingBehavior.Braking) { - Auxiliaries.Signals.Internal_Engine_Power = 0; + Auxiliaries.Signals.InternalEnginePower = 0.SI<Watt>(); //(float)((0.9 * torqueEngine * angularSpeed - DataBus.BrakePower) / 1000).Value(); } else { // smart aux should be on during braking } } - Auxiliaries.Signals.EngineMotoringPower = (float)(-DataBus.EngineDragPower(angularSpeed).Value() / 1000); - Auxiliaries.Signals.EngineSpeed = angularSpeed.Value() / Constants.RPMToRad; - Auxiliaries.Signals.PreExistingAuxPower = 0; //mAAUX_Global.PreExistingAuxPower; + Auxiliaries.Signals.EngineMotoringPower = -DataBus.EngineDragPower(angularSpeed); + Auxiliaries.Signals.EngineSpeed = angularSpeed; + Auxiliaries.Signals.PreExistingAuxPower = 0.SI<Watt>(); //mAAUX_Global.PreExistingAuxPower; Auxiliaries.Signals.Idle = DataBus.VehicleStopped; Auxiliaries.Signals.InNeutral = DataBus.Gear == 0; Auxiliaries.Signals.RunningCalc = true; @@ -235,7 +233,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl //mAAUX_Global.Internal_Engine_Power; //'Power coming out of Advanced Model is in Watts. - return ((double)Auxiliaries.AuxiliaryPowerAtCrankWatts).SI<Watt>(); + return Auxiliaries.AuxiliaryPowerAtCrankWatts; } protected class FuelConsumptionAdapter : IFuelConsumptionMap @@ -244,10 +242,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public bool AllowExtrapolation { get; set; } - public double GetFuelConsumption(double torque, double angularVelocity) + public KilogramPerSecond GetFuelConsumption(NewtonMeter torque, PerSecond angularVelocity) { - return FcMap.GetFuelConsumption(torque.SI<NewtonMeter>(), angularVelocity.RPMtoRad(), AllowExtrapolation).Value() * - 1000 * 3600; + return FcMap.GetFuelConsumption(torque, angularVelocity, AllowExtrapolation); } } diff --git a/VectoCore/VectoCore/Utils/Physics.cs b/VectoCore/VectoCore/Utils/Physics.cs index d6fc577855771f0e27495b3131326c6a690a4d48..8f5bf94c62883d108664e9ba93cb5a653f3cdb05 100644 --- a/VectoCore/VectoCore/Utils/Physics.cs +++ b/VectoCore/VectoCore/Utils/Physics.cs @@ -44,12 +44,12 @@ namespace TUGraz.VectoCore.Utils /// <summary> /// Density of air. /// </summary> - public static SI AirDensity = 1.188.SI().Kilo.Gramm.Per.Cubic.Meter; + public static KilogramPerCubicMeter AirDensity = 1.188.SI<KilogramPerCubicMeter>(); /// <summary> /// Density of fuel. /// </summary> - public static SI FuelDensity = 0.832.SI().Kilo.Gramm.Per.Cubic.Dezi.Meter; + public static KilogramPerCubicMeter FuelDensity = 832.SI<KilogramPerCubicMeter>(); public static readonly double RollResistanceExponent = 0.9; diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index acdc9603ce1092dfd9a4285356e54c4bd2075234..5cea0c4b85482bfd52ed426a1a5e7d9ae48c8b29 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -268,7 +268,6 @@ <Compile Include="Utils\SwitchExtension.cs" /> <Compile Include="Utils\Validation.cs" /> <Compile Include="Utils\VectoCSVFile.cs" /> - <Compile Include="Utils\VectoMath.cs" /> <Compile Include="Utils\DelaunayMap.cs" /> </ItemGroup> <ItemGroup> diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs index c37bb9de86ef2916385038d0eb399aa95f62ac7f..b3e7ad768ddaf1ee45375ed1c0f212fd4ca11886 100644 --- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/AuxDemandTest.cs @@ -63,7 +63,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); - Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-3); + Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-2); } [Test] @@ -89,7 +89,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries busAux.CommitSimulationStep(modalData); } - Assert.AreEqual(79.303, ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); + Assert.AreEqual(79.303.SI().Gramm.Value(), ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); engineDrivelinePower = -15000.SI<Watt>(); internalPower = -50; @@ -101,7 +101,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries busAux.CommitSimulationStep(modalData); } - Assert.AreEqual(82.5783, ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); + Assert.AreEqual(82.5783.SI().Gramm.Value(), ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); engineDrivelinePower = (driveLinePower * 1000).SI<Watt>(); internalPower = 148; @@ -113,7 +113,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries busAux.CommitSimulationStep(modalData); } - Assert.AreEqual(162.4654, ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); + Assert.AreEqual(162.4654.SI().Gramm.Value(), ((SI)modalData[ModalResultField.AA_TotalCycleFC_Grams]).Value(), 0.0001); } public static BusAuxiliariesAdapter CreateBusAuxAdapterForTesting(double vehicleWeight, out MockDriver driver) diff --git a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs index a86b9525a98f59c947178e1f546e37db063f737d..44e6fedf96064350d01b49732f05015c0e50d6c1 100644 --- a/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs +++ b/VectoCore/VectoCoreTest/Integration/BusAuxiliaries/BusAdapterTest.cs @@ -66,7 +66,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); - Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-3); + Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-2); } [Test] @@ -98,7 +98,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed, (internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed); - Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-3); + Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-2); } [Test]