From 8d44f93ec2b9ebd446eb9bd44de3bd84d3da4bba Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Thu, 4 Apr 2019 10:03:16 +0200 Subject: [PATCH] implementing reading XMLs V2.0 --- .../VectoCommon/InputData/DataSourceType.cs | 3 +- .../XMLAuxiliaryDeclarationDataProvider.cs | 13 +++- .../XMLDeclarationADASDataProvider.cs | 40 ++++++++++++ .../XMLDeclarationAirdragDataProvider.cs | 14 ++++ .../XMLDeclarationAngledriveDataProvider.cs | 17 +++++ .../XMLDeclarationAuxiliariesDataProvider.cs | 12 ++++ .../XMLDeclarationAxleDataProvider.cs | 18 ++++- .../XMLDeclarationAxlegearDataProvider.cs | 21 +++++- .../XMLDeclarationAxlesDataProvider.cs | 30 +++++++-- .../XMLDeclarationComponentsDataProvider.cs | 15 +++++ .../XMLDeclarationEngineDataProvider.cs | 14 ++++ .../XMLDeclarationGearboxDataProvider.cs | 26 ++++++-- .../XMLDeclarationInputDataProvider.cs | 8 ++- .../XMLDeclarationJobInputDataProvider.cs | 24 ++++++- .../XMLDeclarationPTODataProvider.cs | 15 ++++- .../XMLDeclarationRetarderDataProvider.cs | 23 ++++++- ...LDeclarationTorqueConverterDataProvider.cs | 14 ++++ .../XMLDeclarationTyreDataProvider.cs | 15 +++++ .../XMLDeclarationVehicleDataProvider.cs | 65 ++++++++++++++++++- .../Declaration/DataProvider/XMLGearData.cs | 45 +++++++++---- .../XMLDeclarationInputDataV10InjectModule.cs | 2 +- .../XMLDeclarationInputDataV20InjectModule.cs | 1 + .../Declaration/Reader/Impl/XMLADASReader.cs | 23 ++++++- .../XML/XMLDeclarationReaderVersionsTest.cs | 6 ++ 24 files changed, 425 insertions(+), 39 deletions(-) diff --git a/VectoCommon/VectoCommon/InputData/DataSourceType.cs b/VectoCommon/VectoCommon/InputData/DataSourceType.cs index 3a0efe5913..32276c0047 100644 --- a/VectoCommon/VectoCommon/InputData/DataSourceType.cs +++ b/VectoCommon/VectoCommon/InputData/DataSourceType.cs @@ -38,7 +38,8 @@ namespace TUGraz.VectoCommon.InputData JSONFile, Missing, XMLFile, - XMLEmbedded + XMLEmbedded, + DefaultValue } public static class DataSourceTypeExtensions diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs index 730ef22f1f..27f75a36db 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs @@ -21,9 +21,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public virtual AuxiliaryType Type { - get { - return _type ?? (_type = BaseNode.LocalName.ParseEnum<AuxiliaryType>()).Value; - } + get { return _type ?? (_type = BaseNode.LocalName.ParseEnum<AuxiliaryType>()).Value; } } public virtual IList<string> Technology @@ -45,4 +43,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + public class XMLAuxiliaryDeclarationDataProviderV20 : XMLAuxiliaryDeclarationDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + + public XMLAuxiliaryDeclarationDataProviderV20(XmlNode auxNode, IXMLDeclarationVehicleData vehicle) : base( + auxNode, vehicle) { } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs index f72f28048e..f979f3faf9 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs @@ -53,4 +53,44 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationADASDataProviderV20 : XMLDeclarationADASDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationADASDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) + : base(vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType + { + get { return DataSourceType.DefaultValue; } + } + + public override bool EngineStopStart + { + get { return false; } + } + + public override bool EcoRollWitoutEngineStop + { + get { return false; } + } + + public override bool EcoRollWithEngineStop + { + get { return false; } + } + + public override PredictiveCruiseControlType PredictiveCruiseControl + { + get { return PredictiveCruiseControlType.None; } + } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs index 2e888eb629..0b8c202ec8 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs @@ -47,4 +47,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationAirdragDataProviderV20 : XMLDeclarationAirdragDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationAirdragDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs index b909ab80f0..d000b8ca11 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs @@ -63,4 +63,21 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationAngledriveDataProviderV20 : XMLDeclarationAngledriveDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationAngledriveDataProviderV20( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( + vehicle, componentNode, sourceFile) { } + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs index 1ec5ab6e90..4ef22aaca2 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs @@ -34,6 +34,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider } _auxiliaries = new List<IAuxiliaryDeclarationInputData>(); + //var auxNodes = GetNodes(XMLNames.Auxiliaries_Auxiliary); var auxNodes = BaseNode.SelectNodes(XMLHelper.QueryLocalName(XMLNames.Auxiliaries_Auxiliary_Technology) + "/.."); if (auxNodes == null) { @@ -56,4 +57,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationAuxiliariesDataProviderV20 : XMLDeclarationAuxiliariesDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationAuxiliariesDataProviderV20( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( + vehicle, componentNode, sourceFile) { } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs index 4c6550c7fd..203177d12f 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs @@ -17,7 +17,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider protected bool? _twinTyre; protected AxleType? _axleType; - public XMLDeclarationAxleDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) + public XMLDeclarationAxleDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) + : base(componentNode, sourceFile) { SourceType = DataSourceType.XMLFile; } @@ -63,4 +64,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationAxleDataProviderV20 : XMLDeclarationAxleDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationAxleDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) + : base(vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs index cf5f684767..22333c6aad 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs @@ -14,7 +14,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; - public XMLDeclarationAxlegearDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + public XMLDeclarationAxlegearDataProviderV10( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) { SourceType = DataSourceType.XMLFile; @@ -48,6 +49,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider return value.ParseEnum<AxleLineType>(); } } + #endregion #region Overrides of AbstractXMLResource @@ -61,4 +63,21 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationAxlegearDataProviderV20 : XMLDeclarationAxlegearDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationAxlegearDataProviderV20( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( + vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + } + } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs index 3109365eb5..f00167c164 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs @@ -8,7 +8,8 @@ using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; using TUGraz.VectoCore.Utils; -namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ public class XMLDeclarationAxlesDataProviderV10 : AbstractXMLType, IXMLAxlesDeclarationInputData { public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; @@ -16,8 +17,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { protected IAxleDeclarationInputData[] _axles; - public XMLDeclarationAxlesDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(componentNode) - { DataSource = new DataSource() { SourceType = DataSourceType.XMLFile, SourceFile = sourceFile, SourceVersion = XMLHelper.GetVersionFromNamespaceUri(NAMESPACE_URI)}; } + public XMLDeclarationAxlesDataProviderV10( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(componentNode) + { + DataSource = new DataSource() { + SourceType = DataSourceType.XMLFile, + SourceFile = sourceFile, + SourceVersion = XMLHelper.GetVersionFromNamespaceUri(NAMESPACE_URI) + }; + } #region Implementation of IAxlesDeclarationInputData @@ -27,10 +35,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { if (_axles != null) { return _axles; } + var axleNodes = GetNodes(new[] { XMLNames.AxleWheels_Axles, XMLNames.AxleWheels_Axles_Axle }); if (axleNodes == null) { return new List<IAxleDeclarationInputData>(); } + _axles = new IAxleDeclarationInputData[axleNodes.Count]; foreach (XmlNode axlenode in axleNodes) { var axleNumber = GetAttribute(axlenode, XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr).ToInt(); @@ -43,6 +53,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { _axles[axleNumber - 1] = Reader.CreateAxle(axlenode); } + return _axles; } } @@ -61,4 +72,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { #endregion } -} \ No newline at end of file + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationAxlesDataProviderV20 : XMLDeclarationAxlesDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationAxlesDataProviderV20( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( + vehicle, componentNode, sourceFile) { } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs index 8722547828..2994f42cef 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs @@ -103,4 +103,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationComponentsDataProviderV20 : XMLDeclarationComponentsDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationComponentsDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs index a6e2083442..fe1a045a75 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs @@ -114,4 +114,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationEngineDataProviderV20 : XMLDeclarationEngineDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationEngineDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs index 490d7ad3cb..8dd051da51 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs @@ -20,7 +20,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public XMLDeclarationGearboxDataProviderV10( IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : - base(componentNode, sourceFile) { } + base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLEmbedded; + } #region Overrides of AbstractXMLResource @@ -29,10 +32,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider get { return NAMESPACE_URI; } } - protected override DataSourceType SourceType - { - get { return DataSourceType.XMLFile; } - } + protected override DataSourceType SourceType { get; } #endregion @@ -89,4 +89,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationGearboxDataProviderV20 : XMLDeclarationGearboxDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationGearboxDataProviderV20( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( + vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs index 635e8770a7..84f76ad8bc 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs @@ -76,7 +76,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration #endregion - public virtual IDeclarationJobInputData JobInputData { @@ -87,9 +86,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration public virtual XElement XMLHash { get; private set; } } + // --------------------------------------------------------------------------------------- + public class XMLDeclarationInputDataProviderV20 : XMLDeclarationInputDataProviderV10 { public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; public XMLDeclarationInputDataProviderV20(XmlDocument xmlDoc, string fileName) : base(xmlDoc, fileName) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs index c5c3d0dfdc..c145e526ab 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs @@ -8,10 +8,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { public class XMLDeclarationJobInputDataProviderV10 : AbstractXMLResource, IXMLDeclarationJobInputData { - protected IVehicleDeclarationInputData _vehicle; - public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + protected IVehicleDeclarationInputData _vehicle; + public XMLDeclarationJobInputDataProviderV10(XmlNode node, IXMLDeclarationInputData inputProvider, string fileName) : base(node, fileName) { @@ -44,7 +44,10 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider get { return _vehicle ?? (_vehicle = Reader.CreateVehicle); } } - public virtual string JobName { get { return Vehicle.Identifier; } } + public virtual string JobName + { + get { return Vehicle.Identifier; } + } #endregion @@ -55,4 +58,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationJobInputDataProviderV20 : XMLDeclarationJobInputDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationJobInputDataProviderV20(XmlNode node, IXMLDeclarationInputData inputProvider, string fileName) : + base(node, inputProvider, fileName) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs index 2cec1dfb05..f071dc9975 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs @@ -27,14 +27,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider if ("none".Equals(shaftGearWheels, StringComparison.InvariantCultureIgnoreCase)) { return "None"; } - if ("only one engaged gearwheel above oil level".Equals(shaftGearWheels, StringComparison.CurrentCultureIgnoreCase)) { + if ("only one engaged gearwheel above oil level".Equals( + shaftGearWheels, StringComparison.CurrentCultureIgnoreCase)) { return "only one engaged gearwheel above oil level"; } + var otherElements = GetString(XMLNames.Vehicle_PTO_OtherElements); var ptoTech = string.Format("{0} - {1}", shaftGearWheels, otherElements); if (DeclarationData.PTOTransmission.GetTechnologies().Contains(ptoTech)) { return ptoTech; } + throw new VectoException("PTO Technology {0} invalid!", ptoTech); } } @@ -51,4 +54,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationPTODataProviderV20 : XMLDeclarationPTODataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationPTODataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) + : base(vehicle, componentNode, sourceFile) { } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs index 630df24a9b..218c54498d 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs @@ -14,7 +14,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider protected IXMLDeclarationVehicleData Vehicle; - public XMLDeclarationRetarderDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + public XMLDeclarationRetarderDataProviderV10( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) { SourceType = DataSourceType.XMLFile; @@ -36,7 +37,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public virtual TableData LossMap { get { - return ReadTableData(XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry, AttributeMappings.RetarderLossmapMapping); + return ReadTableData( + XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry, + AttributeMappings.RetarderLossmapMapping); } } @@ -53,4 +56,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationRetarderDataProviderV20 : XMLDeclarationRetarderDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationRetarderDataProviderV20( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base( + vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs index eb2c79b0a0..de17452f7d 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs @@ -43,4 +43,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationTorqueConverterDataProviderV20 : XMLDeclarationTorqueConverterDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + public XMLDeclarationTorqueConverterDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + } + } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs index bd5b7da7e7..ec6b6c7f56 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs @@ -52,4 +52,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationTyreDataProviderV20 : XMLDeclarationTyreDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationTyreDataProviderV20(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) + : base(vehicle, componentNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs index 11336ae0c6..eb0875b6ab 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs @@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider SourceType = DataSourceType.XMLFile; } - + public virtual IXMLComponentReader ComponentReader { protected get; set; } public virtual IXMLPTOReader PTOReader { protected get; set; } @@ -65,7 +65,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider protected IPTOTransmissionInputData _ptoData; - public IXMLDeclarationJobInputData Job { get; } + public IXMLDeclarationJobInputData Job { get; } public virtual string Identifier { @@ -240,7 +240,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData - #endregion #region Overrides of AbstractXMLResource @@ -254,4 +253,64 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider #endregion } + + // --------------------------------------------------------------------------------------- + + public class XMLDeclarationVehicleDataProviderV20 : XMLDeclarationVehicleDataProviderV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLDeclarationVehicleDataProviderV20(IXMLDeclarationJobInputData jobData, XmlNode xmlNode, string sourceFile) : + base(jobData, xmlNode, sourceFile) { } + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + public override bool VocationalVehicle + { + get { return false; } + } + + public override bool SleeperCab + { + get { return true; } + } + + public override TankSystem? TankSystem + { + get { return VectoCommon.InputData.TankSystem.Compressed; } + } + + public override IAdvancedDriverAssistantSystemDeclarationInputData ADAS + { + get { return ADASReader.ADASInputData; } + } + + public override bool ZeroEmissionVehicle + { + get { return false; } + } + + public override bool HybridElectricHDV + { + get { return false; } + } + + public override bool DualFuelVehicle + { + get { return false; } + } + + public override Watt MaxNetPower1 + { + get { return null; } + } + + public override Watt MaxNetPower2 + { + get { return null; } + } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs index 44371b7488..711f241de7 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs @@ -10,8 +10,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { public abstract class XMLAbstractGearData : AbstractXMLType { - protected TableData _lossmap; + protected DataSource _dataSource; protected XMLAbstractGearData(XmlNode gearNode, string sourceFile) : base(gearNode) { @@ -20,6 +20,20 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider public virtual string SourceFile { get; } + + public virtual DataSource DataSource + { + get { + return _dataSource ?? (_dataSource = new DataSource() { + SourceFile = SourceFile, + SourceType = DataSourceType.XMLEmbedded, + SourceVersion = XMLHelper.GetVersionFromNamespaceUri(SchemaNamespace) + }); + } + } + + protected abstract string SchemaNamespace { get; } + #region Implementation of ITransmissionInputData public virtual int Gear @@ -39,8 +53,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { get { return _lossmap ?? (_lossmap = XMLHelper.ReadTableData( - AttributeMappings.TransmissionLossmapMapping, - GetNodes(new[] { XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry }))); + AttributeMappings.TransmissionLossmapMapping, + GetNodes(new[] { XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry }))); } } @@ -64,8 +78,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider get { return null; } } - - #endregion } @@ -75,13 +87,24 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; - protected DataSource _dataSource; - public XMLGearDataV10(XmlNode gearNode, string sourceFile) : base(gearNode, sourceFile) { } - public virtual DataSource DataSource - { - get { return _dataSource ?? (_dataSource = new DataSource() { SourceFile = SourceFile, SourceType = DataSourceType.XMLEmbedded, SourceVersion = XMLHelper.GetVersionFromNamespaceUri(NAMESPACE_URI) }); } - } + #region Overrides of XMLAbstractGearData + + protected override string SchemaNamespace { get { return NAMESPACE_URI; } } + + #endregion + } + + // --------------------------------------------------------------------------------------- + + public class XMLGearDataV20 : XMLGearDataV10 + { + public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; + + public XMLGearDataV20(XmlNode gearNode, string sourceFile) : base(gearNode, sourceFile) { } + + protected override string SchemaNamespace { get { return NAMESPACE_URI; } } + } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV10InjectModule.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV10InjectModule.cs index 42413b1565..2a332a3070 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV10InjectModule.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV10InjectModule.cs @@ -41,7 +41,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationRetarderDataProviderV10.NAMESPACE_URI)); Bind<IXMLGearboxDeclarationInputData>().To<XMLDeclarationGearboxDataProviderV10>() - .Named(XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationGearboxDataProviderV10.NAMESPACE_URI)); + .Named(XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationGearboxDataProviderV10.NAMESPACE_URI)); Bind<IXMLGearData>().To<XMLGearDataV10>().Named(XMLHelper.GetVersionFromNamespaceUri(XMLGearDataV10.NAMESPACE_URI)); diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV20InjectModule.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV20InjectModule.cs index 61f7e59787..5ceb158cc6 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV20InjectModule.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV20InjectModule.cs @@ -1,4 +1,5 @@ using Ninject.Modules; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl; diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs index 221c95dd82..aa87a537f4 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs @@ -16,7 +16,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl public IDeclarationInjectFactory Factory { protected get; set; } protected IXMLDeclarationVehicleData Vehicle; - private IAdvancedDriverAssistantSystemDeclarationInputData _adas; + protected IAdvancedDriverAssistantSystemDeclarationInputData _adas; public XMLADASReaderV10(IXMLDeclarationVehicleData vehicle, XmlNode vehicleNode, bool verifyXML) : base( @@ -37,8 +37,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl protected virtual IAdvancedDriverAssistantSystemDeclarationInputData ADASCreator( string version, XmlNode componentNode, string sourceFile) { + if (version == null) { + version = XMLHelper.GetVersionFromNamespaceUri(SchemaVersion); + } return Factory.CreateADASData(version, Vehicle, componentNode, sourceFile); } + + public virtual string SchemaVersion + { + get { return NAMESPACE_URI; } + } } // --------------------------------------------------------------------------------------- @@ -47,6 +55,17 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl { public new const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V20; - public XMLADASReaderV20(IXMLDeclarationVehicleData vehicle, XmlNode vehicleNode, bool verifyXML) : base(vehicle, vehicleNode, verifyXML) { } + public XMLADASReaderV20(IXMLDeclarationVehicleData vehicle, XmlNode vehicleNode, bool verifyXML) : base( + vehicle, vehicleNode, verifyXML) { } + + public override IAdvancedDriverAssistantSystemDeclarationInputData ADASInputData + { + get { return _adas ?? (_adas = CreateComponent(XMLNames.Vehicle_ADAS, ADASCreator, true)); } + } + + public override string SchemaVersion + { + get { return NAMESPACE_URI; } + } } } diff --git a/VectoCore/VectoCoreTest/XML/XMLDeclarationReaderVersionsTest.cs b/VectoCore/VectoCoreTest/XML/XMLDeclarationReaderVersionsTest.cs index 96459fff88..18c27ac8cb 100644 --- a/VectoCore/VectoCoreTest/XML/XMLDeclarationReaderVersionsTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLDeclarationReaderVersionsTest.cs @@ -42,6 +42,12 @@ namespace TUGraz.VectoCore.Tests.XML } + [TestCase(@"SchemaVersion2.0\vecto_vehicle-components_1.0.xml")] + public void TestReadingJobVersion_V20_ComponentsV10(string jobFile) + { + ReadDeclarationJob(jobFile); + } + public void ReadDeclarationJob(string jobfile) { var filename = Path.Combine(@"TestData\XML\XMLReaderDeclaration", jobfile); -- GitLab