diff --git a/VECTO.sln b/VECTO.sln index f368a7cfa675a942f32fac4d8d2d66d5c04fecb1..229fc267a786be62817c49b1440a9c9eb4cbcc42 100644 --- a/VECTO.sln +++ b/VECTO.sln @@ -69,6 +69,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HashingCmd", "HashingCmd\Ha EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Article10Notifications", "..\VECTO-Article10\Article10Notifications\Article10Notifications.csproj", "{EF99431D-4227-44C3-B2BD-DE8AE3E672CA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VECTO_GIT", "..\STUDENTEN_PROJEKTE\Kober_VectoGIT\VECTO_GIT\VECTO_GIT\VECTO_GIT.csproj", "{A684BC49-C9B3-4C0C-8D2E-A13077853EDA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug PerformanceStats|Any CPU = Debug PerformanceStats|Any CPU @@ -724,6 +726,48 @@ Global {EF99431D-4227-44C3-B2BD-DE8AE3E672CA}.ReleaseTUG|x64.Build.0 = Release|Any CPU {EF99431D-4227-44C3-B2BD-DE8AE3E672CA}.ReleaseTUG|x86.ActiveCfg = Release|Any CPU {EF99431D-4227-44C3-B2BD-DE8AE3E672CA}.ReleaseTUG|x86.Build.0 = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceStats|Any CPU.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceStats|Any CPU.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceStats|x64.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceStats|x64.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceStats|x86.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceStats|x86.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceTrace|Any CPU.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceTrace|Any CPU.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceTrace|x64.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceTrace|x64.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceTrace|x86.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug PerformanceTrace|x86.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug|x64.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug|x64.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug|x86.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Debug|x86.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.DebugTUG|Any CPU.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.DebugTUG|Any CPU.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.DebugTUG|x64.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.DebugTUG|x64.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.DebugTUG|x86.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.DebugTUG|x86.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Deploy|Any CPU.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Deploy|Any CPU.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Deploy|x64.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Deploy|x64.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Deploy|x86.ActiveCfg = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Deploy|x86.Build.0 = Debug|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Release|Any CPU.Build.0 = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Release|x64.ActiveCfg = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Release|x64.Build.0 = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Release|x86.ActiveCfg = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.Release|x86.Build.0 = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.ReleaseTUG|Any CPU.ActiveCfg = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.ReleaseTUG|Any CPU.Build.0 = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.ReleaseTUG|x64.ActiveCfg = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.ReleaseTUG|x64.Build.0 = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.ReleaseTUG|x86.ActiveCfg = Release|Any CPU + {A684BC49-C9B3-4C0C-8D2E-A13077853EDA}.ReleaseTUG|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VectoCommon/VectoCommon/InputData/DigestData.cs b/VectoCommon/VectoCommon/InputData/DigestData.cs new file mode 100644 index 0000000000000000000000000000000000000000..20f7568d7a66007c1dec334d164d5d48cb9a546d --- /dev/null +++ b/VectoCommon/VectoCommon/InputData/DigestData.cs @@ -0,0 +1,80 @@ +using System.Collections.Generic; +using System.Xml; +using System.Xml.Linq; +using System.Xml.XPath; + +namespace TUGraz.VectoCommon.InputData { + public class DigestData + { + private const string ReferenceElementXPath = ".//*[local-name()='Reference']"; + private const string TransformElementXPath = ".//*[local-name()='Transform']"; + private const string DigestMethodElementXPath = ".//*[local-name()='DigestMethod']"; + + private const string UriAttr = "URI"; + private const string AlgorithmAttr = "Algorithm"; + + private const string ReferenceUriAttrXPath = ReferenceElementXPath + "/@" + UriAttr; + private const string TransformAlgorithmAttrXPath = TransformElementXPath + "/@" + AlgorithmAttr; + private const string DigestMethodAlgorithmAttrXPath = DigestMethodElementXPath + "/@" + AlgorithmAttr; + private const string DigestValueElementXPath = ".//*[local-name()='DigestValue']"; + + public DigestData(string reference, string[] c14n, string digestMethod, string digestValue) + { + Reference = reference; + CanonicalizationMethods = c14n; + DigestMethod = digestMethod; + DigestValue = digestValue; + } + + public DigestData(XPathNavigator navigator) + { + Reference = navigator.SelectSingleNode(ReferenceUriAttrXPath)?.InnerXml; + var nodes = navigator.Select(TransformAlgorithmAttrXPath); + var c14n = new List<string>(); + while (nodes.MoveNext()) { + c14n.Add(nodes.Current.InnerXml); + } + CanonicalizationMethods = c14n.ToArray(); + DigestMethod = navigator.SelectSingleNode(DigestMethodAlgorithmAttrXPath)?.InnerXml; + DigestValue = navigator.SelectSingleNode(DigestValueElementXPath)?.InnerXml; + } + + public DigestData(XmlNode xmlNode) + { + Reference = xmlNode.SelectSingleNode(ReferenceUriAttrXPath)?.InnerXml; + var nodes = xmlNode.SelectNodes(TransformAlgorithmAttrXPath); + var c14n = new List<string>(); + if (nodes != null) { + for (var i = 0; i < nodes.Count; i++) { + c14n.Add(nodes[i].InnerXml); + } + } + CanonicalizationMethods = c14n.ToArray(); + DigestMethod = xmlNode.SelectSingleNode(DigestMethodAlgorithmAttrXPath)?.InnerXml; + DigestValue = xmlNode.SelectSingleNode(DigestValueElementXPath)?.InnerXml; + } + + public DigestData(XNode xmlNode) + { + Reference = xmlNode.XPathSelectElement(ReferenceElementXPath)?.Attribute(XName.Get(UriAttr))?.Value; + var nodes = xmlNode.XPathSelectElements(TransformElementXPath); + var c14n = new List<string>(); + + foreach (var node in nodes) { + c14n.Add(node.Attribute(XName.Get(AlgorithmAttr))?.Value); + } + + CanonicalizationMethods = c14n.ToArray(); + DigestMethod = xmlNode.XPathSelectElement(DigestMethodElementXPath)?.Attribute(XName.Get(AlgorithmAttr))?.Value; + DigestValue = xmlNode.XPathSelectElement(DigestValueElementXPath)?.Value; + } + + public string DigestValue { get; } + + public string Reference { get; } + + public string[] CanonicalizationMethods { get; } + public string DigestMethod { get; } + + } +} \ No newline at end of file diff --git a/VectoCommon/VectoCommon/InputData/VTPDeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/VTPDeclarationInputData.cs index 7d068d7d91891989938a7c543dc9ca63d30784de..9fc2ccc636f2173964d2b5a59b590ba792e8f7a3 100644 --- a/VectoCommon/VectoCommon/InputData/VTPDeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/VTPDeclarationInputData.cs @@ -30,8 +30,7 @@ */ using System.Collections.Generic; -using System.Xml; -using System.Xml.XPath; +using System.Linq; using TUGraz.VectoCommon.Hashing; using TUGraz.VectoCommon.Utils; using TUGraz.VectoHashing; @@ -73,56 +72,4 @@ namespace TUGraz.VectoCommon.InputData DigestData JobDigest { get; } } - - public class DigestData - { - private const string ReferenceQueryXPath = ".//*[local-name()='Reference']/@URI"; - private const string AlgorithmQueryXPath = ".//*[local-name()='Transform']/@Algorithm"; - private const string DigestMethodQueryXPath = ".//*[local-name()='DigestMethod']/@Algorithm"; - private const string DigestValueQuerXPath = ".//*[local-name()='DigestValue']"; - - public DigestData(string reference, string[] c14n, string digestMethod, string digestValue) - { - Reference = reference; - CanonicalizationMethods = c14n; - DigestMethod = digestMethod; - DigestValue = digestValue; - } - - public DigestData(XPathNavigator navigator) - { - Reference = navigator.SelectSingleNode(ReferenceQueryXPath)?.InnerXml; - var nodes = navigator.Select(AlgorithmQueryXPath); - var c14n = new List<string>(); - while (nodes.MoveNext()) { - c14n.Add(nodes.Current.InnerXml); - } - CanonicalizationMethods = c14n.ToArray(); - DigestMethod = navigator.SelectSingleNode(DigestMethodQueryXPath)?.InnerXml; - DigestValue = navigator.SelectSingleNode(DigestValueQuerXPath)?.InnerXml; - } - - public DigestData(XmlNode xmlNode) - { - Reference = xmlNode.SelectSingleNode(ReferenceQueryXPath)?.InnerXml; - var nodes = xmlNode.SelectNodes(AlgorithmQueryXPath); - var c14n = new List<string>(); - if (nodes != null) { - for (var i = 0; i < nodes.Count; i++) { - c14n.Add(nodes[i].InnerXml); - } - } - CanonicalizationMethods = c14n.ToArray(); - DigestMethod = xmlNode.SelectSingleNode(DigestMethodQueryXPath)?.InnerXml; - DigestValue = xmlNode.SelectSingleNode(DigestValueQuerXPath)?.InnerXml; - } - - public string DigestValue { get; } - - public string Reference { get; } - - public string[] CanonicalizationMethods { get; } - public string DigestMethod { get; } - - } } diff --git a/VectoCommon/VectoCommon/VectoCommon.csproj b/VectoCommon/VectoCommon/VectoCommon.csproj index 17342123e9971a8b6d7baca0e4332c1d4418da65..298bb028ec8c7d1d6834302e47dae3e564b5294e 100644 --- a/VectoCommon/VectoCommon/VectoCommon.csproj +++ b/VectoCommon/VectoCommon/VectoCommon.csproj @@ -53,6 +53,7 @@ <Compile Include="Hashing\IVectoHash.cs" /> <Compile Include="Hashing\VectoComponents.cs" /> <Compile Include="InputData\DataSourceType.cs" /> + <Compile Include="InputData\DigestData.cs" /> <Compile Include="InputData\TableData.cs"> <SubType>Component</SubType> </Compile> diff --git a/VectoCore/VectoCore/Configuration/Constants.cs b/VectoCore/VectoCore/Configuration/Constants.cs index c2ab1fa9bbff6d924021407485c279c608b99010..13c86c1ba175a202c0a6f6f2bafd67cc048ae12e 100644 --- a/VectoCore/VectoCore/Configuration/Constants.cs +++ b/VectoCore/VectoCore/Configuration/Constants.cs @@ -175,6 +175,8 @@ namespace TUGraz.VectoCore.Configuration public const string VectoDeclarationDefinitionsNS = "urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v" + XSDDeclarationVersion; + public const string VectoDeclarationComponentNS = "urn:tugraz:ivt:VectoAPI:DeclarationComponent:v" + XSDDeclarationVersion; + public const string VectoEngineeringDefinitionsNS = "urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v" + XSDEngineeringVersion; diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAirdragDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAirdragDataProvider.cs index 3316bad53e7958b95d6721941ae462f815a140d4..5fd01fd3643afd6794dcb02dedd910e9e9a364a4 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAirdragDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAirdragDataProvider.cs @@ -29,10 +29,16 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; +using System.Xml; +using System.Xml.Linq; +using System.Xml.XPath; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration { @@ -48,6 +54,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration XMLNames.ComponentDataWrapper); } + public XMLDeclarationAirdragDataProvider(XDocument xml) + { + if (xml.Document == null) { + throw new ArgumentException("No Document found"); + } + Navigator = xml.Document.CreateNavigator(); + Manager = new XmlNamespaceManager(Navigator.NameTable ?? new NameTable()); + Helper = new XPathHelper(ExecutionMode.Declaration); + Manager.AddNamespace(Constants.XML.DeclarationNSPrefix, Constants.XML.VectoDeclarationDefinitionsNS); + Manager.AddNamespace(Constants.XML.RootNSPrefix, Constants.XML.VectoDeclarationComponentNS); + + XBasePath = Helper.Query(Helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix), + Helper.NSPrefix(XMLNames.Component_AirDrag, Constants.XML.RootNSPrefix), + XMLNames.ComponentDataWrapper); + SourceType = DataSourceType.Embedded; + } + public new CertificationMethod CertificationMethod { get { return CertificationMethod.Measured; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAngledriveDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAngledriveDataProvider.cs index c7a7a2a43ced783bb0486c2d488de3a1900a807d..7304e62304038e86249ff15a0dbc01d29d5605f3 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAngledriveDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAngledriveDataProvider.cs @@ -29,11 +29,17 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; +using System.Xml; +using System.Xml.Linq; +using System.Xml.XPath; using TUGraz.IVT.VectoXML; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration { @@ -47,6 +53,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration XMLNames.ComponentDataWrapper); } + public XMLDeclarationAngledriveDataProvider(XDocument xml) + { + if (xml.Document == null) { + throw new ArgumentException("No Document found"); + } + Navigator = xml.Document.CreateNavigator(); + Manager = new XmlNamespaceManager(Navigator.NameTable ?? new NameTable()); + Helper = new XPathHelper(ExecutionMode.Declaration); + Manager.AddNamespace(Constants.XML.DeclarationNSPrefix, Constants.XML.VectoDeclarationDefinitionsNS); + Manager.AddNamespace(Constants.XML.RootNSPrefix, Constants.XML.VectoDeclarationComponentNS); + + XBasePath = Helper.Query(Helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix), + Helper.NSPrefix(XMLNames.Component_Angledrive, Constants.XML.RootNSPrefix), + XMLNames.ComponentDataWrapper); + SourceType = DataSourceType.Embedded; + } + public AngledriveType Type { get { return InputData.XMLJob.XMLVehicle.AngulargearType; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAxlegearDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAxlegearDataProvider.cs index 21911f8e28cec6f1d0c14f15ca4af8e8b2dce3a0..e2366ed8d9f6a0f0b6a3da0566264bca0a9eca20 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAxlegearDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAxlegearDataProvider.cs @@ -29,50 +29,73 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using TUGraz.IVT.VectoXML; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Resources; -using TUGraz.VectoCommon.Utils; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration -{ - public class XMLDeclarationAxlegearDataProvider : AbstractDeclarationXMLComponentDataProvider, IAxleGearInputData - { - public XMLDeclarationAxlegearDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) - : base(xmlInputDataProvider) - { - XBasePath = Helper.Query(VehiclePath, - XMLNames.Vehicle_Components, - XMLNames.Component_Axlegear, - XMLNames.ComponentDataWrapper); - } - - public double Ratio - { - get { return GetDoubleElementValue(XMLNames.Axlegear_Ratio); } - } - - public TableData LossMap - { - get { - return ReadTableData(AttributeMappings.TransmissionLossmapMapping, - Helper.Query(XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry)); - } - } - - public double Efficiency - { - get { throw new VectoException("Efficiency not supported in Declaration Mode!"); } - } - - public AxleLineType LineType - { - get { - var value = GetElementValue(XMLNames.Axlegear_LineType); - return value.ParseEnum<AxleLineType>(); - } - } - } +using System; +using System.Xml; +using System.Xml.Linq; +using System.Xml.XPath; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration +{ + public class XMLDeclarationAxlegearDataProvider : AbstractDeclarationXMLComponentDataProvider, IAxleGearInputData + { + public XMLDeclarationAxlegearDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) + : base(xmlInputDataProvider) + { + XBasePath = Helper.Query(VehiclePath, + XMLNames.Vehicle_Components, + XMLNames.Component_Axlegear, + XMLNames.ComponentDataWrapper); + } + + public XMLDeclarationAxlegearDataProvider(XDocument xml) + { + if (xml.Document == null) { + throw new ArgumentException("No Document found"); + } + Navigator = xml.Document.CreateNavigator(); + Manager = new XmlNamespaceManager(Navigator.NameTable ?? new NameTable()); + Helper = new XPathHelper(ExecutionMode.Declaration); + Manager.AddNamespace(Constants.XML.DeclarationNSPrefix, Constants.XML.VectoDeclarationDefinitionsNS); + Manager.AddNamespace(Constants.XML.RootNSPrefix, Constants.XML.VectoDeclarationComponentNS); + + XBasePath = Helper.Query(Helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix), + Helper.NSPrefix(XMLNames.Component_Axlegear, Constants.XML.RootNSPrefix), + XMLNames.ComponentDataWrapper); + SourceType = DataSourceType.Embedded; + } + + public double Ratio + { + get { return GetDoubleElementValue(XMLNames.Axlegear_Ratio); } + } + + public TableData LossMap + { + get { + return ReadTableData(AttributeMappings.TransmissionLossmapMapping, + Helper.Query(XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry)); + } + } + + public double Efficiency + { + get { throw new VectoException("Efficiency not supported in Declaration Mode!"); } + } + + public AxleLineType LineType + { + get { + var value = GetElementValue(XMLNames.Axlegear_LineType); + return value.ParseEnum<AxleLineType>(); + } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationEngineDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationEngineDataProvider.cs index 8cbde3273993228b1ddd0e46ff90e0727cd91127..877d6ed9480d455ba3e6ff8db2477fd4c535fcee 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationEngineDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationEngineDataProvider.cs @@ -30,11 +30,16 @@ */ using System; +using System.Xml; +using System.Xml.Linq; +using System.Xml.XPath; using TUGraz.IVT.VectoXML; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration { @@ -50,6 +55,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration XMLNames.ComponentDataWrapper); } + public XMLDeclarationEngineDataProvider(XDocument xml) + { + if (xml.Document == null) { + throw new ArgumentException("No Document found"); + } + Navigator = xml.Document.CreateNavigator(); + Manager = new XmlNamespaceManager(Navigator.NameTable ?? new NameTable()); + Helper = new XPathHelper(ExecutionMode.Declaration); + Manager.AddNamespace(Constants.XML.DeclarationNSPrefix, Constants.XML.VectoDeclarationDefinitionsNS); + Manager.AddNamespace(Constants.XML.RootNSPrefix, Constants.XML.VectoDeclarationComponentNS); + + XBasePath = Helper.Query(Helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix), + Helper.NSPrefix(XMLNames.Component_Engine, Constants.XML.RootNSPrefix), + XMLNames.ComponentDataWrapper); + SourceType = DataSourceType.Embedded; + } + public CubicMeter Displacement { get { return GetDoubleElementValue(XMLNames.Engine_Displacement).SI(Unit.SI.Cubic.Centi.Meter).Cast<CubicMeter>(); } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationGearboxDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationGearboxDataProvider.cs index 12f5484dd9164073e44489c49de511874b0ab76f..c0e9cd2444ee748a9169cd6ec02c70fc278807d9 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationGearboxDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationGearboxDataProvider.cs @@ -29,95 +29,116 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; -using System.Collections.Generic; -using System.Xml; -using TUGraz.IVT.VectoXML; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Resources; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.InputData.Impl; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration -{ - public class XMLDeclarationGearboxDataProvider : AbstractDeclarationXMLComponentDataProvider, - IGearboxDeclarationInputData - { - public XMLDeclarationGearboxDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) - : base(xmlInputDataProvider) - { - XBasePath = Helper.Query(VehiclePath, - XMLNames.Vehicle_Components, - XMLNames.Component_Gearbox, - XMLNames.ComponentDataWrapper); - } - - public new CertificationMethod CertificationMethod - { - get { return GetElementValue(XMLNames.Component_Gearbox_CertificationMethod).ParseEnum<CertificationMethod>(); } - } - - public GearboxType Type - { - get { - var value = GetElementValue(XMLNames.Gearbox_TransmissionType); - switch (value) { - case "MT": - case "SMT": - return GearboxType.MT; - case "AMT": - return GearboxType.AMT; - case "APT-S": - case "AT - Serial": - return GearboxType.ATSerial; - case "APT-P": - case "AT - PowerSplit": - return GearboxType.ATPowerSplit; - } - throw new ArgumentOutOfRangeException("GearboxType", value); - } - } - - public IList<ITransmissionInputData> Gears - { - get { - var retVal = new List<ITransmissionInputData>(); - var gears = Navigator.Select( - Helper.Query(XBasePath, XMLNames.Gearbox_Gears, XMLNames.Gearbox_Gears_Gear), - Manager); - while (gears.MoveNext()) { - var gear = gears.Current.GetAttribute(XMLNames.Gearbox_Gear_GearNumber_Attr, ""); - retVal.Add(ReadGear(gear)); - } - return retVal; - } - } - - public ITorqueConverterDeclarationInputData TorqueConverter - { - get { - return new XMLDeclarationTorqueConverterDataProvider(InputData); - } - } - - protected ITransmissionInputData ReadGear(string gearNr) - { - var retVal = new TransmissionInputData(); - var gearPath = Helper.Query(XMLNames.Gearbox_Gears, - Helper.QueryConstraint(XMLNames.Gearbox_Gears_Gear, XMLNames.Gearbox_Gear_GearNumber_Attr, gearNr)); - retVal.Ratio = GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gear_Ratio)); - retVal.Gear = XmlConvert.ToUInt16(gearNr); - retVal.LossMap = ReadTableData(AttributeMappings.TransmissionLossmapMapping, - Helper.Query(gearPath, XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry)); - - if (ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque))) { - retVal.MaxTorque = GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque)).SI<NewtonMeter>(); - } - if (ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gear_MaxSpeed))) { - retVal.MaxInputSpeed = GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gear_MaxSpeed)).RPMtoRad(); - } - return retVal; - } - } +using System; +using System.Collections.Generic; +using System.Xml; +using System.Xml.Linq; +using System.Xml.XPath; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.Impl; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration +{ + public class XMLDeclarationGearboxDataProvider : AbstractDeclarationXMLComponentDataProvider, + IGearboxDeclarationInputData + { + public XMLDeclarationGearboxDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) + : base(xmlInputDataProvider) + { + XBasePath = Helper.Query(VehiclePath, + XMLNames.Vehicle_Components, + XMLNames.Component_Gearbox, + XMLNames.ComponentDataWrapper); + } + + public XMLDeclarationGearboxDataProvider(XDocument xml) + { + if (xml.Document == null) { + throw new ArgumentException("No Document found"); + } + Navigator = xml.Document.CreateNavigator(); + Manager = new XmlNamespaceManager(Navigator.NameTable ?? new NameTable()); + Helper = new XPathHelper(ExecutionMode.Declaration); + Manager.AddNamespace(Constants.XML.DeclarationNSPrefix, Constants.XML.VectoDeclarationDefinitionsNS); + Manager.AddNamespace(Constants.XML.RootNSPrefix, Constants.XML.VectoDeclarationComponentNS); + + XBasePath = Helper.Query(Helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix), + Helper.NSPrefix(XMLNames.Component_Gearbox, Constants.XML.RootNSPrefix), + XMLNames.ComponentDataWrapper); + SourceType = DataSourceType.Embedded; + } + + public new CertificationMethod CertificationMethod + { + get { return GetElementValue(XMLNames.Component_Gearbox_CertificationMethod).ParseEnum<CertificationMethod>(); } + } + + public GearboxType Type + { + get { + var value = GetElementValue(XMLNames.Gearbox_TransmissionType); + switch (value) { + case "MT": + case "SMT": + return GearboxType.MT; + case "AMT": + return GearboxType.AMT; + case "APT-S": + case "AT - Serial": + return GearboxType.ATSerial; + case "APT-P": + case "AT - PowerSplit": + return GearboxType.ATPowerSplit; + } + throw new ArgumentOutOfRangeException("GearboxType", value); + } + } + + public IList<ITransmissionInputData> Gears + { + get { + var retVal = new List<ITransmissionInputData>(); + var gears = Navigator.Select( + Helper.Query(XBasePath, XMLNames.Gearbox_Gears, XMLNames.Gearbox_Gears_Gear), + Manager); + while (gears.MoveNext()) { + var gear = gears.Current.GetAttribute(XMLNames.Gearbox_Gear_GearNumber_Attr, ""); + retVal.Add(ReadGear(gear)); + } + return retVal; + } + } + + public ITorqueConverterDeclarationInputData TorqueConverter + { + get { + return new XMLDeclarationTorqueConverterDataProvider(InputData); + } + } + + protected ITransmissionInputData ReadGear(string gearNr) + { + var retVal = new TransmissionInputData(); + var gearPath = Helper.Query(XMLNames.Gearbox_Gears, + Helper.QueryConstraint(XMLNames.Gearbox_Gears_Gear, XMLNames.Gearbox_Gear_GearNumber_Attr, gearNr)); + retVal.Ratio = GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gear_Ratio)); + retVal.Gear = XmlConvert.ToUInt16(gearNr); + retVal.LossMap = ReadTableData(AttributeMappings.TransmissionLossmapMapping, + Helper.Query(gearPath, XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry)); + + if (ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque))) { + retVal.MaxTorque = GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque)).SI<NewtonMeter>(); + } + if (ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gear_MaxSpeed))) { + retVal.MaxInputSpeed = GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gear_MaxSpeed)).RPMtoRad(); + } + return retVal; + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationRetarderDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationRetarderDataProvider.cs index b26ec24374aa7eccd72b727c6f2ca4c64b1dd187..be89789219d00e33627a2d36138eab0d33aa5f14 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationRetarderDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationRetarderDataProvider.cs @@ -29,15 +29,24 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; +using System.Xml; +using System.Xml.Linq; +using System.Xml.XPath; using TUGraz.IVT.VectoXML; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration { public class XMLDeclarationRetarderDataProvider : AbstractDeclarationXMLComponentDataProvider, IRetarderInputData { + private RetarderType? _type; + private double? _ratio; + public XMLDeclarationRetarderDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) : base(xmlInputDataProvider) { XBasePath = Helper.Query(VehiclePath, @@ -46,6 +55,24 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration XMLNames.ComponentDataWrapper); } + public XMLDeclarationRetarderDataProvider(XDocument xml, RetarderType type, double ratio) + { + _type = type; + _ratio = ratio; + if (xml.Document != null) { + Navigator = xml.Document.CreateNavigator(); + Manager = new XmlNamespaceManager(Navigator.NameTable ?? new NameTable()); + Helper = new XPathHelper(ExecutionMode.Declaration); + Manager.AddNamespace(Constants.XML.DeclarationNSPrefix, Constants.XML.VectoDeclarationDefinitionsNS); + Manager.AddNamespace(Constants.XML.RootNSPrefix, Constants.XML.VectoDeclarationComponentNS); + + XBasePath = Helper.Query(Helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix), + Helper.NSPrefix(XMLNames.Component_Retarder, Constants.XML.RootNSPrefix), + XMLNames.ComponentDataWrapper); + SourceType = DataSourceType.Embedded; + } + } + public override bool SavedInDeclarationMode { @@ -54,12 +81,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration public RetarderType Type { - get { return InputData.XMLJob.XMLVehicle.RetarderType; } + get { return _type ?? InputData.XMLJob.XMLVehicle.RetarderType; } } public double Ratio { - get { return InputData.XMLJob.XMLVehicle.RetarderRatio; } + get { return _ratio ?? InputData.XMLJob.XMLVehicle.RetarderRatio; } } public TableData LossMap diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationTorqueConverterDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationTorqueConverterDataProvider.cs index d58fc85465b5d6133a8f8a3ba4dd6136234d1866..902f4c539fce79a068b8cebe4bc84d20153c1b1c 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationTorqueConverterDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationTorqueConverterDataProvider.cs @@ -29,9 +29,16 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; +using System.Xml; +using System.Xml.Linq; +using System.Xml.XPath; using TUGraz.IVT.VectoXML; using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration { @@ -48,6 +55,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration XMLNames.ComponentDataWrapper); } + public XMLDeclarationTorqueConverterDataProvider(XDocument xml) + { + if (xml.Document == null) { + throw new ArgumentException("No Document found"); + } + Navigator = xml.Document.CreateNavigator(); + Manager = new XmlNamespaceManager(Navigator.NameTable ?? new NameTable()); + Helper = new XPathHelper(ExecutionMode.Declaration); + Manager.AddNamespace(Constants.XML.DeclarationNSPrefix, Constants.XML.VectoDeclarationDefinitionsNS); + Manager.AddNamespace(Constants.XML.RootNSPrefix, Constants.XML.VectoDeclarationComponentNS); + + XBasePath = Helper.Query(Helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix), + Helper.NSPrefix(XMLNames.Component_TorqueConverter, Constants.XML.RootNSPrefix), + XMLNames.ComponentDataWrapper); + SourceType = DataSourceType.Embedded; + } + public TableData TCData { get diff --git a/VectoCore/VectoCore/InputData/Impl/InputData.cs b/VectoCore/VectoCore/InputData/Impl/InputData.cs index e38d027ea1133dd249642316628aa638ad877d42..5c083991994a2f7bd350743b6f4d5985ff41c938 100644 --- a/VectoCore/VectoCore/InputData/Impl/InputData.cs +++ b/VectoCore/VectoCore/InputData/Impl/InputData.cs @@ -148,9 +148,9 @@ namespace TUGraz.VectoCore.InputData.Impl public string ID { get; internal set; } - public AuxiliaryType Type { get; internal set; } + public AuxiliaryType Type { get; set; } - public IList<string> Technology { get; internal set; } + public IList<string> Technology { get; set; } public double TransmissionRatio { get; internal set; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs index fc23ef472f843b2f32945cefc55049047ee65079..502dfae3a8170391f98fe93aa24b2bbb4e47fc29 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/AbstractSimulationDataAdapter.cs @@ -232,7 +232,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter internal AngledriveData DoCreateAngledriveData(IAngledriveInputData data, bool useEfficiencyFallback) { try { - var type = data.Type; + var type = data?.Type ?? AngledriveType.None; switch (type) { case AngledriveType.LossesIncludedInGearbox: diff --git a/VectoCore/VectoCore/Properties/AssemblyInfo.cs b/VectoCore/VectoCore/Properties/AssemblyInfo.cs index 55a5acd245f5a6840c4984f5bc662724c338a162..4ef07debd6733aeeb2c5c088ba64d6be186fdaa3 100644 --- a/VectoCore/VectoCore/Properties/AssemblyInfo.cs +++ b/VectoCore/VectoCore/Properties/AssemblyInfo.cs @@ -50,4 +50,5 @@ using System.Runtime.InteropServices; [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VectoCoreTest")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VectoAPITest")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VectoXML")] -[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("XMLTest")] \ No newline at end of file +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("XMLTest")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("VECTO_GIT")]