Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit b1334665 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

reading electric components of hybrid vehicle works in testcase

parent df6d04d2
No related branches found
No related tags found
No related merge requests found
Showing with 127 additions and 16 deletions
......@@ -208,3 +208,4 @@ DISTR/
EPTP/
201*-VECTO-*.zip
Documentation/VehiclesReleaseComparisonDeclarationMode/tmp/
.vs/
namespace TUGraz.VectoCommon.InputData {
using TUGraz.VectoCommon.Utils;
namespace TUGraz.VectoCommon.InputData {
public enum PowertrainPosition
{
HybridP0,
......@@ -7,4 +9,14 @@
HybridP3,
HybridP4
}
public static class PowertrainPositionHelper
{
public const string Prefix = "Hybrid";
public static PowertrainPosition Parse(string pos)
{
return (Prefix + pos).ParseEnum<PowertrainPosition>();
}
}
}
\ No newline at end of file
......@@ -237,6 +237,10 @@ namespace TUGraz.VectoCore.Configuration
public const string GearshiftDataFile = ".vtcu";
public const string BatteryFile = ".vbat";
public const string ElectricMotorFile = ".vem";
public const string CycleFile = ".vdri";
public const string DriverAccelerationCurve = ".vacc";
......
......@@ -81,6 +81,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
case Constants.FileExtensions.GearshiftDataFile:
tmp = JSONInputDataFactory.ReadShiftParameters(filename, tolerateMissing);
break;
case Constants.FileExtensions.BatteryFile:
tmp = JSONInputDataFactory.ReadBatteryData(filename, tolerateMissing);
break;
case Constants.FileExtensions.ElectricMotorFile:
tmp = JSONInputDataFactory.ReadElectricMotorData(filename, tolerateMissing);
break;
}
tmp.Switch()
......
......@@ -111,6 +111,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
return new JSONVehicleDataV8(json, filename, job, tolerateMissing);
case 9:
return new JSONVehicleDataV9(json, filename, job, tolerateMissing);
case 10:
return new JSONVehicleDataV10(json, filename, job, tolerateMissing);
default:
throw new VectoException("Vehicle-File: Unsupported FileVersion. Got {0}", version);
}
......
......@@ -48,6 +48,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
{
public class JSONVehicleDataV10 : JSONVehicleDataV9
{
private JSONElectricStorageEngineeringInputData _batteries;
private JSONElectricMotors _electricMotors;
public JSONVehicleDataV10(JObject data, string fileName, IJSONVehicleComponents job, bool tolerateMissing = false) :
base(data, fileName, job, tolerateMissing) { }
......@@ -55,19 +58,73 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
protected override IElectricMachinesEngineeringInputData GetElectricMachines()
{
// TODO!
throw new NotImplementedException();
return _electricMotors ?? (_electricMotors = ReadMotors());
}
protected override IElectricStorageEngineeringInputData GetElectricStorage()
{
// TODO!
throw new NotImplementedException();
return _batteries ?? (_batteries = ReadBatteries());
}
protected virtual JSONElectricMotors ReadMotors()
{
var retVal = new List<ElectricMachineEntry<IElectricMotorEngineeringInputData>>();
foreach (var entry in Body["ElectricMotors"])
{
var tmp = new ElectricMachineEntry<IElectricMotorEngineeringInputData>()
{
Position = PowertrainPositionHelper.Parse(entry.GetEx<string>("Position")),
Count = entry.GetEx<int>("Count"),
ElectricMachine = JSONInputDataFactory.ReadElectricMotorData(Path.Combine(BasePath, entry.GetEx<string>("MotorFile")), false)
};
retVal.Add(tmp);
}
return new JSONElectricMotors(retVal);
}
protected virtual JSONElectricStorageEngineeringInputData ReadBatteries()
{
return new JSONElectricStorageEngineeringInputData() {
Count = Body["Battery"].GetEx<int>("NumPacks"),
BatteryPack = JSONInputDataFactory.ReadBatteryData(Path.Combine(BasePath, Body["Battery"].GetEx<string>("BatteryFile")), false)
};
}
#endregion
}
public class JSONElectricMotors : IElectricMachinesEngineeringInputData {
private readonly IList<ElectricMachineEntry<IElectricMotorEngineeringInputData>> _entries;
public JSONElectricMotors(List<ElectricMachineEntry<IElectricMotorEngineeringInputData>> entries)
{
_entries = entries;
}
IList<ElectricMachineEntry<IElectricMotorDeclarationInputData>> IElectricMachinesDeclarationInputData.Entries
{
get { return _entries.Cast<ElectricMachineEntry<IElectricMotorDeclarationInputData>>().ToList(); }
//get { return null; }
}
public virtual IList<ElectricMachineEntry<IElectricMotorEngineeringInputData>> Entries
{
get { return _entries; }
}
}
public class JSONElectricStorageEngineeringInputData : IElectricStorageEngineeringInputData {
IBatteryPackDeclarationInputData IElectricStorageDeclarationInputData.BatteryPack
{
get { return BatteryPack; }
}
public IBatteryPackEngineeringInputData BatteryPack { get; internal set; }
public int Count { get; internal set; }
}
// ###################################################################
// ###################################################################
......
......@@ -47,7 +47,7 @@ namespace TUGraz.VectoCore.Utils
public static string VersionNumber
{
get {
return "0.6.0.1884" + SUFFIX;
return "0.6.0.1901" + SUFFIX;
}
}
......
using System.IO;
using NUnit.Framework;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.InputData.FileIO.JSON;
using TUGraz.VectoCore.InputData.Reader.ComponentData;
......@@ -54,8 +55,8 @@ namespace TUGraz.VectoCore.Tests.FileIO
Assert.AreEqual("-401.07", fld.Rows[0][ElectricFullLoadCurveReader.Fields.GenerationTorque]);
var fldMap = ElectricFullLoadCurveReader.Create(fld);
Assert.AreEqual(401.07, fldMap.FullLoadDriveTorque(0.RPMtoRad()).Value());
Assert.AreEqual(-407.07, fldMap.FullGenerationTorque(0.RPMtoRad()).Value());
Assert.AreEqual(-401.07, fldMap.FullLoadDriveTorque(0.RPMtoRad()).Value());
Assert.AreEqual(401.07, fldMap.FullGenerationTorque(0.RPMtoRad()).Value());
var pwr = inputProvider.EfficiencyMap;
Assert.AreEqual("0", pwr.Rows[0][ElectricMotorMapReader.Fields.MotorSpeed]);
......@@ -63,8 +64,35 @@ namespace TUGraz.VectoCore.Tests.FileIO
Assert.AreEqual("9.8449", pwr.Rows[0][ElectricMotorMapReader.Fields.PowerElectrical]);
var pwrMap = ElectricMotorMapReader.Create(pwr);
Assert.AreEqual(9844.9, pwrMap.LookupElectricPower(-0.RPMtoRad(), -800.SI<NewtonMeter>()).ElectricalPower.Value());
Assert.AreEqual(-10171.0, pwrMap.LookupElectricPower(-0.RPMtoRad(), -800.SI<NewtonMeter>()).ElectricalPower.Value());
}
[TestCase()]
public void TestReadHybridVehicle()
{
var inputProvider = JSONInputDataFactory.ReadJsonJob(@"TestData\Hybrids\GenericVehicle_Group2_P2\Class2_RigidTruck_ParHyb_ENG.vecto");
var engineering = inputProvider as IEngineeringInputDataProvider;
Assert.NotNull(engineering);
var bat = engineering.JobInputData.Vehicle.Components.ElectricStorage;
Assert.NotNull(bat);
Assert.AreEqual(2, bat.Count);
Assert.AreEqual(5, bat.BatteryPack.MaxCurrentFactor);
Assert.AreEqual(0.12, bat.BatteryPack.InternalResistance.Value());
var em = engineering.JobInputData.Vehicle.Components.ElectricMachines;
Assert.NotNull(em);
Assert.AreEqual(1, em.Entries.Count);
Assert.AreEqual(PowertrainPosition.HybridP2, em.Entries[0].Position);
Assert.AreEqual(0.15, em.Entries[0].ElectricMachine.Inertia.Value());
}
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
"CreatedBy": "",
"Date": "2017-07-13T14:14:29.3226830Z",
"AppVersion": "3",
"FileVersion": 7
"FileVersion": 10
},
"Body": {
"SavedInDeclMode": false,
......@@ -32,16 +32,17 @@
"LossMap": "",
"Cycle": ""
},
"ElectricMotors": {
[
"ElectricMotors": [
{
"Count": 1,
"Position": "P2",
"MotorFile": "GenericEMotor240kW.vem"
}
],
},
"Battery": {
"Battery": {
"NumPacks": 2,
"BatteryFile": "GenericBattery.vbat",
}
},
"TorqueLimits": {},
"IdlingSpeed": 0.0,
"AxleConfig": {
......
......@@ -8,7 +8,7 @@
"Body": {
"SavedInDeclMode": false,
"Model": "Generic Battery",
"InternalResistance": 1.1,
"InternalResistance": 0.12,
"SOC_min": 20,
"SOC_max": 80,
"MaxCurrentFactor": 5,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment