diff --git a/VECTO/Input Files/Vehicle.vb b/VECTO/Input Files/Vehicle.vb index 86d76167b1ce8ebc6d9663fe2a1748fe0f5bdc1c..44ea5ee203d53693a74b9f93d820ff66c6132019 100644 --- a/VECTO/Input Files/Vehicle.vb +++ b/VECTO/Input Files/Vehicle.vb @@ -27,7 +27,7 @@ Imports TUGraz.VectoCore.Utils <CustomValidation(GetType(Vehicle), "ValidateVehicle")> Public Class Vehicle - Implements IVehicleEngineeringInputData, IVehicleDeclarationInputData, IRetarderInputData, IPTOTransmissionInputData, + Implements IVehicleEngineeringInputData, IVehicleDeclarationInputData, IRetarderInputData, IPTOTransmissionInputData, IAngledriveInputData 'V2 MassMax is now saved in [t] instead of [kg] @@ -97,7 +97,7 @@ Public Class Vehicle Dim ptoData As PTOData = Nothing Dim angledriveData As AngledriveData - Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), + Dim modeService As ExecutionModeServiceContainer = TryCast(validationContext.GetService(GetType(ExecutionMode)), ExecutionModeServiceContainer) Dim mode As ExecutionMode = If(modeService Is Nothing, ExecutionMode.Declaration, modeService.Mode) @@ -310,34 +310,34 @@ Public Class Vehicle Public ReadOnly Property CurbWeightChassis As Kilogram Implements IVehicleDeclarationInputData.CurbWeightChassis Get - Return Mass.SI(Of Kilogram)() + Return Mass.SI (Of Kilogram)() End Get End Property Public ReadOnly Property GrossVehicleMassRating As Kilogram _ Implements IVehicleDeclarationInputData.GrossVehicleMassRating Get - Return MassMax.SI().Ton.Cast(Of Kilogram)() + Return MassMax.SI().Ton.Cast (Of Kilogram)() End Get End Property Public ReadOnly Property AirDragArea As SquareMeter Implements IVehicleDeclarationInputData.AirDragArea Get - Return CdA0.SI(Of SquareMeter)() + Return CdA0.SI (Of SquareMeter)() End Get End Property Public ReadOnly Property IVehicleEngineeringInputData_Axles As IList(Of IAxleEngineeringInputData) _ Implements IVehicleEngineeringInputData.Axles Get - Return AxleWheels().Cast(Of IAxleEngineeringInputData)().ToList() + Return AxleWheels().Cast (Of IAxleEngineeringInputData)().ToList() End Get End Property Public ReadOnly Property IVehicleDeclarationInputData_Axles As IList(Of IAxleDeclarationInputData) _ Implements IVehicleDeclarationInputData.Axles Get - Return AxleWheels().Cast(Of IAxleDeclarationInputData)().ToList() + Return AxleWheels().Cast (Of IAxleDeclarationInputData)().ToList() End Get End Property @@ -345,18 +345,18 @@ Public Class Vehicle Return Axles.Select(Function(axle) New AxleInputData With { .SourceType = DataSourceType.JSONFile, .Source = FilePath, - .Inertia = axle.Inertia.SI(Of KilogramSquareMeter)(), + .Inertia = axle.Inertia.SI (Of KilogramSquareMeter)(), .Wheels = axle.Wheels, .AxleWeightShare = axle.Share, .TwinTyres = axle.TwinTire, .RollResistanceCoefficient = axle.RRC, - .TyreTestLoad = axle.FzISO.SI(Of Newton)() + .TyreTestLoad = axle.FzISO.SI (Of Newton)() }) End Function Public ReadOnly Property CurbWeightExtra As Kilogram Implements IVehicleEngineeringInputData.CurbWeightExtra Get - Return MassExtra.SI(Of Kilogram)() + Return MassExtra.SI (Of Kilogram)() End Get End Property @@ -377,14 +377,14 @@ Public Class Vehicle Public ReadOnly Property IVehicleEngineeringInputData_DynamicTyreRadius As Meter _ Implements IVehicleEngineeringInputData.DynamicTyreRadius Get - Return DynamicTyreRadius.SI().Milli.Meter.Cast(Of Meter)() + Return DynamicTyreRadius.SI().Milli.Meter.Cast (Of Meter)() End Get End Property Public ReadOnly Property IVehicleEngineeringInputData_Loading As Kilogram _ Implements IVehicleEngineeringInputData.Loading Get - Return Loading.SI(Of Kilogram)() + Return Loading.SI (Of Kilogram)() End Get End Property @@ -431,7 +431,7 @@ Public Class Vehicle Public ReadOnly Property Efficiency As Double Implements IAngledriveInputData.Efficiency Get - Return If(IsNumeric(AngledriveLossMapFile.OriginalPath), AngledriveLossMapFile.OriginalPath.ToDouble(), -1.0) + Return If(IsNumeric(AngledriveLossMapFile.OriginalPath), AngledriveLossMapFile.OriginalPath.ToDouble(), - 1.0) End Get End Property @@ -445,6 +445,9 @@ Public Class Vehicle Public ReadOnly Property IPTOTransmissionInputData_PTOCycle As TableData Implements IPTOTransmissionInputData.PTOCycle Get + If String.IsNullOrWhiteSpace(PtoCycle.FullPath) Then + Return Nothing + End If Return VectoCSVFile.Read(PtoCycle.FullPath) End Get End Property diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 730bae0a4cd0153aa598827de23dcf9633551cb1..1d2484751a7c4b93d2ca4f6e4e7657f932277498 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -318,11 +318,13 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter public PTOData CreatePTOTransmissionData(IPTOTransmissionInputData pto) { if (pto.PTOTransmissionType != "None") { - return new PTOData { + var ptoData = new PTOData { TransmissionType = pto.PTOTransmissionType, LossMap = PTOIdleLossMapReader.Create(pto.PTOLossMap), - PTOCycle = DrivingCycleDataReader.ReadFromDataTable(pto.PTOCycle, CycleType.PTO, "PTO", false) }; + if (pto.PTOCycle != null) + ptoData.PTOCycle = DrivingCycleDataReader.ReadFromDataTable(pto.PTOCycle, CycleType.PTO, "PTO", false); + return ptoData; } return null; diff --git a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs index 52f4d456a618408f8f453cae091583e715967287..bcfcba8473084fc2d22c24067bed86168bfb09ec 100644 --- a/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs +++ b/VectoCore/VectoCore/Models/Simulation/Data/VectoRunData.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -182,8 +183,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Data return new ValidationResult( string.Format( - "Interpolation of AxleGear-LossMap failed with torque={0} and angularSpeed={1} (gear={2}, velocity={3})", - axlegearTorque, axleAngularVelocity.ConvertTo().Rounds.Per.Minute, gear.Key, velocity)); + "Interpolation of AxleGear-LossMap failed with torque={0} and angularSpeed={1} (gear={2}, velocity={3})", + axlegearTorque, axleAngularVelocity.ConvertTo().Rounds.Per.Minute, gear.Key, velocity)); } } } @@ -191,6 +192,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Data } } + if (runData.Cycle.Entries.Any(e => e.PTOActive)) { + if (runData.PTO == null || runData.PTO.PTOCycle == null) + return new ValidationResult("PTOCycle is used in DrivingCycle, but is not defined in Vehicle-Data."); + } + return ValidationResult.Success; } } diff --git a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs index a86533bba213a8f20875b44304a1089b4da46eec..3239ca696771a6f31f7b2318c3274346d07d5ba0 100644 --- a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs @@ -478,8 +478,14 @@ namespace TUGraz.VectoCore.OutputData public static WattSecond AuxiliaryWork(this IModalDataContainer data, DataColumn auxCol) { - var simulationIntervals = data.GetValues<Second>(ModalResultField.simulationInterval); - return data.GetValues<Watt>(auxCol).Zip(simulationIntervals, (value, dt) => value * dt).Sum().Cast<WattSecond>(); + var simulationIntervals = data.GetValues<Second>(ModalResultField.simulationInterval).ToArray(); + var auxValues = data.GetValues<Watt>(auxCol).ToArray(); + var sum = 0.SI<WattSecond>(); + for (var i = 0; i < simulationIntervals.Length; i++) { + if (auxValues[i] != null && simulationIntervals[i] != null) + sum += auxValues[i] * simulationIntervals[i]; + } + return sum; } public static MeterPerSquareSecond[] AccelerationPer3Seconds(this IModalDataContainer data)