From bdef0ed69e34a69acd02ec61fc0d485ac68adca9 Mon Sep 17 00:00:00 2001 From: "VKMTHD\\franzjosefkober" <franz.josef.kober@ivt.tugraz.at> Date: Tue, 31 Aug 2021 14:26:31 +0200 Subject: [PATCH] finished battery reader implementation, with unit test --- VECTO/GUI/BatteryForm.vb | 4 +- VECTO/Input Files/Battery.vb | 4 +- VECTO/Input Files/Vehicle.vb | 4 +- .../InputData/DeclarationInputData.cs | 4 +- .../Resources/XMLNames.Designer.cs | 198 ++++++++++++++++++ .../VectoCommon/Resources/XMLNames.resx | 66 ++++++ .../InputData/FileIO/JSON/JSONBattery.cs | 4 +- ...ectricStorageSystemDeclarationInputData.cs | 122 ++++++----- .../EngineeringDataAdapter.cs | 4 +- .../SimulationComponent/BatterySystemTest.cs | 4 +- .../XML/XMLDeclarationInputv210.cs | 99 +++++++-- 11 files changed, 430 insertions(+), 83 deletions(-) diff --git a/VECTO/GUI/BatteryForm.vb b/VECTO/GUI/BatteryForm.vb index 1061abaabc..84073d97a7 100644 --- a/VECTO/GUI/BatteryForm.vb +++ b/VECTO/GUI/BatteryForm.vb @@ -185,8 +185,8 @@ Public Class BatteryForm Dim battery As IBatteryPackEngineeringInputData = ctype(reess, IBatteryPackEngineeringInputData) tbCapacity.Text = battery.Capacity.AsAmpHour.ToGUIFormat() - tbSoCMin.Text = (battery.MinSOC * 100).ToGUIFormat() - tbSoCMax.Text = (battery.MaxSOC * 100).ToGUIFormat() + tbSoCMin.Text = (battery.MinSOC.Value * 100).ToGUIFormat() + tbSoCMax.Text = (battery.MaxSOC.Value * 100).ToGUIFormat() tbMaxCurrentMap.Text = GetRelativePath(battery.MaxCurrentMap.Source, basePath) tbSoCCurve.Text = GetRelativePath(battery.VoltageCurve.Source, basePath) diff --git a/VECTO/Input Files/Battery.vb b/VECTO/Input Files/Battery.vb index 3fec3e9066..1c3b847257 100644 --- a/VECTO/Input Files/Battery.vb +++ b/VECTO/Input Files/Battery.vb @@ -211,13 +211,13 @@ Public Class Battery End Get End Property - Public ReadOnly Property MinSOC As Double Implements IBatteryPackDeclarationInputData.MinSOC + Public ReadOnly Property MinSOC As Double? Implements IBatteryPackDeclarationInputData.MinSOC Get Return BatMinSoc / 100.0 End Get End Property - Public ReadOnly Property MaxSOC As Double Implements IBatteryPackDeclarationInputData.MaxSOC + Public ReadOnly Property MaxSOC As Double? Implements IBatteryPackDeclarationInputData.MaxSOC Get Return BatMaxSoc / 100.0 End Get diff --git a/VECTO/Input Files/Vehicle.vb b/VECTO/Input Files/Vehicle.vb index a7caf65f06..af6b409de9 100644 --- a/VECTO/Input Files/Vehicle.vb +++ b/VECTO/Input Files/Vehicle.vb @@ -982,8 +982,8 @@ Public Class ElectricStorageWrapper Public ReadOnly Property CertificationMethod As CertificationMethod Implements IComponentInputData.CertificationMethod Public ReadOnly Property CertificationNumber As String Implements IComponentInputData.CertificationNumber Public ReadOnly Property DigestValue As DigestData Implements IComponentInputData.DigestValue - Public ReadOnly Property MinSOC As Double Implements IBatteryPackDeclarationInputData.MinSOC - Public ReadOnly Property MaxSOC As Double Implements IBatteryPackDeclarationInputData.MaxSOC + Public ReadOnly Property MinSOC As Double? Implements IBatteryPackDeclarationInputData.MinSOC + Public ReadOnly Property MaxSOC As Double? Implements IBatteryPackDeclarationInputData.MaxSOC Public ReadOnly Property BatteryType As BatteryType Implements IBatteryPackDeclarationInputData.BatteryType Public ReadOnly Property Capacity As AmpereSecond Implements IBatteryPackDeclarationInputData.Capacity Public ReadOnly Property ConnectorsSubsystemsIncluded As Boolean Implements IBatteryPackDeclarationInputData.ConnectorsSubsystemsIncluded diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index 858200a68f..5e4f2c7ab4 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -805,9 +805,9 @@ namespace TUGraz.VectoCommon.InputData public interface IBatteryPackDeclarationInputData : IREESSPackInputData { - double MinSOC { get; } + double? MinSOC { get; } - double MaxSOC { get; } + double? MaxSOC { get; } BatteryType BatteryType { get; } diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs index 88f2622dc2..4d797f7db0 100644 --- a/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs +++ b/VectoCommon/VectoCommon/Resources/XMLNames.Designer.cs @@ -492,6 +492,33 @@ namespace TUGraz.VectoCommon.Resources { } } + /// <summary> + /// Looks up a localized string similar to SOCmax. + /// </summary> + public static string Battery_SOCmax { + get { + return ResourceManager.GetString("Battery_SOCmax", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to SOCmin. + /// </summary> + public static string Battery_SOCmin { + get { + return ResourceManager.GetString("Battery_SOCmin", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to StringID. + /// </summary> + public static string Battery_StringID { + get { + return ResourceManager.GetString("Battery_StringID", resourceCulture); + } + } + /// <summary> /// Looks up a localized string similar to APTEcoRollReleaseLockupClutch. /// </summary> @@ -2841,6 +2868,177 @@ namespace TUGraz.VectoCommon.Resources { } } + /// <summary> + /// Looks up a localized string similar to BatteryType. + /// </summary> + public static string REESS_BatteryType { + get { + return ResourceManager.GetString("REESS_BatteryType", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to ConnectorsSubsystemsIncluded. + /// </summary> + public static string REESS_ConnectorsSubsystemsIncluded { + get { + return ResourceManager.GetString("REESS_ConnectorsSubsystemsIncluded", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to CurrentLimits. + /// </summary> + public static string REESS_CurrentLimits { + get { + return ResourceManager.GetString("REESS_CurrentLimits", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to maxChargingCurrent. + /// </summary> + public static string REESS_CurrentLimits_MaxChargingCurrent { + get { + return ResourceManager.GetString("REESS_CurrentLimits_MaxChargingCurrent", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to maxDischargingCurrent. + /// </summary> + public static string REESS_CurrentLimits_MaxDischargingCurrent { + get { + return ResourceManager.GetString("REESS_CurrentLimits_MaxDischargingCurrent", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to SoC. + /// </summary> + public static string REESS_CurrentLimits_SoC { + get { + return ResourceManager.GetString("REESS_CurrentLimits_SoC", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to InternalResistance. + /// </summary> + public static string REESS_InternalResistanceCurve { + get { + return ResourceManager.GetString("REESS_InternalResistanceCurve", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to R_10. + /// </summary> + public static string REESS_InternalResistanceCurve_R10 { + get { + return ResourceManager.GetString("REESS_InternalResistanceCurve_R10", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to R_120. + /// </summary> + public static string REESS_InternalResistanceCurve_R120 { + get { + return ResourceManager.GetString("REESS_InternalResistanceCurve_R120", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to R_2. + /// </summary> + public static string REESS_InternalResistanceCurve_R2 { + get { + return ResourceManager.GetString("REESS_InternalResistanceCurve_R2", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to R_20. + /// </summary> + public static string REESS_InternalResistanceCurve_R20 { + get { + return ResourceManager.GetString("REESS_InternalResistanceCurve_R20", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to SoC. + /// </summary> + public static string REESS_InternalResistanceCurve_SoC { + get { + return ResourceManager.GetString("REESS_InternalResistanceCurve_SoC", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to JunctionboxIncluded. + /// </summary> + public static string REESS_JunctionboxIncluded { + get { + return ResourceManager.GetString("REESS_JunctionboxIncluded", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to Entry. + /// </summary> + public static string REESS_MapEntry { + get { + return ResourceManager.GetString("REESS_MapEntry", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to OCV. + /// </summary> + public static string REESS_OCV { + get { + return ResourceManager.GetString("REESS_OCV", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to OCV. + /// </summary> + public static string REESS_OCV_OCV { + get { + return ResourceManager.GetString("REESS_OCV_OCV", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to SoC. + /// </summary> + public static string REESS_OCV_SoC { + get { + return ResourceManager.GetString("REESS_OCV_SoC", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to RatedCapacity. + /// </summary> + public static string REESS_RatedCapacity { + get { + return ResourceManager.GetString("REESS_RatedCapacity", resourceCulture); + } + } + + /// <summary> + /// Looks up a localized string similar to TestingTemperature. + /// </summary> + public static string REESS_TestingTemperature { + get { + return ResourceManager.GetString("REESS_TestingTemperature", resourceCulture); + } + } + /// <summary> /// Looks up a localized string similar to CdxA. /// </summary> diff --git a/VectoCommon/VectoCommon/Resources/XMLNames.resx b/VectoCommon/VectoCommon/Resources/XMLNames.resx index 85480acf69..dee2fed602 100644 --- a/VectoCommon/VectoCommon/Resources/XMLNames.resx +++ b/VectoCommon/VectoCommon/Resources/XMLNames.resx @@ -1638,4 +1638,70 @@ <data name="ElectricEnergyStorage_Capacitor" xml:space="preserve"> <value>Capacitor</value> </data> + <data name="Battery_SOCmax" xml:space="preserve"> + <value>SOCmax</value> + </data> + <data name="Battery_SOCmin" xml:space="preserve"> + <value>SOCmin</value> + </data> + <data name="Battery_StringID" xml:space="preserve"> + <value>StringID</value> + </data> + <data name="REESS_BatteryType" xml:space="preserve"> + <value>BatteryType</value> + </data> + <data name="REESS_ConnectorsSubsystemsIncluded" xml:space="preserve"> + <value>ConnectorsSubsystemsIncluded</value> + </data> + <data name="REESS_CurrentLimits" xml:space="preserve"> + <value>CurrentLimits</value> + </data> + <data name="REESS_InternalResistanceCurve" xml:space="preserve"> + <value>InternalResistance</value> + </data> + <data name="REESS_InternalResistanceCurve_R10" xml:space="preserve"> + <value>R_10</value> + </data> + <data name="REESS_InternalResistanceCurve_R120" xml:space="preserve"> + <value>R_120</value> + </data> + <data name="REESS_InternalResistanceCurve_R2" xml:space="preserve"> + <value>R_2</value> + </data> + <data name="REESS_InternalResistanceCurve_R20" xml:space="preserve"> + <value>R_20</value> + </data> + <data name="REESS_InternalResistanceCurve_SoC" xml:space="preserve"> + <value>SoC</value> + </data> + <data name="REESS_JunctionboxIncluded" xml:space="preserve"> + <value>JunctionboxIncluded</value> + </data> + <data name="REESS_MapEntry" xml:space="preserve"> + <value>Entry</value> + </data> + <data name="REESS_OCV" xml:space="preserve"> + <value>OCV</value> + </data> + <data name="REESS_OCV_OCV" xml:space="preserve"> + <value>OCV</value> + </data> + <data name="REESS_OCV_SoC" xml:space="preserve"> + <value>SoC</value> + </data> + <data name="REESS_RatedCapacity" xml:space="preserve"> + <value>RatedCapacity</value> + </data> + <data name="REESS_TestingTemperature" xml:space="preserve"> + <value>TestingTemperature</value> + </data> + <data name="REESS_CurrentLimits_MaxChargingCurrent" xml:space="preserve"> + <value>maxChargingCurrent</value> + </data> + <data name="REESS_CurrentLimits_MaxDischargingCurrent" xml:space="preserve"> + <value>maxDischargingCurrent</value> + </data> + <data name="REESS_CurrentLimits_SoC" xml:space="preserve"> + <value>SoC</value> + </data> </root> \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBattery.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBattery.cs index a1da80d84c..7fa174a630 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBattery.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONBattery.cs @@ -26,9 +26,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public DigestData DigestValue => null; - public double MinSOC => Body.GetEx<double>("SOC_min") / 100.0; + public double? MinSOC => Body.GetEx<double>("SOC_min") / 100.0; - public double MaxSOC => Body.GetEx<double>("SOC_max") / 100.0; + public double? MaxSOC => Body.GetEx<double>("SOC_max") / 100.0; public BatteryType BatteryType { get; } AmpereSecond IBatteryPackDeclarationInputData.Capacity => Body.GetEx<double>("Capacity").SI(Unit.SI.Ampere.Hour).Cast<AmpereSecond>(); diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricStorageSystemDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricStorageSystemDeclarationInputData.cs index 212c80e5b8..b55b536c88 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricStorageSystemDeclarationInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricStorageSystemDeclarationInputData.cs @@ -2,6 +2,7 @@ using System.Xml; using System.Xml.Linq; using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; @@ -17,41 +18,36 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public static readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); private IList<IElectricStorageDeclarationInputData> _electricStorageElements; + private IXMLDeclarationVehicleData _vehicle; - #region Implementation of IElectricStorageSystemDeclarationInputData - - public IList<IElectricStorageDeclarationInputData> ElectricStorageElements => - _electricStorageElements ?? (_electricStorageElements = GetElectricStorages()); - - #endregion - public XMLElectricStorageSystemDeclarationInputData( IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) { - + _vehicle = vehicle; + SourceType = DataSourceType.XMLEmbedded; } - #region Implementation of IXMLResource + #region Implementation of IElectricStorageSystemDeclarationInputData - protected override XNamespace SchemaNamespace => NAMESPACE_URI; - protected override DataSourceType SourceType { get; } + public virtual IList<IElectricStorageDeclarationInputData> ElectricStorageElements => + _electricStorageElements ?? (_electricStorageElements = GetElectricStorages()); #endregion - + private IList<IElectricStorageDeclarationInputData> GetElectricStorages() { - var electricStorages = new List<IElectricStorageDeclarationInputData>(); - - var batteries = GetNodes("Battery"); + var batteries = GetNodes(XMLNames.ElectricEnergyStorage_Battery); if (!(batteries?.Count > 0)) return null; + + var electricStorages = new List<IElectricStorageDeclarationInputData>(); foreach (XmlNode battery in batteries) { - var electricStorage = new XMLElectricStorageDeclaration { - REESSPack = StorageTypeReader.CreateREESSInputData(battery, REESSType.Battery), - StringId = XmlConvert.ToInt32(GetString("StringID", battery)) - }; - electricStorages.Add(electricStorage); + electricStorages.Add( + new XMLElectricStorageDeclaration { + REESSPack = StorageTypeReader.CreateREESSInputData(battery, REESSType.Battery), + StringId = XmlConvert.ToInt32(GetString(XMLNames.Battery_StringID, battery)) + }); } return electricStorages; @@ -59,22 +55,30 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IXMLElectricStorageSystemDeclarationInputData - public IXMLREESSReader StorageTypeReader { get; set; } + public virtual IXMLREESSReader StorageTypeReader { protected get; set; } #endregion - } - - public class XMLElectricStorageDeclaration : IElectricStorageDeclarationInputData - { - #region Implementation of IElectricStorageDeclarationInputData + + #region Implementation of IXMLResource - public IREESSPackInputData REESSPack { get; set; } - public int Count { get; set; } - public int StringId { get; set; } + protected override XNamespace SchemaNamespace => NAMESPACE_URI; + protected override DataSourceType SourceType { get; } #endregion + + public class XMLElectricStorageDeclaration : IElectricStorageDeclarationInputData + { + #region Implementation of IElectricStorageDeclarationInputData + public IREESSPackInputData REESSPack { get; set; } + public int Count { get; set; } + public int StringId { get; set; } + + #endregion + } } - + + // --------------------------------------------------------------------------------------- + public class XMLBatteryPackDeclarationDeclarationInputData : AbstractCommonComponentType, IXMLBatteryPackDeclarationInputData { @@ -85,6 +89,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLBatteryPackDeclarationDeclarationInputData( XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) { + SourceType = DataSourceType.XMLEmbedded; } #region Implementation of IREESSPackInputData @@ -95,30 +100,41 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IBatteryPackDeclarationInputData - public double MinSOC => GetDouble("SOCmin", 0); - public double MaxSOC => GetDouble("SOCmax", 0); - public BatteryType BatteryType => BatteryTypeHelper.Parse(GetString("BatteryType")); - public AmpereSecond Capacity => GetDouble("RatedCapacity").SI<AmpereSecond>() * 3600; - public bool ConnectorsSubsystemsIncluded => GetBool("ConnectorsSubsystemsIncluded"); - public bool JunctionboxIncluded => GetBool("JunctionboxIncluded"); - public Kelvin TestingTemperature => GetDouble("TestingTemperature", 0).DegCelsiusToKelvin(); - - public TableData InternalResistanceCurve => ReadTableData("InternalResistance", "Entry", new Dictionary<string, string> { - {"SoC", "SoC"}, - {"R_2", "R_2"}, - {"R_10", "R_10"}, - {"R_20", "R_20"} - }); - - public TableData VoltageCurve => ReadTableData("OCV", "Entry", new Dictionary<string, string> { - {"SoC", "SoC"}, - {"OCV", "OCV"} + public virtual double? MinSOC => + ElementExists(XMLNames.Battery_SOCmin) ? GetDouble(XMLNames.Battery_SOCmin) : (double?)null; + + public virtual double? MaxSOC => + ElementExists(XMLNames.Battery_SOCmax) ? GetDouble(XMLNames.Battery_SOCmax) : (double?)null; + + public virtual BatteryType BatteryType => BatteryTypeHelper.Parse(GetString(XMLNames.REESS_BatteryType)); + public virtual AmpereSecond Capacity => GetDouble(XMLNames.REESS_RatedCapacity).SI<AmpereSecond>() * 3600; + public virtual bool ConnectorsSubsystemsIncluded => GetBool(XMLNames.REESS_ConnectorsSubsystemsIncluded); + public virtual bool JunctionboxIncluded => GetBool(XMLNames.REESS_JunctionboxIncluded); + + public virtual Kelvin TestingTemperature => + ElementExists(XMLNames.REESS_TestingTemperature) + ? GetDouble(XMLNames.REESS_TestingTemperature).DegCelsiusToKelvin() : null; + + public virtual TableData InternalResistanceCurve => ReadTableData(XMLNames.REESS_InternalResistanceCurve, XMLNames.REESS_MapEntry, + new Dictionary<string, string> { + {XMLNames.REESS_InternalResistanceCurve_SoC, XMLNames.REESS_InternalResistanceCurve_SoC}, + {XMLNames.REESS_InternalResistanceCurve_R2, XMLNames.REESS_InternalResistanceCurve_R2}, + {XMLNames.REESS_InternalResistanceCurve_R10, XMLNames.REESS_InternalResistanceCurve_R10}, + {XMLNames.REESS_InternalResistanceCurve_R20, XMLNames.REESS_InternalResistanceCurve_R20}, + {XMLNames.REESS_InternalResistanceCurve_R120, XMLNames.REESS_InternalResistanceCurve_R120} + }); + + public virtual TableData VoltageCurve => ReadTableData(XMLNames.REESS_OCV, XMLNames.REESS_MapEntry, + new Dictionary<string, string> { + {XMLNames.REESS_OCV_SoC, XMLNames.REESS_OCV_SoC}, + {XMLNames.REESS_OCV_OCV, XMLNames.REESS_OCV_OCV} }); - - public TableData MaxCurrentMap => ReadTableData("CurrentLimits", "Entry", new Dictionary<string, string> { - {"SoC", "SoC"}, - {"maxChagingCurrent", "maxChagingCurrent"}, - {"maxDischargingCurrent", "maxDischargingCurrent"} + + public virtual TableData MaxCurrentMap => ReadTableData(XMLNames.REESS_CurrentLimits, XMLNames.REESS_MapEntry, + new Dictionary<string, string> { + {XMLNames.REESS_CurrentLimits_SoC, XMLNames.REESS_CurrentLimits_SoC}, + {XMLNames.REESS_CurrentLimits_MaxChargingCurrent, XMLNames.REESS_CurrentLimits_MaxChargingCurrent}, + {XMLNames.REESS_CurrentLimits_MaxDischargingCurrent, XMLNames.REESS_CurrentLimits_MaxDischargingCurrent} }); #endregion diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index 99b1947732..ee7142b7d5 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -727,8 +727,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter for (var i = 0; i < entry.Count; i++) { retVal.Batteries.Add(Tuple.Create(entry.StringId, new BatteryData() { - MinSOC = b.MinSOC, - MaxSOC = b.MaxSOC, + MinSOC = b.MinSOC.Value, + MaxSOC = b.MaxSOC.Value, MaxCurrent = BatteryMaxCurrentReader.Create(b.MaxCurrentMap), Capacity = b.Capacity, InternalResistance = diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponent/BatterySystemTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponent/BatterySystemTest.cs index cfd14d54e2..0942204784 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponent/BatterySystemTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponent/BatterySystemTest.cs @@ -348,8 +348,8 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent #region Implementation of IBatteryPackDeclarationInputData - public double MinSOC => 0.2; - public double MaxSOC => 0.8; + public double? MinSOC => 0.2; + public double? MaxSOC => 0.8; public BatteryType BatteryType { get; } public AmpereSecond Capacity { get; } public bool ConnectorsSubsystemsIncluded { get; } diff --git a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputv210.cs b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputv210.cs index 5accdcdee1..8aff73ccf3 100644 --- a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputv210.cs +++ b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputv210.cs @@ -9,6 +9,7 @@ using NUnit.Framework; using TUGraz.VectoCommon.BusAuxiliaries; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.Models.Simulation; @@ -255,8 +256,7 @@ namespace TUGraz.VectoCore.Tests.XML Assert.IsNotNull(vehicle.Components.AirdragInputData); Assert.IsNotNull(vehicle.Components.ElectricStorage); TestElectricStorageElements(vehicle.Components.ElectricStorage.ElectricStorageElements); - - + Assert.IsNotNull(vehicle.Components.PTOTransmissionInputData); Assert.AreEqual(0.SI<CubicMeter>(), vehicle.CargoVolume); Assert.IsNotNull(vehicle.TorqueLimits); @@ -264,9 +264,6 @@ namespace TUGraz.VectoCore.Tests.XML // Assert.IsNotNull(vehicle.MaxPropulsionTorque);//Vehicle Max Prop. Limit } - - - #region Test Electric Machines Reader private void TestElectricMachines(IElectricMachinesDeclarationInputData electricMachines) @@ -358,27 +355,97 @@ namespace TUGraz.VectoCore.Tests.XML { Assert.IsNotNull(elements); Assert.AreEqual(2, elements.Count); + + TestFirstBatterySystemEntry(elements[0]); + TestSecondBatterySystemEntry(elements[1]); + } - foreach (var entry in elements) { - TestREESS(entry); - } - - - + private void TestFirstBatterySystemEntry(IElectricStorageDeclarationInputData entry) + { + Assert.AreEqual(0, entry.StringId); + Assert.AreEqual("a", entry.REESSPack.Manufacturer); + Assert.AreEqual("a", entry.REESSPack.Model); + Assert.AreEqual("tokena", entry.REESSPack.CertificationNumber); + Assert.AreEqual(DateTime.Parse("2017-01-01T00:00:00Z").ToUniversalTime(), entry.REESSPack.Date); + Assert.AreEqual("aaaaa", entry.REESSPack.AppVersion); + Assert.AreEqual(CertificationMethod.Measured, entry.REESSPack.CertificationMethod); + Assert.IsNotNull(entry.REESSPack.DigestValue); + + var battery = (IBatteryPackDeclarationInputData)entry.REESSPack; + Assert.AreEqual(20, battery.MinSOC); + Assert.AreEqual(80, battery.MaxSOC); + Assert.AreEqual(BatteryType.HPBS, battery.BatteryType); + Assert.AreEqual(72.00.SI<AmpereSecond>() * 3600, battery.Capacity); + Assert.AreEqual(true, battery.ConnectorsSubsystemsIncluded); + Assert.AreEqual(true, battery.JunctionboxIncluded); + Assert.AreEqual(20.0.DegCelsiusToKelvin(), battery.TestingTemperature); + + Assert.IsNotNull(battery.VoltageCurve);//OVC Data + TestOCVTableRow("0", "620.00", battery.VoltageCurve.Rows[0]); + TestOCVTableRow("100", "640.00", battery.VoltageCurve.Rows[1]); + Assert.IsNotNull(battery.InternalResistanceCurve); + TestInternalResistanceTableRow("0", "10.00", "11.00", "12.00", battery.InternalResistanceCurve.Rows[0]); + TestInternalResistanceTableRow("100","12.00" ,"14.00","16.00", battery.InternalResistanceCurve.Rows[1]); + Assert.IsNotNull(battery.MaxCurrentMap);//CurrentLimits Data + TestCurrentLimitsTableRow("0", "50.00", "0.00", battery.MaxCurrentMap.Rows[0]); + TestCurrentLimitsTableRow("100", "0.00", "50.00", battery.MaxCurrentMap.Rows[1]); } - private void TestREESS(IElectricStorageDeclarationInputData storage) + private void TestSecondBatterySystemEntry(IElectricStorageDeclarationInputData entry) { - Assert.AreEqual(1, storage.StringId); + Assert.AreEqual(1, entry.StringId); + Assert.AreEqual("b", entry.REESSPack.Manufacturer); + Assert.AreEqual("b", entry.REESSPack.Model); + Assert.AreEqual("tokenb", entry.REESSPack.CertificationNumber); + Assert.AreEqual(DateTime.Parse("2017-02-02T00:00:00Z").ToUniversalTime(), entry.REESSPack.Date); + Assert.AreEqual("bbbbb", entry.REESSPack.AppVersion); + Assert.AreEqual(CertificationMethod.Measured, entry.REESSPack.CertificationMethod); + Assert.IsNotNull(entry.REESSPack.DigestValue); + + var battery = (IBatteryPackDeclarationInputData)entry.REESSPack; + Assert.IsNull(battery.MinSOC); + Assert.IsNull(battery.MaxSOC); + Assert.AreEqual(BatteryType.HPBS, battery.BatteryType); + Assert.AreEqual(73.00.SI<AmpereSecond>() * 3600, battery.Capacity); + Assert.AreEqual(true, battery.ConnectorsSubsystemsIncluded); + Assert.AreEqual(true, battery.JunctionboxIncluded); + Assert.AreEqual(20.0.DegCelsiusToKelvin(), battery.TestingTemperature); + + Assert.IsNotNull(battery.VoltageCurve);//OVC Data + TestOCVTableRow("0", "621.00", battery.VoltageCurve.Rows[0]); + TestOCVTableRow("100", "641.00", battery.VoltageCurve.Rows[1]); + Assert.IsNotNull(battery.InternalResistanceCurve); + TestInternalResistanceTableRow("0", "11.00", "12.00", "13.00", battery.InternalResistanceCurve.Rows[0]); + TestInternalResistanceTableRow("100", "12.00", "14.00", "16.00", battery.InternalResistanceCurve.Rows[1]); + Assert.IsNotNull(battery.MaxCurrentMap);//CurrentLimits Data + TestCurrentLimitsTableRow("0", "51.00", "0.00", battery.MaxCurrentMap.Rows[0]); + TestCurrentLimitsTableRow("100", "0.00", "50.00", battery.MaxCurrentMap.Rows[1]); } + private void TestOCVTableRow(string soc, string ocv, DataRow row) + { + Assert.AreEqual(soc, row[XMLNames.REESS_OCV_SoC]); + Assert.AreEqual(ocv, row[XMLNames.REESS_OCV_OCV]); + } + private void TestInternalResistanceTableRow(string soc, string r2, string r10, string r20, DataRow row) + { + Assert.AreEqual(soc, row[XMLNames.REESS_InternalResistanceCurve_SoC]); + Assert.AreEqual(r2, row[XMLNames.REESS_InternalResistanceCurve_R2]); + Assert.AreEqual(r10, row[XMLNames.REESS_InternalResistanceCurve_R10]); + Assert.AreEqual(r20, row[XMLNames.REESS_InternalResistanceCurve_R20]); + } - - #endregion - + private void TestCurrentLimitsTableRow(string soc, string maxChargingCurrent, string maxDischargingCurrent, + DataRow row) + { + Assert.AreEqual(soc, row[XMLNames.REESS_CurrentLimits_SoC]); + Assert.AreEqual(maxChargingCurrent, row[XMLNames.REESS_CurrentLimits_MaxChargingCurrent]); + Assert.AreEqual(maxDischargingCurrent, row[XMLNames.REESS_CurrentLimits_MaxDischargingCurrent]); + } + #endregion #region Test existence of torque converter -- GitLab