diff --git a/Generic Vehicles/Declaration Mode/xEV XML Jobs/Lorries/Group5_HEV_P2_supercap.xml b/Generic Vehicles/Declaration Mode/xEV XML Jobs/Lorries/Group5_HEV_P2_supercap.xml index 9721a6509c3123397b7d6650c8ab1df48176c809..23351fee0ca510baf52b7f51c99dcf3f21093123 100644 --- a/Generic Vehicles/Declaration Mode/xEV XML Jobs/Lorries/Group5_HEV_P2_supercap.xml +++ b/Generic Vehicles/Declaration Mode/xEV XML Jobs/Lorries/Group5_HEV_P2_supercap.xml @@ -1,5 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="2.0" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationInput:v2.0" xmlns:di="http://www.w3.org/2000/09/xmldsig#" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationJob V:\VectoCore\VectoCore\Resources\XSD/VectoDeclarationJob.xsd" xmlns:v1.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" xmlns:v2.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" xmlns:v2.1="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.1" xmlns:v2.3="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.3" xmlns:v2.4="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.4"> +<tns:VectoInputDeclaration + xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.4" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + schemaVersion="2.0" + xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationInput:v2.0" + xmlns:di="http://www.w3.org/2000/09/xmldsig#" + xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationJob V:\VectoCore\VectoCore\Resources\XSD/VectoDeclarationJob.xsd" + xmlns:v1.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" + xmlns:v2.0="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.0" + xmlns:v2.3="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.3" + xmlns:v2.6="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v2.6"> <v2.0:Vehicle xsi:type="Vehicle_HEV-Px_HeavyLorryDeclarationType" id="Group5_HEV_P2_sc"> <Manufacturer>TU Graz</Manufacturer> <ManufacturerAddress>Inffeldgasse 19</ManufacturerAddress> @@ -2219,19 +2229,19 @@ </ElectricMachine> <ElectricEnergyStorage> <Capacitor> - <Data xsi:type="v2.3:CapacitorSystemDataType" id="CAP-qwertz"> - <v2.3:Manufacturer>SuperCAP Factory</v2.3:Manufacturer> - <v2.3:Model>Super cap 7000</v2.3:Model> - <v2.3:CertificationNumber>123456789</v2.3:CertificationNumber> - <v2.3:Date>2017-01-01T00:00:00Z</v2.3:Date> - <v2.3:AppVersion>aaaaa</v2.3:AppVersion> - <v2.3:CertificationMethod>Measured</v2.3:CertificationMethod> - <v2.3:Capacitance>37.00</v2.3:Capacitance> - <v2.3:InternalResistance>5.00</v2.3:InternalResistance> - <v2.3:MinVoltage>100.00</v2.3:MinVoltage> - <v2.3:MaxVoltage>900.00</v2.3:MaxVoltage> - <v2.3:MaxChargingCurrent>2200.00</v2.3:MaxChargingCurrent> - <v2.3:MaxDischargingCurrent>2200.00</v2.3:MaxDischargingCurrent> + <Data xsi:type="v2.6:CapacitorSystemDataType" id="CAP-qwertz"> + <v2.6:Manufacturer>SuperCAP Factory</v2.6:Manufacturer> + <v2.6:Model>Super cap 7000</v2.6:Model> + <v2.6:CertificationNumber>123456789</v2.6:CertificationNumber> + <v2.6:Date>2017-01-01T00:00:00Z</v2.6:Date> + <v2.6:AppVersion>aaaaa</v2.6:AppVersion> + <v2.6:CertificationMethod>Measured</v2.6:CertificationMethod> + <v2.6:Capacitance>37.00</v2.6:Capacitance> + <v2.6:InternalResistance>5000.00</v2.6:InternalResistance> + <v2.6:MinVoltage>100.00</v2.6:MinVoltage> + <v2.6:MaxVoltage>900.00</v2.6:MaxVoltage> + <v2.6:MaxChargingCurrent>2200.00</v2.6:MaxChargingCurrent> + <v2.6:MaxDischargingCurrent>2200.00</v2.6:MaxDischargingCurrent> </Data> <Signature> <di:Reference> diff --git a/VectoCommon/VectoCommon/Utils/SI.cs b/VectoCommon/VectoCommon/Utils/SI.cs index 7a3cddf04fbb7a0a272b7a5dd6b150158a0e1535..e3874d08a39f351f360e91a87e3e521018201760 100644 --- a/VectoCommon/VectoCommon/Utils/SI.cs +++ b/VectoCommon/VectoCommon/Utils/SI.cs @@ -1354,7 +1354,21 @@ namespace TUGraz.VectoCommon.Utils public double AsMilliOhm => Val * 1000; } - public class Farad : SIBase<Farad> + public class SpecificResistance : SIBase<SpecificResistance> + { + private static readonly int[] Units = { 1, 2, -3 + 1, -2 + 1, 0, 0, 0 }; + + private SpecificResistance(double val) : base(val, Units) { } + + public override string UnitString => "ΩAs"; + + public static Ohm operator /(SpecificResistance spr, AmpereSecond amps) + { + return SIBase<Ohm>.Create(spr.Val / amps.Value()); + } + } + + public class Farad : SIBase<Farad> { private static readonly int[] Units = { -1, -2, 4, 2, 0, 0, 0 }; diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricStorageSystemDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricStorageSystemDeclarationInputData.cs index b837673929ee14f78b9b0e580aea1154e6422e4c..204c5d7233433cb54ada72a8a242bb39022d576c 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricStorageSystemDeclarationInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLElectricStorageSystemDeclarationInputData.cs @@ -211,7 +211,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public const string XSD_TYPE = "BatterySystemStandardValuesDataType"; public static readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); - public XMLBatteryPackDeclarationInputDataStandardV23(XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) { } + public XMLBatteryPackDeclarationInputDataStandardV23(XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) + { + throw new VectoException($"{XSD_TYPE} v2.3 is no longer supported. Use newer version instead."); + } #region Overrides of AbstractBatteryPackDeclarationInputDataProvider @@ -284,84 +287,78 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } - - - public class XMLBatteryPackDeclarationDeclarationInputDataV24 : AbstractCommonComponentType, - IXMLBatteryPackDeclarationInputData + public class XMLBatteryPackDeclarationInputDataStandardV26 : AbstractBatteryPackDeclarationInputDataProvider { - public static readonly XNamespace NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V24; - public const string XSD_TYPE = "REESSBatteryType"; - public static readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); - - [Obsolete] - public XMLBatteryPackDeclarationDeclarationInputDataV24(XmlNode componentNode, string sourceFile) - : base(componentNode, sourceFile) - { - throw new NotImplementedException("Replaced with v2.3 dataprovider"); - //SourceType = DataSourceType.XMLEmbedded; - } - - #region Implementation of IREESSPackInputData - - public REESSType StorageType => REESSType.Battery; - - #endregion - - #region Implementation of IBatteryPackDeclarationInputData - - public virtual double? MinSOC => - ElementExists(XMLNames.Battery_SOCmin) ? GetDouble(XMLNames.Battery_SOCmin) / 100 : (double?)null; + public static readonly XNamespace NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V26; + public const string XSD_TYPE = "BatterySystemStandardValuesDataType"; + public static readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); - public virtual double? MaxSOC => - ElementExists(XMLNames.Battery_SOCmax) ? GetDouble(XMLNames.Battery_SOCmax) / 100 : (double?)null; + private SpecificResistances _specificResistances; - public virtual BatteryType BatteryType => GetString(XMLNames.REESS_BatteryType).ParseEnum<BatteryType>(); - public virtual AmpereSecond Capacity => GetDouble(XMLNames.REESS_RatedCapacity).SI(Unit.SI.Ampere.Hour).Cast<AmpereSecond>(); + public XMLBatteryPackDeclarationInputDataStandardV26(XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) + { + _specificResistances = new SpecificResistances(); + } - public virtual bool? ConnectorsSubsystemsIncluded => CertificationMethod == CertificationMethod.StandardValues - ? (bool?)null - : GetBool(XMLNames.REESS_ConnectorsSubsystemsIncluded); + protected override XNamespace NamespaceURI => NAMESPACE_URI; - public virtual bool? JunctionboxIncluded => CertificationMethod == CertificationMethod.StandardValues - ? (bool?)null - : GetBool(XMLNames.REESS_JunctionboxIncluded); + protected override TableData GetMaxCurrentMap() + { + var entries = base.GetMaxCurrentMap(); - public virtual Kelvin TestingTemperature => CertificationMethod != CertificationMethod.StandardValues - ? GetDouble(XMLNames.REESS_TestingTemperature).DegCelsiusToKelvin() - : null; + var requiredEntrySoCs = new List<int>() { 0, 30, 80, 100 }; - public virtual TableData InternalResistanceCurve => ReadTableData(XMLNames.REESS_InternalResistanceCurve, XMLNames.REESS_MapEntry, - AttributeMappings.InternalResistanceMap); - - public virtual TableData VoltageCurve => ReadTableData(XMLNames.REESS_OCV, XMLNames.REESS_MapEntry, - AttributeMappings.VoltageMap); - - public virtual TableData MaxCurrentMap => ReadTableData(XMLNames.REESS_CurrentLimits, XMLNames.REESS_MapEntry, - AttributeMappings.MaxCurrentMap); + foreach (var soc in requiredEntrySoCs) + { + if (!entries.AsEnumerable().Any(z => z.Field<string>(XMLNames.REESS_CurrentLimits_SoC).ToInt() == soc)) + { + throw new VectoException($"Battery does not contain Current Limit entry for SoC: {soc}"); + } + } - #endregion + return entries; + } - #region Overrides of AbstractXMLResource + protected override TableData GetInternalResistanceCurve() + { + const int SoC = 50; + + var mapSoC = BatterySOCReader.Create(VoltageCurve); + if (!mapSoC.ContainsSoC(SoC / 100.0)) + { + throw new VectoException($"Battery SoC map does not contain entry with SoC: {SoC}"); + } - protected override XNamespace SchemaNamespace => NAMESPACE_URI; - protected override DataSourceType SourceType => DataSourceType.XMLFile; + var vNom = mapSoC.Lookup(SoC / 100.0); + var minCells = vNom / 4.0.SI<Volt>(); + var maxCells = vNom / 3.0.SI<Volt>(); - #endregion - } + var resistances = base.GetInternalResistanceCurve(); + var specificResistanceData = _specificResistances.Lookup(BatteryType); - // --------------------------------------------------------------------------------------- + //var rowSoC = resistances.AsEnumerable().First(); + foreach (DataRow rowSoC in resistances.AsEnumerable()) { + var soc = rowSoC.ParseDouble(0); + for (var i = 1; i < resistances.Columns.Count; i++) { + var resistance = rowSoC.ParseDouble(i).SI(Unit.SI.Milli.Ohm).Cast<Ohm>(); + var resistanceName = resistances.Columns[i].ColumnName; - public class XMLBatteryPackDeclarationDeclarationInputDataV01 : XMLBatteryPackDeclarationDeclarationInputDataV24 - { - public static readonly XNamespace NAMESPACE_URI = XMLDefinitions.DECLARATION_MULTISTAGE_BUS_VEHICLE_NAMESPACE_VO1; - public const string XSD_TYPE = "REESSBatteryType"; + var specificResistance = specificResistanceData.GetValue(resistanceName); + var cellResistance = specificResistance / Capacity; - public static readonly string QUALIFIED_XSD_TYPE = - XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); + var minResistance = cellResistance * minCells.Value(); + var maxResistance = cellResistance * maxCells.Value(); - public XMLBatteryPackDeclarationDeclarationInputDataV01(XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) { } + if ((resistance < minResistance) || (resistance > maxResistance)) { + Log.Warn( + $@"Battery {resistanceName}: {resistance.AsMilliOhm}, for SoC: {soc}, out of range [{minResistance.AsMilliOhm.ToString("N2")}, {maxResistance.AsMilliOhm.ToString("N2")}]"); + } + } + } - } + return resistances; + } + } public class XMLBatteryPackDeclarationInputDataMeasuredV01 : AbstractBatteryPackDeclarationInputDataProvider { @@ -395,15 +392,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider // --------------------------------------------------------------------------------------- - public class XMLSuperCapDeclarationInputDataV24 : AbstractCommonComponentType, IXMLSuperCapDeclarationInputData + public class XMLSuperCapDeclarationInputDataV23 : AbstractCommonComponentType, IXMLSuperCapDeclarationInputData { - public static readonly XNamespace NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V24; - public const string XSD_TYPE = "REESSCapacitorType"; + public static readonly XNamespace NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V23; + public const string XSD_TYPE = "CapacitorSystemDataType"; public static readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); - public XMLSuperCapDeclarationInputDataV24(XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) + public XMLSuperCapDeclarationInputDataV23(XmlNode componentNode, string sourceFile, bool disallowed = true) : base(componentNode, sourceFile) { - //SourceType = DataSourceType.XMLEmbedded; + if (disallowed && CertificationMethod == CertificationMethod.StandardValues) + { + throw new VectoException($"Capacitor v2.3 is no longer supported. Use newer version instead."); + } } #region Implementation of IREESSPackInputData @@ -454,10 +454,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + // --------------------------------------------------------------------------------------- + + public class XMLSuperCapDeclarationInputDataV26 : XMLSuperCapDeclarationInputDataV23 + { + public static new readonly XNamespace NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V26; + public const string XSD_TYPE = "CapacitorSystemDataType"; + public static new readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); + + public XMLSuperCapDeclarationInputDataV26(XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile, false) + {} + + public override Ohm InternalResistance => GetDouble(XMLNames.Capacitor_InternalResistance).SI(Unit.SI.Milli.Ohm).Cast<Ohm>(); + } // --------------------------------------------------------------------------------------- - public class XMLSuperCapDeclarationInputDataV01 : XMLSuperCapDeclarationInputDataV24 + public class XMLSuperCapDeclarationInputDataV01 : XMLSuperCapDeclarationInputDataV23 { public static readonly XNamespace NAMESPACE_URI = XMLDefinitions.DECLARATION_MULTISTAGE_BUS_VEHICLE_NAMESPACE_VO1; public const string XSD_TYPE = "REESSCapacitorType"; @@ -465,7 +478,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public static readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); - public XMLSuperCapDeclarationInputDataV01(XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) { } + public XMLSuperCapDeclarationInputDataV01(XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile, false) { } #region Overrides of XMLSuperCapDeclarationInputDataV24 diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV24InjectModule.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV24InjectModule.cs index 8aa7fded10387a5ce50bec634dc94f5f333a7809..ba282f2dfc7d15bcbfd2824dbb3beda978cd4a28 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV24InjectModule.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV24InjectModule.cs @@ -330,8 +330,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules Bind<IXMLBatteryPackDeclarationInputData>().To<XMLBatteryPackDeclarationInputDataStandardV23>() .Named(XMLBatteryPackDeclarationInputDataStandardV23.QUALIFIED_XSD_TYPE); - Bind<IXMLSuperCapDeclarationInputData>().To<XMLSuperCapDeclarationInputDataV24>() - .Named(XMLSuperCapDeclarationInputDataV24.QUALIFIED_XSD_TYPE); + Bind<IXMLSuperCapDeclarationInputData>().To<XMLSuperCapDeclarationInputDataV23>() + .Named(XMLSuperCapDeclarationInputDataV23.QUALIFIED_XSD_TYPE); Bind<IXMLADCDeclarationInputData>().To<XMLADCDeclarationInputDataV23>() .Named(XMLADCDeclarationInputDataV23.QUALIFIED_XSD_TYPE); diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV26InjectModule.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV26InjectModule.cs new file mode 100644 index 0000000000000000000000000000000000000000..2f2d87990cef420d4bada40b4838b3be406982c6 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV26InjectModule.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Ninject.Modules; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules +{ + public class XMLDeclarationInputDataV26InjectModule : NinjectModule + { + public override void Load() + { + Bind<IXMLBatteryPackDeclarationInputData>().To<XMLBatteryPackDeclarationInputDataStandardV26>() + .Named(XMLBatteryPackDeclarationInputDataStandardV26.QUALIFIED_XSD_TYPE); + + Bind<IXMLSuperCapDeclarationInputData>().To<XMLSuperCapDeclarationInputDataV26>() + .Named(XMLSuperCapDeclarationInputDataV26.QUALIFIED_XSD_TYPE); + } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationReaderInjectModule.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationReaderInjectModule.cs index bcf6935cf2fe1a08e0bb911765aef5f4e1b2bb2b..e0a061613422f72f83f0c16f6792c3e97d6ab42c 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationReaderInjectModule.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationReaderInjectModule.cs @@ -54,7 +54,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration new XMLDeclarationInputDataV23InjectModule(), new XMLDeclarationInputDataV24InjectModule(), new XMLDeclarationInputDataV25InjectModule(), - new XMLDeclarationInputDataMultistageV01InjectModule(), + new XMLDeclarationInputDataV26InjectModule(), + new XMLDeclarationInputDataMultistageV01InjectModule(), }); #endregion diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs index 44e4917f43367c240fb95afe26faf0957fe03828..2034b4fee98539cabf9112e36d708bc0f53eacd8 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs @@ -615,7 +615,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl public const string XSD_TYPE = "ElectricEnergyStorageType"; public static readonly string QUALIFIED_XSD_TYPE = XMLHelper.CombineNamespace(NAMESPACE_URI.NamespaceName, XSD_TYPE); - [Inject] public virtual IDeclarationInjectFactory Factory { protected get; set; } + [Inject] public virtual IDeclarationInjectFactory Factory { protected get; set; } public XMLREESSReaderV24(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( componentNode) { } @@ -651,6 +651,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl protected virtual ISuperCapDeclarationInputData SuperCapCreator(string version, XmlNode componentNode, string sourcefile) { + var dataNode = GetNode(XMLNames.ComponentDataWrapper, componentNode); + version = XMLHelper.GetXsdType(dataNode.SchemaInfo.SchemaType); return Factory.CreateSuperCapDeclarationInputData(version, componentNode, sourcefile); } diff --git a/VectoCore/VectoCore/Models/Declaration/SpecificResistances.cs b/VectoCore/VectoCore/Models/Declaration/SpecificResistances.cs new file mode 100644 index 0000000000000000000000000000000000000000..a8d1a85331d1e072da6af6343d6c2c0a3765a411 --- /dev/null +++ b/VectoCore/VectoCore/Models/Declaration/SpecificResistances.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.Models.Declaration +{ + public class SpecificResistances : LookupData<BatteryType, SpecificResistances.SpecificResistancesData> + { + protected override string ResourceId => DeclarationData.DeclarationDataResourcePrefix + ".SpecificResistances.csv"; + protected override string ErrorMessage => "SpecificResistances Lookup Error: no value found. Key: '{0}'"; + + public struct SpecificResistancesData + { + public SpecificResistance Ri_2; // mOhm x Ah + public SpecificResistance Ri_10; + public SpecificResistance Ri_20; + public SpecificResistance Ri_120; + + public SpecificResistance GetValue(string variable) + { + var modifiedVariable = variable.Replace('-', '_'); + + switch (modifiedVariable) + { + case nameof(Ri_2): return Ri_2; + case nameof(Ri_10): return Ri_10; + case nameof(Ri_20): return Ri_20; + case nameof(Ri_120): return Ri_120; + default: throw new ArgumentOutOfRangeException($"{variable} is not part of SpecificResistancesData"); + } + } + } + + public override SpecificResistancesData Lookup(BatteryType key) + { + return base.Lookup(key); + } + + protected override void ParseData(DataTable table) + { + var ri120 = nameof(SpecificResistancesData.Ri_120).ToLower(); + + foreach (DataRow row in table.Rows) + { + var val = new SpecificResistancesData() + { + Ri_2 = row.ParseDouble(nameof(SpecificResistancesData.Ri_2).ToLower()).SI(Unit.SI.Milli.Ohm.Ampere.Hour).Cast<SpecificResistance>(), + Ri_10 = row.ParseDouble(nameof(SpecificResistancesData.Ri_10).ToLower()).SI(Unit.SI.Milli.Ohm.Ampere.Hour).Cast<SpecificResistance>(), + Ri_20 = row.ParseDouble(nameof(SpecificResistancesData.Ri_20).ToLower()).SI(Unit.SI.Milli.Ohm.Ampere.Hour).Cast<SpecificResistance>(), + Ri_120 = !row.IsNull(ri120) && !String.IsNullOrWhiteSpace(row[ri120].ToString()) ? row.ParseDouble(ri120).SI(Unit.SI.Milli.Ohm.Ampere.Hour).Cast<SpecificResistance>() : null + }; + + var type = (BatteryType)Enum.Parse(typeof(BatteryType), row["type"].ToString()); + + Data.Add(type, val); + } + } + + } +} diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricComponents/Battery/BatteryData.cs b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricComponents/Battery/BatteryData.cs index a30f9d9d6eb3d0b5fc765894cb6d127ceb5b1ba4..008ff5673cd3ab51aeaa7d3a4eccc82083938a19 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricComponents/Battery/BatteryData.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Data/ElectricComponents/Battery/BatteryData.cs @@ -140,6 +140,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.ElectricComponents.Ba Entries[idx].BatteryVolts, soc); } + public bool ContainsSoC(double soc) + { + return Entries.Any(x => x.SOC.IsEqual(soc)); + } + protected int FindIndex(double soc) { if (soc < Entries.First().SOC) diff --git a/VectoCore/VectoCore/Resources/Declaration/SpecificResistances.csv b/VectoCore/VectoCore/Resources/Declaration/SpecificResistances.csv new file mode 100644 index 0000000000000000000000000000000000000000..9b026f7a7a3ccefbc22f4a9f667b0a76f1737ea2 --- /dev/null +++ b/VectoCore/VectoCore/Resources/Declaration/SpecificResistances.csv @@ -0,0 +1,3 @@ +Type, Ri_2, Ri_10, Ri_20, Ri_120 +HEBS, 210, 240, 270, 390 +HPBS, 40, 45, 50, \ No newline at end of file diff --git a/VectoCore/VectoCore/Resources/XSD/VectoDeclarationDefinitions.2.6.xsd b/VectoCore/VectoCore/Resources/XSD/VectoDeclarationDefinitions.2.6.xsd index a330a3055e73a83405387ae4569df21f63dee8cc..15b9aff84f6204443f0872c73b84ef3dd6795200 100644 --- a/VectoCore/VectoCore/Resources/XSD/VectoDeclarationDefinitions.2.6.xsd +++ b/VectoCore/VectoCore/Resources/XSD/VectoDeclarationDefinitions.2.6.xsd @@ -440,7 +440,7 @@ <xs:element name="CurrentLimits"> <xs:complexType> <xs:sequence> - <xs:element name="Entry" type="v2.3:BatterySystemCurrentLimitsEntryType" minOccurs="2" maxOccurs="unbounded"/> + <xs:element name="Entry" type="v2.3:BatterySystemCurrentLimitsEntryType" minOccurs="4" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> diff --git a/VectoCore/VectoCore/Utils/XMLDefinitions.cs b/VectoCore/VectoCore/Utils/XMLDefinitions.cs index c25b4ebb2fedf5aedeca7646c24e23787f3d8268..7c6d79f032837406f2afb54a09c33fb38f77aefc 100644 --- a/VectoCore/VectoCore/Utils/XMLDefinitions.cs +++ b/VectoCore/VectoCore/Utils/XMLDefinitions.cs @@ -102,9 +102,10 @@ namespace TUGraz.VectoCore.Utils public const string DECLARATION_DEFINITIONS_NAMESPACE_URI_V24 = DECLARATION_NAMESPACE + ":v2.4"; public const string DECLARATION_DEFINITIONS_NAMESPACE_URI_V25 = DECLARATION_NAMESPACE + ":v2.5"; + public const string DECLARATION_DEFINITIONS_NAMESPACE_URI_V26 = DECLARATION_NAMESPACE + ":v2.6"; - public const string DECLARATION_INPUT_NAMESPACE = "urn:tugraz:ivt:VectoAPI:DeclarationInput"; + public const string DECLARATION_INPUT_NAMESPACE = "urn:tugraz:ivt:VectoAPI:DeclarationInput"; public const string DECLARATION_INPUT_NAMESPACE_URI_V10 = DECLARATION_INPUT_NAMESPACE + ":v1.0";