diff --git a/HashingCmd/App.config b/HashingCmd/App.config index 8e15646352ec1d9a84bbc6504ef6b46e16bf7823..2d7c95c83af9b756449112dd9939e1c8242c3336 100644 --- a/HashingCmd/App.config +++ b/HashingCmd/App.config @@ -1,6 +1,14 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> </configuration> \ No newline at end of file diff --git a/HashingCmd/Program.cs b/HashingCmd/Program.cs index 40e9e8db88e9b7ef26a447603d7b229ad5553ac9..4312d075b94040dbf2f8fe7e328169e618ee263c 100644 --- a/HashingCmd/Program.cs +++ b/HashingCmd/Program.cs @@ -40,6 +40,7 @@ using System.Xml.Schema; using TUGraz.VectoCommon.Hashing; using TUGraz.VectoCore.Utils; using TUGraz.VectoHashing; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; namespace HashingCmd { @@ -159,8 +160,7 @@ hashingcmd.exe writer.Close(); if (_validateXML) { - new XMLValidator(XmlReader.Create(destination), null, ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType - .DeclarationComponentData); + new XMLValidator(XmlReader.Create(destination), null, ValidationCallBack).ValidateXML(XmlDocumentType.DeclarationComponentData); WriteLine("Valid", ConsoleColor.Green); } @@ -181,8 +181,8 @@ hashingcmd.exe private static void ValidateFile(string filename) { new XMLValidator(XmlReader.Create(filename),null, ValidationCallBack).ValidateXML( - XMLValidator.XmlDocumentType.DeclarationJobData | XMLValidator.XmlDocumentType.CustomerReport | - XMLValidator.XmlDocumentType.ManufacturerReport | XMLValidator.XmlDocumentType.DeclarationComponentData); + XmlDocumentType.DeclarationJobData | XmlDocumentType.CustomerReport | + XmlDocumentType.ManufacturerReport | XmlDocumentType.DeclarationComponentData); } private static void ReadHashAction(string filename, VectoHash h) diff --git a/HashingTool/App.config b/HashingTool/App.config index 8e15646352ec1d9a84bbc6504ef6b46e16bf7823..2d7c95c83af9b756449112dd9939e1c8242c3336 100644 --- a/HashingTool/App.config +++ b/HashingTool/App.config @@ -1,6 +1,14 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> </configuration> \ No newline at end of file diff --git a/HashingTool/Util/AsyncXMLValidator.cs b/HashingTool/Util/AsyncXMLValidator.cs index 7ad48e2afd27f14ee15d051d6e8cf61943f1b89e..f6e8dded14156a67a2395b89c620f271bee182f1 100644 --- a/HashingTool/Util/AsyncXMLValidator.cs +++ b/HashingTool/Util/AsyncXMLValidator.cs @@ -46,7 +46,7 @@ namespace HashingTool.Util _validator = new XMLValidator(xml, resultaction, validationErrorAction); } - public Task<bool> ValidateXML(TUGraz.VectoCore.Utils.XMLValidator.XmlDocumentType docType) + public Task<bool> ValidateXML(TUGraz.VectoCore.Utils.XmlDocumentType docType) { var task = new Task<bool>(() => _validator.ValidateXML(docType)); task.Start(); diff --git a/HashingTool/ViewModel/HashComponentDataViewModel.cs b/HashingTool/ViewModel/HashComponentDataViewModel.cs index 5e2797a407b267b29838d3b7773a94525dfd7aab..f8e1aab09a6008cd15f5883a3ad4a8fdd4030f3d 100644 --- a/HashingTool/ViewModel/HashComponentDataViewModel.cs +++ b/HashingTool/ViewModel/HashComponentDataViewModel.cs @@ -30,7 +30,6 @@ */ using System; -using System.Collections.ObjectModel; using System.ComponentModel; using System.IO; using System.Linq; @@ -43,9 +42,7 @@ using System.Xml.Schema; using HashingTool.Helper; using HashingTool.Util; using HashingTool.ViewModel.UserControl; -using TUGraz.VectoCore.Utils; using TUGraz.VectoHashing; -using TUGraz.VectoHashing.Impl; namespace HashingTool.ViewModel { @@ -172,7 +169,7 @@ namespace HashingTool.ViewModel : e.ValidationEventArgs.Message, e.ValidationEventArgs == null ? 0 : e.ValidationEventArgs.Exception.LineNumber))); }); - await validator.ValidateXML(XMLValidator.XmlDocumentType.DeclarationComponentData); + await validator.ValidateXML(TUGraz.VectoCore.Utils.XmlDocumentType.DeclarationComponentData); } if (ComponentDataValid != null && ComponentDataValid.Value) { //var c14N = XMLHashProvider.DefaultCanonicalizationMethod.ToArray(); diff --git a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs index 2746214881f253c39f3e91e81bccdf7e6dc24508..831815cdfa4382c7aa43bbe1e468adeda6a21967 100644 --- a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs +++ b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs @@ -41,6 +41,7 @@ using System.Xml.Schema; using HashingTool.Helper; using HashingTool.Util; using TUGraz.VectoCore.Utils; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; namespace HashingTool.ViewModel.UserControl { @@ -282,7 +283,7 @@ namespace HashingTool.ViewModel.UserControl : e.ValidationEventArgs.Message, e.ValidationEventArgs == null ? 0 : e.ValidationEventArgs.Exception.LineNumber))); }); - await validator.ValidateXML(XMLValidator.XmlDocumentType.DeclarationComponentData | XMLValidator.XmlDocumentType.DeclarationJobData | XMLValidator.XmlDocumentType.CustomerReport | XMLValidator.XmlDocumentType.ManufacturerReport); + await validator.ValidateXML(XmlDocumentType.DeclarationComponentData | XmlDocumentType.DeclarationJobData | XmlDocumentType.CustomerReport | XmlDocumentType.ManufacturerReport); } catch (Exception e) { LogError(e.Message); } diff --git a/Tools/DeclarationCycleZip/App.config b/Tools/DeclarationCycleZip/App.config index 8e15646352ec1d9a84bbc6504ef6b46e16bf7823..2d7c95c83af9b756449112dd9939e1c8242c3336 100644 --- a/Tools/DeclarationCycleZip/App.config +++ b/Tools/DeclarationCycleZip/App.config @@ -1,6 +1,14 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> </configuration> \ No newline at end of file diff --git a/Tools/GraphDrawer/App.config b/Tools/GraphDrawer/App.config index 8e15646352ec1d9a84bbc6504ef6b46e16bf7823..2d7c95c83af9b756449112dd9939e1c8242c3336 100644 --- a/Tools/GraphDrawer/App.config +++ b/Tools/GraphDrawer/App.config @@ -1,6 +1,14 @@ -<?xml version="1.0" encoding="utf-8" ?> +<?xml version="1.0" encoding="utf-8"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> </configuration> \ No newline at end of file diff --git a/VECTO/GUI/EngineForm.vb b/VECTO/GUI/EngineForm.vb index 3244bc779de2334e05be9216c1ab8b43cd7ac6fe..4c43013ccd157c9ee8ac2872359533e5e456ca22 100644 --- a/VECTO/GUI/EngineForm.vb +++ b/VECTO/GUI/EngineForm.vb @@ -75,7 +75,7 @@ Public Class EngineForm Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadJsonJob(jobFile), IEngineeringInputDataProvider) If (not inputData Is Nothing) Then - Dim gbx as IGearboxDeclarationInputData = inputData.JobInputData.Vehicle.GearboxInputData + Dim gbx as IGearboxDeclarationInputData = inputData.JobInputData.Vehicle.Components.GearboxInputData gbxType = gbx.Type End If End If @@ -179,7 +179,7 @@ Public Class EngineForm Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), IEngineeringInputDataProvider) - engine = inputData.JobInputData.Vehicle.EngineInputData + engine = inputData.JobInputData.Vehicle.Components.EngineInputData If Cfg.DeclMode <> engine.SavedInDeclarationMode Then diff --git a/VECTO/GUI/GearboxForm.vb b/VECTO/GUI/GearboxForm.vb index 755249d320453341fbb7470234f201772f90bf14..b2344cd72bf8b018e6c2592e31248c20ccb374e1 100644 --- a/VECTO/GUI/GearboxForm.vb +++ b/VECTO/GUI/GearboxForm.vb @@ -240,8 +240,8 @@ Public Class GearboxForm Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), IEngineeringInputDataProvider) Dim vehicle As IVehicleEngineeringInputData = inputData.JobInputData.Vehicle - Dim gearbox As IGearboxEngineeringInputData = vehicle.GearboxInputData - Dim axlegear As IAxleGearInputData = vehicle.AxleGearInputData + Dim gearbox As IGearboxEngineeringInputData = vehicle.Components.GearboxInputData + Dim axlegear As IAxleGearInputData = vehicle.Components.AxleGearInputData _vehicleCategory = vehicleCategory @@ -810,7 +810,7 @@ Public Class GearboxForm End If Dim vehicle As IVehicleEngineeringInputData = inputData.JobInputData.Vehicle 'inputData = TryCast(JSONInputDataFactory.ReadComponentData(vectoJob.PathEng(False)), IEngineeringInputDataProvider) - Dim engine As IEngineEngineeringInputData = inputData.JobInputData.Vehicle.EngineInputData + Dim engine As IEngineEngineeringInputData = inputData.JobInputData.Vehicle.Components.EngineInputData Dim engineFld As EngineFullLoadCurve = FullLoadCurveReader.Create(engine.FullLoadCurve) @@ -908,10 +908,10 @@ Public Class GearboxForm End If Dim rDyn As Meter = vehicle.DynamicTyreRadius If rDyn.IsEqual(0) Then - If (vehicle.Axles.Count < 2) Then + If (vehicle.Components.AxleWheels.AxlesEngineering.Count < 2) Then Return Nothing End If - rdyn = vehicle.Axles.Where(Function(axle) axle.AxleType = AxleType.VehicleDriven) _ + rdyn = vehicle.Components.AxleWheels.AxlesEngineering.Where(Function(axle) axle.AxleType = AxleType.VehicleDriven) _ .Select(Function(da) DeclarationData.Wheels.Lookup(da.Tyre.Dimension).DynamicTyreRadius) _ .Average() End If @@ -1057,7 +1057,7 @@ Public Class GearboxForm End If Dim vehicle As IVehicleEngineeringInputData = inputData.JobInputData.Vehicle - Dim engine As IEngineEngineeringInputData = vehicle.EngineInputData + Dim engine As IEngineEngineeringInputData = vehicle.Components.EngineInputData Dim engineFld As EngineFullLoadCurve = FullLoadCurveReader.Create(engine.FullLoadCurve) If VectoJobForm.Visible AndAlso engine.IdleSpeed > 0 Then diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb index 24a32b0046fd862a76ecce58995585fce73c7686..b264c6a785ff32861f38b218d49dd74607a9be89 100644 --- a/VECTO/GUI/MainForm.vb +++ b/VECTO/GUI/MainForm.vb @@ -41,11 +41,14 @@ Imports System.Threading Imports System.Xml Imports System.Xml.Linq Imports Microsoft.VisualBasic.FileIO +Imports Ninject Imports TUGraz.VectoCommon.Exceptions Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Resources Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore +Imports TUGraz.VectoCore.InputData.FileIO.XML Imports TUGraz.VectoCore.InputData.FileIO.XML.Declaration Imports TUGraz.VectoCore.InputData.FileIO.XML.Engineering Imports TUGraz.VectoCore.OutputData @@ -966,11 +969,13 @@ Imports TUGraz.VectoCore.Utils Case ".xml" Dim xDocument As XDocument = xDocument.Load(jobFile) Dim rootNode As String = If(xDocument Is Nothing, "", xDocument.Root.Name.LocalName) + Dim kernel as IKernel = New StandardKernel(new VectoNinjectModule) + Dim xmlInputReader as IXMLInputDataReader = kernel.Get(Of IXMLInputDataReader) Select Case rootNode Case XMLNames.VectoInputEngineering input = New XMLEngineeringInputDataProvider(jobFile, True) Case XMLNames.VectoInputDeclaration - input = New XMLDeclarationInputDataProvider(XmlReader.Create(jobFile), True) + input = xmlInputReader.CreateDeclaration(XmlReader.Create(jobFile), True) End Select End Select @@ -2029,11 +2034,13 @@ Imports TUGraz.VectoCore.Utils Case ".xml" Dim xDocument As XDocument = xDocument.Load(f) Dim rootNode As String = If(xDocument Is Nothing, "", xDocument.Root.Name.LocalName) + Dim kernel as IKernel = New StandardKernel(new VectoNinjectModule) + Dim xmlInputReader as IXMLInputDataReader = kernel.Get(Of IXMLInputDataReader) Select Case rootNode Case XMLNames.VectoInputEngineering input = New XMLEngineeringInputDataProvider(f, True) Case XMLNames.VectoInputDeclaration - input = New XMLDeclarationInputDataProvider(XmlReader.Create(f), True) + input = xmlInputReader.CreateDeclaration(XmlReader.Create(f), True) End Select End Select diff --git a/VECTO/GUI/VectoJobForm.vb b/VECTO/GUI/VectoJobForm.vb index 4a6bd2d9ac1f651c3b29c7b0349e8c1de2b4040d..49d5d40ad364ee3b7dd5ffac9b344607f8b34a05 100644 --- a/VECTO/GUI/VectoJobForm.vb +++ b/VECTO/GUI/VectoJobForm.vb @@ -423,7 +423,7 @@ Public Class VectoJobForm 'Update Form If inputData.JobInputData().EngineOnlyMode Then - TbENG.Text = GetRelativePath(inputData.JobInputData.EngineOnly.Source, _basePath) + TbENG.Text = GetRelativePath(inputData.JobInputData.EngineOnly.DataSource.SourceFile, _basePath) CbEngOnly.Checked = True Try Dim sb As ICycleData @@ -440,9 +440,9 @@ Public Class VectoJobForm CbEngOnly.Checked = False CheckEngOnly() 'Files ----------------------------- - TbVEH.Text = GetRelativePath(inputData.JobInputData.Vehicle.Source, _basePath) - TbENG.Text = GetRelativePath(inputData.JobInputData.Vehicle.EngineInputData.Source, _basePath) - TbGBX.Text = GetRelativePath(inputData.JobInputData.Vehicle.GearboxInputData.Source, _basePath) + TbVEH.Text = GetRelativePath(inputData.JobInputData.Vehicle.DataSource.SourceFile, _basePath) + TbENG.Text = GetRelativePath(inputData.JobInputData.Vehicle.Components.EngineInputData.DataSource.SourceFile, _basePath) + TbGBX.Text = GetRelativePath(inputData.JobInputData.Vehicle.Components.GearboxInputData.DataSource.SourceFile, _basePath) 'Start/Stop Dim driver As IDriverEngineeringInputData = inputData.DriverInputData @@ -452,7 +452,7 @@ Public Class VectoJobForm 'AA-TB 'Try and Select any previously selected Auxiliary Type Dim declarationInput As IDeclarationInputDataProvider = CType(inputData, IDeclarationInputDataProvider) - Dim auxInput As IAuxiliariesDeclarationInputData = declarationInput.JobInputData.Vehicle.AuxiliaryInputData() + Dim auxInput As IAuxiliariesDeclarationInputData = declarationInput.JobInputData.Vehicle.Components.AuxiliaryInputData cboAdvancedAuxiliaries.SelectedIndex = 0 cboAdvancedAuxiliaries.Enabled = False @@ -472,7 +472,7 @@ Public Class VectoJobForm If(driver.AccelerationCurve Is Nothing, "", GetRelativePath(driver.AccelerationCurve.Source, _basePath)) cboAdvancedAuxiliaries.Enabled = True - Dim auxInput As IAuxiliariesEngineeringInputData = inputData.JobInputData.Vehicle.AuxiliaryInputData() + Dim auxInput As IAuxiliariesEngineeringInputData = inputData.JobInputData.Vehicle.Components.AuxiliaryInputData For Each item As AdvancedAuxiliary In cboAdvancedAuxiliaries.Items If _ AuxiliaryModelHelper.Parse(item.AssemblyName) = auxInput.AuxiliaryAssembly AndAlso @@ -1144,7 +1144,7 @@ lbDlog: Try Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(gearboxFile), IEngineeringInputDataProvider) - gearbox = inputData.JobInputData.Vehicle.GearboxInputData + gearbox = inputData.JobInputData.Vehicle.Components.GearboxInputData Catch End Try End If @@ -1228,7 +1228,7 @@ lbDlog: Try Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(engineFile), IEngineeringInputDataProvider) - engine = inputData.JobInputData.Vehicle.EngineInputData + engine = inputData.JobInputData.Vehicle.Components.EngineInputData Catch Return End Try diff --git a/VECTO/GUI/VectoVTPJobForm.vb b/VECTO/GUI/VectoVTPJobForm.vb index 6f1ae1b5e6a6e75aa57d4557b4adbb3004cf6286..13e2adb59216bb9a66c6d95892582d523765aac4 100644 --- a/VECTO/GUI/VectoVTPJobForm.vb +++ b/VECTO/GUI/VectoVTPJobForm.vb @@ -15,11 +15,14 @@ Imports System.IO Imports System.Linq Imports System.Windows.Forms.DataVisualization.Charting Imports System.Xml +Imports Ninject Imports TUGraz.VECTO.Input_Files Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore Imports TUGraz.VectoCore.InputData.FileIO.JSON +Imports TUGraz.VectoCore.InputData.FileIO.XML Imports TUGraz.VectoCore.InputData.FileIO.XML.Declaration Imports TUGraz.VectoCore.InputData.Reader Imports TUGraz.VectoCore.Models.Declaration @@ -39,6 +42,8 @@ Public Class VectoVTPJobForm Private _auxDialog As VehicleAuxiliariesDialog + Dim _xmlInputReader as IXMLInputDataReader + Enum AuxViewColumns AuxID = 0 AuxType = 1 @@ -49,6 +54,9 @@ Public Class VectoVTPJobForm 'Initialise form Private Sub F02_GEN_Load(sender As Object, e As EventArgs) Handles Me.Load + Dim kernel as IKernel = New StandardKernel(new VectoNinjectModule) + _xmlInputReader = kernel.Get(Of IXMLInputDataReader) + _auxDialog = New VehicleAuxiliariesDialog @@ -191,11 +199,11 @@ Public Class VectoVTPJobForm 'Files ----------------------------- - TbVEH.Text = GetRelativePath(inputData.JobInputData.Vehicle.Source, _basePath) + TbVEH.Text = GetRelativePath(inputData.JobInputData.Vehicle.DataSource.SourceFile, _basePath) tbManufacturerRecord.Text = If (cfg.DeclMode, GetRelativePath(inputData.JobInputData.ManufacturerReportInputData.Source, _basePath), "") - Dim auxInput As IAuxiliariesDeclarationInputData = inputData.JobInputData.Vehicle.AuxiliaryInputData() + Dim auxInput As IAuxiliariesDeclarationInputData = inputData.JobInputData.Vehicle.Components.AuxiliaryInputData PopulateAuxiliaryList(auxInput) @@ -367,9 +375,9 @@ Public Class VectoVTPJobForm TbVEH.Text) If File.Exists(vehicleFile) Then Try - Dim inputData As XMLDeclarationInputDataProvider = - New XMLDeclarationInputDataProvider(XmlReader.Create(vehicleFile), True) - Dim auxInput As IAuxiliariesDeclarationInputData = inputData.JobInputData.Vehicle.AuxiliaryInputData() + Dim inputData As IDeclarationInputDataProvider = + _xmlInputReader.CreateDeclaration(XmlReader.Create(vehicleFile), True) + Dim auxInput As IAuxiliariesDeclarationInputData = inputData.JobInputData.Vehicle.Components.AuxiliaryInputData PopulateAuxiliaryList(auxInput) Catch End Try @@ -550,9 +558,9 @@ Public Class VectoVTPJobForm TbVEH.Text) If File.Exists(vehicleFile) Then Try - Dim inputData As XMLDeclarationInputDataProvider = - New XMLDeclarationInputDataProvider(XmlReader.Create(vehicleFile), True) - gearbox = inputData.JobInputData.Vehicle.GearboxInputData + Dim inputData As IDeclarationInputDataProvider = + _xmlInputReader.CreateDeclaration(XmlReader.Create(vehicleFile), True) + gearbox = inputData.JobInputData.Vehicle.Components.GearboxInputData Catch End Try End If @@ -574,9 +582,9 @@ Public Class VectoVTPJobForm TbVEH.Text) If File.Exists(vehicleFile) Then Try - Dim inputData As XMLDeclarationInputDataProvider = - New XMLDeclarationInputDataProvider(XmlReader.Create(vehicleFile), True) - engine = inputData.JobInputData.Vehicle.EngineInputData + Dim inputData As IDeclarationInputDataProvider = + _xmlInputReader.CreateDeclaration(XmlReader.Create(vehicleFile), True) + engine = inputData.JobInputData.Vehicle.Components.EngineInputData Catch Return End Try @@ -653,8 +661,8 @@ Public Class VectoVTPJobForm TbVEH.Text) If File.Exists(vehicleFile) Then Try - Dim inputData As XMLDeclarationInputDataProvider = - New XMLDeclarationInputDataProvider(XmlReader.Create(vehicleFile), True) + Dim inputData As IDeclarationInputDataProvider = + _xmlInputReader.CreateDeclaration(XmlReader.Create(vehicleFile), True) vehicle = inputData.JobInputData.Vehicle Catch End Try diff --git a/VECTO/GUI/VehicleForm.vb b/VECTO/GUI/VehicleForm.vb index 7ca9df1314c98ff924bc5c862e1be5755163d80d..3e0ef9e67b02b403c71e1d62a8626b6a5e3fb035 100644 --- a/VECTO/GUI/VehicleForm.vb +++ b/VECTO/GUI/VehicleForm.vb @@ -347,10 +347,10 @@ Public Class VehicleForm Dim inputData As IEngineeringInputDataProvider = TryCast(JSONInputDataFactory.ReadComponentData(file), IEngineeringInputDataProvider) Dim vehicle As IVehicleEngineeringInputData = inputData.JobInputData.Vehicle - Dim airdrag As IAirdragEngineeringInputData = inputData.JobInputData.Vehicle.AirdragInputData - Dim retarder As IRetarderInputData = inputData.JobInputData.Vehicle.RetarderInputData - Dim angledrive As IAngledriveInputData = inputData.JobInputData.Vehicle.AngledriveInputData - Dim pto As IPTOTransmissionInputData = inputData.JobInputData.Vehicle.PTOTransmissionInputData + Dim airdrag As IAirdragEngineeringInputData = inputData.JobInputData.Vehicle.Components.AirdragInputData + Dim retarder As IRetarderInputData = inputData.JobInputData.Vehicle.Components.RetarderInputData + Dim angledrive As IAngledriveInputData = inputData.JobInputData.Vehicle.Components.AngledriveInputData + Dim pto As IPTOTransmissionInputData = inputData.JobInputData.Vehicle.Components.PTOTransmissionInputData If Cfg.DeclMode <> vehicle.SavedInDeclarationMode Then Select Case WrongMode() @@ -387,7 +387,7 @@ Public Class VehicleForm LvRRC.Items.Clear() Dim i As Integer = 0 Dim a0 As IAxleEngineeringInputData - For Each a0 In vehicle.Axles + For Each a0 In vehicle.Components.AxleWheels.AxlesEngineering i += 1 If Cfg.DeclMode Then Dim inertia As Double = DeclarationData.Wheels.Lookup(a0.Tyre.Dimension).Inertia.Value() diff --git a/VECTO/Input Files/Engine.vb b/VECTO/Input Files/Engine.vb index 55aeba29ba861538151e9886954b20ca97fe7e0b..35795ad13a40716b1306dbaacca36bbd25fecabe 100644 --- a/VECTO/Input Files/Engine.vb +++ b/VECTO/Input Files/Engine.vb @@ -269,18 +269,16 @@ Public Class Engine #Region "IInputData" - Public ReadOnly Property SourceType As DataSourceType Implements IComponentInputData.SourceType + Public ReadOnly Property DataSource As DataSource Implements IComponentInputData.DataSource Get - Return DataSourceType.JSONFile - End Get - End Property - - Public ReadOnly Property Source As String Implements IComponentInputData.Source - Get - Return FilePath + Dim retVal As DataSource = New DataSource() + retVal.SourceType = DataSourceType.JSONFile + retVal.SourceFile = FilePath + Return retVal End Get End Property + Public ReadOnly Property SavedInDeclarationMode As Boolean Implements IComponentInputData.SavedInDeclarationMode Get Return Cfg.DeclMode diff --git a/VECTO/Input Files/Gearbox.vb b/VECTO/Input Files/Gearbox.vb index 4ffe936751a56af3e811c1ee06b4d60799a63f05..67c38f249793e7b558cfc0dc6b6b391be8bed2b1 100644 --- a/VECTO/Input Files/Gearbox.vb +++ b/VECTO/Input Files/Gearbox.vb @@ -217,7 +217,7 @@ Public Class Gearbox Try - engine = doa.CreateEngineData(inputData.JobInputData.Vehicle.EngineInputData, Nothing, gearbox, New List(Of ITorqueLimitInputData), TankSystem.Compressed) + engine = doa.CreateEngineData(inputData.JobInputData.Vehicle.Components.EngineInputData, Nothing, gearbox, New List(Of ITorqueLimitInputData), TankSystem.Compressed) Catch engine = GetDefaultEngine(gearbox.Gears) End Try @@ -227,7 +227,7 @@ Public Class Gearbox Else Dim doa As EngineeringDataAdapter = New EngineeringDataAdapter() Try - engine = doa.CreateEngineData(inputData.JobInputData.Vehicle.EngineInputData, gearbox, New List(Of ITorqueLimitInputData), TankSystem.Compressed) + engine = doa.CreateEngineData(inputData.JobInputData.Vehicle.Components.EngineInputData, gearbox, New List(Of ITorqueLimitInputData), TankSystem.Compressed) Catch engine = GetDefaultEngine(gearbox.Gears) End Try @@ -286,15 +286,12 @@ Public Class Gearbox End Function - Public ReadOnly Property SourceType As DataSourceType Implements IComponentInputData.SourceType + Public ReadOnly Property DataSource As DataSource Implements IComponentInputData.DataSource Get - Return DataSourceType.JSONFile - End Get - End Property - - Public ReadOnly Property Source As String Implements IComponentInputData.Source - Get - Return FilePath + Dim retVal As DataSource = New DataSource() + retVal.SourceType = DataSourceType.JSONFile + retVal.SourceFile = FilePath + Return retVal End Get End Property diff --git a/VECTO/Input Files/VectoEPTPJob.vb b/VECTO/Input Files/VectoEPTPJob.vb index 10643f47af91e0e95ee9212da6c4b3af048d7338..c1a771ad499b2a53907bb88b56cdff318092dd5a 100644 --- a/VECTO/Input Files/VectoEPTPJob.vb +++ b/VECTO/Input Files/VectoEPTPJob.vb @@ -4,13 +4,16 @@ Imports System.ComponentModel.DataAnnotations Imports System.IO Imports System.Linq Imports System.Xml +Imports Ninject Imports TUGraz.VECTO.Input_Files Imports TUGraz.VectoCommon.Exceptions Imports TUGraz.VectoCommon.Hashing Imports TUGraz.VectoCommon.InputData Imports TUGraz.VectoCommon.Models Imports TUGraz.VectoCommon.Utils +Imports TUGraz.VectoCore Imports TUGraz.VectoCore.InputData.FileIO.JSON +Imports TUGraz.VectoCore.InputData.FileIO.XML Imports TUGraz.VectoCore.InputData.FileIO.XML.Declaration Imports TUGraz.VectoCore.InputData.Impl Imports TUGraz.VectoCore.Models.Declaration @@ -32,11 +35,15 @@ Public Class VectoVTPJob Public FanCoefficients As Double() Private _fanDiameter As Meter + Private _xmlInputReader As IXMLInputDataReader Public Sub New() CycleFiles = New List(Of SubPath) _vehicleFile = New SubPath _manufacturerRecord = New SubPath() + + Dim kernel as IKernel = New StandardKernel(new VectoNinjectModule) + _xmlInputReader = kernel.Get(Of IXMLInputDataReader) End Sub Public Property FilePath As String @@ -115,7 +122,7 @@ Public Class VectoVTPJob Get If Not File.Exists(_vehicleFile.FullPath) Then Return Nothing 'Return New JSONComponentInputData(_vehicleFile.FullPath).JobInputData.Vehicle - Return New XMLDeclarationInputDataProvider(_vehicleFile.FullPath, True).JobInputData.Vehicle + Return _xmlInputReader.CreateDeclaration(_vehicleFile.FullPath, True).JobInputData.Vehicle End Get End Property diff --git a/VECTO/Input Files/VectoJob.vb b/VECTO/Input Files/VectoJob.vb index 4eb4521942080a8c4b534fd37a83cab56f62e98c..206c942941080b9a60ee707db7ed868b94a77ccf 100644 --- a/VECTO/Input Files/VectoJob.vb +++ b/VECTO/Input Files/VectoJob.vb @@ -350,8 +350,8 @@ Public Class VectoJob Dim result As IList(Of ValidationResult) = New List(Of ValidationResult) Dim vehicleInputData As IVehicleEngineeringInputData = vectoJob.JobInputData.Vehicle - Dim engineInputData As IEngineDeclarationInputData = vectoJob.JobInputData.Vehicle.EngineInputData - Dim gearboxInputData As IGearboxDeclarationInputData = vectoJob.Vehicle.GearboxInputData + Dim engineInputData As IEngineDeclarationInputData = vectoJob.JobInputData.Vehicle.Components.EngineInputData + Dim gearboxInputData As IGearboxDeclarationInputData = vectoJob.Vehicle.Components.GearboxInputData If vehicleInputData Is Nothing Then _ result.Add(New ValidationResult("Vehicle File is missing or invalid")) @@ -513,7 +513,7 @@ Public Class VectoJob Public ReadOnly Property IEngineeringJobInputData_EngineOnly As IEngineEngineeringInputData Implements IEngineeringJobInputData.EngineOnly Get If Not File.Exists(_engineFile.FullPath) Then Return Nothing - Return New JSONComponentInputData(_engineFile.FullPath, Me).JobInputData.Vehicle.EngineInputData + Return New JSONComponentInputData(_engineFile.FullPath, Me).JobInputData.Vehicle.Components.EngineInputData End Get End Property @@ -604,27 +604,27 @@ Public Class VectoJob Public ReadOnly Property Gearbox As IGearboxEngineeringInputData Implements IJSONVehicleComponents.Gearbox Get - Return New JSONComponentInputData(_gearboxFile.FullPath, Me).JobInputData.Vehicle.GearboxInputData + Return New JSONComponentInputData(_gearboxFile.FullPath, Me).JobInputData.Vehicle.Components.GearboxInputData End Get End Property Public ReadOnly Property TorqueConverter As ITorqueConverterEngineeringInputData Implements IJSONVehicleComponents.TorqueConverter Get - Return New JSONComponentInputData(_gearboxFile.FullPath, Me).JobInputData.Vehicle.TorqueConverterInputData + Return New JSONComponentInputData(_gearboxFile.FullPath, Me).JobInputData.Vehicle.Components.TorqueConverterInputData End Get End Property Public ReadOnly Property AxleGear As IAxleGearInputData Implements IJSONVehicleComponents.AxleGear Get - Return New JSONComponentInputData(_gearboxFile.FullPath, Me).JobInputData.Vehicle.AxleGearInputData + Return New JSONComponentInputData(_gearboxFile.FullPath, Me).JobInputData.Vehicle.Components.AxleGearInputData End Get End Property Public ReadOnly Property Engine As IEngineEngineeringInputData Implements IJSONVehicleComponents.Engine Get - Return New JSONComponentInputData(_engineFile.FullPath, Me).JobInputData.Vehicle.EngineInputData + Return New JSONComponentInputData(_engineFile.FullPath, Me).JobInputData.Vehicle.Components.EngineInputData End Get End Property diff --git a/VECTO/Input Files/Vehicle.vb b/VECTO/Input Files/Vehicle.vb index fab6992313e5068e66aa422c1bcaac5a50538fc1..bb3eaf24ddd7d9c42f90e971b9a15ff389319aa2 100644 --- a/VECTO/Input Files/Vehicle.vb +++ b/VECTO/Input Files/Vehicle.vb @@ -28,7 +28,8 @@ Imports TUGraz.VectoCore.Utils <CustomValidation(GetType(Vehicle), "ValidateVehicle")> Public Class Vehicle Implements IVehicleEngineeringInputData, IVehicleDeclarationInputData, IRetarderInputData, IPTOTransmissionInputData, - IAngledriveInputData, IAirdragEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData + IAngledriveInputData, IAirdragEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData, + IVehicleComponentsEngineering, IVehicleComponentsDeclaration, IAxlesEngineeringInputData, IAxlesDeclarationInputData Private _filePath As String Private _path As String @@ -248,15 +249,12 @@ Public Class Vehicle #Region "IInputData" - Public ReadOnly Property SourceType As DataSourceType Implements IComponentInputData.SourceType + Public ReadOnly Property DataSource As DataSource Implements IComponentInputData.DataSource Get - Return DataSourceType.JSONFile - End Get - End Property - - Public ReadOnly Property Source As String Implements IComponentInputData.Source - Get - Return FilePath + Dim retVal As DataSource = New DataSource() + retVal.SourceType = DataSourceType.JSONFile + retVal.SourceFile = FilePath + Return retVal End Get End Property @@ -320,7 +318,13 @@ Public Class Vehicle End Get End Property - Public ReadOnly Property ExemptedVehicle As Boolean Implements IVehicleDeclarationInputData.ExemptedVehicle + Public ReadOnly Property Identifier As String Implements IVehicleDeclarationInputData.Identifier + get + Return "" + End Get + End Property + + Public ReadOnly Property ExemptedVehicle As Boolean Implements IVehicleDeclarationInputData.ExemptedVehicle get Return false End Get @@ -377,14 +381,14 @@ Public Class Vehicle End Property Public ReadOnly Property IVehicleEngineeringInputData_Axles As IList(Of IAxleEngineeringInputData) _ - Implements IVehicleEngineeringInputData.Axles + Implements IAxlesEngineeringInputData.AxlesEngineering Get Return Axles.Cast(Of IAxleEngineeringInputData)().ToList() End Get End Property Public ReadOnly Property IVehicleDeclarationInputData_Axles As IList(Of IAxleDeclarationInputData) _ - Implements IVehicleDeclarationInputData.Axles + Implements IAxlesDeclarationInputData.AxlesDeclaration Get Return Axles.Cast(Of IAxleDeclarationInputData)().ToList() End Get @@ -403,6 +407,8 @@ Public Class Vehicle End Get End Property + Public ReadOnly Property IVehicleEngineeringInputData_Components As IVehicleComponentsEngineering Implements IVehicleEngineeringInputData.Components + Public ReadOnly Property CrosswindCorrectionMap As TableData _ Implements IAirdragEngineeringInputData.CrosswindCorrectionMap Get @@ -505,21 +511,21 @@ Public Class Vehicle Public ReadOnly Property IDeclarationInputDataProvider_AirdragInputData As IAirdragDeclarationInputData _ - Implements IVehicleDeclarationInputData.AirdragInputData + Implements IVehicleComponentsDeclaration.AirdragInputData Get Return AirdragInputData End Get End Property Public ReadOnly Property AirdragInputData As IAirdragEngineeringInputData _ - Implements IVehicleEngineeringInputData.AirdragInputData + Implements IVehicleComponentsEngineering.AirdragInputData Get Return Me End Get End Property Public ReadOnly Property IDeclarationInputDataProvider_GearboxInputData As IGearboxDeclarationInputData _ - Implements IVehicleDeclarationInputData.GearboxInputData + Implements IVehicleComponentsDeclaration.GearboxInputData Get Return Nothing 'If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing @@ -528,7 +534,7 @@ Public Class Vehicle End Property Public ReadOnly Property GearboxInputData As IGearboxEngineeringInputData _ - Implements IVehicleEngineeringInputData.GearboxInputData + Implements IVehicleComponentsEngineering.GearboxInputData Get Return Nothing 'If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing @@ -537,7 +543,7 @@ Public Class Vehicle End Property Public ReadOnly Property IDeclarationInputDataProvider_TorqueConverterInputData As ITorqueConverterDeclarationInputData _ - Implements IVehicleDeclarationInputData.TorqueConverterInputData + Implements IVehicleComponentsDeclaration.TorqueConverterInputData Get Return Nothing 'If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing @@ -546,7 +552,7 @@ Public Class Vehicle End Property Public ReadOnly Property TorqueConverterInputData As ITorqueConverterEngineeringInputData _ - Implements IVehicleEngineeringInputData.TorqueConverterInputData + Implements IVehicleComponentsEngineering.TorqueConverterInputData Get Return Nothing 'If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing @@ -555,7 +561,7 @@ Public Class Vehicle End Property Public ReadOnly Property IDeclarationInputDataProvider_AxleGearInputData As IAxleGearInputData _ - Implements IVehicleDeclarationInputData.AxleGearInputData + Implements IVehicleComponentsDeclaration.AxleGearInputData Get Return Nothing 'If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing @@ -564,7 +570,7 @@ Public Class Vehicle End Property Public ReadOnly Property AxleGearInputData As IAxleGearInputData _ - Implements IVehicleEngineeringInputData.AxleGearInputData + Implements IVehicleComponentsEngineering.AxleGearInputData Get Return Nothing 'If Not File.Exists(_gearboxFile.FullPath) Then Return Nothing @@ -573,21 +579,21 @@ Public Class Vehicle End Property Public ReadOnly Property DeclarationInputDataProviderAngledriveInputData As IAngledriveInputData _ - Implements IVehicleDeclarationInputData.AngledriveInputData + Implements IVehicleComponentsDeclaration.AngledriveInputData Get Return Me End Get End Property Public ReadOnly Property AngledriveInputData As IAngledriveInputData _ - Implements IVehicleEngineeringInputData.AngledriveInputData + Implements IVehicleComponentsEngineering.AngledriveInputData Get Return Me End Get End Property Public ReadOnly Property IDeclarationInputDataProvider_EngineInputData As IEngineDeclarationInputData _ - Implements IVehicleDeclarationInputData.EngineInputData + Implements IVehicleComponentsDeclaration.EngineInputData Get Return Nothing 'If Not File.Exists(_engineFile.FullPath) Then Return Nothing @@ -596,7 +602,7 @@ Public Class Vehicle End Property Public ReadOnly Property EngineInputData As IEngineEngineeringInputData _ - Implements IVehicleEngineeringInputData.EngineInputData + Implements IVehicleComponentsEngineering.EngineInputData Get Return Nothing 'If Not File.Exists(_engineFile.FullPath) Then Return Nothing @@ -604,27 +610,28 @@ Public Class Vehicle End Get End Property - Public Function AuxiliaryInputData() As IAuxiliariesEngineeringInputData _ - Implements IVehicleEngineeringInputData.AuxiliaryInputData - - Return Nothing - End Function + Public ReadOnly Property IVehicleComponentsDeclaration_AuxiliaryInputData As IAuxiliariesDeclarationInputData Implements IVehicleComponentsDeclaration.AuxiliaryInputData + get + return nothing + End Get + End Property - Public Function IDeclarationInputDataProvider_AuxiliaryInputData() As IAuxiliariesDeclarationInputData _ - Implements IVehicleDeclarationInputData.AuxiliaryInputData + Public ReadOnly Property AuxiliaryInputData As IAuxiliariesEngineeringInputData Implements IVehicleComponentsEngineering.AuxiliaryInputData + get + Return Nothing + End Get + End Property - Return Nothing - End Function Public ReadOnly Property IDeclarationInputDataProvider_RetarderInputData As IRetarderInputData _ - Implements IVehicleDeclarationInputData.RetarderInputData + Implements IVehicleComponentsDeclaration.RetarderInputData Get Return Me End Get End Property Public ReadOnly Property RetarderInputData As IRetarderInputData _ - Implements IVehicleEngineeringInputData.RetarderInputData + Implements IVehicleComponentsEngineering.RetarderInputData Get Return Me End Get @@ -639,19 +646,31 @@ Public Class Vehicle 'End Property Public ReadOnly Property IDeclarationInputDataProvider_PTOTransmissionInputData As IPTOTransmissionInputData _ - Implements IVehicleDeclarationInputData.PTOTransmissionInputData + Implements IVehicleComponentsDeclaration.PTOTransmissionInputData Get Return Me End Get End Property Public ReadOnly Property PTOTransmissionInputData As IPTOTransmissionInputData _ - Implements IVehicleEngineeringInputData.PTOTransmissionInputData + Implements IVehicleComponentsEngineering.PTOTransmissionInputData Get Return Me End Get End Property + Public ReadOnly Property IVehicleComponentsDeclaration_AxleWheels As IAxlesDeclarationInputData Implements IVehicleComponentsDeclaration.AxleWheels + get + Return Me + End Get + End Property + + Public ReadOnly Property AxleWheels As IAxlesEngineeringInputData Implements IVehicleComponentsEngineering.AxleWheels + get + Return me + End Get + End Property + Public ReadOnly Property VocationalVehicle As Boolean Implements IVehicleDeclarationInputData.VocationalVehicle get Return DeclarationData.Vehicle.VocationalVehicleDefault @@ -670,6 +689,12 @@ Public Class Vehicle End Get End Property + Public ReadOnly Property IVehicleEngineeringInputData_ADAS As IAdvancedDriverAssistantSystemsEngineering Implements IVehicleEngineeringInputData.ADAS + get + Return Nothing + End Get + End Property + Public ReadOnly Property ADAS As IAdvancedDriverAssistantSystemDeclarationInputData Implements IVehicleDeclarationInputData.ADAS get return Me @@ -706,6 +731,12 @@ Public Class Vehicle End Get End Property + Public ReadOnly Property Components As IVehicleComponentsDeclaration Implements IVehicleDeclarationInputData.Components + get + Return Me + End Get + End Property + Public ReadOnly Property EngineStopStart As Boolean Implements IAdvancedDriverAssistantSystemDeclarationInputData.EngineStopStart get return DeclarationData.Vehicle.ADAS.EngineStopStartDefault @@ -731,4 +762,9 @@ Public Class Vehicle End Property + Public ReadOnly Property IAxlesEngineeringInputData_DataSource As DataSource Implements IAxlesEngineeringInputData.DataSource + get + Return New DataSource() With {.SourceType = DataSourceType.JSONFile} + End Get + End Property End Class diff --git a/VECTO/OutputData/JSONFileWriter.vb b/VECTO/OutputData/JSONFileWriter.vb index 3d2a9822678bb6f6673d9e04a2aa3984aeb2eeaa..011cdff10cc06d56cc3b5454b898cf73f3aaab53 100644 --- a/VECTO/OutputData/JSONFileWriter.vb +++ b/VECTO/OutputData/JSONFileWriter.vb @@ -222,7 +222,7 @@ Public Class JSONFileWriter {"IdlingSpeed", vehicle.EngineIdleSpeed.AsRPM}, {"AxleConfig", New Dictionary(Of String, Object) From { {"Type", vehicle.AxleConfiguration.GetName()}, - {"Axles", From axle In vehicle.Axles Select New Dictionary(Of String, Object) From { + {"Axles", From axle In vehicle.Components.AxleWheels.AxlesEngineering Select New Dictionary(Of String, Object) From { {"Inertia", axle.Tyre.Inertia.Value()}, {"Wheels", axle.Tyre.Dimension}, {"AxleWeightShare", axle.AxleWeightShare}, @@ -258,7 +258,7 @@ Public Class JSONFileWriter body.Add("EngineOnlyMode", job.EngineOnlyMode) If job.EngineOnlyMode Then - body.Add("EngineFile", GetRelativePath(job.EngineOnly.Source, basePath)) + body.Add("EngineFile", GetRelativePath(job.EngineOnly.DataSource.SourceFile, basePath)) body.Add("Cycles", job.Cycles.Select(Function(x) GetRelativePath(x.CycleData.Source, Path.GetDirectoryName(filename))).ToArray()) WriteFile(header, body, filename) @@ -266,12 +266,12 @@ Public Class JSONFileWriter End If 'Main Files - body.Add("VehicleFile", GetRelativePath(job.Vehicle.Source, basePath)) - body.Add("EngineFile", GetRelativePath(input.JobInputData.Vehicle.EngineInputData.Source, basePath)) - body.Add("GearboxFile", GetRelativePath(input.JobInputData.Vehicle.GearboxInputData.Source, basePath)) + body.Add("VehicleFile", GetRelativePath(job.Vehicle.DataSource.SourceFile, basePath)) + body.Add("EngineFile", GetRelativePath(input.JobInputData.Vehicle.Components.EngineInputData.DataSource.SourceFile, basePath)) + body.Add("GearboxFile", GetRelativePath(input.JobInputData.Vehicle.Components.GearboxInputData.DataSource.SourceFile, basePath)) - Dim aux As IAuxiliariesEngineeringInputData = job.Vehicle.AuxiliaryInputData() + Dim aux As IAuxiliariesEngineeringInputData = job.Vehicle.Components.AuxiliaryInputData 'AA-TB 'ADVANCED AUXILIARIES body.Add("AuxiliaryAssembly", aux.AuxiliaryAssembly.GetName()) @@ -369,7 +369,7 @@ Public Class JSONFileWriter 'Body Dim body As Dictionary(Of String, Object) = New Dictionary(Of String, Object) body.Add("SavedInDeclMode", declarationmode) - body.Add("DeclarationVehicle", GetRelativePath(job.Vehicle.Source, Path.GetDirectoryName(filename))) + body.Add("DeclarationVehicle", GetRelativePath(job.Vehicle.DataSource.SourceFile, Path.GetDirectoryName(filename))) if declarationmode Then body.add("ManufacturerRecord", GetRelativePath(job.ManufacturerReportInputData.Source, Path.GetDirectoryName(filename))) body.Add("Mileage", job.Mileage.ConvertToKiloMeter().Value) diff --git a/VECTO/VECTO.vbproj b/VECTO/VECTO.vbproj index 570c353ea57d5565cc73285b41e2f2df3780a61b..8da3cd75d8fd10c6905d847d8c5bd67554dea8a8 100644 --- a/VECTO/VECTO.vbproj +++ b/VECTO/VECTO.vbproj @@ -161,6 +161,9 @@ <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> + <Reference Include="Ninject"> + <HintPath>..\..\STUDENTEN_PROJEKTE\Kober_VectoGIT\VECTO_GIT\packages\Ninject.3.3.4\lib\net45\Ninject.dll</HintPath> + </Reference> <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <HintPath>..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath> <Private>True</Private> diff --git a/VECTO/app.config b/VECTO/app.config index 0b81d52e3616de752ce81d671c703e6c5d4d3cf4..1f668ae00dcefff41565a30af74dd4f2b3fd9580 100644 --- a/VECTO/app.config +++ b/VECTO/app.config @@ -11,6 +11,10 @@ <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" /> </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" /> + </dependentAssembly> </assemblyBinding> </runtime> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="false" throwExceptions="false" internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"> diff --git a/VectoCommon/VectoCommon/InputData/DataSourceType.cs b/VectoCommon/VectoCommon/InputData/DataSourceType.cs index f49c6e64eab5ae33d4c1c34da184dbb9728459de..6aa6e157df62e91153a68b748653585b93389550 100644 --- a/VectoCommon/VectoCommon/InputData/DataSourceType.cs +++ b/VectoCommon/VectoCommon/InputData/DataSourceType.cs @@ -36,6 +36,7 @@ namespace TUGraz.VectoCommon.InputData Embedded, CSVFile, JSONFile, - Missing + Missing, + XMLFile } } \ No newline at end of file diff --git a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs index 3fa00720bdc440f2275751e801d191be41e0abdf..489934a6701b49bacd821f0b80fb97358586ea42 100644 --- a/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs +++ b/VectoCommon/VectoCommon/InputData/DeclarationInputData.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Net.NetworkInformation; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -48,10 +49,8 @@ namespace TUGraz.VectoCommon.InputData public interface IComponentInputData { - DataSourceType SourceType { get; } - - string Source { get; } - + DataSource DataSource { get; } + bool SavedInDeclarationMode { get; } string Manufacturer { get; } @@ -67,8 +66,24 @@ namespace TUGraz.VectoCommon.InputData DigestData DigestValue { get; } } + public class DataSource + { + public DataSourceType SourceType { get; set; } + + public string SourceFile { get; set; } + + public string SourceVersion { get; set; } + + public string SourcePath + { + get { return SourceFile != null ? Path.GetDirectoryName(Path.GetFullPath(SourceFile)) : null; } + } + } + public interface IVehicleDeclarationInputData : IComponentInputData { + string Identifier { get; } + bool ExemptedVehicle { get; } string VIN { get; } @@ -112,30 +127,11 @@ namespace TUGraz.VectoCommon.InputData /// P044, P045, P046, P047, P048, P108 /// cf. VECTO Input Parameters.xlsx /// </summary> - IList<IAxleDeclarationInputData> Axles { get; } string ManufacturerAddress { get; } PerSecond EngineIdleSpeed { get; } - IAirdragDeclarationInputData AirdragInputData { get; } - - IGearboxDeclarationInputData GearboxInputData { get; } - - ITorqueConverterDeclarationInputData TorqueConverterInputData { get; } - - IAxleGearInputData AxleGearInputData { get; } - - IAngledriveInputData AngledriveInputData { get; } - - IEngineDeclarationInputData EngineInputData { get; } - - IAuxiliariesDeclarationInputData AuxiliaryInputData(); - - IRetarderInputData RetarderInputData { get; } - - IPTOTransmissionInputData PTOTransmissionInputData { get; } - // new (optional) input fields bool VocationalVehicle { get; } @@ -157,6 +153,46 @@ namespace TUGraz.VectoCommon.InputData Watt MaxNetPower1 { get; } Watt MaxNetPower2 { get; } + + // components + + IVehicleComponentsDeclaration Components { get; } + + } + + public interface IVehicleComponentsDeclaration + { + + IAirdragDeclarationInputData AirdragInputData { get; } + + IGearboxDeclarationInputData GearboxInputData { get; } + + ITorqueConverterDeclarationInputData TorqueConverterInputData { get; } + + IAxleGearInputData AxleGearInputData { get; } + + IAngledriveInputData AngledriveInputData { get; } + + IEngineDeclarationInputData EngineInputData { get; } + + IAuxiliariesDeclarationInputData AuxiliaryInputData { get; } + + IRetarderInputData RetarderInputData { get; } + + IPTOTransmissionInputData PTOTransmissionInputData { get; } + + IAxlesDeclarationInputData AxleWheels { get; } + + } + + public interface IAxlesDeclarationInputData + { + /// <summary> + /// parameters for every axle + /// P044, P045, P046, P047, P048, P108 + /// cf. VECTO Input Parameters.xlsx + /// </summary> + IList<IAxleDeclarationInputData> AxlesDeclaration { get; } } public interface IAdvancedDriverAssistantSystemDeclarationInputData @@ -269,6 +305,7 @@ namespace TUGraz.VectoCommon.InputData AxleType AxleType { get; } ITyreDeclarationInputData Tyre { get; } + } public interface ITyreDeclarationInputData : IComponentInputData diff --git a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs index ac3a2fe287070abc5f0d9c4d4eba7552de8219ba..9b8e2c521e916ab67df497894a2c750e86ebafc8 100644 --- a/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs +++ b/VectoCommon/VectoCommon/InputData/EngineeringInputData.cs @@ -68,13 +68,6 @@ namespace TUGraz.VectoCommon.InputData /// </summary> Kilogram Loading { get; } - /// <summary> - /// parameters for every axle - /// P044, P045, P046, P047, P048, P108 - /// cf. VECTO Input Parameters.xlsx - /// </summary> - new IList<IAxleEngineeringInputData> Axles { get; } - /// <summary> /// P049 /// cf. VECTO Input Parameters.xlsx @@ -83,7 +76,17 @@ namespace TUGraz.VectoCommon.InputData Meter Height { get; } + new IVehicleComponentsEngineering Components { get; } + IAdvancedDriverAssistantSystemsEngineering ADAS { get; } + } + + public interface IAdvancedDriverAssistantSystemsEngineering + { } + + + public interface IVehicleComponentsEngineering + { new IAirdragEngineeringInputData AirdragInputData { get; } new IGearboxEngineeringInputData GearboxInputData { get; } @@ -96,11 +99,30 @@ namespace TUGraz.VectoCommon.InputData new IEngineEngineeringInputData EngineInputData { get; } - new IAuxiliariesEngineeringInputData AuxiliaryInputData(); + new IAuxiliariesEngineeringInputData AuxiliaryInputData { get; } new IRetarderInputData RetarderInputData { get; } new IPTOTransmissionInputData PTOTransmissionInputData { get; } + + /// <summary> + /// parameters for every axle + /// P044, P045, P046, P047, P048, P108 + /// cf. VECTO Input Parameters.xlsx + /// </summary> + IAxlesEngineeringInputData AxleWheels { get; } + } + + public interface IAxlesEngineeringInputData + { + /// <summary> + /// parameters for every axle + /// P044, P045, P046, P047, P048, P108 + /// cf. VECTO Input Parameters.xlsx + /// </summary> + IList<IAxleEngineeringInputData> AxlesEngineering { get; } + + DataSource DataSource { get; } } public interface IAirdragEngineeringInputData : IAirdragDeclarationInputData diff --git a/VectoCommon/VectoHashingTest/VectoHashTest.cs b/VectoCommon/VectoHashingTest/VectoHashTest.cs index 67dc3fc197486c17a8207510d7e0e3789fe367a5..733cb953b442e120fd93f2eb7af8d966ef8225ad 100644 --- a/VectoCommon/VectoHashingTest/VectoHashTest.cs +++ b/VectoCommon/VectoHashingTest/VectoHashTest.cs @@ -41,6 +41,7 @@ using TUGraz.VectoCore.Utils; using TUGraz.VectoHashing; using VectoHashingTest.Utils; using Assert = NUnit.Framework.Assert; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; namespace VectoHashingTest { @@ -415,7 +416,7 @@ namespace VectoHashingTest // re-load generated XML and perform XSD validation var validator = new XMLValidator(XmlReader.Create(destination)); - Assert.IsTrue(validator.ValidateXML(XMLValidator.XmlDocumentType.DeclarationComponentData)); + Assert.IsTrue(validator.ValidateXML(XmlDocumentType.DeclarationComponentData)); } diff --git a/VectoCommon/VectoHashingTest/VectoHashingTest.csproj b/VectoCommon/VectoHashingTest/VectoHashingTest.csproj index 0da0cb793e3ca6e73a3695e044bb577ce0641819..bdadbe799ba320d8ef6283dba505f9a90d7d189f 100644 --- a/VectoCommon/VectoHashingTest/VectoHashingTest.csproj +++ b/VectoCommon/VectoHashingTest/VectoHashingTest.csproj @@ -181,6 +181,7 @@ </ProjectReference> </ItemGroup> <ItemGroup> + <None Include="app.config" /> <None Include="packages.config" /> </ItemGroup> <Choose> diff --git a/VectoConsole/App.config b/VectoConsole/App.config index 380c2ac3a3a6544e8a9067637070bea3cbbee493..5f6645457280551ad79226bed655e31773493ed4 100644 --- a/VectoConsole/App.config +++ b/VectoConsole/App.config @@ -9,26 +9,17 @@ </startup> <runtime> <loadFromRemoteSources enabled="true" /> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" /> + </dependentAssembly> + </assemblyBinding> </runtime> - <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" - autoReload="false" - throwExceptions="false" - internalLogLevel="Off" - internalLogFile="c:\temp\nlog-internal.log"> + <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="false" throwExceptions="false" internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"> <targets async="true"> - <target xsi:type="Console" - name="ConsoleLogger" - error="true" /> - <target xsi:type="File" - name="LogFile" - fileName="${basedir}/logs/log.txt" - layout="${longdate} [${processid}:${threadid}@${machinename}] ${callsite:skipFrames=1} ${level:uppercase=true}: ${message} ${exception:format=tostring}" - keepFileOpen="false" - archiveFileName="${basedir}/logs/archive{#}.txt" - maxArchiveFiles="1" - archiveAboveSize="10000000" /> + <target xsi:type="Console" name="ConsoleLogger" error="true" /> + <target xsi:type="File" name="LogFile" fileName="${basedir}/logs/log.txt" layout="${longdate} [${processid}:${threadid}@${machinename}] ${callsite:skipFrames=1} ${level:uppercase=true}: ${message} ${exception:format=tostring}" keepFileOpen="false" archiveFileName="${basedir}/logs/archive{#}.txt" maxArchiveFiles="1" archiveAboveSize="10000000" /> </targets> <rules> <logger name="TUGraz.VectoCore.Models.Simulation.Impl.SimulatorFactory" minlevel="Info" writeTo="LogFile" /> diff --git a/VectoConsole/Program.cs b/VectoConsole/Program.cs index 96c05780c4ae3514d4f8dbec444d5c7924ef011e..fd63938efe229f62dd1247929f57f281ec905186 100644 --- a/VectoConsole/Program.cs +++ b/VectoConsole/Program.cs @@ -38,14 +38,17 @@ using System.Reflection; using System.Threading; using System.Xml; using System.Xml.Linq; +using Ninject; using NLog; using NLog.Config; using NLog.Targets; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.FileIO.JSON; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.InputData.FileIO.XML.Engineering; using TUGraz.VectoCore.Models.Simulation.Impl; @@ -100,9 +103,11 @@ Examples: private static JobContainer _jobContainer; private static bool _quiet; private static bool _debugEnabled; + private static IKernel _kernel; private static int Main(string[] args) { + _kernel = new StandardKernel(new VectoNinjectModule()); try { // on -h display help and terminate. if (args.Contains("-h")) { @@ -194,6 +199,8 @@ Examples: return 1; } + var inputReader = _kernel.Get<IXMLInputDataReader>(); + foreach (var file in jobFiles) { WriteLine(@"Reading job: " + file); var extension = Path.GetExtension(file); @@ -210,7 +217,7 @@ Examples: dataProvider = new XMLEngineeringInputDataProvider(file, true); break; case "VectoInputDeclaration": - dataProvider = new XMLDeclarationInputDataProvider(XmlReader.Create(file), true); + dataProvider = inputReader.CreateDeclaration(XmlReader.Create(file), true); break; } break; diff --git a/VectoConsole/VectoConsole.csproj b/VectoConsole/VectoConsole.csproj index fca3542b300e7f45fa094a2985d1eb9a850ffbd6..c5377452b1a9ddc3256d6a586d24e974eefe6602 100644 --- a/VectoConsole/VectoConsole.csproj +++ b/VectoConsole/VectoConsole.csproj @@ -54,6 +54,9 @@ </PropertyGroup> <ItemGroup> <Reference Include="Microsoft.CSharp" /> + <Reference Include="Ninject"> + <HintPath>..\..\STUDENTEN_PROJEKTE\Kober_VectoGIT\VECTO_GIT\packages\Ninject.3.3.4\lib\net45\Ninject.dll</HintPath> + </Reference> <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <HintPath>..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath> <Private>True</Private> diff --git a/VectoCore/ModelbasedTests/ModelbasedTests.csproj b/VectoCore/ModelbasedTests/ModelbasedTests.csproj index c71bf370e8d5743098187dbec86fe0b35872f91d..765791030f1c7d6fe547f6910a29bdfcc36f7a87 100644 --- a/VectoCore/ModelbasedTests/ModelbasedTests.csproj +++ b/VectoCore/ModelbasedTests/ModelbasedTests.csproj @@ -72,6 +72,7 @@ </ProjectReference> </ItemGroup> <ItemGroup> + <None Include="app.config" /> <None Include="packages.config" /> </ItemGroup> <Choose> diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs index 82d5e86a4f71dfcb7e243a19728ab630abdbcfed..23eaaab748ab44ce799c405d579b658fc8c2abbd 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONComponentInputData.cs @@ -45,7 +45,7 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.FileIO.JSON { public class JSONComponentInputData : IEngineeringInputDataProvider, IDeclarationInputDataProvider, - IEngineeringJobInputData, IVehicleEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData + IEngineeringJobInputData, IVehicleEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData, IAdvancedDriverAssistantSystemsEngineering, IVehicleComponentsDeclaration, IVehicleComponentsEngineering { protected IGearboxEngineeringInputData Gearbox; protected IAxleGearInputData AxleGear; @@ -57,6 +57,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON protected IPTOTransmissionInputData PTOTransmission; private IAirdragEngineeringInputData AirdragData; private string _filename; + private IAxlesDeclarationInputData _axleWheelsDecl; + private IAxlesEngineeringInputData _axleWheelsEng; public JSONComponentInputData(string filename, IJSONVehicleComponents job, bool tolerateMissing = false) @@ -83,7 +85,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON .If<IRetarderInputData>(c => Retarder = c) .If<ITorqueConverterEngineeringInputData>(c => TorqueConverter = c) .If<IAngledriveInputData>(c => Angledrive = c) - .If<IPTOTransmissionInputData>(c => PTOTransmission = c); + .If<IPTOTransmissionInputData>(c => PTOTransmission = c) + .If<IAxlesDeclarationInputData>(c => _axleWheelsDecl = c) + .If<IAxlesEngineeringInputData>(c => _axleWheelsEng = c); ; _filename = filename; } @@ -109,9 +113,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return null; } } - public DataSourceType SourceType + public DataSource DataSource { - get { return DataSourceType.JSONFile; } + get { return new DataSource { SourceType = DataSourceType.JSONFile, SourceFile = _filename }; } } public string Source @@ -149,6 +153,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return ""; } } + public string Identifier { get { return Vehicle.Identifier; } } + public bool ExemptedVehicle { get { return false; } } public string VIN @@ -186,9 +192,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return VehicleData.TorqueLimits; } } - IList<IAxleEngineeringInputData> IVehicleEngineeringInputData.Axles + IAxlesDeclarationInputData IVehicleComponentsDeclaration.AxleWheels { - get { return VehicleData.Axles; } + get { return _axleWheelsDecl; } } public Meter DynamicTyreRadius @@ -201,6 +207,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return VehicleData.Height; } } + IVehicleComponentsEngineering IVehicleEngineeringInputData.Components + { + get { return this; } + } + + IAdvancedDriverAssistantSystemsEngineering IVehicleEngineeringInputData.ADAS + { + get { return this; } + } + public IAirdragEngineeringInputData AirdragInputData { get { return AirdragData; } @@ -216,12 +232,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return TorqueConverter; } } - IAxleGearInputData IVehicleEngineeringInputData.AxleGearInputData + IAxleGearInputData IVehicleComponentsDeclaration.AxleGearInputData { get { return AxleGear; } } - IAngledriveInputData IVehicleEngineeringInputData.AngledriveInputData + IAngledriveInputData IVehicleComponentsDeclaration.AngledriveInputData { get { return Angledrive; } } @@ -236,9 +252,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Vehicle.Loading; } } - IList<IAxleDeclarationInputData> IVehicleDeclarationInputData.Axles + IAxlesEngineeringInputData IVehicleComponentsEngineering.AxleWheels { - get { return Vehicle.Axles.Cast<IAxleDeclarationInputData>().ToList(); } + get { return _axleWheelsEng; } } public string ManufacturerAddress @@ -251,27 +267,27 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return VehicleData.EngineIdleSpeed; } } - IAirdragDeclarationInputData IVehicleDeclarationInputData.AirdragInputData + IAirdragDeclarationInputData IVehicleComponentsDeclaration.AirdragInputData { get { return AirdragInputData; } } - IGearboxDeclarationInputData IVehicleDeclarationInputData.GearboxInputData + IGearboxDeclarationInputData IVehicleComponentsDeclaration.GearboxInputData { get { return GearboxInputData; } } - ITorqueConverterDeclarationInputData IVehicleDeclarationInputData.TorqueConverterInputData + ITorqueConverterDeclarationInputData IVehicleComponentsDeclaration.TorqueConverterInputData { get { return TorqueConverterInputData; } } - IAxleGearInputData IVehicleDeclarationInputData.AxleGearInputData + IAxleGearInputData IVehicleComponentsEngineering.AxleGearInputData { get { return AxleGear; } } - IAngledriveInputData IVehicleDeclarationInputData.AngledriveInputData + IAngledriveInputData IVehicleComponentsEngineering.AngledriveInputData { get { return Angledrive; } } @@ -282,22 +298,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } - IEngineDeclarationInputData IVehicleDeclarationInputData.EngineInputData + IEngineDeclarationInputData IVehicleComponentsDeclaration.EngineInputData { get { return Engine; } } - IAuxiliariesDeclarationInputData IVehicleDeclarationInputData.AuxiliaryInputData() + IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData { - throw new NotImplementedException(); + get { throw new NotImplementedException(); } } - IRetarderInputData IVehicleEngineeringInputData.RetarderInputData + IRetarderInputData IVehicleComponentsEngineering.RetarderInputData { get { return Retarder; } } - IPTOTransmissionInputData IVehicleEngineeringInputData.PTOTransmissionInputData + IPTOTransmissionInputData IVehicleComponentsEngineering.PTOTransmissionInputData { get { return PTOTransmission; } } @@ -312,17 +328,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public Watt MaxNetPower1 { get { return null; } } public Watt MaxNetPower2 { get { return null; } } - IAuxiliariesEngineeringInputData IVehicleEngineeringInputData.AuxiliaryInputData() + IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components + { + get { return this; } + } + + IAuxiliariesEngineeringInputData IVehicleComponentsEngineering.AuxiliaryInputData { - throw new NotImplementedException(); + get { throw new NotImplementedException(); } } - IRetarderInputData IVehicleDeclarationInputData.RetarderInputData + IRetarderInputData IVehicleComponentsDeclaration.RetarderInputData { get { return Retarder; } } - IPTOTransmissionInputData IVehicleDeclarationInputData.PTOTransmissionInputData + IPTOTransmissionInputData IVehicleComponentsDeclaration.PTOTransmissionInputData { get { return PTOTransmission; } } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs index 100a8513162bc3a1eb8ea16c77f7cf2d75eeb30b..f34c95258b042c6758694eef4d1e6ebf2fb27c50 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONEngineData.cs @@ -215,6 +215,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return 1; } } + public string Manufacturer { get { return "N/A"; } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs index 01ca566134802c6c5996b53f4841c18d70bc91ea..075ea9fdd64b0fe7886e4138bbf18a60c64f1a76 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONInputData.cs @@ -36,6 +36,7 @@ using System.IO; using System.Linq; using System.Xml; using System.Xml.Linq; +using Ninject; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Hashing; using TUGraz.VectoCommon.InputData; @@ -43,6 +44,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.InputData.Impl; using TUGraz.VectoCore.Models.Declaration; @@ -56,13 +58,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { public const string MissingFileSuffix = " -- (MISSING!)"; - private readonly string _sourceFile; + protected readonly string _sourceFile; + + protected readonly string Version; protected readonly JObject Body; protected JSONFile(JObject data, string filename, bool tolerateMissing = false) { - //var header = (JObject)data.GetEx(JsonKeys.JsonHeader); + var header = (JObject)data.GetEx(JsonKeys.JsonHeader); + Version = header.GetEx<string>(JsonKeys.JsonHeader_FileVersion); Body = (JObject)data.GetEx(JsonKeys.JsonBody); _sourceFile = Path.GetFullPath(filename); TolerateMissing = tolerateMissing; @@ -70,9 +75,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON protected bool TolerateMissing { get; set; } - public DataSourceType SourceType + public DataSource DataSource { - get { return DataSourceType.JSONFile; } + get { return new DataSource { SourceType = DataSourceType.JSONFile, SourceFile = _sourceFile, SourceVersion = Version }; } } public string Source @@ -663,6 +668,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON { private IDictionary<VectoComponents, IList<string>> _componentDigests = null; private DigestData _jobDigest = null; + private IXMLInputDataReader _inputReader; public JSONVTPInputDataV4(JObject data, string filename, bool tolerateMissing = false) : base( data, filename, tolerateMissing) @@ -671,6 +677,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON Path.Combine(Path.GetFullPath(BasePath), Body["DeclarationVehicle"].Value<string>())); VectoManufacturerReportHash = Body["ManufacturerRecord"] != null ? VectoHash.Load( Path.Combine(Path.GetFullPath(BasePath), Body["ManufacturerRecord"].Value<string>())) : null; + + var kernel = new StandardKernel(new VectoNinjectModule()); + _inputReader = kernel.Get<IXMLInputDataReader>(); } public IVTPEngineeringJobInputData JobInputData @@ -686,7 +695,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public IVehicleDeclarationInputData Vehicle { get { - return new XMLDeclarationInputDataProvider( + return _inputReader.CreateDeclaration( Path.Combine(Path.GetFullPath(BasePath), Body["DeclarationVehicle"].Value<string>()), true).JobInputData.Vehicle; } diff --git a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs index 522d802fc27312461cbb39a2b5c5b6b7abb8fff1..7bce4ac8bf3dbee908a981ea0a15fbdface89dd8 100644 --- a/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs +++ b/VectoCore/VectoCore/InputData/FileIO/JSON/JSONVehicleData.cs @@ -44,7 +44,7 @@ using TUGraz.VectoCore.Models.Declaration; namespace TUGraz.VectoCore.InputData.FileIO.JSON { public class JSONVehicleDataV7 : JSONFile, IVehicleEngineeringInputData, IRetarderInputData, IAngledriveInputData, - IPTOTransmissionInputData, IAirdragEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData + IPTOTransmissionInputData, IAirdragEngineeringInputData, IAdvancedDriverAssistantSystemDeclarationInputData, IVehicleComponentsDeclaration, IVehicleComponentsEngineering, IAxlesEngineeringInputData, IAxlesDeclarationInputData { public JSONVehicleDataV7(JObject data, string fileName, IJSONVehicleComponents job, bool tolerateMissing = false) : base(data, fileName, tolerateMissing) @@ -56,6 +56,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region IVehicleInputData + public string Identifier { get { return Path.GetFileNameWithoutExtension(_sourceFile); } } + public bool ExemptedVehicle { get { return false; } } public string VIN @@ -127,6 +129,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body["VehicleHeight"] == null ? null : Body.GetEx<double>("VehicleHeight").SI<Meter>(); } } + IVehicleComponentsEngineering IVehicleEngineeringInputData.Components + { + get { return this; } + } + + IAdvancedDriverAssistantSystemsEngineering IVehicleEngineeringInputData.ADAS + { + get { return null; } + } + public virtual AxleConfiguration AxleConfiguration { get { @@ -151,7 +163,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Body["IdlingSpeed"] != null ? Body.GetEx<double>("IdlingSpeed").RPMtoRad() : null; } } - IList<IAxleDeclarationInputData> IVehicleDeclarationInputData.Axles + IList<IAxleDeclarationInputData> IAxlesDeclarationInputData.AxlesDeclaration { get { return AxleWheels().Cast<IAxleDeclarationInputData>().ToList(); } } @@ -167,7 +179,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON ? axle.GetEx<string>("Type").ParseEnum<AxleType>() : (idx == 1 ? AxleType.VehicleDriven : AxleType.VehicleNonDriven), Tyre = new TyreInputData() { - SourceType = DataSourceType.JSONFile, + DataSource = new DataSource { + SourceType = DataSourceType.JSONFile, + SourceFile = Source, + SourceVersion = Version, + }, Source = Source, Inertia = axle.GetEx<double>(JsonKeys.Vehicle_Axles_Inertia).SI<KilogramSquareMeter>(), Dimension = axle.GetEx<string>(JsonKeys.Vehicle_Axles_Wheels), @@ -181,42 +197,42 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON #region "VehicleComponents" - IAirdragDeclarationInputData IVehicleDeclarationInputData.AirdragInputData + IAirdragDeclarationInputData IVehicleComponentsDeclaration.AirdragInputData { get { return this; } } - IAirdragEngineeringInputData IVehicleEngineeringInputData.AirdragInputData + IAirdragEngineeringInputData IVehicleComponentsEngineering.AirdragInputData { get { return this; } } - IGearboxDeclarationInputData IVehicleDeclarationInputData.GearboxInputData + IGearboxDeclarationInputData IVehicleComponentsDeclaration.GearboxInputData { get { return Job.Gearbox; } } - IGearboxEngineeringInputData IVehicleEngineeringInputData.GearboxInputData + IGearboxEngineeringInputData IVehicleComponentsEngineering.GearboxInputData { get { return Job.Gearbox; } } - ITorqueConverterDeclarationInputData IVehicleDeclarationInputData.TorqueConverterInputData + ITorqueConverterDeclarationInputData IVehicleComponentsDeclaration.TorqueConverterInputData { get { return Job.TorqueConverter; } } - ITorqueConverterEngineeringInputData IVehicleEngineeringInputData.TorqueConverterInputData + ITorqueConverterEngineeringInputData IVehicleComponentsEngineering.TorqueConverterInputData { get { return Job.TorqueConverter; } } - IAxleGearInputData IVehicleEngineeringInputData.AxleGearInputData + IAxleGearInputData IVehicleComponentsEngineering.AxleGearInputData { get { return Job.AxleGear; } } - IAngledriveInputData IVehicleEngineeringInputData.AngledriveInputData + IAngledriveInputData IVehicleComponentsEngineering.AngledriveInputData { get { return this; } } @@ -226,32 +242,42 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON get { return Job.Engine; } } - IAxleGearInputData IVehicleDeclarationInputData.AxleGearInputData + IAxleGearInputData IVehicleComponentsDeclaration.AxleGearInputData { get { return Job.AxleGear; } } - IAngledriveInputData IVehicleDeclarationInputData.AngledriveInputData + IAngledriveInputData IVehicleComponentsDeclaration.AngledriveInputData { get { return this; } } - IEngineDeclarationInputData IVehicleDeclarationInputData.EngineInputData + IEngineDeclarationInputData IVehicleComponentsDeclaration.EngineInputData { get { return Job.Engine; } } - IAuxiliariesDeclarationInputData IVehicleDeclarationInputData.AuxiliaryInputData() + IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData + { + get { return Job.DeclarationAuxiliaries; } + } + + IRetarderInputData IVehicleComponentsEngineering.RetarderInputData { - return Job.DeclarationAuxiliaries; + get { return this; } } - IRetarderInputData IVehicleEngineeringInputData.RetarderInputData + IPTOTransmissionInputData IVehicleComponentsEngineering.PTOTransmissionInputData { get { return this; } } - IPTOTransmissionInputData IVehicleEngineeringInputData.PTOTransmissionInputData + IAxlesEngineeringInputData IVehicleComponentsEngineering.AxleWheels + { + get { return this; } + } + + IAxlesDeclarationInputData IVehicleComponentsDeclaration.AxleWheels { get { return this; } } @@ -273,18 +299,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON public Watt MaxNetPower2 { get { return null; } } - IAuxiliariesEngineeringInputData IVehicleEngineeringInputData.AuxiliaryInputData() + IVehicleComponentsDeclaration IVehicleDeclarationInputData.Components + { + get { return this; } + } + + IAuxiliariesEngineeringInputData IVehicleComponentsEngineering.AuxiliaryInputData { - return Job.EngineeringAuxiliaries; + get { return Job.EngineeringAuxiliaries; } } - IRetarderInputData IVehicleDeclarationInputData.RetarderInputData + IRetarderInputData IVehicleComponentsDeclaration.RetarderInputData { get { return this; } } - IPTOTransmissionInputData IVehicleDeclarationInputData.PTOTransmissionInputData + IPTOTransmissionInputData IVehicleComponentsDeclaration.PTOTransmissionInputData { get { return this; } } @@ -521,5 +552,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON } } #endregion + + #region Implementation of IAxlesEngineeringInputData + + public IList<IAxleEngineeringInputData> AxlesEngineering { get; } + + #endregion } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/AbstractDeclarationXMLComponentDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/AbstractDeclarationXMLComponentDataProvider.cs deleted file mode 100644 index c935d2fe6b32f226a83961749081289e1e9c3ab5..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/AbstractDeclarationXMLComponentDataProvider.cs +++ /dev/null @@ -1,198 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using System.Collections.Generic; -using System.Linq; -using System.Xml; -using System.Xml.XPath; -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 abstract class AbstractDeclarationXMLComponentDataProvider - { - protected readonly XMLDeclarationInputDataProvider InputData; - protected XPathNavigator Navigator; - - protected string XBasePath = ""; - protected XmlNamespaceManager Manager; - - - protected readonly string VehiclePath; - - protected XPathHelper Helper; - - protected AbstractDeclarationXMLComponentDataProvider() {} - - protected AbstractDeclarationXMLComponentDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) - { - InputData = xmlInputDataProvider; - Navigator = xmlInputDataProvider.Document.CreateNavigator(); - Manager = new XmlNamespaceManager(Navigator.NameTable ?? new NameTable()); - Helper = new XPathHelper(ExecutionMode.Declaration); - Helper.AddNamespaces(Manager); - - SourceType = DataSourceType.Embedded; - - VehiclePath = Helper.QueryAbs( - Helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix), - XMLNames.Component_Vehicle - ); - } - - public string Source { get { return InputData.Source; } } - - public DataSourceType SourceType { get; protected set; } - - public virtual bool SavedInDeclarationMode - { - get { return true; } - } - - public virtual string Manufacturer - { - get { return GetElementValue(XMLNames.Component_Manufacturer); } - } - - public virtual string Model - { - get { return GetElementValue(XMLNames.Component_Model); } - } - - - public virtual string Date - { - get { return GetElementValue(XMLNames.Component_Date); } - } - - public virtual CertificationMethod CertificationMethod - { - get { - var value = GetElementValue(XMLNames.Component_CertificationMethod); - return value.ParseEnum<CertificationMethod>(); - } - } - - public virtual string CertificationNumber - { - get { return GetElementValue(XMLNames.Component_CertificationNumber); } - } - - public virtual DigestData DigestValue - { - get { return new DigestData(Navigator.SelectSingleNode(XBasePath + "/..", Manager)); } - } - - - protected bool ElementExists(string relativePath) - { - var path = Helper.Query(XBasePath, relativePath.Any() ? relativePath : null); - - var node = Navigator.SelectSingleNode(path, Manager); - return node != null; - } - - protected string GetElementValue(string relativePath) - { - var path = Helper.Query(XBasePath, relativePath.Any() ? relativePath : null); - - var node = Navigator.SelectSingleNode(path, Manager); - if (node == null) { - throw new VectoException("Node {0} not found in input data", path); - } - return node.InnerXml; - } - - protected string[] GetElementValues(string querypath) - { - var path = Helper.Query(XBasePath, querypath.Any() ? querypath : null); - - var nodes = Navigator.Select(path, Manager); - var retVal = new List<string>(); - while (nodes.MoveNext()) { - retVal.Add(nodes.Current.InnerXml); - } - - return retVal.ToArray(); - } - - protected double GetDoubleElementValue(string relativePath) - { - return GetElementValue(relativePath).ToDouble(); - } - - protected string GetAttributeValue(string relativePath, string attrName) - { - var nodes = - Navigator.Select(string.IsNullOrWhiteSpace(relativePath) ? XBasePath : Helper.Query(XBasePath, relativePath), - Manager); - if (nodes.Count == 0) { - return null; - } - nodes.MoveNext(); - return nodes.Current.GetAttribute(attrName, ""); - } - - protected TableData ReadTableData(Dictionary<string, string> attributeMapping, string relativePath, - XPathNavigator origin = null) - { - var startNode = origin ?? Navigator.SelectSingleNode(XBasePath, Manager); - if (startNode == null) { - throw new VectoException("start node for base-path {0} not found!", XBasePath); - } - var table = new TableData(); - foreach (var entry in attributeMapping) { - if (startNode.Select(Helper.Query(relativePath, "@" + entry.Value), Manager).Count == 0) { - continue; - } - table.Columns.Add(entry.Key); - } - var nodes = startNode.Select(relativePath, Manager); - while (nodes.MoveNext()) { - var row = table.NewRow(); - foreach (var attribute in attributeMapping) { - if (nodes.Current.SelectSingleNode("@" + attribute.Value) != null) { - row[attribute.Key] = nodes.Current.GetAttribute(attribute.Value, ""); - } - } - table.Rows.Add(row); - } - - return table; - } - } -} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractCommonComponentType.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractCommonComponentType.cs new file mode 100644 index 0000000000000000000000000000000000000000..bbea1649bb544ca9f0f89b6b696d8ee0da277fcd --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractCommonComponentType.cs @@ -0,0 +1,63 @@ +using System.Collections.Generic; +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { + public abstract class AbstractCommonComponentType : AbstractXMLResource + { + protected AbstractCommonComponentType(XmlNode node, string source) : base(node, source) { } + + public bool SavedInDeclarationMode + { + get { return true; } + } + + public string Manufacturer + { + get { return GetString(XMLNames.Component_Manufacturer); } + } + + public string Model + { + get { return GetString(XMLNames.Component_Model); } + } + + public string Date + { + get { return GetString(XMLNames.Component_Date); } + } + + public virtual CertificationMethod CertificationMethod + { + get { + var certMethod = GetString(XMLNames.Component_Gearbox_CertificationMethod, required:false) ?? GetString(XMLNames.Component_CertificationMethod, required:false); + return certMethod != null ? EnumHelper.ParseEnum<CertificationMethod>(certMethod) : CertificationMethod.Measured; + } + } + + protected TableData ReadTableData(string baseElement, string entryElement, Dictionary<string, string> mapping) + { + var entries = BaseNode.SelectNodes( + XMLHelper.QueryLocalName(baseElement, entryElement)); + if (entries != null && entries.Count > 0) { + return XMLHelper.ReadTableData(mapping, entries); + } + + return null; + } + + public virtual string CertificationNumber + { + get { return "N.A."; } + } + + public virtual DigestData DigestValue + { + get { return null; } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractXMLResource.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractXMLResource.cs new file mode 100644 index 0000000000000000000000000000000000000000..c3eb2ebb9ffe8b39a98d6f5503fd1858c51e851d --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractXMLResource.cs @@ -0,0 +1,27 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { + public abstract class AbstractXMLResource : AbstractXMLType, IXMLResource + { + protected string SourceFile; + + public AbstractXMLResource(XmlNode node, string source) : base(node) + { + SourceFile = source; + } + + public virtual DataSource DataSource + { + get { return new DataSource() { SourceFile = SourceFile, SourceVersion = SourceVersion, SourceType = SourceType }; } + } + + + protected string SourceVersion { get { return XMLHelper.GetVersionFromNamespaceUri(SchemaNamespace); } } + + protected abstract string SchemaNamespace { get; } + + protected abstract DataSourceType SourceType { get; } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractXMLType.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractXMLType.cs new file mode 100644 index 0000000000000000000000000000000000000000..3d41006f8c8e75ee25bd88851cdc005598c8bd9c --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/AbstractXMLType.cs @@ -0,0 +1,80 @@ +using System.Xml; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { + public abstract class AbstractXMLType + { + protected readonly XmlNode BaseNode; + + protected AbstractXMLType(XmlNode node) + { + BaseNode = node; + } + + protected bool ElementExists(string nodeName) + { + return GetNode(nodeName, BaseNode, required:false) != null; + } + + protected string GetString(string nodeName, XmlNode basenode = null, bool required = true) + { + return GetNode(nodeName, basenode, required)?.InnerText; + } + + protected double GetDouble(string nodeName, double? fallbackValue = null) + { + var node = GetNode(nodeName, required: fallbackValue != null); + + return node?.InnerText.ToDouble() ?? fallbackValue.Value; + } + + protected double GetDouble(string[] nodePath, double? fallbackValue = null) + { + var node = GetNode(nodePath, required: fallbackValue == null); + + return node?.InnerText.ToDouble() ?? fallbackValue.Value; + } + + protected bool GetBool(string nodeName) + { + return XmlConvert.ToBoolean(GetNode(nodeName).InnerText); + } + + protected XmlNode GetNode(string[] nodeName, XmlNode baseNode = null, bool required = true) + { + return DoGetNode(XMLHelper.QueryLocalName(nodeName), baseNode, required); + } + + protected XmlNode GetNode(string nodeName, XmlNode baseNode = null, bool required = true) + { + return DoGetNode(XMLHelper.QueryLocalName(nodeName), baseNode, required); + } + + private XmlNode DoGetNode(string xpathQuery, XmlNode baseNode, bool required) + { + var node = (baseNode ?? BaseNode)?.SelectSingleNode(xpathQuery); + if (required && node == null) { + throw new VectoException("Node {0} not found", xpathQuery); + } + + return node; + } + + protected XmlNodeList GetNodes(string nodeName, XmlNode baseNode = null) + { + return (baseNode ?? BaseNode).SelectNodes(XMLHelper.QueryLocalName(nodeName)); + } + + protected XmlNodeList GetNodes(string[] nodeName, XmlNode baseNode = null) + { + return (baseNode ?? BaseNode).SelectNodes(XMLHelper.QueryLocalName(nodeName)); + } + + protected string GetAttribute(XmlNode node, string attribute) + { + return node?.Attributes?.GetNamedItem(attribute)?.InnerText; + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..3c001b436f53135563b14093ca367572409e7010 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLAuxiliaryDeclarationDataProvider.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Xml; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLAuxiliaryDeclarationDataProviderV10 : AbstractXMLType, IXMLAuxiliaryDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + protected AuxiliaryType? _type; + private IList<string> _technology; + + public XMLAuxiliaryDeclarationDataProviderV10(XmlNode auxNode, IXMLDeclarationVehicleData vehicle) : base(auxNode) { } + + #region Implementation of IAuxiliaryDeclarationInputData + + public AuxiliaryType Type + { + get { + return _type ?? (_type = BaseNode.LocalName.ParseEnum<AuxiliaryType>()).Value; + } + } + + public IList<string> Technology + { + get { + if (_technology != null) { + return _technology; + } + + _technology = new List<string>(); + var techNodes = GetNodes(XMLNames.Auxiliaries_Auxiliary_Technology); + foreach (XmlNode techNode in techNodes) { + _technology.Add(techNode.InnerText); + } + + return _technology; + } + } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..0303045574034e6dd41b0175f565b34b1efa250c --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationADASDataProvider.cs @@ -0,0 +1,56 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationADASDataProviderV10 : AbstractCommonComponentType, + IXMLAdvancedDriverAssistantSystemDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + public XMLDeclarationADASDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) + : base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + } + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + + #region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData + + public bool EngineStopStart + { + get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ADAS_EngineStopStart)); } + } + + public bool EcoRollWitoutEngineStop + { + get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ADAS_EcoRollWithoutEngineStop)); } + } + + public bool EcoRollWithEngineStop + { + get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ADAS_EcoRollWithEngineStopStart)); } + } + + public PredictiveCruiseControlType PredictiveCruiseControl + { + get { return PredictiveCruiseControlTypeHelper.Parse(GetString(XMLNames.Vehicle_ADAS_PCC)); } + } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..75c8c99488ea9963092ceced97e1a18868ae2147 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAirdragDataProvider.cs @@ -0,0 +1,50 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationAirdragDataProviderV10 : AbstractCommonComponentType, IXMLAirdragDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + public XMLDeclarationAirdragDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + } + + #region Implementation of IAirdragDeclarationInputData + + public SquareMeter AirDragArea + { + get { + return ElementExists(XMLNames.AirDrag_DeclaredCdxA) + ? GetDouble(XMLNames.AirDrag_DeclaredCdxA).SI<SquareMeter>() + : null; + } + } + + public new CertificationMethod CertificationMethod + { + get { return CertificationMethod.Measured; } + } + + #endregion + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..92b6847892172da99a4ca84af7b0d1d8028adbfc --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAngledriveDataProvider.cs @@ -0,0 +1,66 @@ +using System.Collections.Generic; +using System.Xml; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationAngledriveDataProviderV10 : AbstractCommonComponentType, IXMLAngledriveInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + protected IXMLDeclarationVehicleData Vehicle; + + + public XMLDeclarationAngledriveDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + Vehicle = vehicle; + } + + #region Implementation of IAngledriveInputData + + public AngledriveType Type + { + get { return Vehicle.AngledriveType; } + } + + public double Ratio + { + get { return GetDouble(XMLNames.AngleDrive_Ratio); } + } + + public TableData LossMap + { + get { + return ReadTableData( + XMLNames.AngleDrive_TorqueLossMap, XMLNames.Angledrive_LossMap_Entry, + AttributeMappings.TransmissionLossmapMapping); + } + } + + public double Efficiency + { + get { throw new VectoException("Efficiency not supported in Declaration Mode!"); } + } + + #endregion + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..f6f23d39914979520cd3d10236441fc465669d8f --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAuxiliariesDataProvider.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +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 +{ + public class XMLDeclarationAuxiliariesDataProviderV10 : AbstractXMLType, IXMLAuxiliariesDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + protected IList<IAuxiliaryDeclarationInputData> _auxiliaries; + + + public XMLDeclarationAuxiliariesDataProviderV10( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(componentNode) { } + + #region Implementation of IAuxiliariesDeclarationInputData + + public bool SavedInDeclarationMode + { + get { return true; } + } + + public IList<IAuxiliaryDeclarationInputData> Auxiliaries + { + get { + if (_auxiliaries != null) { + return _auxiliaries; + } + + _auxiliaries = new List<IAuxiliaryDeclarationInputData>(); + //var auxNodes = GetNodes(XMLNames.Auxiliaries_Auxiliary); + var auxNodes = BaseNode.SelectNodes(XMLHelper.QueryLocalName(XMLNames.Auxiliaries_Auxiliary_Technology) + "/.."); + if (auxNodes == null) { + return _auxiliaries; + } + + foreach (XmlNode auxNode in auxNodes) { + _auxiliaries.Add(Reader.CreateAuxiliary(auxNode)); + } + + return _auxiliaries; + } + } + + #endregion + + #region Implementation of IXMLAuxiliariesDeclarationInputData + + public IXMLComponentReader Reader { protected get; set; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..af2db27e1922aad3daa1c75be894aaacb47607eb --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxleDataProvider.cs @@ -0,0 +1,66 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +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 +{ + public class XMLDeclarationAxleDataProviderV10 : AbstractCommonComponentType, IXMLAxleDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + private ITyreDeclarationInputData _tyre; + private bool? _twinTyre; + private AxleType? _axleType; + + public XMLDeclarationAxleDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + } + + #region Implementation of IAxleDeclarationInputData + + public bool TwinTyres + { + get { + return _twinTyre ?? (_twinTyre = XmlConvert.ToBoolean(GetString(XMLNames.AxleWheels_Axles_Axle_TwinTyres))).Value; + } + } + + public AxleType AxleType + { + get { + return _axleType ?? (_axleType = GetString(XMLNames.AxleWheels_Axles_Axle_AxleType).ParseEnum<AxleType>()).Value; + } + } + + public ITyreDeclarationInputData Tyre + { + get { return _tyre ?? (_tyre = Reader.Tyre); } + } + + #endregion + + + #region Implementation of IXMLAxleDeclarationInputData + + public IXMLComponentReader Reader { protected get; set; } + + #endregion + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..e9b9dfca67ede900979acd1614ccdda284ec6209 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlegearDataProvider.cs @@ -0,0 +1,64 @@ +using System.Xml; +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.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationAxlegearDataProviderV10 : AbstractCommonComponentType, IXMLAxleGearInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + public XMLDeclarationAxlegearDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + } + + #region Implementation of IAxleGearInputData + + public double Ratio + { + get { return GetDouble(XMLNames.Axlegear_Ratio); } + } + + public TableData LossMap + { + get { + return ReadTableData( + XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry, + AttributeMappings.TransmissionLossmapMapping); + } + } + + public double Efficiency + { + get { throw new VectoException("Efficiency not supported in Declaration Mode!"); } + } + + public AxleLineType LineType + { + get { + var value = GetString(XMLNames.Axlegear_LineType); + return value.ParseEnum<AxleLineType>(); + } + } + #endregion + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..a460257e7303af0a80c5356e4fc2acd7f9ec5870 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationAxlesDataProvider.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using System.Xml; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider { + public class XMLDeclarationAxlesDataProviderV10 : AbstractXMLType, IXMLAxlesDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + 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)}; } + + #region Implementation of IAxlesDeclarationInputData + + public IList<IAxleDeclarationInputData> AxlesDeclaration + { + get { + 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(); + if (axleNumber < 1 || axleNumber > _axles.Length) { + throw new VectoException("Axle #{0} exceeds axle count", axleNumber); + } + if (_axles[axleNumber - 1] != null) { + throw new VectoException("Axle #{0} defined multiple times!", axleNumber); + } + + _axles[axleNumber - 1] = Reader.CreateAxle(axlenode); + } + return _axles; + } + } + + #endregion + + #region Implementation of IXMLResource + + public DataSource DataSource { get; } + + #endregion + + #region Implementation of IXMLAxlesDeclarationInputData + + public IXMLComponentReader Reader { protected get; set; } + + #endregion + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..1c7f41f7bc7ba325767b38ecb383765af1faf8fe --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationComponentsDataProvider.cs @@ -0,0 +1,106 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; +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 +{ + public class XMLDeclarationComponentsDataProviderV10 : AbstractCommonComponentType, IXMLVehicleComponentsDeclaration + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + + protected IAirdragDeclarationInputData _airdragInputData; + protected IGearboxDeclarationInputData _gearboxInputData; + protected IAxleGearInputData _axleGearInputData; + protected IAngledriveInputData _angledriveInputData; + protected IEngineDeclarationInputData _engineInputData; + protected IAuxiliariesDeclarationInputData _auxInputData; + protected IRetarderInputData _retarderInputData; + protected IAxlesDeclarationInputData _axleWheels; + protected IPTOTransmissionInputData _ptoInputData; + protected IXMLDeclarationVehicleData _vehicle; + + + public XMLDeclarationComponentsDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + _vehicle = vehicle; + } + + #region Implementation of IVehicleComponentsDeclaration + + public IAirdragDeclarationInputData AirdragInputData + { + get { return _airdragInputData ?? (_airdragInputData = ComponentReader.AirdragInputData); } + } + + public IGearboxDeclarationInputData GearboxInputData + { + get { return _gearboxInputData ?? (_gearboxInputData = ComponentReader.GearboxInputData); } + } + + public ITorqueConverterDeclarationInputData TorqueConverterInputData + { + get { return GearboxInputData.TorqueConverter; } + } + + public IAxleGearInputData AxleGearInputData + { + get { return _axleGearInputData ?? (_axleGearInputData = ComponentReader.AxleGearInputData); } + } + + public IAngledriveInputData AngledriveInputData + { + get { return _angledriveInputData ?? (_angledriveInputData = ComponentReader.AngledriveInputData); } + } + + public IEngineDeclarationInputData EngineInputData + { + get { return _engineInputData ?? (_engineInputData = ComponentReader.EngineInputData); } + } + + IAuxiliariesDeclarationInputData IVehicleComponentsDeclaration.AuxiliaryInputData + { + get { return _auxInputData ?? (_auxInputData = ComponentReader.AuxiliaryData); } + } + + public IRetarderInputData RetarderInputData + { + get { return _retarderInputData ?? (_retarderInputData = ComponentReader.RetarderInputData); } + } + + public IPTOTransmissionInputData PTOTransmissionInputData + { + get { return _vehicle.PTOTransmissionInputData; } + } + + public IAxlesDeclarationInputData AxleWheels + { + get { return _axleWheels ?? (_axleWheels = ComponentReader.AxlesDeclarationInputData); } + } + + #endregion + + #region Implementation of IXMLVehicleComponentsDeclaration + + public IXMLComponentReader ComponentReader { protected get; set; } + + + #endregion + + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..0f4d66e78a3f319cc224b51546ab4e021ce77aef --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationEngineDataProvider.cs @@ -0,0 +1,117 @@ +using System; +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.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationEngineDataProviderV10 : AbstractCommonComponentType, IXMLEngineDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + public XMLDeclarationEngineDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + } + + #region Implementation of IEngineDeclarationInputData + + public CubicMeter Displacement + { + get { return GetDouble(XMLNames.Engine_Displacement).SI(Unit.SI.Cubic.Centi.Meter).Cast<CubicMeter>(); } + } + + public PerSecond IdleSpeed + { + get { return GetDouble(XMLNames.Engine_IdlingSpeed).RPMtoRad(); } + } + + public FuelType FuelType + { + get { + var value = GetString(XMLNames.Engine_FuelType); + if ("LPG".Equals(value, StringComparison.InvariantCultureIgnoreCase)) { + return FuelType.LPGPI; + } + if ("NG".Equals(value, StringComparison.InvariantCultureIgnoreCase)) { + return FuelType.NGPI; + } + + return value.ParseEnum<FuelType>(); + } + } + + public TableData FuelConsumptionMap + { + get { + return ReadTableData(XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry, AttributeMappings.FuelConsumptionMapMapping); + } + } + + public TableData FullLoadCurve + { + get { + return ReadTableData(XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FullLoadCurve_Entry, AttributeMappings.EngineFullLoadCurveMapping); + } + } + + public Watt RatedPowerDeclared + { + get { return GetDouble(XMLNames.Engine_RatedPower).SI<Watt>(); } + } + + public PerSecond RatedSpeedDeclared + { + get { return GetDouble(XMLNames.Engine_RatedSpeed).RPMtoRad(); } + } + + public NewtonMeter MaxTorqueDeclared + { + get { return GetDouble(XMLNames.Engine_MaxTorque).SI<NewtonMeter>(); } + } + + public double WHTCMotorway + { + get { return GetDouble(XMLNames.Engine_WHTCMotorway); } + } + + public double WHTCRural + { + get { return GetDouble(XMLNames.Engine_WHTCRural); } + } + + public double WHTCUrban + { + get { return GetDouble(XMLNames.Engine_WHTCUrban); } + } + + public double ColdHotBalancingFactor + { + get { return GetDouble(XMLNames.Engine_ColdHotBalancingFactor); } + } + + public double CorrectionFactorRegPer + { + get { return GetDouble(XMLNames.Engine_CorrectionFactor_RegPer); } + } + + #endregion + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..02bb69008f715e78b4f9671aa2ad3c737929c8f4 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationGearboxDataProvider.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +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 +{ + public class XMLDeclarationGearboxDataProviderV10 : AbstractCommonComponentType, IXMLGearboxDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + protected ITorqueConverterDeclarationInputData _torqueConverter; + private IList<ITransmissionInputData> _gears; + + public XMLDeclarationGearboxDataProviderV10( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + base(componentNode, sourceFile) { } + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType + { + get { return DataSourceType.XMLFile; } + } + + #endregion + + #region Implementation of IGearboxDeclarationInputData + + public GearboxType Type + { + get { + var value = GetString(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 { + if (_gears != null) { + return _gears; + } + _gears = new List<ITransmissionInputData>(); + + var gearNodes = GetNodes(new[] { XMLNames.Gearbox_Gears, XMLNames.Gearbox_Gears_Gear }); + if (gearNodes != null) { + foreach (XmlNode gearNode in gearNodes) { + _gears.Add(Reader.CreateGear(gearNode)); + } + } + + return _gears; + } + } + + public ITorqueConverterDeclarationInputData TorqueConverter { get { + return _torqueConverter ?? (_torqueConverter = Reader.TorqueConverterInputData); + } } + + #endregion + + #region Implementation of IXMLGearboxDeclarationInputData + + public IXMLComponentReader Reader { protected get; set; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs similarity index 53% rename from VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationInputDataProvider.cs rename to VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs index 7db6853fe18707db6bd8fa783308c3dd5f8db8db..e4b4cb65b419294a1ee9f480231577cca109171d 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationInputDataProvider.cs @@ -1,102 +1,86 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using System; -using System.IO; -using System.Xml; -using System.Xml.Linq; -using System.Xml.Schema; -using System.Xml.XPath; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCore.Utils; -using TUGraz.VectoHashing; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration -{ - public class XMLDeclarationInputDataProvider : IDeclarationInputDataProvider - { - internal readonly XPathDocument Document; - - private readonly XMLDeclarationJobInputDataProvider _xmlJobData; - - - public XMLDeclarationInputDataProvider(string filename, bool verifyXml) : - this(XmlReader.Create(filename), filename, verifyXml) - { - } - - public XMLDeclarationInputDataProvider(XmlReader inputData, bool verifyXml) : this(inputData, "", verifyXml) - { - - } - - protected XMLDeclarationInputDataProvider(XmlReader inputData, string source, bool verifyXml) - { - Source = source; - var xmldoc = new XmlDocument(); - xmldoc.Load(inputData); - - if (verifyXml) { - new XMLValidator(xmldoc, null, ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType.DeclarationJobData); - } - - var h = VectoHash.Load(xmldoc); - XMLHash = h.ComputeXmlHash(); - Document = new XPathDocument(new XmlNodeReader(xmldoc)); - - _xmlJobData = new XMLDeclarationJobInputDataProvider(this); - } - - public string Source { get; protected set; } - - private static void ValidationCallBack(XmlSeverityType severity, ValidationEvent evt) - { - if (severity == XmlSeverityType.Error) { - var args = evt.ValidationEventArgs; - throw new VectoException("Validation error: {0}" + Environment.NewLine + - "Line: {1}", args.Message, args.Exception.LineNumber); - } - } - - public IDeclarationJobInputData JobInputData - { - get { return _xmlJobData; } - } - - public XMLDeclarationJobInputDataProvider XMLJob - { - get { return _xmlJobData; } - } - - public XElement XMLHash { get; private set; } - } -} +/* +* This file is part of VECTO. +* +* Copyright © 2012-2019 European Union +* +* Developed by Graz University of Technology, +* Institute of Internal Combustion Engines and Thermodynamics, +* Institute of Technical Informatics +* +* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +* by the European Commission - subsequent versions of the EUPL (the "Licence"); +* You may not use VECTO except in compliance with the Licence. +* You may obtain a copy of the Licence at: +* +* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +* +* Unless required by applicable law or agreed to in writing, VECTO +* distributed under the Licence is distributed on an "AS IS" basis, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the Licence for the specific language governing permissions and +* limitations under the Licence. +* +* Authors: +* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +*/ + +using System; +using System.IO; +using System.Xml; +using System.Xml.Linq; +using System.Xml.Schema; +using System.Xml.XPath; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; +using TUGraz.VectoHashing; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration +{ + public class XMLDeclarationInputDataProviderV10 : AbstractXMLResource, IXMLDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + internal readonly XmlDocument Document; + protected IDeclarationJobInputData JobData; + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace { get { return NAMESPACE_URI; } } + protected override DataSourceType SourceType { get; } + + #endregion + + #region Implementation of IXMLDeclarationInputData + + public IXMLDeclarationInputDataReader Reader { protected get; set; } + + #endregion + + public XMLDeclarationInputDataProviderV10(XmlDocument xmlDoc, string fileName) : base(xmlDoc.DocumentElement, fileName) + { + Document = xmlDoc; + SourceType = DataSourceType.XMLFile; + } + + + public IDeclarationJobInputData JobInputData + { + get { return JobData ?? (JobData = Reader.JobData); } + } + + + public XElement XMLHash { get; private set; } + + + + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..243b6597a2a3cf163dc102b9d3951a34e396598e --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationJobInputDataProvider.cs @@ -0,0 +1,58 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; +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 +{ + public class XMLDeclarationJobInputDataProviderV10 : AbstractXMLResource, IXMLDeclarationJobInputData + { + private IVehicleDeclarationInputData _vehicle; + + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + public XMLDeclarationJobInputDataProviderV10(XmlNode node, IXMLDeclarationInputData inputProvider, string fileName) : + base(node, fileName) + { + InputData = inputProvider; + } + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType + { + get { return DataSourceType.XMLFile; } + } + + #endregion + + #region Implementation of IDeclarationJobInputData + + public bool SavedInDeclarationMode + { + get { return true; } + } + + public IVehicleDeclarationInputData Vehicle + { + get { return _vehicle ?? (_vehicle = Reader.CreateVehicle); } + } + + public string JobName { get { return Vehicle.Identifier; } } + + #endregion + + #region Implementation of IXMLDeclarationJobInputData + + public IXMLJobDataReader Reader { protected get; set; } + public IXMLDeclarationInputData InputData { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..2cec1dfb05a7ae15b5d47237fccebac31b7ca5d2 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationPTODataProvider.cs @@ -0,0 +1,54 @@ +using System; +using System.Linq; +using System.Xml; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationPTODataProviderV10 : AbstractXMLType, IXMLPTOTransmissionInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + public XMLDeclarationPTODataProviderV10( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : base(componentNode) { } + + + #region Implementation of IPTOTransmissionInputData + + public virtual string PTOTransmissionType + { + get { + var shaftGearWheels = GetString(XMLNames.Vehicle_PTO_ShaftsGearWheels); + if ("none".Equals(shaftGearWheels, StringComparison.InvariantCultureIgnoreCase)) { + return "None"; + } + 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); + } + } + + public virtual TableData PTOLossMap + { + get { return null; } + } + + public virtual TableData PTOCycle + { + get { return null; } + } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..fb091d2f34022b8e1ff2cadfc59e1d91541847be --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationRetarderDataProvider.cs @@ -0,0 +1,56 @@ +using System.Xml; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationRetarderDataProviderV10 : AbstractCommonComponentType, IXMLRetarderInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + protected IXMLDeclarationVehicleData Vehicle; + + public XMLDeclarationRetarderDataProviderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + Vehicle = vehicle; + } + + #region Implementation of IRetarderInputData + + public RetarderType Type + { + get { return Vehicle.RetarderType; } + } + + public double Ratio + { + get { return Vehicle.RetarderRatio; } + } + + public TableData LossMap + { + get { + return ReadTableData(XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry, AttributeMappings.RetarderLossmapMapping); + } + } + + #endregion + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..d3935aff1370a357d0ba589ea73bdcf9670ddfe4 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTorqueConverterDataProvider.cs @@ -0,0 +1,46 @@ +using System.Xml; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationTorqueConverterDataProviderV10 : AbstractCommonComponentType, + IXMLTorqueConverterDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + public XMLDeclarationTorqueConverterDataProviderV10( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + } + + #region Implementation of ITorqueconverterDeclarationInputData + + public TableData TCData + { + get { + return ReadTableData( + XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry, + AttributeMappings.TorqueConverterDataMapping); + } + } + + #endregion + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..e419cde543e7e3d799aa9dfd3e1069a68cb27128 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationTyreDataProvider.cs @@ -0,0 +1,55 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationTyreDataProviderV10 : AbstractCommonComponentType, IXMLTyreDeclarationInputData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + private string _dimension; + private double? _rrc; + private Newton _fzIso; + + public XMLDeclarationTyreDataProviderV10( + IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile) : + base(componentNode, sourceFile) + { + SourceType = DataSourceType.XMLFile; + } + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + + #region Implementation of ITyreDeclarationInputData + + public string Dimension + { + get { return _dimension ?? (_dimension = GetString(XMLNames.AxleWheels_Axles_Axle_Dimension)); } + } + + public double RollResistanceCoefficient + { + get { return _rrc ?? (_rrc = GetDouble(XMLNames.AxleWheels_Axles_Axle_RRCDeclared)).Value; } + } + + public Newton TyreTestLoad + { + get { return _fzIso ?? (_fzIso = GetDouble(XMLNames.AxleWheels_Axles_Axle_FzISO).SI<Newton>()); } + } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..d7a4da5738ca25b64a68ed0a519a8d3b82227090 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLDeclarationVehicleDataProvider.cs @@ -0,0 +1,259 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2019 European Union +* +* Developed by Graz University of Technology, +* Institute of Internal Combustion Engines and Thermodynamics, +* Institute of Technical Informatics +* +* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +* by the European Commission - subsequent versions of the EUPL (the "Licence"); +* You may not use VECTO except in compliance with the Licence. +* You may obtain a copy of the Licence at: +* +* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +* +* Unless required by applicable law or agreed to in writing, VECTO +* distributed under the Licence is distributed on an "AS IS" basis, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the Licence for the specific language governing permissions and +* limitations under the Licence. +* +* Authors: +* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; +using TUGraz.VectoCore.InputData.Impl; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public class XMLDeclarationVehicleDataProviderV10 : AbstractCommonComponentType, IXMLDeclarationVehicleData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + public IXMLComponentReader ComponentReader { protected get; set; } + + public IXMLPTOReader PTOReader { protected get; set; } + + public IXMLADASReader ADASReader { protected get; set; } + + private IVehicleComponentsDeclaration _components; + private IPTOTransmissionInputData _ptoData; + + + public XMLDeclarationVehicleDataProviderV10(IXMLDeclarationJobInputData jobData, XmlNode xmlNode, string sourceFile) + : base(xmlNode, sourceFile) + { + Job = jobData; + SourceType = DataSourceType.XMLFile; + } + + public IXMLDeclarationJobInputData Job { get; } + + public string Identifier + { + get { return GetAttribute(BaseNode, XMLNames.Component_ID_Attr); } + } + + public bool ExemptedVehicle + { + get { return ElementExists(XMLNames.Vehicle_HybridElectricHDV) && ElementExists(XMLNames.Vehicle_DualFuelVehicle); } + } + + public string VIN + { + get { return GetString(XMLNames.Vehicle_VIN); } + } + + public LegislativeClass LegislativeClass + { + get { return GetString(XMLNames.Vehicle_LegislativeClass).ParseEnum<LegislativeClass>(); } + } + + public VehicleCategory VehicleCategory + { + get { + var val = GetString(XMLNames.Vehicle_VehicleCategory); + if ("Rigid Lorry".Equals(val, StringComparison.InvariantCultureIgnoreCase)) { + return VehicleCategory.RigidTruck; + } + + return val.ParseEnum<VehicleCategory>(); + } + } + + public Kilogram CurbMassChassis + { + get { return GetDouble(XMLNames.Vehicle_CurbMassChassis).SI<Kilogram>(); } + } + + + public Kilogram GrossVehicleMassRating + { + get { return GetDouble(XMLNames.Vehicle_GrossVehicleMass).SI<Kilogram>(); } + } + + public IList<ITorqueLimitInputData> TorqueLimits + { + get { + var retVal = new List<ITorqueLimitInputData>(); + var limits = GetNodes(new[] { XMLNames.Vehicle_TorqueLimits, XMLNames.Vehicle_TorqueLimits_Entry }); + foreach (XmlNode current in limits) { + if (current.Attributes != null) { + retVal.Add( + new TorqueLimitInputData() { + Gear = GetAttribute(current, XMLNames.Vehicle_TorqueLimits_Entry_Gear_Attr).ToInt(), + MaxTorque = GetAttribute(current, XMLNames.Vehicle_TorqueLimits_Entry_MaxTorque_Attr) + .ToDouble().SI<NewtonMeter>() + }); + } + } + + return retVal; + } + } + + public AxleConfiguration AxleConfiguration + { + get { return AxleConfigurationHelper.Parse(GetString(XMLNames.Vehicle_AxleConfiguration)); } + } + + public string ManufacturerAddress + { + get { return GetString(XMLNames.Component_ManufacturerAddress); } + } + + public PerSecond EngineIdleSpeed + { + get { return GetDouble(XMLNames.Vehicle_IdlingSpeed).RPMtoRad(); } + } + + public double RetarderRatio + { + get { return GetDouble(XMLNames.Vehicle_RetarderRatio); } + } + + public IPTOTransmissionInputData PTOTransmissionInputData + { + get { return _ptoData ?? (_ptoData = PTOReader.PTOInputData); } + } + + public RetarderType RetarderType + { + get { + var value = GetString(XMLNames.Vehicle_RetarderType); //.ParseEnum<RetarderType>(); + switch (value) { + case "None": return RetarderType.None; + case "Losses included in Gearbox": return RetarderType.LossesIncludedInTransmission; + case "Engine Retarder": return RetarderType.EngineRetarder; + case "Transmission Input Retarder": return RetarderType.TransmissionInputRetarder; + case "Transmission Output Retarder": return RetarderType.TransmissionOutputRetarder; + } + + throw new ArgumentOutOfRangeException("RetarderType", value); + } + } + + public AngledriveType AngledriveType + { + get { return GetString(XMLNames.Vehicle_AngledriveType).ParseEnum<AngledriveType>(); } + } + + public bool VocationalVehicle + { + get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_VocationalVehicle)); } + } + + public bool SleeperCab + { + get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_SleeperCab)); } + } + + public TankSystem? TankSystem + { + get { + return ElementExists(XMLNames.Vehicle_NgTankSystem) + ? EnumHelper.ParseEnum<TankSystem>(GetString(XMLNames.Vehicle_NgTankSystem)) + : (TankSystem?)null; + } + } + + public IAdvancedDriverAssistantSystemDeclarationInputData ADAS + { + get { return ADASReader.ADASInputData; } + } + + public bool ZeroEmissionVehicle + { + get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_ZeroEmissionVehicle)); } + } + + public bool HybridElectricHDV + { + get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_HybridElectricHDV)); } + } + + public bool DualFuelVehicle + { + get { return XmlConvert.ToBoolean(GetString(XMLNames.Vehicle_DualFuelVehicle)); } + } + + public Watt MaxNetPower1 + { + get { + return ElementExists(XMLNames.Vehicle_MaxNetPower1) + ? GetDouble(XMLNames.Vehicle_MaxNetPower1).SI<Watt>() + : null; + } + } + + public Watt MaxNetPower2 + { + get { + return ElementExists(XMLNames.Vehicle_MaxNetPower2) + ? GetDouble(XMLNames.Vehicle_MaxNetPower2).SI<Watt>() + : null; + } + } + + public IVehicleComponentsDeclaration Components + { + get { return _components ?? (_components = ComponentReader.ComponentInputData); } + } + + #region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData + + + #endregion + + #region Overrides of AbstractXMLResource + + protected override string SchemaNamespace + { + get { return NAMESPACE_URI; } + } + + protected override DataSourceType SourceType { get; } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs new file mode 100644 index 0000000000000000000000000000000000000000..bec7194a75ba9e83db0c6a40aa5d859857250957 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/DataProvider/XMLGearData.cs @@ -0,0 +1,70 @@ +using System.Xml; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider +{ + public abstract class XMLAbstractGearData : AbstractXMLType + { + protected TableData _lossmap; + + protected XMLAbstractGearData(XmlNode gearNode) : base(gearNode) { } + + #region Implementation of ITransmissionInputData + + public virtual int Gear + { + get { + return XmlConvert.ToUInt16( + BaseNode.Attributes?.GetNamedItem(XMLNames.Gearbox_Gear_GearNumber_Attr).InnerText ?? "0"); + } + } + + public virtual double Ratio + { + get { return GetString(XMLNames.Gearbox_Gear_Ratio).ToDouble(double.NaN); } + } + + public virtual TableData LossMap + { + get { + return _lossmap ?? (_lossmap = XMLHelper.ReadTableData( + AttributeMappings.TransmissionLossmapMapping, + GetNodes(new[] { XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry }))); + } + } + + public virtual double Efficiency + { + get { return double.NaN; } + } + + public virtual NewtonMeter MaxTorque + { + get { return GetNode(XMLNames.Gearbox_Gears_MaxTorque, required: false)?.InnerText.ToDouble().SI<NewtonMeter>(); } + } + + public virtual PerSecond MaxInputSpeed + { + get { return GetNode(XMLNames.Gearbox_Gear_MaxSpeed, required: false)?.InnerText.ToDouble().RPMtoRad(); } + } + + public virtual TableData ShiftPolygon + { + get { return null; } + } + + #endregion + } + + public class XMLGearDataV10 : XMLAbstractGearData, IXMLGearData + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + public XMLGearDataV10(XmlNode gearNode) : base(gearNode) { } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Factory/IDeclarationInjectFactory.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Factory/IDeclarationInjectFactory.cs new file mode 100644 index 0000000000000000000000000000000000000000..0b6009740785bfdd526f46fc8989b8237c92a005 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Factory/IDeclarationInjectFactory.cs @@ -0,0 +1,89 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory +{ + public interface IDeclarationInjectFactory + { + /* + * Ninject automatically creates a factory class for this interface + * + * the first argument is used to lookup the named binding for the required return type, the remaining + * parameters are the constructor arguments + * + */ + + IXMLDeclarationInputData CreateInputProvider(string version, XmlDocument xmlDoc, string fileName); + + IXMLDeclarationJobInputData CreateJobData( + string version, XmlNode node, IXMLDeclarationInputData inputProvider, string fileName); + + IXMLDeclarationVehicleData CreateVehicleData( + string version, IXMLDeclarationJobInputData jobData, XmlNode xmlNode, string sourceFile); + + IXMLVehicleComponentsDeclaration CreateComponentData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + + IXMLAirdragDeclarationInputData CreateAirdragData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLGearboxDeclarationInputData CreateGearboxData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLGearData CreateGearData(string version, XmlNode gearNode); + + + IXMLTorqueConverterDeclarationInputData CreateTorqueconverterData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLAxleGearInputData CreateAxlegearData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLAngledriveInputData CreateAngledriveData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLEngineDeclarationInputData CreateEngineData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLRetarderInputData CreateRetarderData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLAuxiliariesDeclarationInputData CreateAuxiliariesData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLPTOTransmissionInputData CreatePTOData( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLAxlesDeclarationInputData CreateAxleWheels(string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLAxleDeclarationInputData CreateAxleData(string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLTyreDeclarationInputData CreateTyre(string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + IXMLAuxiliaryDeclarationInputData CreateAuxiliaryData(string version, XmlNode auxNode, IXMLDeclarationVehicleData vehicle); + + IXMLAdvancedDriverAssistantSystemDeclarationInputData CreateADASData(string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, string sourceFile); + + + // --------------------------------------------------------------------------------------------- + + IXMLDeclarationInputDataReader CreateInputReader( + string version, IXMLDeclarationInputData inputData, XmlNode baseNode, bool verifyXML); + + IXMLJobDataReader CreateJobReader( + string version, IXMLDeclarationJobInputData jobData, XmlNode jobNode, bool verifyXML); + + IXMLComponentReader CreateComponentReader( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentsNode, bool verifyXML); + + IXMLADASReader CreateADASReader( + string version, IXMLDeclarationVehicleData vehicle, XmlNode vehicleNode, bool verifyXML); + + IXMLPTOReader CreatePTOReader( + string version, IXMLDeclarationVehicleData vehicle, XmlNode componentNode, bool verifyXML); + } + +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/IXMLDeclarationInputDataReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/IXMLDeclarationInputDataReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..cc0921b0ee696de8ea7974484597a72b96ac3265 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/IXMLDeclarationInputDataReader.cs @@ -0,0 +1,9 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration +{ + public interface IXMLDeclarationInputDataReader + { + IDeclarationJobInputData JobData { get; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAirdragDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAirdragDeclarationInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..3473976a14775a3d75dc089f1f474e7f51282444 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAirdragDeclarationInputData.cs @@ -0,0 +1,6 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLAirdragDeclarationInputData : IAirdragDeclarationInputData, IXMLResource { } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAngledriveInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAngledriveInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..25a159171904c1e95c562359744f153a4dd31eac --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAngledriveInputData.cs @@ -0,0 +1,6 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLAngledriveInputData : IAngledriveInputData, IXMLResource { } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAuxiliariesDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAuxiliariesDeclarationInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..7af8c927b9cc0b40f3aa833668dee834c9abb74d --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAuxiliariesDeclarationInputData.cs @@ -0,0 +1,15 @@ +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLAuxiliariesDeclarationInputData : IAuxiliariesDeclarationInputData + { + IXMLComponentReader Reader { set; } + } + + public interface IXMLAuxiliaryDeclarationInputData : IAuxiliaryDeclarationInputData + { + + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAxleDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAxleDeclarationInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..999e0cd8591bfa6a3b12db04bb4f8e3c72864878 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAxleDeclarationInputData.cs @@ -0,0 +1,9 @@ +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces { + public interface IXMLAxleDeclarationInputData : IAxleDeclarationInputData, IXMLResource + { + IXMLComponentReader Reader { set; } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAxleGearInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAxleGearInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..abc809e0218e211aa8af88801a451dc989329de4 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAxleGearInputData.cs @@ -0,0 +1,6 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLAxleGearInputData : IAxleGearInputData, IXMLResource { } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAxlesDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAxlesDeclarationInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..081e165b930edacfb7125e5fc20621ed46fabde1 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLAxlesDeclarationInputData.cs @@ -0,0 +1,9 @@ +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces { + public interface IXMLAxlesDeclarationInputData : IAxlesDeclarationInputData, IXMLResource + { + IXMLComponentReader Reader { set; } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLDeclarationInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..074178188367155536473846cbd6e77cb06d1429 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLDeclarationInputData.cs @@ -0,0 +1,9 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLDeclarationInputData : IDeclarationInputDataProvider, IXMLResource + { + IXMLDeclarationInputDataReader Reader { set; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLDeclarationJobInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLDeclarationJobInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..671e52b5ecf2ec26594fdcc76cb24f21090eec2f --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLDeclarationJobInputData.cs @@ -0,0 +1,12 @@ +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLDeclarationJobInputData : IDeclarationJobInputData, IXMLResource + { + IXMLJobDataReader Reader { set; } + + IXMLDeclarationInputData InputData { get; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLDeclarationVehicleData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLDeclarationVehicleData.cs new file mode 100644 index 0000000000000000000000000000000000000000..9e35e4c5a8c747b75d8597340d7b4233d413943a --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLDeclarationVehicleData.cs @@ -0,0 +1,24 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLDeclarationVehicleData : IVehicleDeclarationInputData, IXMLResource + { + IXMLComponentReader ComponentReader { set; } + + IXMLPTOReader PTOReader { set; } + + IXMLADASReader ADASReader { set; } + + AngledriveType AngledriveType { get; } + + RetarderType RetarderType { get; } + + double RetarderRatio { get; } + IPTOTransmissionInputData PTOTransmissionInputData { get; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLEngineDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLEngineDeclarationInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..667267e920c8b05a59a20f17e54049b99931abd2 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLEngineDeclarationInputData.cs @@ -0,0 +1,6 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLEngineDeclarationInputData : IEngineDeclarationInputData, IXMLResource { } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLGearData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLGearData.cs new file mode 100644 index 0000000000000000000000000000000000000000..c4a119022b2396a7dd1c42715ddfaa9b29748d05 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLGearData.cs @@ -0,0 +1,5 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces { + public interface IXMLGearData : ITransmissionInputData { } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLGearboxDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLGearboxDeclarationInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..51ac9f0415f7bb3c1cd7d84748692526cacc0e1b --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLGearboxDeclarationInputData.cs @@ -0,0 +1,10 @@ +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLGearboxDeclarationInputData : IGearboxDeclarationInputData, IXMLResource + { + IXMLComponentReader Reader { set; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLPTOTransmissionInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLPTOTransmissionInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..212e663c2b9a25f332c3cbe33c12be2d8fe70143 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLPTOTransmissionInputData.cs @@ -0,0 +1,6 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLPTOTransmissionInputData : IPTOTransmissionInputData { } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLRetarderInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLRetarderInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..eeca03652a2bd7425505748ae8fa9d21d581a87c --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLRetarderInputData.cs @@ -0,0 +1,6 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLRetarderInputData : IRetarderInputData, IXMLResource { } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLTorqueConverterDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLTorqueConverterDeclarationInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..6fece7ebb74d92ef8e3d9974168304b6c7fb19a2 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLTorqueConverterDeclarationInputData.cs @@ -0,0 +1,6 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLTorqueConverterDeclarationInputData : ITorqueConverterDeclarationInputData, IXMLResource { } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLTyreDeclarationInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLTyreDeclarationInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..a5f7e52a0b96a95c014c81e9098a1f7d2cb506fc --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLTyreDeclarationInputData.cs @@ -0,0 +1,6 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLTyreDeclarationInputData : ITyreDeclarationInputData, IXMLResource { } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLVehicleComponentsDeclaration.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLVehicleComponentsDeclaration.cs new file mode 100644 index 0000000000000000000000000000000000000000..c93fa26c9a15b9ec71b7c3e749fb93a509d87726 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Interfaces/IXMLVehicleComponentsDeclaration.cs @@ -0,0 +1,18 @@ +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces +{ + public interface IXMLVehicleComponentsDeclaration : IVehicleComponentsDeclaration, IXMLResource + { + IXMLComponentReader ComponentReader { set; } + + //IXMLADASReader ADASReader { set; } + + //IXMLPTOReader PTOReader { set; } + } + + public interface IXMLAdvancedDriverAssistantSystemDeclarationInputData : + IAdvancedDriverAssistantSystemDeclarationInputData, + IXMLResource { } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV10InjectModule.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV10InjectModule.cs new file mode 100644 index 0000000000000000000000000000000000000000..42413b15650cf7b214d88a05ea4f13019d43ef04 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/NinjectModules/XMLDeclarationInputDataV10InjectModule.cs @@ -0,0 +1,93 @@ +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; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules +{ + public class XMLDeclarationInputDataV10InjectModule : NinjectModule + { + #region Overrides of NinjectModule + + public override void Load() + { + Bind<IXMLDeclarationInputData>().To<XMLDeclarationInputDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationInputDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLDeclarationJobInputData>().To<XMLDeclarationJobInputDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationJobInputDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLDeclarationVehicleData>().To<XMLDeclarationVehicleDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationVehicleDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLVehicleComponentsDeclaration>().To<XMLDeclarationComponentsDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationComponentsDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLAirdragDeclarationInputData>().To<XMLDeclarationAirdragDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationAirdragDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLAngledriveInputData>().To<XMLDeclarationAngledriveDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationAngledriveDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLAxleGearInputData>().To<XMLDeclarationAxlegearDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationAxlegearDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLEngineDeclarationInputData>().To<XMLDeclarationEngineDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationEngineDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLRetarderInputData>().To<XMLDeclarationRetarderDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationRetarderDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLGearboxDeclarationInputData>().To<XMLDeclarationGearboxDataProviderV10>() + .Named(XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationGearboxDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLGearData>().To<XMLGearDataV10>().Named(XMLHelper.GetVersionFromNamespaceUri(XMLGearDataV10.NAMESPACE_URI)); + + Bind<IXMLTorqueConverterDeclarationInputData>().To<XMLDeclarationTorqueConverterDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationTorqueConverterDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLAxlesDeclarationInputData>().To<XMLDeclarationAxlesDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationAxlesDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLAxleDeclarationInputData>().To<XMLDeclarationAxleDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationAxleDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLTyreDeclarationInputData>().To<XMLDeclarationTyreDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationTyreDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLAuxiliariesDeclarationInputData>().To<XMLDeclarationAuxiliariesDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationAuxiliariesDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLAuxiliaryDeclarationInputData>().To<XMLAuxiliaryDeclarationDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLAuxiliaryDeclarationDataProviderV10.NAMESPACE_URI)); + + Bind<IXMLPTOTransmissionInputData>().To<XMLDeclarationPTODataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationPTODataProviderV10.NAMESPACE_URI)); + + Bind<IXMLAdvancedDriverAssistantSystemDeclarationInputData>() + .To<XMLDeclarationADASDataProviderV10>().Named( + XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationADASDataProviderV10.NAMESPACE_URI)); + + // --------------------------------------------------------------------------------------- + + Bind<IXMLDeclarationInputDataReader>().To<XMLDeclarationInputReaderV10>() + .Named(XMLHelper.GetVersionFromNamespaceUri(XMLDeclarationInputReaderV10.NAMESPACE_URI)); + + Bind<IXMLJobDataReader>().To<XMLJobDataReaderV10>() + .Named(XMLHelper.GetVersionFromNamespaceUri(XMLJobDataReaderV10.NAMESPACE_URI)); + + Bind<IXMLComponentReader>().To<XMLComponentReaderV10>() + .Named(XMLHelper.GetVersionFromNamespaceUri(XMLComponentReaderV10.NAMESPACE_URI)); + + Bind<IXMLPTOReader>().To<XMLPTOReaderV10>() + .Named(XMLHelper.GetVersionFromNamespaceUri(XMLPTOReaderV10.NAMESPACE_URI)); + + Bind<IXMLADASReader>().To<XMLADASReaderV10>() + .Named(XMLHelper.GetVersionFromNamespaceUri(XMLADASReaderV10.NAMESPACE_URI)); + } + + #endregion + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLADASReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLADASReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..cd416d8d8944e5a5ae8302fda3ed9f790af6cab1 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLADASReader.cs @@ -0,0 +1,9 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader +{ + public interface IXMLADASReader + { + IAdvancedDriverAssistantSystemDeclarationInputData ADASInputData { get; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLComponentReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLComponentReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..1a8a1001e2c971c8300b1d73f912d163d621be3b --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLComponentReader.cs @@ -0,0 +1,26 @@ +using System.Xml; +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader +{ + public interface IXMLComponentReader + { + IVehicleComponentsDeclaration ComponentInputData { get; } + + IAirdragDeclarationInputData AirdragInputData { get; } + IGearboxDeclarationInputData GearboxInputData { get; } + IAxleGearInputData AxleGearInputData { get; } + IAngledriveInputData AngledriveInputData { get; } + IEngineDeclarationInputData EngineInputData { get; } + IAuxiliariesDeclarationInputData AuxiliaryData { get; } + IRetarderInputData RetarderInputData { get; } + IAxlesDeclarationInputData AxlesDeclarationInputData { get; } + + ITorqueConverterDeclarationInputData TorqueConverterInputData { get; } + ITransmissionInputData CreateGear(XmlNode gearNode); + IAuxiliaryDeclarationInputData CreateAuxiliary(XmlNode auxNode); + IAxleDeclarationInputData CreateAxle(XmlNode axleNode); + + ITyreDeclarationInputData Tyre { get; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLJobDataReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLJobDataReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..1da16d101996b1952f2f611be47926e613d478bb --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLJobDataReader.cs @@ -0,0 +1,9 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader +{ + public interface IXMLJobDataReader + { + IVehicleDeclarationInputData CreateVehicle { get; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLPTOReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLPTOReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..002e09edbbf557dc1c2363975f90ae52283e87d2 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/IXMLPTOReader.cs @@ -0,0 +1,9 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader +{ + public interface IXMLPTOReader + { + IPTOTransmissionInputData PTOInputData { get; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..e9ad4290c980a63c13ba7bbe52df93d7032e33d8 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/AbstractComponentReader.cs @@ -0,0 +1,46 @@ +using System; +using System.Xml; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl +{ + public abstract class AbstractComponentReader + { + protected bool VerifyXML; + protected readonly XmlNode BaseNode; + protected readonly IXMLResource ParentComponent; + + public AbstractComponentReader(IXMLResource parent, XmlNode baseNode, bool verifyXML) + { + BaseNode = baseNode; + ParentComponent = parent; + VerifyXML = verifyXML; + } + + protected virtual T CreateComponent<T>( + string component, Func<string, XmlNode, string, T> componentCreator, bool createDummy = false) + { + var componentNode = BaseNode.LocalName == component + ? BaseNode + : BaseNode.SelectSingleNode(XMLHelper.QueryLocalName(component)); + var dataNode = + componentNode?.SelectSingleNode(string.Format("./*[local-name()='{0}']", XMLNames.ComponentDataWrapper)); + if (componentNode != null) { + var version = XMLHelper.GetSchemaVersion(dataNode ?? componentNode); + return componentCreator(version, componentNode, ParentComponent.DataSource.SourceFile); + } + + if (createDummy) { + try { + return componentCreator(null, null, null); + } catch (Exception e) { + throw new VectoException("failed to create dummy instance for component {0}", e, component); + } + } + + throw new VectoException("Component {0} not found!", component); + } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..9014fc86664da38d84b00aea499c0d35236aafd5 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLADASReader.cs @@ -0,0 +1,43 @@ +using System.Xml; +using Ninject; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl +{ + public class XMLADASReaderV10 : AbstractComponentReader, IXMLADASReader + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + [Inject] + public IDeclarationInjectFactory Factory { protected get; set; } + + protected IXMLDeclarationVehicleData Vehicle; + private IAdvancedDriverAssistantSystemDeclarationInputData _adas; + + + public XMLADASReaderV10(IXMLDeclarationVehicleData vehicle, XmlNode vehicleNode, bool verifyXML) : base( + vehicle, vehicleNode, verifyXML) + { + Vehicle = vehicle; + } + + #region Implementation of IXMLADASReader + + public IAdvancedDriverAssistantSystemDeclarationInputData ADASInputData + { + get { return _adas ?? (_adas = CreateComponent(XMLNames.Vehicle_ADAS, ADASCreator)); } + } + + #endregion + + protected IAdvancedDriverAssistantSystemDeclarationInputData ADASCreator( + string version, XmlNode componentNode, string sourceFile) + { + return Factory.CreateADASData(version, Vehicle, componentNode, sourceFile); + } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..b08f7f2570ff498b7444fca784ac25122ef4ce58 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLComponentReader.cs @@ -0,0 +1,245 @@ +using System; +using System.Xml; +using Ninject; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Factory; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl +{ + public class XMLComponentReaderV10 : AbstractComponentReader, IXMLComponentReader + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + protected IXMLDeclarationVehicleData Vehicle; + + private IVehicleComponentsDeclaration _components; + private IGearboxDeclarationInputData _gearboxInputData; + private IAxleGearInputData _axlegearInputData; + private IAngledriveInputData _angledriveInputData; + private IEngineDeclarationInputData _engineInputData; + private IRetarderInputData _retarderInputData; + private IAxlesDeclarationInputData _axlesInputData; + private IAirdragDeclarationInputData _airdragInputData; + private IAuxiliariesDeclarationInputData _auxiliaryInputData; + private ITorqueConverterDeclarationInputData _torqueConverterInputData; + + + [Inject] + public IDeclarationInjectFactory Factory { protected get; set; } + + public XMLComponentReaderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentsNode, bool verifyXML) : base( + vehicle, componentsNode, verifyXML) + { + if (componentsNode == null) { + throw new VectoException("component node must not be null!"); + } + + Vehicle = vehicle; + } + + #region Implementation of IXMLComponentReader + + public IVehicleComponentsDeclaration ComponentInputData + { + get { return _components ?? (_components = CreateComponent(XMLNames.Vehicle_Components, ComponentsCreator)); } + } + + public IAirdragDeclarationInputData AirdragInputData + { + get { + return _airdragInputData ?? (_airdragInputData = CreateComponent(XMLNames.Component_AirDrag, AirdragCreator)); + } + } + + public IGearboxDeclarationInputData GearboxInputData + { + get { + return _gearboxInputData ?? (_gearboxInputData = CreateComponent(XMLNames.Component_Gearbox, GearboxCreator)); + } + } + + public ITorqueConverterDeclarationInputData TorqueConverterInputData + { + get { + return _torqueConverterInputData ?? (_torqueConverterInputData = CreateComponent( + XMLNames.Component_TorqueConverter, TorqueConverterCreator)); + } + } + + public ITransmissionInputData CreateGear(XmlNode gearNode) + { + var version = XMLHelper.GetSchemaVersion(gearNode); + try { + return Factory.CreateGearData(version, gearNode); + } catch (Exception e) { + var gearNumber = gearNode.Attributes?.GetNamedItem(XMLNames.Gearbox_Gear_GearNumber_Attr).InnerText; + throw new VectoException( + "Unsupported XML Version! Node: {0} Gear: {1} Version: {2}", e, gearNode.LocalName, gearNumber, version); + } + } + + public IAuxiliaryDeclarationInputData CreateAuxiliary(XmlNode auxNode) + { + var version = XMLHelper.GetSchemaVersion(auxNode); + try { + return Factory.CreateAuxiliaryData(version, auxNode, Vehicle); + } catch (Exception e) { + throw new VectoException("Unsupported XML version! Node: {0} version: {1}", e, auxNode.LocalName, version); + } + } + + public IAxleDeclarationInputData CreateAxle(XmlNode axleNode) + { + var version = XMLHelper.GetSchemaVersion(axleNode); + try { + var axle = Factory.CreateAxleData(version, Vehicle, axleNode, (Vehicle as IXMLResource).DataSource.SourceFile); + axle.Reader = Factory.CreateComponentReader(version, Vehicle, axleNode, VerifyXML); + return axle; + } catch (Exception e) { + var axleNumber = axleNode.Attributes?.GetNamedItem(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr).InnerText; + throw new VectoException( + "Unsupported XML Version! Node: {0} Axle: {1} Version: {2}", e, axleNode.LocalName, axleNumber, version); + } + } + + + public IAxleGearInputData AxleGearInputData + { + get { + return _axlegearInputData ?? (_axlegearInputData = CreateComponent(XMLNames.Component_Axlegear, AxlegearCreator)); + } + } + + + public IAngledriveInputData AngledriveInputData + { + get { + return _angledriveInputData ?? + (_angledriveInputData = CreateComponent(XMLNames.Component_Angledrive, AngledriveCreator, true)); + } + } + + public IEngineDeclarationInputData EngineInputData + { + get { return _engineInputData ?? (_engineInputData = CreateComponent(XMLNames.Component_Engine, EngineCreator)); } + } + + + public IAuxiliariesDeclarationInputData AuxiliaryData + { + get { + return _auxiliaryInputData ?? + (_auxiliaryInputData = CreateComponent(XMLNames.Component_Auxiliaries, AuxiliaryCreator)); + } + } + + + public IRetarderInputData RetarderInputData + { + get { + return _retarderInputData ?? + (_retarderInputData = CreateComponent(XMLNames.Component_Retarder, RetarderCreator, true)); + } + } + + + public IAxlesDeclarationInputData AxlesDeclarationInputData + { + get { + return _axlesInputData ?? (_axlesInputData = CreateComponent(XMLNames.Component_AxleWheels, AxleWheelsCreator)); + } + } + + public ITyreDeclarationInputData Tyre + { + get { return CreateComponent(XMLNames.AxleWheels_Axles_Axle_Tyre, TyreCreator); } + } + + #endregion + + protected IAirdragDeclarationInputData AirdragCreator(string version, XmlNode componentNode, string sourceFile) + { + return Factory.CreateAirdragData(version, Vehicle, componentNode, sourceFile); + } + + protected IGearboxDeclarationInputData GearboxCreator(string version, XmlNode componentNode, string sourceFile) + { + var gbx = Factory.CreateGearboxData(version, Vehicle, componentNode, sourceFile); + gbx.Reader = Factory.CreateComponentReader(version, Vehicle, componentNode, VerifyXML); + return gbx; + } + + protected ITorqueConverterDeclarationInputData TorqueConverterCreator( + string version, XmlNode componentNode, string sourceFile) + { + if (version == null) { + return new XMLDeclarationTorqueConverterDataProviderV10(Vehicle, componentNode, sourceFile); + } + + return Factory.CreateTorqueconverterData(version, Vehicle, componentNode, sourceFile); + } + + protected IAxleGearInputData AxlegearCreator(string version, XmlNode componentNode, string sourceFile) + { + return Factory.CreateAxlegearData(version, Vehicle, componentNode, sourceFile); + } + + protected IAngledriveInputData AngledriveCreator(string version, XmlNode componentNode, string sourceFile) + { + if (version == null) { + return new XMLDeclarationAngledriveDataProviderV10(Vehicle, componentNode, sourceFile); + } + + return Factory.CreateAngledriveData(version, Vehicle, componentNode, sourceFile); + } + + protected IEngineDeclarationInputData EngineCreator(string version, XmlNode componentNode, string sourceFile) + { + return Factory.CreateEngineData(version, Vehicle, componentNode, sourceFile); + } + + protected IRetarderInputData RetarderCreator(string version, XmlNode componentNode, string sourceFile) + { + if (version == null) { + return new XMLDeclarationRetarderDataProviderV10(Vehicle, componentNode, sourceFile); + } + + return Factory.CreateRetarderData(version, Vehicle, componentNode, sourceFile); + } + + protected IAxlesDeclarationInputData AxleWheelsCreator(string version, XmlNode componentNode, string sourceFile) + { + var axles = Factory.CreateAxleWheels(version, Vehicle, componentNode, sourceFile); + axles.Reader = Factory.CreateComponentReader(version, Vehicle, componentNode, VerifyXML); + return axles; + } + + + protected ITyreDeclarationInputData TyreCreator(string version, XmlNode componentNode, string sourceFile) + { + return Factory.CreateTyre(version, Vehicle, componentNode, sourceFile); + } + + + protected IAuxiliariesDeclarationInputData AuxiliaryCreator(string version, XmlNode componentNode, string sourceFile) + { + var aux = Factory.CreateAuxiliariesData(version, Vehicle, componentNode, sourceFile); + aux.Reader = Factory.CreateComponentReader(version, Vehicle, componentNode, VerifyXML); + return aux; + } + + + protected IVehicleComponentsDeclaration ComponentsCreator(string version, XmlNode componentNode, string sourcefile) + { + var components = Factory.CreateComponentData(version, Vehicle, componentNode, sourcefile); + components.ComponentReader = Factory.CreateComponentReader(version, Vehicle, componentNode, VerifyXML); + return components; + } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationInputReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationInputReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..fb6d3a5bfc3da4502893b18f54276c1ee7da82bc --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLDeclarationInputReader.cs @@ -0,0 +1,47 @@ +using System.Xml; +using Ninject; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.InputData.FileIO.XML.Engineering; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl +{ + public class XMLDeclarationInputReaderV10 : AbstractComponentReader, IXMLDeclarationInputDataReader + { + private XmlNode JobNode; + protected IXMLDeclarationInputData InputData; + private IDeclarationJobInputData _jobData; + + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + [Inject] + public IDeclarationInjectFactory Factory { protected get; set; } + + public XMLDeclarationInputReaderV10(IXMLDeclarationInputData inputData, XmlNode baseNode, bool verifyXML) : base( + inputData, baseNode, verifyXML) + { + JobNode = baseNode; + InputData = inputData; + } + + #region Implementation of IXMLDeclarationInputReader + + public IDeclarationJobInputData JobData + { + get { return _jobData ?? (_jobData = CreateComponent(XMLNames.VectoInputDeclaration, JobCreator)); } + } + + #endregion + + private IDeclarationJobInputData JobCreator(string version, XmlNode node, string arg3) + { + var job = Factory.CreateJobData(version, BaseNode, InputData, InputData.DataSource.SourceFile); + var jobNode = + job.Reader = Factory.CreateJobReader(version, job, JobNode, VerifyXML); + return job; + } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLJobDataReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLJobDataReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..15cf87b1cc344c8c9bac29f0f3f413be0146b7c9 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLJobDataReader.cs @@ -0,0 +1,48 @@ +using System.Xml; +using Ninject; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl +{ + public class XMLJobDataReaderV10 : AbstractComponentReader, IXMLJobDataReader + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + protected IXMLDeclarationJobInputData JobData; + private XmlNode JobNode; + private IVehicleDeclarationInputData _vehicle; + + [Inject] + public IDeclarationInjectFactory Factory { protected get; set; } + + public XMLJobDataReaderV10(IXMLDeclarationJobInputData jobData, XmlNode jobNode, bool verifyXML) : base (jobData, jobNode, verifyXML) + { + JobNode = jobNode; + JobData = jobData; + } + + #region Implementation of IXMLJobDataReader + + public IVehicleDeclarationInputData CreateVehicle + { + get { return _vehicle ?? (_vehicle = CreateComponent(XMLNames.Component_Vehicle, VehicleCreator)); } + } + + + #endregion + + private IVehicleDeclarationInputData VehicleCreator(string version, XmlNode vehicleNode, string sourceFile) + { + var vehicle = Factory.CreateVehicleData(version, JobData, vehicleNode, sourceFile); + vehicle.ComponentReader = Factory.CreateComponentReader(version, vehicle, vehicleNode, VerifyXML); + vehicle.ADASReader = Factory.CreateADASReader(version, vehicle, vehicleNode, VerifyXML); + vehicle.PTOReader = Factory.CreatePTOReader(version, vehicle, vehicleNode, VerifyXML); + return vehicle; + } + + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLPTOReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLPTOReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..62a17a9da3a443539272208b0d8feb4ff416465f --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/Reader/Impl/XMLPTOReader.cs @@ -0,0 +1,42 @@ +using System.Xml; +using Ninject; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Interfaces; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader.Impl +{ + public class XMLPTOReaderV10 : AbstractComponentReader, IXMLPTOReader + { + public const string NAMESPACE_URI = XMLDefinitions.DECLARATION_DEFINITIONS_NAMESPACE_URI_V10; + + [Inject] + public IDeclarationInjectFactory Factory { protected get; set; } + + protected IXMLDeclarationVehicleData Vehicle; + private IPTOTransmissionInputData _ptoInputData; + + + public XMLPTOReaderV10(IXMLDeclarationVehicleData vehicle, XmlNode componentNode, bool verifyXML) : base( + vehicle, componentNode, verifyXML) + { + Vehicle = vehicle; + } + + #region Implementation of IXMLPTOReader + + public IPTOTransmissionInputData PTOInputData + { + get { return _ptoInputData ?? (_ptoInputData = CreateComponent(XMLNames.Vehicle_PTO, PTOCreator)); } + } + + #endregion + + protected IPTOTransmissionInputData PTOCreator(string version, XmlNode componentNode, string sourceFile) + { + return Factory.CreatePTOData(version, Vehicle, componentNode, sourceFile); + } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAirdragDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAirdragDataProvider.cs deleted file mode 100644 index 5fd01fd3643afd6794dcb02dedd910e9e9a364a4..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAirdragDataProvider.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* 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 -{ - public class XMLDeclarationAirdragDataProvider : AbstractDeclarationXMLComponentDataProvider, - IAirdragDeclarationInputData - { - public XMLDeclarationAirdragDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) - : base(xmlInputDataProvider) - { - XBasePath = Helper.Query(VehiclePath, - XMLNames.Vehicle_Components, - XMLNames.Component_AirDrag, - 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; } - } - - public SquareMeter AirDragArea - { - get { return ElementExists(XMLNames.AirDrag_DeclaredCdxA) ? GetDoubleElementValue(XMLNames.AirDrag_DeclaredCdxA).SI<SquareMeter>() : null; } - } - } -} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAngledriveDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAngledriveDataProvider.cs deleted file mode 100644 index 7304e62304038e86249ff15a0dbc01d29d5605f3..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAngledriveDataProvider.cs +++ /dev/null @@ -1,99 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* 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 -{ - public class XMLDeclarationAngledriveDataProvider : AbstractDeclarationXMLComponentDataProvider, IAngledriveInputData - { - public XMLDeclarationAngledriveDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) : base(xmlInputDataProvider) - { - XBasePath = Helper.Query(VehiclePath, - XMLNames.Vehicle_Components, - XMLNames.Component_Angledrive, - 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; } - } - - public double Ratio - { - get { return GetDoubleElementValue(XMLNames.AngleDrive_Ratio); } - } - - public TableData LossMap - { - get - { - return ReadTableData(AttributeMappings.TransmissionLossmapMapping, - Helper.Query( - XMLNames.AngleDrive_TorqueLossMap, - XMLNames.Angledrive_LossMap_Entry)); - } - } - - public double Efficiency - { - get { throw new VectoException("Efficiency not supported in Declaration Mode!"); } - } - } -} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAuxiliaryDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAuxiliaryDataProvider.cs deleted file mode 100644 index 8f2c58ee081bc2dde3629765f5d57378bebb1400..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAuxiliaryDataProvider.cs +++ /dev/null @@ -1,78 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using System.Collections.Generic; -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 XMLDeclarationAuxiliaryDataProvider : AbstractDeclarationXMLComponentDataProvider, - IAuxiliariesDeclarationInputData - { - public XMLDeclarationAuxiliaryDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) : base(xmlInputDataProvider) - { - XBasePath = Helper.Query(VehiclePath, - XMLNames.Vehicle_Components, - XMLNames.Component_Auxiliaries, - XMLNames.ComponentDataWrapper); - } - - - public IList<IAuxiliaryDeclarationInputData> Auxiliaries - { - get - { - var retVal = new List<IAuxiliaryDeclarationInputData>(); - var auxiliaries = Navigator.Select(Helper.Query(XBasePath, - Helper.QueryConstraint("*", - Helper.NSPrefix(XMLNames.Auxiliaries_Auxiliary_Technology), null, "")), - Manager); - - while (auxiliaries.MoveNext()) { - var techlistNodes = auxiliaries.Current.Select(Helper.NSPrefix(XMLNames.Auxiliaries_Auxiliary_Technology), Manager); - var technologyList = new List<string>(); - while (techlistNodes.MoveNext()) { - technologyList.Add(techlistNodes.Current.Value); - } - retVal.Add(new AuxiliaryDataInputData { - Type = auxiliaries.Current.Name.ParseEnum<AuxiliaryType>(), - Technology = technologyList, - }); - } - return retVal; - } - } - } -} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAxlegearDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAxlegearDataProvider.cs deleted file mode 100644 index e2366ed8d9f6a0f0b6a3da0566264bca0a9eca20..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationAxlegearDataProvider.cs +++ /dev/null @@ -1,101 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* 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.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 deleted file mode 100644 index 877d6ed9480d455ba3e6ff8db2477fd4c535fcee..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationEngineDataProvider.cs +++ /dev/null @@ -1,156 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* 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.VectoCommon.Utils; -using TUGraz.VectoCore.Configuration; -using TUGraz.VectoCore.Utils; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration -{ - public class XMLDeclarationEngineDataProvider : AbstractDeclarationXMLComponentDataProvider, - IEngineDeclarationInputData - { - public XMLDeclarationEngineDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) - : base(xmlInputDataProvider) - { - XBasePath = Helper.Query(VehiclePath, - XMLNames.Vehicle_Components, - XMLNames.Component_Engine, - 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>(); } - } - - public PerSecond IdleSpeed - { - get { return GetDoubleElementValue(XMLNames.Engine_IdlingSpeed).RPMtoRad(); } - } - - public FuelType FuelType - { - get { - var value = GetElementValue(XMLNames.Engine_FuelType); - if ("LPG".Equals(value, StringComparison.InvariantCultureIgnoreCase)) { - return FuelType.LPGPI; - } - if ("NG".Equals(value, StringComparison.InvariantCultureIgnoreCase)) { - return FuelType.NGPI; - } - - return value.ParseEnum<FuelType>(); - } - } - - public TableData FuelConsumptionMap - { - get { - return ReadTableData(AttributeMappings.FuelConsumptionMapMapping, - Helper.Query(XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry)); - } - } - - public TableData FullLoadCurve - { - get { - return ReadTableData(AttributeMappings.EngineFullLoadCurveMapping, - Helper.Query(XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FullLoadCurve_Entry)); - } - } - - public Watt RatedPowerDeclared - { - get { return GetDoubleElementValue(XMLNames.Engine_RatedPower).SI<Watt>(); } - } - - public PerSecond RatedSpeedDeclared - { - get { return GetDoubleElementValue(XMLNames.Engine_RatedSpeed).RPMtoRad(); } - } - - public NewtonMeter MaxTorqueDeclared - { - get { return GetDoubleElementValue(XMLNames.Engine_MaxTorque).SI<NewtonMeter>(); } - } - - public double WHTCMotorway - { - get { return GetDoubleElementValue(XMLNames.Engine_WHTCMotorway); } - } - - public double WHTCRural - { - get { return GetDoubleElementValue(XMLNames.Engine_WHTCRural); } - } - - public double WHTCUrban - { - get { return GetDoubleElementValue(XMLNames.Engine_WHTCUrban); } - } - - public double ColdHotBalancingFactor - { - get { return GetDoubleElementValue(XMLNames.Engine_ColdHotBalancingFactor); } - } - - public double CorrectionFactorRegPer - { - get { return GetDoubleElementValue(XMLNames.Engine_CorrectionFactor_RegPer); } - } - } -} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationGearboxDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationGearboxDataProvider.cs deleted file mode 100644 index c0e9cd2444ee748a9169cd6ec02c70fc278807d9..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationGearboxDataProvider.cs +++ /dev/null @@ -1,144 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -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/XMLDeclarationJobInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationJobInputDataProvider.cs deleted file mode 100644 index b56d9901b20f24f1c547a046284717c4ba14d38a..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationJobInputDataProvider.cs +++ /dev/null @@ -1,65 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Resources; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration -{ - // ReSharper disable once InconsistentNaming - public class XMLDeclarationJobInputDataProvider : AbstractDeclarationXMLComponentDataProvider, IDeclarationJobInputData - { - private readonly XMLDeclarationVehicleDataProvider _vehicle; - - public XMLDeclarationJobInputDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) - : base(xmlInputDataProvider) - { - XBasePath = VehiclePath; - _vehicle = new XMLDeclarationVehicleDataProvider(xmlInputDataProvider); - } - - - public IVehicleDeclarationInputData Vehicle - { - get { return _vehicle; } - } - - public XMLDeclarationVehicleDataProvider XMLVehicle - { - get { return _vehicle; } - } - - public string JobName - { - get { return GetAttributeValue("", XMLNames.Component_ID_Attr); } - } - } -} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationReaderInjectModule.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationReaderInjectModule.cs new file mode 100644 index 0000000000000000000000000000000000000000..91462f4e5bcb57a8743e341871d174c3c8fe8c8f --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationReaderInjectModule.cs @@ -0,0 +1,31 @@ +using Ninject.Extensions.Factory; +using Ninject.Modules; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.NinjectModules; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Reader; +using TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Factory; +using TUGraz.VectoCore.Utils.Ninject; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration +{ + public class XMLDeclarationReaderInjectModule : NinjectModule + { + #region Overrides of NinjectModule + + public override void Load() + { + Bind<IDeclarationInjectFactory>().ToFactory(() => new UseFirstArgumentAsInstanceProvider()); + + Bind<IXMLInputDataReader>().To<XMLInputDataFactory>(); + + Kernel?.Load(new INinjectModule[] { + new XMLDeclarationInputDataV10InjectModule(), + }); + + // dummy + Bind<IEngineeringInjectFactory>().ToFactory(() => new UseFirstArgumentAsInstanceProvider()); + + #endregion + } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationRetarderDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationRetarderDataProvider.cs deleted file mode 100644 index be89789219d00e33627a2d36138eab0d33aa5f14..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationRetarderDataProvider.cs +++ /dev/null @@ -1,101 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* 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, - XMLNames.Vehicle_Components, - XMLNames.Component_Retarder, - 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 - { - get { return true; } - } - - public RetarderType Type - { - get { return _type ?? InputData.XMLJob.XMLVehicle.RetarderType; } - } - - public double Ratio - { - get { return _ratio ?? InputData.XMLJob.XMLVehicle.RetarderRatio; } - } - - public TableData LossMap - { - get - { - return ReadTableData(AttributeMappings.RetarderLossmapMapping, - Helper.Query(XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry)); - } - } - } -} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationTorqueConverterDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationTorqueConverterDataProvider.cs deleted file mode 100644 index 902f4c539fce79a068b8cebe4bc84d20153c1b1c..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationTorqueConverterDataProvider.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* 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 XMLDeclarationTorqueConverterDataProvider : AbstractDeclarationXMLComponentDataProvider, - ITorqueConverterDeclarationInputData - { - public XMLDeclarationTorqueConverterDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) - : base(xmlInputDataProvider) - { - XBasePath = Helper.Query(VehiclePath, - XMLNames.Vehicle_Components, - XMLNames.Component_Gearbox, - XMLNames.Component_TorqueConverter, - 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 - { - return ReadTableData(AttributeMappings.TorqueConverterDataMapping, - Helper.Query(XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry)); - } - } - } -} \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs deleted file mode 100644 index 878db64c77a37c1f90cee008a6ec34b90f6e086e..0000000000000000000000000000000000000000 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs +++ /dev/null @@ -1,317 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2019 European Union -* -* Developed by Graz University of Technology, -* Institute of Internal Combustion Engines and Thermodynamics, -* Institute of Technical Informatics -* -* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved -* by the European Commission - subsequent versions of the EUPL (the "Licence"); -* You may not use VECTO except in compliance with the Licence. -* You may obtain a copy of the Licence at: -* -* https://joinup.ec.europa.eu/community/eupl/og_page/eupl -* -* Unless required by applicable law or agreed to in writing, VECTO -* distributed under the Licence is distributed on an "AS IS" basis, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the Licence for the specific language governing permissions and -* limitations under the Licence. -* -* Authors: -* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology -* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology -* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology -* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology -* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology -* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology -*/ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Xml; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Resources; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.InputData.Impl; -using TUGraz.VectoCore.Models.Declaration; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration -{ - public class XMLDeclarationVehicleDataProvider : AbstractDeclarationXMLComponentDataProvider, - IVehicleDeclarationInputData, IPTOTransmissionInputData, IAdvancedDriverAssistantSystemDeclarationInputData - { - private readonly IAuxiliariesDeclarationInputData XMLAuxiliaryData; - - public XMLDeclarationVehicleDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) - : base(xmlInputDataProvider) - { - XBasePath = VehiclePath; - AirdragInputData = new XMLDeclarationAirdragDataProvider(xmlInputDataProvider); - AxleGearInputData = new XMLDeclarationAxlegearDataProvider(xmlInputDataProvider); - AngledriveInputData = new XMLDeclarationAngledriveDataProvider(xmlInputDataProvider); - EngineInputData = new XMLDeclarationEngineDataProvider(xmlInputDataProvider); - GearboxInputData = new XMLDeclarationGearboxDataProvider(xmlInputDataProvider); - TorqueConverterInputData = new XMLDeclarationTorqueConverterDataProvider(xmlInputDataProvider); - RetarderInputData = new XMLDeclarationRetarderDataProvider(xmlInputDataProvider); - XMLAuxiliaryData = new XMLDeclarationAuxiliaryDataProvider(xmlInputDataProvider); - } - - public bool ExemptedVehicle - { - get { return ElementExists(XMLNames.Vehicle_HybridElectricHDV) && ElementExists(XMLNames.Vehicle_DualFuelVehicle); } - } - - public string VIN - { - get { return GetElementValue(XMLNames.Vehicle_VIN); } - } - - public LegislativeClass LegislativeClass - { - get { return GetElementValue(XMLNames.Vehicle_LegislativeClass).ParseEnum<LegislativeClass>(); } - } - - public VehicleCategory VehicleCategory - { - get { var val = GetElementValue(XMLNames.Vehicle_VehicleCategory); - if ("Rigid Lorry".Equals(val, StringComparison.InvariantCultureIgnoreCase)) { - return VehicleCategory.RigidTruck; - } - return val.ParseEnum<VehicleCategory>(); } - } - - public Kilogram CurbMassChassis - { - get { return GetDoubleElementValue(XMLNames.Vehicle_CurbMassChassis).SI<Kilogram>(); } - } - - - public Kilogram GrossVehicleMassRating - { - get { return GetDoubleElementValue(XMLNames.Vehicle_GrossVehicleMass).SI<Kilogram>(); } - } - - public IList<ITorqueLimitInputData> TorqueLimits - { - get { - var retVal = new List<ITorqueLimitInputData>(); - var limits = - Navigator.Select(Helper.Query(VehiclePath, XMLNames.Vehicle_TorqueLimits, XMLNames.Vehicle_TorqueLimits_Entry), - Manager); - while (limits.MoveNext()) { - retVal.Add(new TorqueLimitInputData() { - Gear = limits.Current.GetAttribute(XMLNames.Vehicle_TorqueLimits_Entry_Gear_Attr, "").ToInt(), - MaxTorque = - limits.Current.GetAttribute(XMLNames.Vehicle_TorqueLimits_Entry_MaxTorque_Attr, "").ToDouble().SI<NewtonMeter>() - }); - } - return retVal; - } - } - - public AxleConfiguration AxleConfiguration - { - get { return AxleConfigurationHelper.Parse(GetElementValue(XMLNames.Vehicle_AxleConfiguration)); } - } - - public IList<IAxleDeclarationInputData> Axles - { - get { - var axles = Navigator.Select(Helper.Query(VehiclePath, XMLNames.Vehicle_Components, XMLNames.Component_AxleWheels, - XMLNames.ComponentDataWrapper, XMLNames.AxleWheels_Axles, XMLNames.AxleWheels_Axles_Axle), Manager); - - var retVal = new IAxleDeclarationInputData[axles.Count]; - while (axles.MoveNext()) { - var axleNumber = axles.Current.GetAttribute(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, "").ToInt(); - if (axleNumber < 1 || axleNumber > retVal.Length) { - throw new VectoException("Axle #{0} exceeds axle count", axleNumber); - } - if (retVal[axleNumber - 1] != null) { - throw new VectoException("Axle #{0} defined multiple times!", axleNumber); - } - var axleType = axles.Current.SelectSingleNode(Helper.NSPrefix(XMLNames.AxleWheels_Axles_Axle_AxleType), Manager); - var twinTyres = axles.Current.SelectSingleNode(Helper.NSPrefix(XMLNames.AxleWheels_Axles_Axle_TwinTyres), Manager); - var steered = axles.Current.SelectSingleNode(Helper.NSPrefix(XMLNames.AxleWheels_Axles_Axle_Steered), Manager); - var tyre = - axles.Current.SelectSingleNode(Helper.Query(XMLNames.AxleWheels_Axles_Axle_Tyre, XMLNames.ComponentDataWrapper), - Manager); - if (tyre == null) { - throw new VectoException("Axle #{0} contains no tyre definition", axleNumber); - } - var dimension = tyre.SelectSingleNode(Helper.NSPrefix(XMLNames.AxleWheels_Axles_Axle_Dimension), Manager); - var rollResistance = tyre.SelectSingleNode(Helper.NSPrefix(XMLNames.AxleWheels_Axles_Axle_RRCDeclared), Manager); - var tyreTestLoad = tyre.SelectSingleNode(Helper.NSPrefix(XMLNames.AxleWheels_Axles_Axle_FzISO), Manager); - var certirficationNumber = tyre.SelectSingleNode(Helper.NSPrefix(XMLNames.Component_CertificationNumber), Manager); - retVal[axleNumber - 1] = new AxleInputData { - AxleType = axleType == null ? AxleType.VehicleNonDriven : axleType.Value.ParseEnum<AxleType>(), - TwinTyres = twinTyres != null && XmlConvert.ToBoolean(twinTyres.Value), - Steered = steered != null && XmlConvert.ToBoolean(steered.Value), - Tyre = new TyreInputData() { - TyreTestLoad = tyreTestLoad == null ? null : tyreTestLoad.Value.ToDouble().SI<Newton>(), - RollResistanceCoefficient = rollResistance == null ? double.NaN : rollResistance.Value.ToDouble(), - Dimension = dimension == null ? null : dimension.Value, - CertificationNumber = certirficationNumber == null ? null : certirficationNumber.Value, - CertificationMethod = CertificationMethod.Measured, - DigestValue = new DigestData(tyre.SelectSingleNode(Helper.Query("..//*[local-name()='DigestValue']/.."), Manager)) - } - }; - } - return retVal; - } - } - - public string ManufacturerAddress - { - get { return GetElementValue(XMLNames.Component_ManufacturerAddress); } - } - - public PerSecond EngineIdleSpeed - { - get { return GetDoubleElementValue(XMLNames.Vehicle_IdlingSpeed).RPMtoRad(); } - } - - public double RetarderRatio - { - get { return GetDoubleElementValue(XMLNames.Vehicle_RetarderRatio); } - } - - public RetarderType RetarderType - { - get { - var value = GetElementValue(XMLNames.Vehicle_RetarderType); //.ParseEnum<RetarderType>(); - switch (value) { - case "None": - return RetarderType.None; - case "Losses included in Gearbox": - return RetarderType.LossesIncludedInTransmission; - case "Engine Retarder": - return RetarderType.EngineRetarder; - case "Transmission Input Retarder": - return RetarderType.TransmissionInputRetarder; - case "Transmission Output Retarder": - return RetarderType.TransmissionOutputRetarder; - } - throw new ArgumentOutOfRangeException("RetarderType", value); - } - } - - public AngledriveType AngulargearType - { - get { return GetElementValue(XMLNames.Vehicle_AngledriveType).ParseEnum<AngledriveType>(); } - } - - public string PTOTransmissionType - { - get { - var shaftGearWheels = GetElementValue(Helper.Query(XMLNames.Vehicle_PTO, XMLNames.Vehicle_PTO_ShaftsGearWheels)); - if ("none".Equals(shaftGearWheels, StringComparison.InvariantCultureIgnoreCase)) { - return "None"; - } - if ("only one engaged gearwheel above oil level".Equals(shaftGearWheels, StringComparison.CurrentCultureIgnoreCase)) { - return "only one engaged gearwheel above oil level"; - } - var otherElements = GetElementValue(Helper.Query(XMLNames.Vehicle_PTO, 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); - } - } - - public TableData PTOLossMap - { - get { return null; } - } - - public TableData PTOCycle - { - get { return null; } - } - - public IAirdragDeclarationInputData AirdragInputData { get; private set; } - - public IGearboxDeclarationInputData GearboxInputData { get; private set; } - - public ITorqueConverterDeclarationInputData TorqueConverterInputData { get; private set; } - - public IAxleGearInputData AxleGearInputData { get; private set; } - - public IAngledriveInputData AngledriveInputData { get; private set; } - - public IEngineDeclarationInputData EngineInputData { get; private set; } - - public IAuxiliariesDeclarationInputData AuxiliaryInputData() - { - return XMLAuxiliaryData; - } - - public IRetarderInputData RetarderInputData { get; private set; } - - public IPTOTransmissionInputData PTOTransmissionInputData - { - get { return this; } - } - - public bool VocationalVehicle { get { - return XmlConvert.ToBoolean(GetElementValue(XMLNames.Vehicle_VocationalVehicle)); - } } - public bool SleeperCab { get { - return XmlConvert.ToBoolean(GetElementValue(XMLNames.Vehicle_SleeperCab)); - } } - public TankSystem? TankSystem { get { - return ElementExists(XMLNames.Vehicle_NgTankSystem) - ? EnumHelper.ParseEnum<TankSystem>(GetElementValue(XMLNames.Vehicle_NgTankSystem)) - : (TankSystem?)null; - } } - - public IAdvancedDriverAssistantSystemDeclarationInputData ADAS { get { return this; } } - - public bool ZeroEmissionVehicle { get { - return XmlConvert.ToBoolean(GetElementValue(XMLNames.Vehicle_ZeroEmissionVehicle)); - } } - public bool HybridElectricHDV { get { - return XmlConvert.ToBoolean(GetElementValue(XMLNames.Vehicle_HybridElectricHDV)); - } } - public bool DualFuelVehicle { get { - return XmlConvert.ToBoolean(GetElementValue(XMLNames.Vehicle_DualFuelVehicle)); - } } - public Watt MaxNetPower1 { get { - return ElementExists(XMLNames.Vehicle_MaxNetPower1) - ? GetDoubleElementValue(XMLNames.Vehicle_MaxNetPower1).SI<Watt>() - : null; - } } - public Watt MaxNetPower2 { get { - return ElementExists(XMLNames.Vehicle_MaxNetPower2) - ? GetDoubleElementValue(XMLNames.Vehicle_MaxNetPower2).SI<Watt>() - : null; - } } - - #region Implementation of IAdvancedDriverAssistantSystemDeclarationInputData - - public bool EngineStopStart { get { - return XmlConvert.ToBoolean(GetElementValue(Helper.Query(XMLNames.Vehicle_ADAS, XMLNames.Vehicle_ADAS_EngineStopStart))); - } } - public bool EcoRollWitoutEngineStop { get { - return XmlConvert.ToBoolean(GetElementValue(Helper.Query(XMLNames.Vehicle_ADAS, XMLNames.Vehicle_ADAS_EcoRollWithoutEngineStop))); - } } - public bool EcoRollWithEngineStop { get { - return XmlConvert.ToBoolean(GetElementValue(Helper.Query(XMLNames.Vehicle_ADAS, XMLNames.Vehicle_ADAS_EcoRollWithEngineStopStart))); - } } - - public PredictiveCruiseControlType PredictiveCruiseControl - { - get { - return PredictiveCruiseControlTypeHelper.Parse(GetElementValue(Helper.Query(XMLNames.Vehicle_ADAS, XMLNames.Vehicle_ADAS_PCC))); - } - } - - #endregion - } -} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs index a0813e7cb2c2c573e439b611fe32996c48279098..aff2437d3f098791c131f5c5530de503ecc4da01 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs @@ -29,24 +29,36 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Xml; using System.Xml.XPath; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering { - public class AbstractEngineeringXMLComponentDataProvider : AbstractDeclarationXMLComponentDataProvider + public class AbstractEngineeringXMLComponentDataProvider //: AbstractDeclarationXMLComponentDataProvider { - protected new readonly XMLEngineeringInputDataProvider InputData; + protected readonly XMLEngineeringInputDataProvider InputData; + + protected XPathNavigator Navigator; protected readonly string FSBasePath; + protected string XBasePath = ""; + protected XmlNamespaceManager Manager; + + + protected readonly string VehiclePath; + + protected XPathHelper Helper; protected readonly XmlDocument XMLDocument; @@ -66,40 +78,49 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering SourceType = DataSourceType.Embedded; } - public new string Source { get { return FSBasePath; } } + public virtual DataSource DataSource + { + get { return new DataSource() { SourceFile = Source, SourceVersion = SourceVersion, SourceType = SourceType }; } + } + public string Source { get { return InputData.Source; } } + public DataSourceType SourceType { get; protected set; } + + protected string SourceVersion { get { return XMLHelper.GetVersionFromNamespaceUri(SchemaNamespace); } } + + protected string SchemaNamespace { get { return null; } } - public override bool SavedInDeclarationMode + public bool SavedInDeclarationMode { get { return false; } } - public override string Manufacturer + public string Manufacturer { get { return GetElementValue(XMLNames.Component_Manufacturer); } } - public override string Model + public string Model { get { return GetElementValue(XMLNames.Component_Model); } } - public override string Date + public string Date { get { return GetElementValue(XMLNames.Component_Date); } } - public override DigestData DigestValue + public DigestData DigestValue { get { return null; } } - public override string CertificationNumber + public string CertificationNumber { get { return "N.A."; } } - public override CertificationMethod CertificationMethod + public CertificationMethod CertificationMethod { get { return CertificationMethod.NotCertified; } } @@ -127,5 +148,69 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering XMLNames.ExtResource_Type_Value_CSV)); } } + + protected bool ElementExists(string relativePath) + { + var path = Helper.Query(XBasePath, relativePath.Any() ? relativePath : null); + + var node = Navigator.SelectSingleNode(path, Manager); + return node != null; + } + + protected string GetElementValue(string relativePath) + { + var path = Helper.Query(XBasePath, relativePath.Any() ? relativePath : null); + + var node = Navigator.SelectSingleNode(path, Manager); + if (node == null) { + throw new VectoException("Node {0} not found in input data", path); + } + return node.InnerXml; + } + + protected double GetDoubleElementValue(string relativePath) + { + return GetElementValue(relativePath).ToDouble(); + } + + protected string GetAttributeValue(string relativePath, string attrName) + { + var nodes = + Navigator.Select(string.IsNullOrWhiteSpace(relativePath) ? XBasePath : Helper.Query(XBasePath, relativePath), + Manager); + if (nodes.Count == 0) { + return null; + } + nodes.MoveNext(); + return nodes.Current.GetAttribute(attrName, ""); + } + + protected TableData ReadTableData(Dictionary<string, string> attributeMapping, string relativePath, + XPathNavigator origin = null) + { + var startNode = origin ?? Navigator.SelectSingleNode(XBasePath, Manager); + if (startNode == null) { + throw new VectoException("start node for base-path {0} not found!", XBasePath); + } + var table = new TableData(); + foreach (var entry in attributeMapping) { + if (startNode.Select(Helper.Query(relativePath, "@" + entry.Value), Manager).Count == 0) { + continue; + } + table.Columns.Add(entry.Key); + } + var nodes = startNode.Select(relativePath, Manager); + while (nodes.MoveNext()) { + var row = table.NewRow(); + foreach (var attribute in attributeMapping) { + if (nodes.Current.SelectSingleNode("@" + attribute.Value) != null) { + row[attribute.Key] = nodes.Current.GetAttribute(attribute.Value, ""); + } + } + table.Rows.Add(row); + } + + return table; + } } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Factory/IEngineeringInjectFactory.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Factory/IEngineeringInjectFactory.cs new file mode 100644 index 0000000000000000000000000000000000000000..2b7098c4eff575b8db9973ff012d2eac1e971ede --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Factory/IEngineeringInjectFactory.cs @@ -0,0 +1,13 @@ +using System.Xml; +using TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Interfaces; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Factory +{ + public interface IEngineeringInjectFactory + { + IXMLEngineeringInputData CreateInputProvider(string version, XmlDocument xmldoc, string fileName); + + IXMLEngineeringInputReader CreateInputReader( + string version, IXMLEngineeringInputData inputData, XmlNode documentElement, bool verifyXml); + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/IXMLEngineeringInputReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/IXMLEngineeringInputReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..4b8dc294030fd7a26966f85bff3d9b156a16a5a3 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/IXMLEngineeringInputReader.cs @@ -0,0 +1,11 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public interface IXMLEngineeringInputReader + { + IEngineeringJobInputData JobData { get; } + + IDriverEngineeringInputData DriverModel { get; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Interfaces/IXMLEngineeringInputData.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Interfaces/IXMLEngineeringInputData.cs new file mode 100644 index 0000000000000000000000000000000000000000..23e47cf71520354401077026b3df7f9d23d9c1d9 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/Interfaces/IXMLEngineeringInputData.cs @@ -0,0 +1,10 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Interfaces +{ + public interface IXMLEngineeringInputData : IEngineeringInputDataProvider, IXMLResource + { + IXMLEngineeringInputReader Reader { set; } + + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAirdragDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAirdragDataProvider.cs index cbe4b1f24b85e1eceb1890ee932e5069103f41e8..5e4f236b86e42b353de5511f82e168debbf29130 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAirdragDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAirdragDataProvider.cs @@ -63,5 +63,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering Helper.Query(XMLNames.Vehicle_CrosswindCorrectionData, XMLNames.Vehicle_CrosswindCorrectionData_Entry)); } } + + #region Implementation of IComponentInputData + + + + #endregion } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringInputDataProvider.cs index 9965f64c8ddd02c4ed9311f9e829cc5a2fc8fd59..69818e68603af0b3cea51c394353673acbb30061 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringInputDataProvider.cs @@ -39,6 +39,7 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Utils; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering { @@ -94,7 +95,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering var xmldoc = new XmlDocument(); xmldoc.Load(inputData); if (VerifyXml) { - new XMLValidator(xmldoc, null, ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType.EngineeringData); + new XMLValidator(xmldoc, null, ValidationCallBack).ValidateXML(XmlDocumentType.EngineeringJobData); } Document = xmldoc; } @@ -151,8 +152,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering var vehicleDocument = new XmlDocument(); vehicleDocument.Load(XmlReader.Create(Path.Combine(Path.GetDirectoryName(FileName) ?? "./", vehicleFile))); if (VerifyXml) { - new XMLValidator(vehicleDocument, null, ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType - .EngineeringData); + new XMLValidator(vehicleDocument, null, ValidationCallBack).ValidateXML(XmlDocumentType.EngineeringJobData); } var vehicleCompPath = helper.QueryAbs( @@ -195,5 +195,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering { get { return XMLEngineeringDriverData; } } + + public string Source { get; private set; } } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs index 769b62228da0736052834b937a5e7b9afcae52ec..6b5a34cd195ed18ce06b73e1ec98bfdecf7f761a 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs @@ -45,15 +45,16 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.InputData.Impl; using TUGraz.VectoCore.Utils; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering { public class XMLEngineeringVehicleDataProvider : AbstractEngineeringXMLComponentDataProvider, - IVehicleEngineeringInputData, - IPTOTransmissionInputData + IVehicleEngineeringInputData, IPTOTransmissionInputData, IVehicleComponentsEngineering, IAuxiliariesEngineeringInputData { protected internal XMLEngineeringAuxiliaryDataProvider XMLEngineeringAuxiliaryData; protected internal XMLEngineeringAxlegearDataProvider AxlegearData; + public XMLEngineeringVehicleDataProvider(XMLEngineeringInputDataProvider jobProvider, XmlDocument vehicleDocument, string xmlBasePath, string fsBasePath) @@ -75,6 +76,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering get { return GetAttributeValue("", XMLNames.Component_ID_Attr); } } + public string Identifier { get { return GetVehicleID; } } + public bool ExemptedVehicle { get { return false; } } public string VIN @@ -156,6 +159,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering } } + IVehicleComponentsEngineering IVehicleEngineeringInputData.Components + { + get { return this; } + } + + IAdvancedDriverAssistantSystemsEngineering IVehicleEngineeringInputData.ADAS + { + get { return null; } + } + public AxleConfiguration AxleConfiguration { @@ -177,11 +190,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering get { return null; } } - IList<IAxleDeclarationInputData> IVehicleDeclarationInputData.Axles - { - get { return AxleEngineeringInput().Cast<IAxleDeclarationInputData>().ToList(); } - } - + private IEnumerable<AxleInputData> AxleEngineeringInput() { var axlePath = Helper.Query( @@ -245,21 +254,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering public IAirdragEngineeringInputData AirdragInputData { get; private set; } - IAirdragDeclarationInputData IVehicleDeclarationInputData.AirdragInputData - { - get { return AirdragInputData; } - } - - IGearboxDeclarationInputData IVehicleDeclarationInputData.GearboxInputData - { - get { return GearboxInputData; } - } - - ITorqueConverterDeclarationInputData IVehicleDeclarationInputData.TorqueConverterInputData - { - get { return TorqueConverterInputData; } - } - + public IGearboxEngineeringInputData GearboxInputData { get; private set; } public ITorqueConverterEngineeringInputData TorqueConverterInputData { get; private set; } @@ -271,26 +266,22 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering public IAngledriveInputData AngledriveInputData { get; private set; } - IEngineDeclarationInputData IVehicleDeclarationInputData.EngineInputData - { - get { return EngineInputData; } - } - public IEngineEngineeringInputData EngineInputData { get; private set; } - public IAuxiliariesEngineeringInputData AuxiliaryInputData() + IAuxiliariesEngineeringInputData IVehicleComponentsEngineering.AuxiliaryInputData { - return XMLEngineeringAuxiliaryData; + get { return this; } } - IAuxiliariesDeclarationInputData IVehicleDeclarationInputData.AuxiliaryInputData() + public IAuxiliariesEngineeringInputData AuxiliaryInputData() { - throw new NotImplementedException(); + return XMLEngineeringAuxiliaryData; } public IRetarderInputData RetarderInputData { get; private set; } public IPTOTransmissionInputData PTOTransmissionInputData { get; private set; } + public IAxlesEngineeringInputData AxleWheels { get; } public bool VocationalVehicle { get { return false; } } public bool SleeperCab { get { return true; } } public TankSystem? TankSystem { get; } @@ -300,6 +291,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering public bool DualFuelVehicle { get { return false; } } public Watt MaxNetPower1 { get { return null; } } public Watt MaxNetPower2 { get { return null; } } + public IVehicleComponentsDeclaration Components { get; } #region "FactoryMethods" @@ -367,8 +359,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering var componentDocument = new XmlDocument(); componentDocument.Load(XmlReader.Create(Path.Combine(FSBasePath, componentFile))); if (verifyXml) { - new XMLValidator(componentDocument, null, XMLEngineeringInputDataProvider.ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType - .EngineeringData); + new XMLValidator(componentDocument, null, XMLEngineeringInputDataProvider.ValidationCallBack).ValidateXML(XmlDocumentType + .EngineeringJobData); } return creator(InputData, componentDocument, Helper.QueryAbs(Helper.NSPrefix(XMLNames.VectoComponentEngineering, Constants.XML.RootNSPrefix), componentName, @@ -431,5 +423,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering } #endregion + + #region Implementation of IAuxiliariesEngineeringInputData + + public IList<IAuxiliaryEngineeringInputData> Auxiliaries { get; } + public AuxiliaryModel AuxiliaryAssembly { get; } + public string AuxiliaryVersion { get; } + public string AdvancedAuxiliaryFilePath { get; } + + #endregion } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/IXMLInputDataReader.cs b/VectoCore/VectoCore/InputData/FileIO/XML/IXMLInputDataReader.cs new file mode 100644 index 0000000000000000000000000000000000000000..666ddaf8330b9ba091776d8a4c69c37bff3a9a48 --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/IXMLInputDataReader.cs @@ -0,0 +1,25 @@ +using System.IO; +using System.Xml; +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML +{ + public interface IXMLInputDataReader + { + IInputDataProvider Create(string filename, bool verifyXML); + + IInputDataProvider Create(Stream inputData, bool verifyXML); + + IInputDataProvider Create(XmlReader inputData, bool verifyXML); + + IEngineeringInputDataProvider CreateEngineering(string filename, bool verifyXML); + + IEngineeringInputDataProvider CreateEngineering(Stream inputData, bool verifyXML); + + IEngineeringInputDataProvider CreateEngineering(XmlReader inputData, bool verifyXML); + + IDeclarationInputDataProvider CreateDeclaration(string filename, bool verifyXML); + + IDeclarationInputDataProvider CreateDeclaration(XmlReader inputData, bool verifyXML); + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/IXMLResource.cs b/VectoCore/VectoCore/InputData/FileIO/XML/IXMLResource.cs new file mode 100644 index 0000000000000000000000000000000000000000..a15cc8e37214a52437bc0ba157d6cf8a53c205bf --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/IXMLResource.cs @@ -0,0 +1,9 @@ +using TUGraz.VectoCommon.InputData; + +namespace TUGraz.VectoCore.InputData.FileIO.XML +{ + public interface IXMLResource + { + DataSource DataSource { get; } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/XMLInputDataFactory.cs b/VectoCore/VectoCore/InputData/FileIO/XML/XMLInputDataFactory.cs new file mode 100644 index 0000000000000000000000000000000000000000..b45865c404397597e3a8cfaed534b30ecb3aac6e --- /dev/null +++ b/VectoCore/VectoCore/InputData/FileIO/XML/XMLInputDataFactory.cs @@ -0,0 +1,133 @@ +using System; +using System.IO; +using System.Xml; +using Ninject; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.Factory; +using TUGraz.VectoCore.InputData.FileIO.XML.Engineering.Factory; +using TUGraz.VectoCore.Utils; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; + +namespace TUGraz.VectoCore.InputData.FileIO.XML +{ + public class XMLInputDataFactory : IXMLInputDataReader + { + [Inject] + public IDeclarationInjectFactory DeclarationFactory { protected get; set; } + + [Inject] + public IEngineeringInjectFactory EngineeringFactory { protected get; set; } + + public IInputDataProvider Create(string filename, bool verifyXML) + { + return ReadXmlDoc(XmlReader.Create(filename), filename, verifyXML); + } + + public IInputDataProvider Create(Stream inputData, bool verifyXML) + { + return ReadXmlDoc(XmlReader.Create(inputData), null, verifyXML); + } + + public IInputDataProvider Create(XmlReader inputData, bool verifyXML) + { + return ReadXmlDoc(inputData, null, verifyXML); + } + + public IEngineeringInputDataProvider CreateEngineering(string filename, bool verifyXML) + { + return DoCreateEngineering(XmlReader.Create(filename), filename, verifyXML); + } + + + + public IEngineeringInputDataProvider CreateEngineering(Stream inputData, bool verifyXML) + { + return DoCreateEngineering(XmlReader.Create(inputData), null, verifyXML); + } + + public IEngineeringInputDataProvider CreateEngineering(XmlReader inputData, bool verifyXML) + { + return DoCreateEngineering(inputData, null, verifyXML); + } + + + + public IDeclarationInputDataProvider CreateDeclaration(string filename, bool verifyXML) + { + return DoCreateDeclaration(XmlReader.Create(filename), filename, verifyXML); + } + + public IDeclarationInputDataProvider CreateDeclaration(XmlReader inputData, bool verifyXML) + { + return DoCreateDeclaration(inputData, null, verifyXML); + } + + + private IDeclarationInputDataProvider DoCreateDeclaration(XmlReader inputData, string source, bool verifyXML) + { + var retVal = ReadXmlDoc(inputData, source, verifyXML) as IDeclarationInputDataProvider; + if (retVal == null) { + throw new VectoException("Input data is not in declaration mode!"); + } + + return retVal; + } + + private IEngineeringInputDataProvider DoCreateEngineering(XmlReader inputData, string source, bool verifyXML) + { + var retVal = ReadXmlDoc(inputData, source, verifyXML) as IEngineeringInputDataProvider; + if (retVal == null) { + throw new VectoException("Input data is not in engineering mode!"); + } + + return retVal; + } + + private IInputDataProvider ReadXmlDoc(XmlReader inputData, string source, bool verifyXML) + { + var xmlDoc = new XmlDocument(); + xmlDoc.Load(inputData); + if (xmlDoc.DocumentElement == null) { + throw new VectoException("empty xml document!"); + } + var documentType = XMLHelper.GetDocumentType(xmlDoc.DocumentElement.LocalName); + if (documentType == null) { + throw new VectoException("unknown xml file! {0}", xmlDoc.DocumentElement.LocalName); + } + + if (verifyXML) { + new XMLValidator(xmlDoc, null, XMLValidator.CallBackExceptionOnError).ValidateXML(documentType.Value); + } + + switch (documentType.Value) { + case XmlDocumentType.DeclarationJobData: return ReadDeclarationJob(xmlDoc, source, verifyXML); + case XmlDocumentType.EngineeringJobData: return ReadEngineeringJob(xmlDoc, source, verifyXML); + case XmlDocumentType.EngineeringComponentData: + case XmlDocumentType.DeclarationComponentData: + case XmlDocumentType.ManufacturerReport: + case XmlDocumentType.CustomerReport: + throw new VectoException("XML Document {0} not supported as simulation input!", documentType.Value); + default: throw new ArgumentOutOfRangeException(); + } + } + + private IEngineeringInputDataProvider ReadEngineeringJob(XmlDocument xmlDoc, string source, bool verifyXML) + { + var versionNumber = XMLHelper.GetSchemaVersion(xmlDoc.DocumentElement); + + var input = EngineeringFactory.CreateInputProvider(versionNumber, xmlDoc, source); + input.Reader = EngineeringFactory.CreateInputReader(versionNumber, input, xmlDoc.DocumentElement, verifyXML); + return input; + } + + private IDeclarationInputDataProvider ReadDeclarationJob(XmlDocument xmlDoc, string source, bool verifyXML) + { + var versionNumber = XMLHelper.GetSchemaVersion(xmlDoc.DocumentElement); + + var input = DeclarationFactory.CreateInputProvider(versionNumber, xmlDoc, source); + input.Reader = DeclarationFactory.CreateInputReader(versionNumber, input, xmlDoc.DocumentElement, verifyXML); + return input; + } + } +} diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLManufacturerReportReader.cs b/VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs similarity index 100% rename from VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLManufacturerReportReader.cs rename to VectoCore/VectoCore/InputData/FileIO/XMLReports/XMLManufacturerReportReader.cs diff --git a/VectoCore/VectoCore/InputData/Impl/InputData.cs b/VectoCore/VectoCore/InputData/Impl/InputData.cs index 5c083991994a2f7bd350743b6f4d5985ff41c938..8a2bc002754c2bf0b4ece842c88a5711fa93934c 100644 --- a/VectoCore/VectoCore/InputData/Impl/InputData.cs +++ b/VectoCore/VectoCore/InputData/Impl/InputData.cs @@ -109,7 +109,7 @@ namespace TUGraz.VectoCore.InputData.Impl { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - public DataSourceType SourceType { get; internal set; } + public DataSource DataSource { get; internal set; } public string Source { get; internal set; } diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index 611504f19fc2146b761be9814d1b5ca0e1677863..a48aa54e463247aec63f36fa5a1a7dcfdae541d3 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -106,7 +106,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter retVal.Loading = loading; retVal.DynamicTyreRadius = - data.Axles.Where(axle => axle.AxleType == AxleType.VehicleDriven) + data.Components.AxleWheels.AxlesDeclaration.Where(axle => axle.AxleType == AxleType.VehicleDriven) .Select(da => DeclarationData.Wheels.Lookup(da.Tyre.Dimension).DynamicTyreRadius) .Average(); retVal.CargoVolume = mission.MissionType != MissionType.Construction ? mission.TotalCargoVolume : 0.SI<CubicMeter>(); @@ -114,11 +114,11 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter retVal.VocationalVehicle = data.VocationalVehicle; retVal.ADAS = CreateADAS(data.ADAS); - var axles = data.Axles; + var axles = data.Components.AxleWheels.AxlesDeclaration; if (axles.Count < mission.AxleWeightDistribution.Length) { throw new VectoException( "Vehicle does not contain sufficient axles. {0} axles defined, {1} axles required", - data.Axles.Count, mission.AxleWeightDistribution.Length); + axles.Count, mission.AxleWeightDistribution.Length); } var axleData = new List<Axle>(); diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs index e89657ef86cab28a877ab7cbbe3c25f78b01e215..ea66535900f694994691ba0c7d1f21141aead9ce 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/EngineeringDataAdapter.cs @@ -60,7 +60,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter retVal.TrailerGrossVehicleWeight = 0.SI<Kilogram>(); retVal.Loading = data.Loading; retVal.DynamicTyreRadius = data.DynamicTyreRadius; - var axles = data.Axles; + var axles = data.Components.AxleWheels.AxlesEngineering; retVal.AxleData = axles.Select(axle => new Axle { WheelsDimension = axle.Tyre.Dimension, @@ -102,7 +102,7 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter data.GrossVehicleMassRating, false); retVal.CrossWindCorrectionCurve = new CrosswindCorrectionCdxALookup(airDragArea, DeclarationDataAdapter.GetDeclarationAirResistanceCurve( - GetAirdragParameterSet(data.VehicleCategory, data.AxleConfiguration, data.Axles.Count), airDragArea, height), + GetAirdragParameterSet(data.VehicleCategory, data.AxleConfiguration, data.Components.AxleWheels.AxlesEngineering.Count), airDragArea, height), CrossWindCorrectionMode.DeclarationModeCorrection); break; default: diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs index 119dcd00190cfcdfb5e806a9e66d5c7f83df1612..f791149169a7c89042570f16332f8df100899a40 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationModeVectoRunDataFactory.cs @@ -107,19 +107,19 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl _driverdata.AccelerationCurve = AccelerationCurveReader.ReadFromStream(_segment.AccelerationFile); var tempVehicle = _dao.CreateVehicleData(vehicle, _segment.Missions.First(), _segment.Missions.First().Loadings.First().Value); - _airdragData = _dao.CreateAirdragData(vehicle.AirdragInputData, + _airdragData = _dao.CreateAirdragData(vehicle.Components.AirdragInputData, _segment.Missions.First(), _segment); - _engineData = _dao.CreateEngineData(vehicle.EngineInputData, + _engineData = _dao.CreateEngineData(vehicle.Components.EngineInputData, vehicle.EngineIdleSpeed, - vehicle.GearboxInputData, vehicle.TorqueLimits, vehicle.TankSystem); - _axlegearData = _dao.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.AxleGearInputData); - _angledriveData = _dao.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.AngledriveInputData); - _gearboxData = _dao.CreateGearboxData(vehicle.GearboxInputData, _engineData, + vehicle.Components.GearboxInputData, vehicle.TorqueLimits, vehicle.TankSystem); + _axlegearData = _dao.CreateAxleGearData(InputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData); + _angledriveData = _dao.CreateAngledriveData(InputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData); + _gearboxData = _dao.CreateGearboxData(vehicle.Components.GearboxInputData, _engineData, _axlegearData.AxleGear.Ratio, tempVehicle.DynamicTyreRadius, tempVehicle.VehicleCategory); - _retarderData = _dao.CreateRetarderData(vehicle.RetarderInputData); + _retarderData = _dao.CreateRetarderData(vehicle.Components.RetarderInputData); - _ptoTransmissionData = _dao.CreatePTOTransmissionData(vehicle.PTOTransmissionInputData); + _ptoTransmissionData = _dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); _municipalPtoTransmissionData = CreateDefaultPTOData(); } @@ -146,7 +146,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl Retarder = _retarderData, Aux = _dao.CreateAuxiliaryData( - InputDataProvider.JobInputData.Vehicle.AuxiliaryInputData(), + InputDataProvider.JobInputData.Vehicle.Components.AuxiliaryInputData, _segment.Missions.First().MissionType, _segment.VehicleClass), PTO = _ptoTransmissionData, @@ -201,12 +201,12 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl var simulationRunData = new VectoRunData { Loading = loading.Key, VehicleData = _dao.CreateVehicleData(vehicle, mission, loading.Value), - AirdragData = _dao.CreateAirdragData(vehicle.AirdragInputData, mission, _segment), + AirdragData = _dao.CreateAirdragData(vehicle.Components.AirdragInputData, mission, _segment), EngineData = _engineData.Copy(), // a copy is necessary because every run has a different correction factor! GearboxData = _gearboxData, AxleGearData = _axlegearData, AngledriveData = _angledriveData, - Aux = _dao.CreateAuxiliaryData(vehicle.AuxiliaryInputData(), mission.MissionType, + Aux = _dao.CreateAuxiliaryData(vehicle.Components.AuxiliaryInputData, mission.MissionType, _segment.VehicleClass), Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()), Retarder = _retarderData, diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs index 7f0d558c81eb7729c0585f4e40eb1f96e4b5c487..29f56dbcb454474323287b445dffa8fe225d0ef0 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/DeclarationVTPModeVectoRunDataFactory.cs @@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl Retarder = RetarderData, Aux = Dao.CreateAuxiliaryData( - JobInputData.Vehicle.AuxiliaryInputData(), + JobInputData.Vehicle.Components.AuxiliaryInputData, Segment.Missions.First().MissionType, Segment.VehicleClass), }; @@ -123,22 +123,22 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl vehicle, Segment.Missions.First(), Segment.Missions.First().Loadings.First().Value); AirdragData = Dao.CreateAirdragData( - vehicle.AirdragInputData, + vehicle.Components.AirdragInputData, Segment.Missions.First(), Segment); EngineData = Dao.CreateEngineData( - vehicle.EngineInputData, + vehicle.Components.EngineInputData, vehicle.EngineIdleSpeed, - vehicle.GearboxInputData, vehicle.TorqueLimits, vehicle.TankSystem); - AxlegearData = Dao.CreateAxleGearData(vehicle.AxleGearInputData); - AngledriveData = Dao.CreateAngledriveData(vehicle.AngledriveInputData); + vehicle.Components.GearboxInputData, vehicle.TorqueLimits, vehicle.TankSystem); + AxlegearData = Dao.CreateAxleGearData(vehicle.Components.AxleGearInputData); + AngledriveData = Dao.CreateAngledriveData(vehicle.Components.AngledriveInputData); GearboxData = Dao.CreateGearboxData( - vehicle.GearboxInputData, EngineData, + vehicle.Components.GearboxInputData, EngineData, AxlegearData.AxleGear.Ratio, tempVehicle.DynamicTyreRadius, tempVehicle.VehicleCategory); - RetarderData = Dao.CreateRetarderData(vehicle.RetarderInputData); + RetarderData = Dao.CreateRetarderData(vehicle.Components.RetarderInputData); PTOTransmissionData = - Dao.CreatePTOTransmissionData(vehicle.PTOTransmissionInputData); + Dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); AuxVTP = CreateVTPAuxData(vehicle); } @@ -163,7 +163,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl runData.Cycle = new DrivingCycleProxy(cycle, mission.MissionType.ToString()); runData.DriverData = Driverdata; runData.Aux = Dao.CreateAuxiliaryData( - JobInputData.Vehicle.AuxiliaryInputData(), mission.MissionType, Segment.VehicleClass); + JobInputData.Vehicle.Components.AuxiliaryInputData, mission.MissionType, Segment.VehicleClass); runData.ExecutionMode = ExecutionMode.Declaration; runData.SimulationType = SimulationType.DistanceCycle; runData.Mission = mission; @@ -188,7 +188,7 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl vtpRunData.Mission = new Mission() { MissionType = MissionType.VerificationTest }; - var ncvStd = DeclarationData.FuelData.Lookup(JobInputData.Vehicle.EngineInputData.FuelType).LowerHeatingValueVecto; + var ncvStd = DeclarationData.FuelData.Lookup(JobInputData.Vehicle.Components.EngineInputData.FuelType).LowerHeatingValueVecto; //var ncvCorrection = ncvStd / JobInputData.NetCalorificValueTestFuel; var mileageCorrection = GetMileagecorrectionFactor(JobInputData.Mileage); vtpRunData.VTPData = new VTPData() { @@ -239,21 +239,21 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl protected virtual List<VectoRunData.AuxData> CreateVTPAuxData(IVehicleDeclarationInputData vehicle) { var auxRD = Dao.CreateAuxiliaryData( - vehicle.AuxiliaryInputData(), MissionType.RegionalDelivery, Segment.VehicleClass) + vehicle.Components.AuxiliaryInputData, MissionType.RegionalDelivery, Segment.VehicleClass) .ToList(); foreach (var entry in auxRD) { entry.MissionType = MissionType.RegionalDelivery; } var auxLH = Dao.CreateAuxiliaryData( - vehicle.AuxiliaryInputData(), MissionType.LongHaul, Segment.VehicleClass) + vehicle.Components.AuxiliaryInputData, MissionType.LongHaul, Segment.VehicleClass) .ToList(); foreach (var entry in auxLH) { entry.MissionType = MissionType.LongHaul; } var auxUD = Dao.CreateAuxiliaryData( - vehicle.AuxiliaryInputData(), MissionType.UrbanDelivery, Segment.VehicleClass) + vehicle.Components.AuxiliaryInputData, MissionType.UrbanDelivery, Segment.VehicleClass) .ToList(); foreach (var entry in auxUD) { entry.MissionType = MissionType.UrbanDelivery; diff --git a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs index 916ea84ee26132608967f8f42e6a11fa7e6dd697..8948c9d6f1c90d0669e561dd4063bfeeb7d68071 100644 --- a/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs +++ b/VectoCore/VectoCore/InputData/Reader/Impl/EngineeringModeVectoRunDataFactory.cs @@ -62,18 +62,18 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl var dao = new EngineeringDataAdapter(); var driver = dao.CreateDriverData(InputDataProvider.DriverInputData); var vehicle = InputDataProvider.JobInputData.Vehicle; - var engineData = dao.CreateEngineData(vehicle.EngineInputData, vehicle.GearboxInputData, + var engineData = dao.CreateEngineData(vehicle.Components.EngineInputData, vehicle.Components.GearboxInputData, vehicle.TorqueLimits, vehicle.TankSystem); var tempVehicle = dao.CreateVehicleData(vehicle); - var axlegearData = dao.CreateAxleGearData(vehicle.AxleGearInputData); - var gearboxData = dao.CreateGearboxData(vehicle.GearboxInputData, engineData, axlegearData.AxleGear.Ratio, + var axlegearData = dao.CreateAxleGearData(vehicle.Components.AxleGearInputData); + var gearboxData = dao.CreateGearboxData(vehicle.Components.GearboxInputData, engineData, axlegearData.AxleGear.Ratio, tempVehicle.DynamicTyreRadius,tempVehicle.VehicleCategory); - var crossWindRequired = vehicle.AirdragInputData.CrossWindCorrectionMode == + var crossWindRequired = vehicle.Components.AirdragInputData.CrossWindCorrectionMode == CrossWindCorrectionMode.VAirBetaLookupTable; - var angledriveData = dao.CreateAngledriveData(vehicle.AngledriveInputData); - var ptoTransmissionData = dao.CreatePTOTransmissionData(vehicle.PTOTransmissionInputData); + var angledriveData = dao.CreateAngledriveData(vehicle.Components.AngledriveInputData); + var ptoTransmissionData = dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); return InputDataProvider.JobInputData.Cycles.Select(cycle => { var drivingCycle = CyclesCache.ContainsKey(cycle.CycleData.Source) @@ -87,11 +87,11 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl AxleGearData = axlegearData, AngledriveData = angledriveData, VehicleData = dao.CreateVehicleData(vehicle), - AirdragData = dao.CreateAirdragData(vehicle.AirdragInputData, vehicle), + AirdragData = dao.CreateAirdragData(vehicle.Components.AirdragInputData, vehicle), DriverData = driver, - Aux = dao.CreateAuxiliaryData(vehicle.AuxiliaryInputData()), - AdvancedAux = dao.CreateAdvancedAuxData(vehicle.AuxiliaryInputData()), - Retarder = dao.CreateRetarderData(vehicle.RetarderInputData), + Aux = dao.CreateAuxiliaryData(vehicle.Components.AuxiliaryInputData), + AdvancedAux = dao.CreateAdvancedAuxData(vehicle.Components.AuxiliaryInputData), + Retarder = dao.CreateRetarderData(vehicle.Components.RetarderInputData), PTO = ptoTransmissionData, Cycle = new DrivingCycleProxy(drivingCycle, cycle.Name), ExecutionMode = ExecutionMode.Engineering, diff --git a/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs b/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs new file mode 100644 index 0000000000000000000000000000000000000000..74b41cf4dace9803b4ad6628b2f02c13206af2de --- /dev/null +++ b/VectoCore/VectoCore/Ninject/VectoNinjectModule.cs @@ -0,0 +1,29 @@ +using Ninject.Modules; +using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; + +namespace TUGraz.VectoCore +{ + public class VectoNinjectModule : NinjectModule + { + #region Overrides of NinjectModule + + public override void Load() + { + LoadModule<XMLDeclarationReaderInjectModule>(); + + // load module engineering reader + + // use ninject for simulator factory? + } + + #endregion + + protected virtual void LoadModule<T>() where T : class, INinjectModule, new() + { + if (Kernel != null && !Kernel.HasModule(typeof(T).FullName)) { + Kernel.Load(new[] { new T() }); + } + + } + } +} diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs index 9acbedb193ee41a0478cc73c6b774c431687c9e5..89d16693e12548b4d5d66ebed30340b1e071b0e5 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs @@ -117,11 +117,11 @@ namespace TUGraz.VectoCore.OutputData.XML protected XElement CreateVehicle(IDeclarationInputDataProvider data) { - var retarder = data.JobInputData.Vehicle.RetarderInputData; - var gearbox = data.JobInputData.Vehicle.GearboxInputData; + var retarder = data.JobInputData.Vehicle.Components.RetarderInputData; + var gearbox = data.JobInputData.Vehicle.Components.GearboxInputData; var vehicle = data.JobInputData.Vehicle; - var engine = data.JobInputData.Vehicle.EngineInputData; - var angledrive = data.JobInputData.Vehicle.AngledriveInputData; + var engine = data.JobInputData.Vehicle.Components.EngineInputData; + var angledrive = data.JobInputData.Vehicle.Components.AngledriveInputData; var id = CreateIdString("VEH-" + vehicle.Model); @@ -158,13 +158,13 @@ namespace TUGraz.VectoCore.OutputData.XML CreateTorqueLimits(vehicle), new XElement(tns + XMLNames.Vehicle_Components, CreateEngine(engine), - CreateGearbox(gearbox, gearbox.Type.AutomaticTransmission() ? vehicle.TorqueConverterInputData : null), + CreateGearbox(gearbox, gearbox.Type.AutomaticTransmission() ? vehicle.Components.TorqueConverterInputData : null), angledrive.Type == AngledriveType.SeparateAngledrive ? CreateAngleDrive(angledrive) : null, retarder.Type.IsDedicatedComponent() ? CreateRetarder(retarder) : null, - CreateAxlegear(vehicle.AxleGearInputData), - CreateAxleWheels(vehicle), - CreateAuxiliaries(vehicle.AuxiliaryInputData()), - CreateAirdrag(vehicle.AirdragInputData) + CreateAxlegear(vehicle.Components.AxleGearInputData), + CreateAxleWheels(vehicle.Components.AxleWheels), + CreateAuxiliaries(vehicle.Components.AuxiliaryInputData), + CreateAirdrag(vehicle.Components.AirdragInputData) ) ); } @@ -309,9 +309,9 @@ namespace TUGraz.VectoCore.OutputData.XML ); } - public XElement CreateAxleWheels(IVehicleDeclarationInputData data, XNamespace ns = null) + public XElement CreateAxleWheels(IAxlesDeclarationInputData data, XNamespace ns = null) { - var axleData = data.Axles; + var axleData = data.AxlesDeclaration; var numAxles = axleData.Count; var axles = new List<XElement>(numAxles); for (var i = 0; i < numAxles; i++) { diff --git a/VectoCore/VectoCore/OutputData/XML/XMLEngineeringWriter.cs b/VectoCore/VectoCore/OutputData/XML/XMLEngineeringWriter.cs index c4c18a2cd5ba5a0f4b30ca5228b973ac5f1d0b29..abfc5edfcd5db6c74995c7c1f409cc3269d27cb6 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLEngineeringWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLEngineeringWriter.cs @@ -153,7 +153,7 @@ namespace TUGraz.VectoCore.OutputData.XML private XElement CreateDriverModel(IEngineeringInputDataProvider engineering) { var driver = engineering.DriverInputData; - var gbx = engineering.JobInputData.Vehicle.GearboxInputData; + var gbx = engineering.JobInputData.Vehicle.Components.GearboxInputData; var lookahead = driver.Lookahead; var overspeed = driver.OverSpeedEcoRoll; @@ -213,11 +213,11 @@ namespace TUGraz.VectoCore.OutputData.XML protected XElement CreateVehicle(IEngineeringInputDataProvider data) { - var retarder = data.JobInputData.Vehicle.RetarderInputData; - var gearbox = data.JobInputData.Vehicle.GearboxInputData; + var retarder = data.JobInputData.Vehicle.Components.RetarderInputData; + var gearbox = data.JobInputData.Vehicle.Components.GearboxInputData; var vehicle = data.JobInputData.Vehicle; - var angledrive = data.JobInputData.Vehicle.AngledriveInputData; - var pto = data.JobInputData.Vehicle.PTOTransmissionInputData; + var angledrive = data.JobInputData.Vehicle.Components.AngledriveInputData; + var pto = data.JobInputData.Vehicle.Components.PTOTransmissionInputData; return new XElement(tns + XMLNames.Component_Vehicle, new XAttribute(XMLNames.Component_ID_Attr, "VEH-" + vehicle.Model), @@ -238,14 +238,14 @@ namespace TUGraz.VectoCore.OutputData.XML new XElement(tns + XMLNames.Vehicle_CurbMassExtra, vehicle.CurbMassExtra.Value()), new XElement(tns + XMLNames.Vehicle_Loading, vehicle.Loading.Value()), new XElement(tns + XMLNames.Vehicle_Components, - CreateEngine(vehicle.EngineInputData), + CreateEngine(vehicle.Components.EngineInputData), CreateGearbox(gearbox, gearbox.TorqueConverter), angledrive.Type == AngledriveType.SeparateAngledrive ? CreateAngleDrive(angledrive) : null, retarder.Type.IsDedicatedComponent() ? CreateRetarder(retarder) : null, - CreateAxlegear(vehicle.AxleGearInputData), + CreateAxlegear(vehicle.Components.AxleGearInputData), CreateAxleWheels(vehicle), - CreateAuxiliaries(vehicle.AuxiliaryInputData(), RemoveInvalidFileCharacters(vehicle.Model)), - CreateAirdrag(vehicle.AirdragInputData) + CreateAuxiliaries(vehicle.Components.AuxiliaryInputData, RemoveInvalidFileCharacters(vehicle.Model)), + CreateAirdrag(vehicle.Components.AirdragInputData) ), new XElement(tns + XMLNames.Vehicle_AdvancedDriverAssist, new XElement(tns + XMLNames.Vehicle_AdvancedDriverAssist_EngineStartStop, @@ -351,7 +351,7 @@ namespace TUGraz.VectoCore.OutputData.XML public XElement CreateAxleWheels(IVehicleEngineeringInputData data) { - var axleData = data.Axles; + var axleData = data.Components.AxleWheels.AxlesEngineering; var numAxles = axleData.Count; var axles = new List<XElement>(numAxles); for (var i = 0; i < numAxles; i++) { diff --git a/VectoCore/VectoCore/Utils/Ninject/UseFirstArgumentAsInstanceProvider.cs b/VectoCore/VectoCore/Utils/Ninject/UseFirstArgumentAsInstanceProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..20a1ddb8d9cc73912084d647fdda1ad6e21ceb5a --- /dev/null +++ b/VectoCore/VectoCore/Utils/Ninject/UseFirstArgumentAsInstanceProvider.cs @@ -0,0 +1,25 @@ +using System.Linq; +using System.Reflection; +using Ninject.Extensions.Factory; +using Ninject.Parameters; + +namespace TUGraz.VectoCore.Utils.Ninject +{ + public class UseFirstArgumentAsInstanceProvider : StandardInstanceProvider + { + #region Overrides of StandardInstanceProvider + + protected override string GetName(MethodInfo methodInfo, object[] arguments) + { + return arguments[0].ToString(); + } + + + protected override IConstructorArgument[] GetConstructorArguments(MethodInfo methodInfo, object[] arguments) + { + return base.GetConstructorArguments(methodInfo, arguments).Skip(1).ToArray(); + } + + #endregion + } +} diff --git a/VectoCore/VectoCore/Utils/XMLDefinitions.cs b/VectoCore/VectoCore/Utils/XMLDefinitions.cs new file mode 100644 index 0000000000000000000000000000000000000000..e4e34a174960d13096b41aaa476cf7f35cecddca --- /dev/null +++ b/VectoCore/VectoCore/Utils/XMLDefinitions.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; + +namespace TUGraz.VectoCore.Utils +{ + [Flags] + public enum XmlDocumentType + { + DeclarationJobData = 1 << 1, + DeclarationComponentData = 1 << 3, + EngineeringJobData = 1 << 4, + EngineeringComponentData = 1 << 5, + ManufacturerReport = 1 << 6, + CustomerReport = 1 << 7, + MonitoringReport = 1 << 8, + } + + + public static class XMLDefinitions + { + //public const string SchemaBaseURL = "file:///E:/QUAM/Workspace/VECTO_quam/VectoCore/VectoCore/Resources/XSD/"; + public const string SCHEMA_BASE_LOCATION = "https://webgate.ec.europa.eu/CITnet/svn/VECTO/trunk/Share/XML/XSD/"; + + + public const string ENGINEERING_INPUT_NAMESPACE_URI_V07 = "urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7"; + + public const string ENGINEERING_DEFINITONS_NAMESPACE_V07 = "urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7"; + + public const string ENGINEERING_INPUT_NAMESPACE_URI_V10 = "urn:tugraz:ivt:VectoAPI:EngineeringInput:v1.0"; + + public const string ENGINEERING_DEFINITONS_NAMESPACE_V10 = "urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v1.0"; + + public const string ENGINEERING_DEFINITONS_NAMESPACE_V10_TEST = "urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v1.0TEST"; + + + + public const string DECLARATION_DEFINITIONS_NAMESPACE_URI_V10 = "urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0"; + + public const string DECLARATION_INPUT_NAMESPACE_URI_V10 = "urn:tugraz:ivt:VectoAPI:DeclarationInput:v1.0"; + + public const string DECLARATION_COMPONENT_NAMESPACE_URI_V10 = "urn:tugraz:ivt:VectoAPI:DeclarationComponent:v1.0"; + + + public const string DECLARATION_MANUFACTURER_REPORT_V05 = "urn:tugraz:ivt:VectoAPI:DeclarationOutput:v0.5"; + + public const string DECLARATION_CUSTOMER_REPORT_V05 = "urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.5"; + + public const string DECLARATION_VTP_REPORT_V01 = "urn:tugraz:ivt:VectoAPI:VTPReport:v0.1"; + + + public const string XML_SCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema-instance"; + + + // mapping of document type + version => supported schema files (+version) + private static Dictionary<Tuple<XmlDocumentType, string>, IList<string>> schemaFilenames = new Dictionary<Tuple<XmlDocumentType, string>, IList<string>>(); + + static XMLDefinitions() + { + RegisterKnownXMLSchemas(); + } + + private static void RegisterKnownXMLSchemas() + { + var declarationJob10 = Tuple.Create(XmlDocumentType.DeclarationJobData, "1.0"); + RegisterXMLSchema(declarationJob10, "VectoInput.1.0.xsd"); + + var declarationComponent10 = Tuple.Create(XmlDocumentType.DeclarationComponentData, "1.0"); + RegisterXMLSchema(declarationComponent10, "VectoComponent.1.0.xsd"); + + var engineeringInput07 = Tuple.Create(XmlDocumentType.EngineeringJobData, "0.7"); + RegisterXMLSchema(engineeringInput07, "VectoEngineeringInput.0.7.xsd"); + + var engineeringInput10 = Tuple.Create(XmlDocumentType.EngineeringJobData, "1.0"); + RegisterXMLSchema(engineeringInput10, "VectoEngineeringInput.1.0.xsd"); + RegisterXMLSchema(engineeringInput10, "VectoEngineeringDefinitionsTEST.1.1.xsd"); + + var engineeringComponent10 = Tuple.Create(XmlDocumentType.EngineeringComponentData, "1.0"); + RegisterXMLSchema(engineeringComponent10, "VectoEngineeringInput.1.0.xsd"); + + var manufacturerReport = Tuple.Create(XmlDocumentType.ManufacturerReport, "0.5"); + RegisterXMLSchema(manufacturerReport, String.Format("VectoOutputManufacturer.{0}.xsd", "0.5")); + + var customerReport = Tuple.Create(XmlDocumentType.CustomerReport, "0.5"); + RegisterXMLSchema(customerReport, String.Format("VectoOutputCustomer.{0}.xsd", "0.5")); + + + } + + private static void RegisterXMLSchema(Tuple<XmlDocumentType, string> doctypeversion, string schemafile) + { + if (!schemaFilenames.ContainsKey(doctypeversion)) { + schemaFilenames[doctypeversion] = new List<string>(); + } + schemaFilenames[doctypeversion].Add(schemafile); + } + + public static IEnumerable<string> GetSchemaFilenames(XmlDocumentType type, string version) + { + var key = Tuple.Create(type, version); + if (!schemaFilenames.ContainsKey(key)) { + throw new Exception(String.Format("Invalid argument {0} - only use single flags", type)); + } + return schemaFilenames[key]; + } + + } +} diff --git a/VectoCore/VectoCore/Utils/XMLHelper.cs b/VectoCore/VectoCore/Utils/XMLHelper.cs index 7dc437f4699e71e2fe20310fec2012c2ab9a551c..a7c32df04f2b41c929a4f2765971ee169c8e900f 100644 --- a/VectoCore/VectoCore/Utils/XMLHelper.cs +++ b/VectoCore/VectoCore/Utils/XMLHelper.cs @@ -30,6 +30,9 @@ */ using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml; using System.Xml.Linq; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.InputData; @@ -38,17 +41,50 @@ using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Declaration; -namespace TUGraz.VectoCore.Utils { +namespace TUGraz.VectoCore.Utils +{ + public static class XMLHelper + { + public static XmlDocumentType? GetDocumentType(string rootElement) + { + switch (rootElement) { + case "VectoInputDeclaration": return XmlDocumentType.DeclarationJobData; + case "VectoInputEngineering": return XmlDocumentType.EngineeringJobData; + case "VectoComponentEngineering": return XmlDocumentType.EngineeringComponentData; + } + + return null; + } + + public static string GetSchemaVersion(XmlElement node) + { + return GetVersionFromNamespaceUri(node.NamespaceURI); + } + + public static string GetSchemaVersion(XmlNode node) + { + var nodeType = node.Attributes?.GetNamedItem("type", "http://www.w3.org/2001/XMLSchema-instance"); + if (nodeType != null) { + var parts = nodeType.InnerText.Split(':'); + if (parts.Length == 2) { + return GetVersionFromNamespaceUri(nodeType.GetNamespaceOfPrefix(parts[0])); + } + } + return GetVersionFromNamespaceUri(node.NamespaceURI); + } - public static class XMLHelper { + public static string GetVersionFromNamespaceUri(string namespaceUri) + { + return namespaceUri.Split(':').Last().Replace("v", ""); + } - public static object[] ValueAsUnit(Kilogram mass, string unit, uint? decimals = 0) { switch (unit) { case "t": return GetValueAsUnit(mass.ConvertToTon(), unit, decimals); case "kg": return GetValueAsUnit(mass.Value(), unit, decimals); } + throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); } @@ -58,6 +94,7 @@ namespace TUGraz.VectoCore.Utils { case "kW": return GetValueAsUnit(power?.ConvertToKiloWatt(), unit, decimals); case "W": return GetValueAsUnit(power?.Value(), unit, decimals); } + throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); } @@ -68,6 +105,7 @@ namespace TUGraz.VectoCore.Utils { case "ccm": return GetValueAsUnit(volume.ConvertToCubicCentiMeter(), unit, decimals); case "m3": return GetValueAsUnit(volume.Value(), unit, decimals); } + throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); } @@ -76,15 +114,17 @@ namespace TUGraz.VectoCore.Utils { switch (unit) { case "rpm": return GetValueAsUnit(angSpeed.ConvertToRoundsPerMinute(), unit, decimals); } + throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); } - + public static object[] ValueAsUnit(MeterPerSecond speed, string unit, uint? decimals) { switch (unit) { case "km/h": return GetValueAsUnit(speed.ConvertToKiloMeterPerHour(), unit, decimals); } + throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); } @@ -93,6 +133,7 @@ namespace TUGraz.VectoCore.Utils { switch (unit) { case "m/s²": return GetValueAsUnit(acc.Value(), unit, decimals); } + throw new NotImplementedException(string.Format("unknown unit '{0}'", unit)); } @@ -109,6 +150,7 @@ namespace TUGraz.VectoCore.Utils { if (value == null) { return new object[0]; } + return new object[] { new XAttribute(XMLNames.Report_Results_Unit_Attr, unit), value.Value.ToXMLFormat(decimals) @@ -123,9 +165,52 @@ namespace TUGraz.VectoCore.Utils { if (fuelData.TankSystem == null) { throw new VectoException("No TankSystem specified!"); } + prefix = fuelData.TankSystem.Value == TankSystem.Liquefied ? "L" : "C"; } + return prefix + fuelData.FuelType.ToXMLFormat(); } + + public static string QueryLocalName(string nodeName) + { + return string.Format(".//*[local-name()='{0}']", nodeName); + } + + public static string QueryLocalName(params string[] nodePath) + { + return "./" + string.Join("/", nodePath.Where(x => x != null).Select(x => $"/*[local-name()='{x}']").ToArray()); + } + + + public static TableData ReadTableData(Dictionary<string, string> attributeMapping, XmlNodeList entryNodes) + { + var table = new TableData(); + var entries = Shim<XmlNode>(entryNodes).ToArray(); + foreach (var mapping in attributeMapping) { + if (entries.All(x => x.Attributes?.GetNamedItem(mapping.Value) != null)) { + table.Columns.Add(mapping.Key); + } + } + foreach (var entry in entries) { + var row = table.NewRow(); + foreach (var mapping in attributeMapping) { + if (entry.Attributes?.GetNamedItem(mapping.Value) != null) { + row[mapping.Key] = entry.Attributes?.GetNamedItem(mapping.Value).InnerText; + } + } + + table.Rows.Add(row); + } + + return table; + } + + private static IEnumerable<T> Shim<T>(XmlNodeList nodes) + { + foreach (var node in nodes) { + yield return (T)node; + } + } } -} \ No newline at end of file +} diff --git a/VectoCore/VectoCore/Utils/XMLValidator.cs b/VectoCore/VectoCore/Utils/XMLValidator.cs index 39d08ba34c8ea88d56af3f1945a4b49ad2710774..1abd89f4361e1e35832fc804fbacada933d8c1d1 100644 --- a/VectoCore/VectoCore/Utils/XMLValidator.cs +++ b/VectoCore/VectoCore/Utils/XMLValidator.cs @@ -36,6 +36,7 @@ using System.Linq; using System.Threading.Tasks; using System.Xml; using System.Xml.Schema; +using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Utils; namespace TUGraz.VectoCore.Utils @@ -47,15 +48,6 @@ namespace TUGraz.VectoCore.Utils private bool _valid; private readonly XmlDocument _doc; - private static Dictionary<XmlDocumentType, Tuple<string, string[]> > schemaFilenames = new Dictionary<XmlDocumentType, Tuple<string, string[]>>() { - {XmlDocumentType.DeclarationJobData, Tuple.Create("VectoInput{0}.xsd", new [] {"1.0"}) }, - {XmlDocumentType.DeclarationComponentData, Tuple.Create("VectoComponent{0}.xsd", new [] {"1.0"}) }, - {XmlDocumentType.EngineeringData, Tuple.Create("VectoEngineeringInput{0}.xsd", new [] {"0.7"}) }, - {XmlDocumentType.ManufacturerReport, Tuple.Create("VectoOutputManufacturer{0}.xsd", new [] {"0.4", "0.5", "0.6", "0.7"}) }, - {XmlDocumentType.CustomerReport , Tuple.Create("VectoOutputCustomer{0}.xsd", new [] {"0.4", "0.5", "0.7"})}, - {XmlDocumentType.MonitoringReport , Tuple.Create("VectoMonitoring{0}.xsd", new [] {"0.7"})}, - }; - private XMLValidator(Action<bool> resultaction, Action<XmlSeverityType, ValidationEvent> validationErrorAction) { _validationErrorAction = validationErrorAction ?? ((x, y) => { }); @@ -80,7 +72,7 @@ namespace TUGraz.VectoCore.Utils if (_doc.DocumentElement == null) { throw new Exception("empty XML document"); } - var version = _doc.DocumentElement.GetAttribute("schemaVersion"); + var version = XMLHelper.GetSchemaVersion(_doc.DocumentElement); _doc.Schemas = GetXMLSchema(docType, version); _doc.Validate(ValidationCallBack); return _valid; @@ -93,6 +85,13 @@ namespace TUGraz.VectoCore.Utils _validationErrorAction(args.Severity, new ValidationEvent { ValidationEventArgs = args }); } + public static void CallBackExceptionOnError(XmlSeverityType severity, ValidationEvent evt) + { + if (severity == XmlSeverityType.Error) { + throw new VectoException("Validation error: {0}", evt.ValidationEventArgs.Message); + } + } + private static XmlSchemaSet GetXMLSchema(XmlDocumentType docType, string version) { var xset = new XmlSchemaSet() { XmlResolver = new XmlResourceResolver() }; @@ -101,42 +100,24 @@ namespace TUGraz.VectoCore.Utils if ((entry & docType) == 0) { continue; } - Stream resource; - var schemaFile = GetSchemaFilename(entry, version); - if (schemaFile == null) { - continue; - } - try { - resource= RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, schemaFile); - } catch (Exception e) { - throw new Exception(string.Format("Unknown XML schema! version: {0}, xml document type: {1} ({2})", entry, version, schemaFile), e); + + var schemaFile = XMLDefinitions.GetSchemaFilenames(entry, version); + foreach (var schema in schemaFile) { + Stream resource; + try { + resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, schema); + } catch (Exception e) { + throw new Exception( + string.Format("Unknown XML schema! version: {0}, xml document type: {1} ({2})", entry, version, schemaFile), e); + } + + var reader = XmlReader.Create(resource, new XmlReaderSettings(), "schema://"); + xset.Add(XmlSchema.Read(reader, null)); } - var reader = XmlReader.Create(resource, new XmlReaderSettings(), "schema://"); - xset.Add(XmlSchema.Read(reader, null)); } xset.Compile(); return xset; } - - public static string GetSchemaFilename(XmlDocumentType type, string version) - { - if (!schemaFilenames.ContainsKey(type)) { - throw new Exception(string.Format("Invalid argument {0} - only use single flags", type)); - } - var entry = schemaFilenames[type]; - return !entry.Item2.Contains(version) ? null : string.Format(entry.Item1, string.IsNullOrWhiteSpace(version) ? "" : "." + version); - } - - [Flags] - public enum XmlDocumentType - { - DeclarationJobData = 1<<1, - DeclarationComponentData = 1<<3, - EngineeringData = 1<<4, - ManufacturerReport = 1<<5, - CustomerReport = 1<<6, - MonitoringReport = 1<<7, - } } public class ValidationEvent diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index aa3d055e325e8a3646e7a166264bcd4f754307af..b65af679a51689c5ce5767e18c739e294b0552b9 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -83,7 +83,10 @@ <Prefer32Bit>false</Prefer32Bit> </PropertyGroup> <ItemGroup> - <Reference Include="DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> + <Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll</HintPath> + <Private>True</Private> + </Reference> <Reference Include="JetBrains.Annotations, Version=2018.3.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL"> <HintPath>..\..\packages\JetBrains.Annotations.2018.3.0\lib\net20\JetBrains.Annotations.dll</HintPath> <Private>True</Private> @@ -93,6 +96,17 @@ <SpecificVersion>False</SpecificVersion> <HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> + <Reference Include="Ninject, Version=3.3.4.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Ninject.3.3.4\lib\net45\Ninject.dll</HintPath> + <Private>True</Private> + </Reference> + <Reference Include="Ninject.Extensions.Factory"> + <HintPath>..\..\..\STUDENTEN_PROJEKTE\Kober_VectoGIT\VECTO_GIT\packages\Ninject.Extensions.Factory.3.3.2\lib\net45\Ninject.Extensions.Factory.dll</HintPath> + </Reference> + <Reference Include="Ninject.Extensions.NamedScope, Version=3.3.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Ninject.Extensions.NamedScope.3.3.0\lib\net45\Ninject.Extensions.NamedScope.dll</HintPath> + <Private>True</Private> + </Reference> <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <HintPath>..\..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath> <Private>True</Private> @@ -120,19 +134,77 @@ <Compile Include="InputData\FileIO\JSON\IJSONVehicleComponents.cs" /> <Compile Include="InputData\FileIO\JSON\JSONComponentInputData.cs" /> <Compile Include="InputData\FileIO\JSON\JsonExtensionMethods.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\AbstractDeclarationXMLComponentDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationAirdragDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationAngledriveDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationAuxiliaryDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationAxlegearDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationEngineDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationGearboxDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationJobInputDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationRetarderDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationTorqueConverterDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationVehicleDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationInputDataProvider.cs" /> - <Compile Include="InputData\FileIO\XML\Declaration\XMLManufacturerReportReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\AbstractCommonComponentType.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\AbstractXMLResource.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\AbstractXMLType.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLAuxiliaryDeclarationDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationADASDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationAirdragDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationAngledriveDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationAuxiliariesDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationAxleDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationAxlegearDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationAxlesDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationComponentsDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationEngineDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationGearboxDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationJobInputDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationPTODataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationRetarderDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationTorqueConverterDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationTyreDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLGearData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLAirdragDeclarationInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLAngledriveInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLAuxiliariesDeclarationInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLAxleDeclarationInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLAxleGearInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLAxlesDeclarationInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLDeclarationJobInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLEngineDeclarationInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLGearboxDeclarationInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLGearData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLPTOTransmissionInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLRetarderInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLTorqueConverterDeclarationInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLTyreDeclarationInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLVehicleComponentsDeclaration.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\Impl\AbstractComponentReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\Impl\XMLADASReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\Impl\XMLComponentReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\Impl\XMLPTOReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\IXMLADASReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\IXMLComponentReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLDeclarationInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\AbstractDeclarationXMLComponentDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Factory\IDeclarationInjectFactory.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Interfaces\IXMLDeclarationVehicleData.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\NinjectModules\XMLDeclarationInputDataV10InjectModule.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\Impl\XMLDeclarationInputReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\Impl\XMLJobDataReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\IXMLJobDataReader.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Reader\IXMLPTOReader.cs" /> + <Compile Include="InputData\FileIO\XML\Engineering\Factory\IEngineeringInjectFactory.cs" /> + <Compile Include="InputData\FileIO\XML\Engineering\Interfaces\IXMLEngineeringInputData.cs" /> + <Compile Include="InputData\FileIO\XML\Engineering\IXMLEngineeringInputReader.cs" /> + <Compile Include="InputData\FileIO\XML\IXMLResource.cs" /> + <Compile Include="InputData\FileIO\XML\XMLInputDataFactory.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\IXMLDeclarationInputDataReader.cs" /> + <Compile Include="InputData\FileIO\XML\IXMLInputDataReader.cs" /> + <Compile Include="Utils\Ninject\UseFirstArgumentAsInstanceProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLDeclarationAirdragDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLDeclarationAngledriveDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLDeclarationAuxiliaryDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLDeclarationAxlegearDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLDeclarationEngineDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLDeclarationGearboxDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLDeclarationJobInputDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\XMLDeclarationReaderInjectModule.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLDeclarationRetarderDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLDeclarationTorqueConverterDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationVehicleDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\DataProvider\XMLDeclarationInputDataProvider.cs" /> + <Compile Include="InputData\FileIO\XML\Declaration\Impl\XMLManufacturerReportReader.cs" /> <Compile Include="InputData\FileIO\XML\Engineering\AbstractEngineeringXMLComponentDataProvider.cs" /> <Compile Include="InputData\FileIO\XML\Engineering\XMLEngineeringAirdragDataProvider.cs" /> <Compile Include="InputData\FileIO\XML\Engineering\XMLEngineeringAngledriveDataProvider.cs" /> @@ -362,10 +434,12 @@ <DesignTime>True</DesignTime> <DependentUpon>VectoVersionCore.tt</DependentUpon> </Compile> + <Compile Include="Utils\XMLDefinitions.cs" /> <Compile Include="Utils\XMLHelper.cs" /> <Compile Include="Utils\XmlResourceResolver.cs" /> <Compile Include="Utils\XMLValidator.cs" /> <Compile Include="Utils\XPathHelper.cs" /> + <Compile Include="Ninject\VectoNinjectModule.cs" /> <Compile Include="VersionNumber1.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> @@ -421,10 +495,6 @@ <SubType>Designer</SubType> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </EmbeddedResource> - <EmbeddedResource Include="Resources\XSD\VectoComponent.xsd"> - <SubType>Designer</SubType> - <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> - </EmbeddedResource> <EmbeddedResource Include="Resources\XSD\VectoEngineeringDefinitions.0.6.xsd"> <SubType>Designer</SubType> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> @@ -494,6 +564,36 @@ <EmbeddedResource Include="Resources\XSD\VectoMonitoring.0.7.xsd"> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoDeclarationDefinitions.2.0.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoDeclarationDefinitions.2.1.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoDeclarationDefinitions.2.2.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoDeclarationDefinitions.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoDeclarationJob.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoComponent.2.0.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoDeclarationComponent.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoEngineeringDefinitions.1.0.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoEngineeringInput.1.0.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoInput.2.0.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> <None Include="Utils\VectoVersionCore.tt"> <Generator>TextTemplatingFileGenerator</Generator> <LastGenOutput>VectoVersionCore.cs</LastGenOutput> @@ -533,6 +633,7 @@ <Name>VectoHashing</Name> </ProjectReference> </ItemGroup> + <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/VectoCore/VectoCore/app.config b/VectoCore/VectoCore/app.config index a4fbc4b605af87b415cce7e84f8c1100815b9cff..64d75508937a7fa38550d00611a18adba3972680 100644 --- a/VectoCore/VectoCore/app.config +++ b/VectoCore/VectoCore/app.config @@ -3,4 +3,12 @@ <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> </configuration> \ No newline at end of file diff --git a/VectoCore/VectoCore/packages.config b/VectoCore/VectoCore/packages.config index 47eabea22f6ab24f1eeca6263a659e0bea7207f0..a7ecc2cafd89bb45cba48132a4827be44b535626 100644 --- a/VectoCore/VectoCore/packages.config +++ b/VectoCore/VectoCore/packages.config @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <packages> + <package id="Castle.Core" version="4.3.1" targetFramework="net45" /> <package id="JetBrains.Annotations" version="2018.3.0" targetFramework="net45" /> <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" /> + <package id="Ninject" version="3.3.4" targetFramework="net45" /> + <package id="Ninject.Extensions.NamedScope" version="3.3.0" targetFramework="net45" /> <package id="NLog" version="4.5.11" targetFramework="net45" /> <package id="System.Runtime" version="4.0.0" targetFramework="net45" /> </packages> \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs b/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs index 9c379daf88055cc24b9fc1bd42c6b256469b02b2..b6f91ba080cb0252133d24be126d0e96a20cc8f6 100644 --- a/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/JsonReadTest.cs @@ -111,7 +111,7 @@ namespace TUGraz.VectoCore.Tests.FileIO ((JObject)json["Body"]).Property("Aux").Remove(); // MK,2016-01-20: Changed for PWheel: aux entry may be missing, and that is ok. - var tmp = new JSONInputDataV2(json, TestJobFile).JobInputData.Vehicle.AuxiliaryInputData().Auxiliaries; + var tmp = new JSONInputDataV2(json, TestJobFile).JobInputData.Vehicle.Components.AuxiliaryInputData.Auxiliaries; Assert.IsTrue(tmp.Count == 0); } diff --git a/VectoCore/VectoCoreTest/FileIO/JsonWriteTest.cs b/VectoCore/VectoCoreTest/FileIO/JsonWriteTest.cs index cf02c9cac0df81058ccf99a6436d9ce865802a3c..869a72a2d16b9e2740f4cb9e7351279c8eec6270 100644 --- a/VectoCore/VectoCoreTest/FileIO/JsonWriteTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/JsonWriteTest.cs @@ -62,7 +62,7 @@ namespace TUGraz.VectoCore.Tests.FileIO var writer = JSONFileWriter.Instance; VECTO_Global.Cfg = new VECTO.Configuration() {DeclMode = true}; - writer.SaveVehicle(vehicleInput, vehicleInput.AirdragInputData, vehicleInput.RetarderInputData, vehicleInput.PTOTransmissionInputData, vehicleInput.AngledriveInputData, outFile); + writer.SaveVehicle(vehicleInput, vehicleInput.Components.AirdragInputData, vehicleInput.Components.RetarderInputData, vehicleInput.Components.PTOTransmissionInputData, vehicleInput.Components.AngledriveInputData, outFile); var savedData = JSONInputDataFactory.ReadComponentData(outFile); var savedInprovider = savedData as IEngineeringInputDataProvider; @@ -83,7 +83,7 @@ namespace TUGraz.VectoCore.Tests.FileIO var inputProvider = input as IEngineeringInputDataProvider; Assert.NotNull(inputProvider); - var engineInputData = inputProvider.JobInputData.Vehicle.EngineInputData; + var engineInputData = inputProvider.JobInputData.Vehicle.Components.EngineInputData; var writer = JSONFileWriter.Instance; @@ -94,7 +94,7 @@ namespace TUGraz.VectoCore.Tests.FileIO var savedInprovider = savedData as IEngineeringInputDataProvider; Assert.NotNull(savedInprovider); - AssertHelper.PublicPropertiesEqual(typeof(IEngineDeclarationInputData),engineInputData, savedInprovider.JobInputData.Vehicle.EngineInputData, + AssertHelper.PublicPropertiesEqual(typeof(IEngineDeclarationInputData),engineInputData, savedInprovider.JobInputData.Vehicle.Components.EngineInputData, new[] { "Source" }); } @@ -112,15 +112,15 @@ namespace TUGraz.VectoCore.Tests.FileIO var writer = JSONFileWriter.Instance; VECTO_Global.Cfg = new VECTO.Configuration() { DeclMode = true }; - writer.SaveGearbox(vehicleInputData.GearboxInputData, vehicleInputData.AxleGearInputData, outFile); + writer.SaveGearbox(vehicleInputData.Components.GearboxInputData, vehicleInputData.Components.AxleGearInputData, outFile); var savedData = JSONInputDataFactory.ReadComponentData(outFile); var savedInprovider = savedData as IEngineeringInputDataProvider; Assert.NotNull(savedInprovider); - AssertHelper.PublicPropertiesEqual(typeof(IGearboxDeclarationInputData), vehicleInputData.GearboxInputData, savedInprovider.JobInputData.Vehicle.GearboxInputData, + AssertHelper.PublicPropertiesEqual(typeof(IGearboxDeclarationInputData), vehicleInputData.Components.GearboxInputData, savedInprovider.JobInputData.Vehicle.Components.GearboxInputData, new[] { "Source" }); - AssertHelper.PublicPropertiesEqual(typeof(IAxleDeclarationInputData), vehicleInputData.AxleGearInputData, savedInprovider.JobInputData.Vehicle.AxleGearInputData, + AssertHelper.PublicPropertiesEqual(typeof(IAxleDeclarationInputData), vehicleInputData.Components.AxleGearInputData, savedInprovider.JobInputData.Vehicle.Components.AxleGearInputData, new[] { "Source" }); } diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/ADASVehicleTest.cs b/VectoCore/VectoCoreTest/Integration/Declaration/ADASVehicleTest.cs index 079dc7c40ee05199ec4927d664ee9d2d86c8ee76..d857f5e8be1a88c8d56aeabcb0d36c25062bbdc8 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/ADASVehicleTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/ADASVehicleTest.cs @@ -34,11 +34,13 @@ using System.IO; using System.Linq; using System.Xml; using System.Xml.Linq; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData; @@ -52,10 +54,16 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration { const string Class5ADAS = @"Testdata\Integration\DeclarationMode\Class5_ADAS\Tractor_4x2_vehicle-class-5_EURO6_2018.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } @@ -90,7 +98,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var writer = new FileOutputWriter(filename); - var inputData = new XMLDeclarationInputDataProvider(modified, true); //.ReadJsonJob(relativeJobPath); + var inputData = xmlInputReader.CreateDeclaration(modified, true); //.ReadJsonJob(relativeJobPath); var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, ActualModalData = true diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/EngineInputDataTests.cs b/VectoCore/VectoCoreTest/Integration/Declaration/EngineInputDataTests.cs index 50730bd1bcfd1dd09b7c0fe196f8433740e99bb4..bcb1badd2df38a858ce027be5ce8608820e1a9f4 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/EngineInputDataTests.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/EngineInputDataTests.cs @@ -33,11 +33,13 @@ using System.Data; using System.IO; using System.Linq; using System.Xml; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.InputData.Reader.ComponentData; using TUGraz.VectoCore.Models.Simulation.Data; @@ -52,10 +54,15 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration { const string SampleVehicleDecl = "TestData/XML/XMLReaderDeclaration/vecto_vehicle-sample.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [TestCase(null, 1.0, 45.542369, TestName = "Engine CF - NONE"), @@ -85,8 +92,8 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration modified = XmlReader.Create(new StringReader(nav.OuterXml)); } - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); - + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputDataProvider, null, validate: false); var first = factory.SimulationRuns().First(); diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/ExemptedVehicleTest.cs b/VectoCore/VectoCoreTest/Integration/Declaration/ExemptedVehicleTest.cs index b525aaaa60c61eab11c84cc68add4409334718a0..ddd93e9f54a220f29c17e84b2fc7c3a70421b684 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/ExemptedVehicleTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/ExemptedVehicleTest.cs @@ -34,6 +34,7 @@ using System.IO; using System.Linq; using System.Xml; using System.Xml.XPath; +using Ninject; using NUnit.Framework; using NUnit.Framework.Internal; using TUGraz.VectoCommon.Exceptions; @@ -41,12 +42,14 @@ using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.Tests.Models.Simulation; using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; namespace TUGraz.VectoCore.Tests.Integration { @@ -55,10 +58,16 @@ namespace TUGraz.VectoCore.Tests.Integration { const string ExemptedVehicle = @"Testdata\Integration\DeclarationMode\ExemptedVehicle\vecto_vehicle-sample_exempted.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [TestCase(ExemptedVehicle, 1)] @@ -79,7 +88,8 @@ namespace TUGraz.VectoCore.Tests.Integration File.Delete(monitoringFile); } - var inputData = new XMLDeclarationInputDataProvider(filename, true); //.ReadJsonJob(relativeJobPath); + var inputData = xmlInputReader.CreateDeclaration(filename, true); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, ActualModalData = true @@ -102,13 +112,13 @@ namespace TUGraz.VectoCore.Tests.Integration Assert.IsTrue(File.Exists(customerFile)); var validator = new XMLValidator(XmlReader.Create(manufactuerFile)); - Assert.IsTrue(validator.ValidateXML(XMLValidator.XmlDocumentType.ManufacturerReport)); + Assert.IsTrue(validator.ValidateXML(XmlDocumentType.ManufacturerReport)); var val2 = new XMLValidator(XmlReader.Create(customerFile)); - Assert.IsTrue(val2.ValidateXML(XMLValidator.XmlDocumentType.CustomerReport)); + Assert.IsTrue(val2.ValidateXML(XmlDocumentType.CustomerReport)); var val3 = new XMLValidator(XmlReader.Create(customerFile)); - Assert.IsTrue(val3.ValidateXML(XMLValidator.XmlDocumentType.MonitoringReport)); + Assert.IsTrue(val3.ValidateXML(XmlDocumentType.MonitoringReport)); } @@ -142,8 +152,8 @@ namespace TUGraz.VectoCore.Tests.Integration var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputData = new XMLDeclarationInputDataProvider(modified, true); - + var inputData = xmlInputReader.CreateDeclaration(modified, true); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, ActualModalData = true @@ -219,8 +229,8 @@ namespace TUGraz.VectoCore.Tests.Integration var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputData = new XMLDeclarationInputDataProvider(modified, true); - + var inputData = xmlInputReader.CreateDeclaration(modified, true); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, ActualModalData = true diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs b/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs index fa82837c5836ffcd44e84289fc41f2c9d3ae5e86..7eb37a39bbedcf9d83090e47ea5dcbb82452bfab 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/NaturalGasVehicles.cs @@ -36,12 +36,14 @@ using System.IO; using System.Xml; using System.Xml.Linq; using System.Xml.XPath; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData; @@ -55,10 +57,16 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration { const string Class5NG = @"Testdata\Integration\DeclarationMode\Class5_NG\Tractor_4x2_vehicle-class-5_EURO6_2018.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } @@ -90,7 +98,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration var modified = XmlReader.Create(new StringReader(nav.OuterXml)); var writer = new MockDeclarationWriter(filename); - var inputData = new XMLDeclarationInputDataProvider(modified, true); //.ReadJsonJob(relativeJobPath); + var inputData = xmlInputReader.CreateDeclaration(modified, true); var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, ActualModalData = true diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/TestMaxMassInMUCycle.cs b/VectoCore/VectoCoreTest/Integration/Declaration/TestMaxMassInMUCycle.cs index d2dce4a88b1f3b317a3f1c0be42a67e7407f660f..f78bd39032abda2684af1b9cb6210167709af9d2 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/TestMaxMassInMUCycle.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/TestMaxMassInMUCycle.cs @@ -31,9 +31,11 @@ using System.IO; using System.Linq; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.InputData.FileIO.JSON; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData.FileIO; @@ -44,10 +46,17 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration [TestFixture()] public class TestMaxMassInMUCycle { + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } @@ -56,7 +65,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Declaration { var relativeJobPath = jobFile; var writer = new FileOutputWriter(relativeJobPath); - var inputData = Path.GetExtension(relativeJobPath) == ".xml" ? new XMLDeclarationInputDataProvider(relativeJobPath, true) : JSONInputDataFactory.ReadJsonJob(relativeJobPath); + var inputData = Path.GetExtension(relativeJobPath) == ".xml" ? xmlInputReader.CreateDeclaration(relativeJobPath, true) : JSONInputDataFactory.ReadJsonJob(relativeJobPath); var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, //ActualModalData = true, diff --git a/VectoCore/VectoCoreTest/Integration/Declaration/VocationalVehicleTest.cs b/VectoCore/VectoCoreTest/Integration/Declaration/VocationalVehicleTest.cs index b32f5865d7702e03c9efc44bf15cd35894fda01d..e29c33eb1a69cca64eabaea5dab460edc4cbe7c7 100644 --- a/VectoCore/VectoCoreTest/Integration/Declaration/VocationalVehicleTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Declaration/VocationalVehicleTest.cs @@ -32,10 +32,12 @@ using System; using System.IO; using System.Linq; +using Ninject; using NUnit.Framework; using NUnit.Framework.Internal; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.InputData.FileIO.JSON; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData.FileIO; @@ -49,10 +51,16 @@ namespace TUGraz.VectoCore.Tests.Integration const string Class4Vocational = @"Testdata\Integration\DeclarationMode\Class4_Vocational\Rigid Truck_4x2_vehicle-class-4_EURO6_2018.xml"; const string Class5Vocational = @"Testdata\Integration\DeclarationMode\Class5_Vocational\Tractor_4x2_vehicle-class-5_EURO6_2018.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } @@ -62,7 +70,7 @@ namespace TUGraz.VectoCore.Tests.Integration public void VocationalTest(string filename, int numRuns) { var writer = new FileOutputWriter(filename); - var inputData = new XMLDeclarationInputDataProvider(filename, true); //.ReadJsonJob(relativeJobPath); + var inputData = xmlInputReader.CreateDeclaration(filename, true); var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, ActualModalData = true diff --git a/VectoCore/VectoCoreTest/Integration/TestVehicleIdlingSpeed.cs b/VectoCore/VectoCoreTest/Integration/TestVehicleIdlingSpeed.cs index b9ffcc9317e273577a0938aeceb108a41c39ed9f..ce8cc40fd6204b3e5bd21680c85cee625ac84782 100644 --- a/VectoCore/VectoCoreTest/Integration/TestVehicleIdlingSpeed.cs +++ b/VectoCore/VectoCoreTest/Integration/TestVehicleIdlingSpeed.cs @@ -31,6 +31,7 @@ using System.IO; using System.Xml; +using Ninject; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; @@ -42,6 +43,7 @@ using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.Utils; using NUnit.Framework; +using TUGraz.VectoCore.InputData.FileIO.XML; namespace TUGraz.VectoCore.Tests.Integration { @@ -50,10 +52,16 @@ namespace TUGraz.VectoCore.Tests.Integration { const string SampleVehicleDecl = "TestData/XML/XMLReaderDeclaration/vecto_vehicle-sample.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [TestCase, Category("LongRunning")] @@ -78,8 +86,8 @@ namespace TUGraz.VectoCore.Tests.Integration var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); - + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputDataProvider, new FileOutputWriter("Idle900")); //factory.WriteModalResults = true; diff --git a/VectoCore/VectoCoreTest/Integration/TorqueLimitsTest.cs b/VectoCore/VectoCoreTest/Integration/TorqueLimitsTest.cs index 5200c206f6eb15e4b93f543550c91236430d88a5..307b95d22e8500967d0032836f0adba914f509dc 100644 --- a/VectoCore/VectoCoreTest/Integration/TorqueLimitsTest.cs +++ b/VectoCore/VectoCoreTest/Integration/TorqueLimitsTest.cs @@ -33,10 +33,12 @@ using System; using System.Data; using System.IO; using System.Linq; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData; @@ -73,10 +75,16 @@ namespace TUGraz.VectoCore.Tests.Integration private const string DeclarationVehicle9GearsFord = @"TestData\Integration\DeclarationMode\EngineSpeedTooHigh\vecto_vehicle-sample_9gears.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } @@ -288,7 +296,7 @@ namespace TUGraz.VectoCore.Tests.Integration [TestCase(DeclarationVehicle9GearsFord)] public void EngineSpeedTooHigh9SpeedGearbox(string jobFile) { - var inputData = new XMLDeclarationInputDataProvider(jobFile, true); + var inputData = xmlInputReader.CreateDeclaration(jobFile, true); var fileWriter = new FileOutputWriter(jobFile); var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter) { WriteModalResults = true, diff --git a/VectoCore/VectoCoreTest/Integration/XMLReportTest.cs b/VectoCore/VectoCoreTest/Integration/XMLReportTest.cs index 72542ba8554a702d240689c8a0d0a0279d863340..9bd1a5a0f694d352182ae91acf7dcd780f5aeb93 100644 --- a/VectoCore/VectoCoreTest/Integration/XMLReportTest.cs +++ b/VectoCore/VectoCoreTest/Integration/XMLReportTest.cs @@ -35,11 +35,13 @@ using System.Text; using System.Xml; using System.Xml.Linq; using System.Xml.XPath; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData; @@ -47,6 +49,7 @@ using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.OutputData.XML; using TUGraz.VectoCore.Tests.XML; using TUGraz.VectoCore.Utils; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; namespace TUGraz.VectoCore.Tests.Integration @@ -54,17 +57,23 @@ namespace TUGraz.VectoCore.Tests.Integration [TestFixture] public class XMLReportTest { + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [TestCase] public void TestXMLReportMetaInformation() { var jobfile = @"Testdata\XML\XMLReaderDeclaration\vecto_vehicle-sample.xml"; - var dataProvider = new XMLDeclarationInputDataProvider(XmlReader.Create(jobfile), true); + var dataProvider = xmlInputReader.CreateDeclaration(jobfile, true); var writer = new FileOutputWriter(jobfile); var xmlReport = new XMLDeclarationReport(writer); var sumData = new SummaryDataContainer(writer); @@ -92,10 +101,10 @@ namespace TUGraz.VectoCore.Tests.Integration Assert.IsFalse(XmlConvert.ToBoolean(manufacturerReport.XPathSelectElement("//*[local-name()='PTO']").Value)); var reportWheels = manufacturerReport.XPathSelectElements("//*[local-name()='TyreCertificationNumber']").ToList(); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.Axles.Count, reportWheels.Count); + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.AxleWheels.AxlesDeclaration.Count, reportWheels.Count); var i = 0; - foreach (var axleDeclarationInputData in dataProvider.JobInputData.Vehicle.Axles) { + foreach (var axleDeclarationInputData in dataProvider.JobInputData.Vehicle.Components.AxleWheels.AxlesDeclaration) { Assert.AreEqual(axleDeclarationInputData.Tyre.CertificationNumber, reportWheels[i++].Value); } @@ -111,7 +120,7 @@ namespace TUGraz.VectoCore.Tests.Integration TestCase(@"TestData\Integration\DeclarationMode\ExemptedVehicle\vecto_vehicle-sample_exempted.xml")] public void TestValidationXMLReports(string jobfile) { - var dataProvider = new XMLDeclarationInputDataProvider(XmlReader.Create(jobfile), true); + var dataProvider = xmlInputReader.CreateDeclaration(jobfile, true); var writer = new FileOutputWriter(jobfile); var xmlReport = new XMLDeclarationReport(writer); var sumData = new SummaryDataContainer(writer); @@ -131,13 +140,13 @@ namespace TUGraz.VectoCore.Tests.Integration jobContainer.WaitFinished(); var mrfValidator = GetValidator(xmlReport.FullReport); - mrfValidator.ValidateXML(XMLValidator.XmlDocumentType.ManufacturerReport); + mrfValidator.ValidateXML(XmlDocumentType.ManufacturerReport); var cifValidator = GetValidator(xmlReport.CustomerReport); - cifValidator.ValidateXML(XMLValidator.XmlDocumentType.CustomerReport); + cifValidator.ValidateXML(XmlDocumentType.CustomerReport); var monitoringValidator = GetValidator(xmlReport.MonitoringReport); - monitoringValidator.ValidateXML(XMLValidator.XmlDocumentType.MonitoringReport); + monitoringValidator.ValidateXML(XmlDocumentType.MonitoringReport); } private static XMLValidator GetValidator(XDocument xmlReport) @@ -206,8 +215,8 @@ namespace TUGraz.VectoCore.Tests.Integration var sumData = new SummaryDataContainer(writer); var jobContainer = new JobContainer(sumData); - var dataProvider = new XMLDeclarationInputDataProvider(modified, true); - + var dataProvider = xmlInputReader.CreateDeclaration(modified, true); + var runsFactory = new SimulatorFactory(ExecutionMode.Declaration, dataProvider, writer, xmlReport) { WriteModalResults = false, Validate = false, diff --git a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs index 3a472ec349c77e82fe7ebcf9f58fd5ca03bd60f2..a3762dfe20bedf8a7aeff8da4383f2ac1ed8942d 100644 --- a/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs +++ b/VectoCore/VectoCoreTest/Models/Declaration/ShiftPolygonTest.cs @@ -33,11 +33,13 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.JSON; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.InputData.Reader; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; @@ -54,11 +56,16 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration [TestFixture] public class ShiftPolygonTest { - + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } @@ -600,16 +607,16 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration Assert.Inconclusive("Confidential File not found. Test cannot run without file."); } - IDeclarationInputDataProvider job = (IDeclarationInputDataProvider)(Path.GetExtension(jobFile) == ".vecto" ? JSONInputDataFactory.ReadJsonJob(jobFile) : new XMLDeclarationInputDataProvider(jobFile, true)); + IDeclarationInputDataProvider job = (IDeclarationInputDataProvider)(Path.GetExtension(jobFile) == ".vecto" ? JSONInputDataFactory.ReadJsonJob(jobFile) : xmlInputReader.CreateDeclaration(jobFile, true)); - var gearboxData = job.JobInputData.Vehicle.GearboxInputData; + var gearboxData = job.JobInputData.Vehicle.Components.GearboxInputData; var idlespeed = VectoMath.Max( - job.JobInputData.Vehicle.EngineIdleSpeed, job.JobInputData.Vehicle.EngineInputData.IdleSpeed); + job.JobInputData.Vehicle.EngineIdleSpeed, job.JobInputData.Vehicle.Components.EngineInputData.IdleSpeed); var dao = new DeclarationDataAdapter(); var engineData = dao.CreateEngineData( - job.JobInputData.Vehicle.EngineInputData, idlespeed, gearboxData, job.JobInputData.Vehicle.TorqueLimits); - var axlegearRatio = job.JobInputData.Vehicle.AxleGearInputData.Ratio; - var rdyn = job.JobInputData.Vehicle.Axles.Where(x => x.AxleType == AxleType.VehicleDriven) + job.JobInputData.Vehicle.Components.EngineInputData, idlespeed, gearboxData, job.JobInputData.Vehicle.TorqueLimits); + var axlegearRatio = job.JobInputData.Vehicle.Components.AxleGearInputData.Ratio; + var rdyn = job.JobInputData.Vehicle.Components.AxleWheels.AxlesDeclaration.Where(x => x.AxleType == AxleType.VehicleDriven) .Select(x => DeclarationData.Wheels.Lookup(x.Tyre.Dimension)).Average(x => x.DynamicTyreRadius.Value()) .SI<Meter>(); @@ -660,6 +667,17 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration { const string BasePath = @"E:\QUAM\Workspace\Daten_INTERN\Testfahrzeuge\"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + + [OneTimeSetUp] + public void RunBeforeAnyTests() + { + Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); + } [Category("LongRunning")] [Ignore("No Assertions - only plotting shift polygons")] @@ -847,15 +865,15 @@ namespace TUGraz.VectoCore.Tests.Models.Declaration [TestCase(@"E:\QUAM\Workspace\VECTO-Bugreports\BugReportTests\Bugreport Jobs\20190307_VECTO-904_Extrapolation\OM-18173493.xml")] public void ComputeShiftPolygonXML(string xmlJob) { - var inputData = new XMLDeclarationInputDataProvider(xmlJob, true); + var inputData = xmlInputReader.CreateDeclaration(xmlJob, true); var dao = new DeclarationDataAdapter(); - var gearboxData = inputData.JobInputData.Vehicle.GearboxInputData; - var engineData = dao.CreateEngineData(inputData.JobInputData.Vehicle.EngineInputData,0.RPMtoRad(), gearboxData, new List<ITorqueLimitInputData>()); + var gearboxData = inputData.JobInputData.Vehicle.Components.GearboxInputData; + var engineData = dao.CreateEngineData(inputData.JobInputData.Vehicle.Components.EngineInputData,0.RPMtoRad(), gearboxData, new List<ITorqueLimitInputData>()); var fullLoadCurves = engineData.FullLoadCurves; - var axlegearRatio = inputData.JobInputData.Vehicle.AxleGearInputData.Ratio; + var axlegearRatio = inputData.JobInputData.Vehicle.Components.AxleGearInputData.Ratio; var vehicle = inputData.JobInputData.Vehicle; var segment = DeclarationData.Segments.Lookup( vehicle.VehicleCategory, vehicle.AxleConfiguration, vehicle.GrossVehicleMassRating, vehicle.CurbMassChassis, diff --git a/VectoCore/VectoCoreTest/Models/Simulation/DeclarationSimulationFactoryTest.cs b/VectoCore/VectoCoreTest/Models/Simulation/DeclarationSimulationFactoryTest.cs index b890bfd432a48cfac8ff72334b232cc48d1d8bfb..695d5868a51142b781750e9388c1668bcf0acd63 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/DeclarationSimulationFactoryTest.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/DeclarationSimulationFactoryTest.cs @@ -32,10 +32,12 @@ using System.IO; using System.Linq; using System.Xml; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; using TUGraz.VectoCore.Configuration; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Utils; @@ -47,10 +49,16 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation { const string SampleVehicleDecl = "TestData/XML/XMLReaderDeclaration/vecto_vehicle-sample.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [TestCase("None", RetarderType.None), @@ -77,8 +85,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); - + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputDataProvider, null) { Validate = false }; var runs = factory.SimulationRuns().ToArray(); @@ -88,8 +96,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation [TestCase()] public void TestEngineCorrectionFactor() { - var inputDataProvider = new XMLDeclarationInputDataProvider(XmlReader.Create(SampleVehicleDecl), true); - + var inputDataProvider = xmlInputReader.CreateDeclaration(SampleVehicleDecl, true); + var factory = new SimulatorFactory(ExecutionMode.Declaration, inputDataProvider, null) { Validate = false }; var runs = factory.SimulationRuns().ToArray(); diff --git a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs index 188b938f63f1bfd4cc6fea3d59fe84cb4589cb4f..1459be646a7b758d7f0b9e780a85a51c5d1638f3 100644 --- a/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs +++ b/VectoCore/VectoCoreTest/Models/SimulationComponentData/ValidationTest.cs @@ -618,7 +618,7 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponentData public class DummyGearboxData : IGearboxEngineeringInputData { - public DataSourceType SourceType { get; set; } + public DataSource DataSource { get; set; } public string Source { get; set; } public bool SavedInDeclarationMode { get; set; } public string Manufacturer { get; set; } diff --git a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs index e78e77a314d5faac2abdd2a48c43a42db82c67f3..410058f6e7a4695d7c4b3a531263ba9534d51c83 100644 --- a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs +++ b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs @@ -48,6 +48,8 @@ using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.Tests.Integration; using TUGraz.VectoCore.Tests.Utils; using System.IO; +using Ninject; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Tests.Models.Simulation; @@ -57,10 +59,17 @@ namespace TUGraz.VectoCore.Tests.Reports [TestFixture] public class ModDataTest { + + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [TestCase(80, 0), @@ -153,7 +162,7 @@ namespace TUGraz.VectoCore.Tests.Reports public void TractionInterruptionTest(string filename, int idx, double expectedTractionInterruption) { var writer = new FileOutputWriter(filename); - var inputData = new XMLDeclarationInputDataProvider(filename, true); + var inputData = xmlInputReader.CreateDeclaration(filename, true); var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, }; @@ -330,12 +339,12 @@ namespace TUGraz.VectoCore.Tests.Reports FuelConsumptionMap fcMap = null; if (engInput != null) { fcMap = FuelConsumptionMapReader.Create(engInput.JobInputData.Vehicle - .EngineInputData.FuelConsumptionMap); + .Components.EngineInputData.FuelConsumptionMap); } var vtpInput = inputData as IVTPEngineeringInputDataProvider; if (vtpInput != null ) { fcMap = FuelConsumptionMapReader.Create(vtpInput.JobInputData.Vehicle - .EngineInputData.FuelConsumptionMap); + .Components.EngineInputData.FuelConsumptionMap); } var disatanceBased = ((VehicleContainer)(jobContainer.Runs.First().Run.GetContainer())).DrivingCycle is DistanceBasedDrivingCycle; @@ -619,7 +628,7 @@ namespace TUGraz.VectoCore.Tests.Reports foreach (var modalResults in modData) { AssertModDataIntegrityAT(modalResults.Item1, auxKeys, modalResults.Item2, - FuelConsumptionMapReader.Create(((IEngineeringInputDataProvider)inputData).JobInputData.Vehicle.EngineInputData.FuelConsumptionMap), true); + FuelConsumptionMapReader.Create(((IEngineeringInputDataProvider)inputData).JobInputData.Vehicle.Components.EngineInputData.FuelConsumptionMap), true); } AssertSumDataIntegrity(sumData, ExecutionMode.Engineering, true); diff --git a/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs b/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs index 4a1ff5ff378b79810d59b8b37512b2ace5cb683a..d8acbfb6d546cb91c26ea1b7c7dfa642f284be53 100644 --- a/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs +++ b/VectoCore/VectoCoreTest/Reports/SumWriterTest.cs @@ -31,6 +31,7 @@ using System.IO; using System.Xml; +using Ninject; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; @@ -43,6 +44,7 @@ using TUGraz.VectoCore.OutputData.XML; using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; using NUnit.Framework; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.Models.Declaration; namespace TUGraz.VectoCore.Tests.Reports @@ -50,10 +52,18 @@ namespace TUGraz.VectoCore.Tests.Reports [TestFixture] public class SumWriterTest { + + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [TestCase] @@ -174,7 +184,7 @@ namespace TUGraz.VectoCore.Tests.Reports public void TestSumDataMetaInformation() { var jobfile = @"Testdata\XML\XMLReaderDeclaration\vecto_vehicle-sample.xml"; - var dataProvider = new XMLDeclarationInputDataProvider(XmlReader.Create(jobfile), true); + var dataProvider = xmlInputReader.CreateDeclaration(jobfile, true); var writer = new FileOutputWriter(jobfile); var xmlReport = new XMLDeclarationReport(writer); var sumData = new SummaryDataContainer(writer); @@ -196,33 +206,33 @@ namespace TUGraz.VectoCore.Tests.Reports Assert.AreEqual(dataProvider.JobInputData.Vehicle.Manufacturer, sumRow[SummaryDataContainer.VEHICLE_MANUFACTURER]); Assert.AreEqual(dataProvider.JobInputData.Vehicle.Model, sumRow[SummaryDataContainer.VEHICLE_MODEL]); Assert.AreEqual(dataProvider.JobInputData.Vehicle.VIN, sumRow[SummaryDataContainer.VIN_NUMBER]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.Manufacturer, + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.Manufacturer, sumRow[SummaryDataContainer.ENGINE_MANUFACTURER]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.Model, sumRow[SummaryDataContainer.ENGINE_MODEL]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.FuelType.ToXMLFormat(), + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.Model, sumRow[SummaryDataContainer.ENGINE_MODEL]); + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.FuelType.ToXMLFormat(), sumRow[SummaryDataContainer.ENGINE_FUEL_TYPE]); - Assert.AreEqual((dataProvider.JobInputData.Vehicle.EngineInputData.RatedPowerDeclared.ConvertToKiloWatt()), + Assert.AreEqual((dataProvider.JobInputData.Vehicle.Components.EngineInputData.RatedPowerDeclared.ConvertToKiloWatt()), ((ConvertedSI)sumRow[SummaryDataContainer.ENGINE_RATED_POWER])); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.RatedSpeedDeclared.AsRPM, + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.RatedSpeedDeclared.AsRPM, (double)((ConvertedSI)sumRow[SummaryDataContainer.ENGINE_RATED_SPEED])); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.Displacement.ConvertToCubicCentiMeter(), + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.Displacement.ConvertToCubicCentiMeter(), ((ConvertedSI)sumRow[SummaryDataContainer.ENGINE_DISPLACEMENT])); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.GearboxInputData.Manufacturer, + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.GearboxInputData.Manufacturer, sumRow[SummaryDataContainer.GEARBOX_MANUFACTURER]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.GearboxInputData.Model, sumRow[SummaryDataContainer.GEARBOX_MODEL]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.AxleGearInputData.Manufacturer, + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.GearboxInputData.Model, sumRow[SummaryDataContainer.GEARBOX_MODEL]); + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.AxleGearInputData.Manufacturer, sumRow[SummaryDataContainer.AXLE_MANUFACTURER]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.AxleGearInputData.Model, sumRow[SummaryDataContainer.AXLE_MODEL]); + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.AxleGearInputData.Model, sumRow[SummaryDataContainer.AXLE_MODEL]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.ColdHotBalancingFactor, + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.ColdHotBalancingFactor, sumRow[SummaryDataContainer.ENGINE_BF_COLD_HOT]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.CorrectionFactorRegPer, + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.CorrectionFactorRegPer, sumRow[SummaryDataContainer.ENGINE_CF_REG_PER]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.WHTCRural, + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.WHTCRural, sumRow[SummaryDataContainer.ENGINE_WHTC_RURAL]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.WHTCUrban, + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.WHTCUrban, sumRow[SummaryDataContainer.ENGINE_WHTC_URBAN]); - Assert.AreEqual(dataProvider.JobInputData.Vehicle.EngineInputData.WHTCMotorway, + Assert.AreEqual(dataProvider.JobInputData.Vehicle.Components.EngineInputData.WHTCMotorway, sumRow[SummaryDataContainer.ENGINE_WHTC_MOTORWAY]); } @@ -240,7 +250,7 @@ namespace TUGraz.VectoCore.Tests.Reports Stream fh = !File.Exists(modFilename) ? File.Create(modFilename) : File.OpenRead(modFilename); var writer = new FileOutputWriter(jobFile); - var inputData = new XMLDeclarationInputDataProvider(jobFile, true); + var inputData = xmlInputReader.CreateDeclaration(jobFile, true); var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, ActualModalData = true @@ -272,7 +282,7 @@ namespace TUGraz.VectoCore.Tests.Reports Stream fh = !File.Exists(sumFilename) ? File.Create(sumFilename) : File.OpenRead(sumFilename); var writer = new FileOutputWriter(jobFile); - var inputData = new XMLDeclarationInputDataProvider(jobFile, true); + var inputData = xmlInputReader.CreateDeclaration(jobFile, true); var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, writer) { WriteModalResults = true, ActualModalData = true diff --git a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs index d6752211e7bce43dfd2dbaa2ecea2aeb7061859f..101206e872ec8b97fdf54f67b192301e2ba80883 100644 --- a/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs +++ b/VectoCore/VectoCoreTest/Utils/MockEngineDataProvider.cs @@ -38,7 +38,7 @@ namespace TUGraz.VectoCore.Tests.Utils { public class MockEngineDataProvider : IEngineEngineeringInputData { - public DataSourceType SourceType { get; set; } + public DataSource DataSource { get; set; } public string Source { get; set; } public bool SavedInDeclarationMode { get; set; } public string Manufacturer { get; set; } diff --git a/VectoCore/VectoCoreTest/VectoCoreTest.csproj b/VectoCore/VectoCoreTest/VectoCoreTest.csproj index b4c63acebdd30e817462f372f12ea33d3238b507..74dbc81805a6db1cfc19a1ed60816b7d4a9bcff2 100644 --- a/VectoCore/VectoCoreTest/VectoCoreTest.csproj +++ b/VectoCore/VectoCoreTest/VectoCoreTest.csproj @@ -40,11 +40,19 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll</HintPath> + <Private>True</Private> + </Reference> <Reference Include="Microsoft.CSharp" /> <Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> + <Reference Include="Ninject, Version=3.3.4.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL"> + <HintPath>..\..\packages\Ninject.3.3.4\lib\net45\Ninject.dll</HintPath> + <Private>True</Private> + </Reference> <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <HintPath>..\..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath> <Private>True</Private> diff --git a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs index 8213b35ad88862be2a7012d094b6772ffb207e18..55506ca91ad9ea99c2727b00301587331e4b96f2 100644 --- a/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLDeclarationInputTest.cs @@ -35,6 +35,7 @@ using System.IO; using System.Linq; using System.Xml; using System.Xml.XPath; +using Ninject; using TUGraz.VectoCommon.Exceptions; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Resources; @@ -52,6 +53,7 @@ using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Utils; using NUnit.Framework; using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.Reader.DataObjectAdapter; namespace TUGraz.VectoCore.Tests.XML @@ -68,20 +70,26 @@ namespace TUGraz.VectoCore.Tests.XML const string SampleVehicleFullDeclCertificationOptions = "TestData/XML/XMLReaderDeclaration/vecto_vehicle-sample_certificationOptions.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [TestCase] - public void TestXMLInputEng() + public void TestXMLInputDecl() { var reader = XmlReader.Create(SampleVehicleDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); - var engineDataProvider = inputDataProvider.JobInputData.Vehicle.EngineInputData; + var engineDataProvider = inputDataProvider.JobInputData.Vehicle.Components.EngineInputData; Assert.IsTrue(engineDataProvider.SavedInDeclarationMode); @@ -142,9 +150,8 @@ namespace TUGraz.VectoCore.Tests.XML engineFuelType.SetValue(fuel); var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, - true); - var fuelTyle = inputDataProvider.JobInputData.Vehicle.EngineInputData.FuelType; + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); + var fuelTyle = inputDataProvider.JobInputData.Vehicle.Components.EngineInputData.FuelType; Assert.AreEqual(fuel, fuelTyle.ToXMLFormat()); var tankSystem = fuelTyle == FuelType.NGPI || fuelTyle == FuelType.NGCI ? TankSystem.Liquefied : (TankSystem?)null; Assert.NotNull(DeclarationData.FuelData.Lookup(fuelTyle, tankSystem)); @@ -175,9 +182,8 @@ namespace TUGraz.VectoCore.Tests.XML engineFuelType.SetValue(fuel); var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, - true); - var fuelTyle = inputDataProvider.JobInputData.Vehicle.EngineInputData.FuelType; + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); + var fuelTyle = inputDataProvider.JobInputData.Vehicle.Components.EngineInputData.FuelType; Assert.AreEqual(fuel, fuelTyle.ToXMLFormat()); AssertHelper.Exception<VectoException>( () => { @@ -190,8 +196,8 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); - var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.GearboxInputData; + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); + var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData; Assert.AreEqual("Generic 40t Long Haul Truck Gearbox", gearboxDataProvider.Model); Assert.AreEqual(GearboxType.AMT, gearboxDataProvider.Type); @@ -216,8 +222,8 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); - var axlegearDataProvider = inputDataProvider.JobInputData.Vehicle.AxleGearInputData; + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); + var axlegearDataProvider = inputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData; Assert.AreEqual("Generic 40t Long Haul Truck AxleGear", axlegearDataProvider.Model); @@ -240,8 +246,8 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); - var retarderDataProvider = inputDataProvider.JobInputData.Vehicle.RetarderInputData; + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); + var retarderDataProvider = inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData; Assert.AreEqual("Generic Retarder", retarderDataProvider.Model); @@ -262,10 +268,10 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); var vehicleDataProvider = inputDataProvider.JobInputData.Vehicle; - var axles = vehicleDataProvider.Axles; + var axles = vehicleDataProvider.Components.AxleWheels.AxlesDeclaration; var tyre = axles[0].Tyre; Assert.AreEqual("315/70 R22.5", tyre.Dimension); @@ -307,11 +313,11 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); var vehicleDataProvider = inputDataProvider.JobInputData.Vehicle; AssertHelper.Exception<VectoException>(() => { - var axles = vehicleDataProvider.Axles; + var axles = vehicleDataProvider.Components.AxleWheels.AxlesDeclaration; }); } @@ -344,7 +350,7 @@ namespace TUGraz.VectoCore.Tests.XML AssertHelper.Exception<VectoException>( () => { - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); }); } @@ -376,11 +382,11 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); var vehicleDataProvider = inputDataProvider.JobInputData.Vehicle; AssertHelper.Exception<VectoException>(() => { - var axles = vehicleDataProvider.Axles; + var axles = vehicleDataProvider.Components.AxleWheels.AxlesDeclaration; }); } @@ -389,8 +395,8 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); - var auxDataProvider = inputDataProvider.JobInputData.Vehicle.AuxiliaryInputData(); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); + var auxDataProvider = inputDataProvider.JobInputData.Vehicle.Components.AuxiliaryInputData; var aux = auxDataProvider.Auxiliaries; var aux1 = aux[0]; @@ -409,7 +415,7 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); var vehicleDataProvider = inputDataProvider.JobInputData.Vehicle; @@ -418,9 +424,9 @@ namespace TUGraz.VectoCore.Tests.XML Assert.AreEqual(7100.0, vehicleDataProvider.CurbMassChassis.Value()); Assert.AreEqual(40000.0, vehicleDataProvider.GrossVehicleMassRating.Value()); - Assert.AreEqual(6.34, inputDataProvider.JobInputData.Vehicle.AirdragInputData.AirDragArea.Value()); + Assert.AreEqual(6.34, inputDataProvider.JobInputData.Vehicle.Components.AirdragInputData.AirDragArea.Value()); - Assert.AreEqual(1.0, inputDataProvider.JobInputData.Vehicle.RetarderInputData.Ratio); + Assert.AreEqual(1.0, inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData.Ratio); } [TestCase] @@ -428,9 +434,9 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleDeclNoAirdrag); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); - Assert.IsNull(inputDataProvider.JobInputData.Vehicle.AirdragInputData.AirDragArea); + Assert.IsNull(inputDataProvider.JobInputData.Vehicle.Components.AirdragInputData.AirDragArea); } [Category("LongRunning")] @@ -443,7 +449,7 @@ namespace TUGraz.VectoCore.Tests.XML var sumWriter = new FileOutputWriter("vecto_vehicle-sample_xml"); var sumData = new SummaryDataContainer(sumWriter); var jobContainer = new JobContainer(sumData); - var dataProvider = new XMLDeclarationInputDataProvider(reader, true); + var dataProvider = xmlInputReader.CreateDeclaration(reader, true); var runsFactory = new SimulatorFactory(ExecutionMode.Declaration, dataProvider, fileWriter); runsFactory.WriteModalResults = true; @@ -458,9 +464,9 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleFullDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); - var tcDataProvider = inputDataProvider.JobInputData.Vehicle.TorqueConverterInputData; + var tcDataProvider = inputDataProvider.JobInputData.Vehicle.Components.TorqueConverterInputData; Assert.AreEqual(3, tcDataProvider.TCData.Rows.Count); @@ -473,10 +479,10 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleFullDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); - var angledriveDataProvider = inputDataProvider.JobInputData.Vehicle.AngledriveInputData; + var angledriveDataProvider = inputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData; Assert.AreEqual(2.345, angledriveDataProvider.Ratio); Assert.AreEqual(6, angledriveDataProvider.LossMap.Rows.Count); @@ -492,7 +498,7 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleFullDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); var vehicleDataProvider = inputDataProvider.JobInputData.Vehicle; Assert.AreEqual(VehicleCategory.Tractor, vehicleDataProvider.VehicleCategory); @@ -500,9 +506,9 @@ namespace TUGraz.VectoCore.Tests.XML Assert.AreEqual(7100.0, vehicleDataProvider.CurbMassChassis.Value()); Assert.AreEqual(40000.0, vehicleDataProvider.GrossVehicleMassRating.Value()); - Assert.AreEqual(6.34, inputDataProvider.JobInputData.Vehicle.AirdragInputData.AirDragArea.Value()); + Assert.AreEqual(6.34, inputDataProvider.JobInputData.Vehicle.Components.AirdragInputData.AirDragArea.Value()); - Assert.AreEqual(1.0, inputDataProvider.JobInputData.Vehicle.RetarderInputData.Ratio); + Assert.AreEqual(1.0, inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData.Ratio); } [TestCase] @@ -510,7 +516,7 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleFullDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); var vehicleDataProvider = inputDataProvider.JobInputData.Vehicle; var torqueLimits = vehicleDataProvider.TorqueLimits.OrderBy(x => x.Gear).ToList(); @@ -525,8 +531,8 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleFullDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); - var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.GearboxInputData; + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); + var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData; var gears = gearboxDataProvider.Gears; Assert.AreEqual(12, gears.Count); @@ -540,8 +546,8 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleFullDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); - var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.GearboxInputData; + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); + var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData; var gears = gearboxDataProvider.Gears; Assert.AreEqual(12, gears.Count); @@ -570,10 +576,10 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); AssertHelper.Exception<VectoException>(() => { - var tmp = inputDataProvider.JobInputData.Vehicle.RetarderInputData.Ratio; + var tmp = inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData.Ratio; }); } @@ -604,7 +610,7 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); var factory = new SimulatorFactory(ExecutionMode.Declaration, inputDataProvider, new FileOutputWriter("dummy")); var jobContainer = new JobContainer(null); @@ -636,9 +642,9 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); - Assert.AreEqual(retarderType, inputDataProvider.JobInputData.Vehicle.RetarderInputData.Type.ToXMLFormat()); + Assert.AreEqual(retarderType, inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData.Type.ToXMLFormat()); } } @@ -664,7 +670,7 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); Assert.AreEqual(axleConfiguration, inputDataProvider.JobInputData.Vehicle.AxleConfiguration.GetName()); } @@ -696,7 +702,7 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); var vehCategory = inputDataProvider.JobInputData.Vehicle.VehicleCategory; Assert.AreEqual(vehicleCategory, vehCategory.ToXMLFormat()); @@ -731,10 +737,10 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); - var tyreDimension = inputDataProvider.JobInputData.Vehicle.Axles.First().Tyre.Dimension; + var tyreDimension = inputDataProvider.JobInputData.Vehicle.Components.AxleWheels.AxlesDeclaration.First().Tyre.Dimension; Assert.AreEqual(wheelDimension, tyreDimension); Assert.IsTrue(DeclarationData.Wheels.GetWheelsDimensions().Contains(tyreDimension), "Unknown tyre dimension {0}", tyreDimension); @@ -786,20 +792,20 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); if (ptoGearWheel == "none") { Assert.AreEqual("None", - inputDataProvider.JobInputData.Vehicle.PTOTransmissionInputData.PTOTransmissionType); + inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData.PTOTransmissionType); } else if (ptoGearWheel == "only one engaged gearwheel above oil level") { Assert.AreEqual(ptoGearWheel, - inputDataProvider.JobInputData.Vehicle.PTOTransmissionInputData.PTOTransmissionType); + inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData.PTOTransmissionType); } else { Assert.AreEqual(string.Format("{0} - {1}", ptoGearWheel, ptoOther), - inputDataProvider.JobInputData.Vehicle.PTOTransmissionInputData.PTOTransmissionType); + inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData.PTOTransmissionType); } - Assert.NotNull(DeclarationData.PTOTransmission.Lookup(inputDataProvider.JobInputData.Vehicle + Assert.NotNull(DeclarationData.PTOTransmission.Lookup(inputDataProvider.JobInputData.Vehicle.Components .PTOTransmissionInputData .PTOTransmissionType)); } @@ -830,10 +836,10 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); - Assert.AreEqual(angleDrive, inputDataProvider.JobInputData.Vehicle.AngledriveInputData.Type.ToXMLFormat()); + Assert.AreEqual(angleDrive, inputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData.Type.ToXMLFormat()); } } @@ -864,10 +870,10 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); - var gbxType = inputDataProvider.JobInputData.Vehicle.GearboxInputData.Type; + var gbxType = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData.Type; Assert.AreEqual(gearboxType, gbxType.ToXMLFormat()); Assert.IsTrue(DeclarationDataAdapter.SupportedGearboxTypes.Contains(gbxType)); } @@ -878,8 +884,8 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); - var ptoDataProvider = inputDataProvider.JobInputData.Vehicle.PTOTransmissionInputData; + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); + var ptoDataProvider = inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData; Assert.AreEqual("None", ptoDataProvider.PTOTransmissionType); } @@ -889,8 +895,8 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleFullDecl); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); - var ptoDataProvider = inputDataProvider.JobInputData.Vehicle.PTOTransmissionInputData; + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); + var ptoDataProvider = inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData; var lookup = DeclarationData.PTOTransmission.Lookup(ptoDataProvider.PTOTransmissionType); Assert.AreEqual("only the drive shaft of the PTO - multi-disc clutch", ptoDataProvider.PTOTransmissionType); @@ -902,16 +908,16 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(SampleVehicleFullDeclCertificationOptions); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); Assert.AreEqual(CertificationMethod.Option2, - inputDataProvider.JobInputData.Vehicle.GearboxInputData.CertificationMethod); + inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData.CertificationMethod); Assert.AreEqual(CertificationMethod.Measured, - inputDataProvider.JobInputData.Vehicle.AxleGearInputData.CertificationMethod); + inputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData.CertificationMethod); Assert.AreEqual(CertificationMethod.Measured, - inputDataProvider.JobInputData.Vehicle.RetarderInputData.CertificationMethod); + inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData.CertificationMethod); Assert.AreEqual(CertificationMethod.Measured, - inputDataProvider.JobInputData.Vehicle.AirdragInputData.CertificationMethod); + inputDataProvider.JobInputData.Vehicle.Components.AirdragInputData.CertificationMethod); } [TestCase] @@ -955,7 +961,7 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(file); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); var vehicle = inputDataProvider.JobInputData.Vehicle; Assert.AreEqual(expectedExempted, vehicle.ExemptedVehicle); } @@ -966,7 +972,7 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(file); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); var vehicle = inputDataProvider.JobInputData.Vehicle; Assert.IsTrue(vehicle.ExemptedVehicle); @@ -982,7 +988,7 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(file); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); var vehicle = inputDataProvider.JobInputData.Vehicle; Assert.IsFalse(vehicle.ExemptedVehicle); @@ -999,7 +1005,7 @@ namespace TUGraz.VectoCore.Tests.XML { var reader = XmlReader.Create(file); - var inputDataProvider = new XMLDeclarationInputDataProvider(reader, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(reader, true); var vehicle = inputDataProvider.JobInputData.Vehicle; var adas = vehicle.ADAS; @@ -1033,7 +1039,7 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); var vehCategory = inputDataProvider.JobInputData.Vehicle.VehicleCategory; @@ -1067,9 +1073,9 @@ namespace TUGraz.VectoCore.Tests.XML var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true); + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); - var fuelType = inputDataProvider.JobInputData.Vehicle.EngineInputData.FuelType; + var fuelType = inputDataProvider.JobInputData.Vehicle.Components.EngineInputData.FuelType; Assert.AreEqual(expectedFuelType, fuelType); } @@ -1117,9 +1123,9 @@ namespace TUGraz.VectoCore.Tests.XML technology.SetValue(tech); var modified = XmlReader.Create(new StringReader(nav.OuterXml)); - var inputDataProvider = new XMLDeclarationInputDataProvider(modified, + var inputDataProvider = xmlInputReader.CreateDeclaration(modified, true); - var techInput = inputDataProvider.JobInputData.Vehicle.AuxiliaryInputData().Auxiliaries.Where(x => x.Type == aux) + var techInput = inputDataProvider.JobInputData.Vehicle.Components.AuxiliaryInputData.Auxiliaries.Where(x => x.Type == aux) .First().Technology.First(); Assert.AreEqual(tech, techInput); diff --git a/VectoCore/VectoCoreTest/XML/XMLEngineeringInputRefTest.cs b/VectoCore/VectoCoreTest/XML/XMLEngineeringInputRefTest.cs index 45289e00066c3bd46688f0c7e2e8e0b82b51ece4..4e2e25bf5074a43590c91d841fdc641727848515 100644 --- a/VectoCore/VectoCoreTest/XML/XMLEngineeringInputRefTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLEngineeringInputRefTest.cs @@ -72,7 +72,7 @@ namespace TUGraz.VectoCore.Tests.XML { var inputDataProvider = new XMLEngineeringInputDataProvider(EngineeringSampleFile, true); - var engineDataProvider = inputDataProvider.JobInputData.Vehicle.EngineInputData; + var engineDataProvider = inputDataProvider.JobInputData.Vehicle.Components.EngineInputData; Assert.IsFalse(engineDataProvider.SavedInDeclarationMode); @@ -107,7 +107,7 @@ namespace TUGraz.VectoCore.Tests.XML public void TestXMLInputGbxReferencedFile() { var inputDataProvider = new XMLEngineeringInputDataProvider(EngineeringSampleFile, true); - var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.GearboxInputData; + var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData; Assert.AreEqual("Generic 40t Long Haul Truck Gearbox", gearboxDataProvider.Model); Assert.AreEqual(GearboxType.AMT, gearboxDataProvider.Type); @@ -137,7 +137,7 @@ namespace TUGraz.VectoCore.Tests.XML public void TestXMLInputGbxTCReferencedFile() { var inputDataProvider = new XMLEngineeringInputDataProvider(EngineeringSampleFile, true); - var tcInputDataProvider = inputDataProvider.JobInputData.Vehicle.GearboxInputData.TorqueConverter; + var tcInputDataProvider = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData.TorqueConverter; Assert.AreEqual("GBX_ShiftPolygons.vgbs", Path.GetFileName(tcInputDataProvider.ShiftPolygon.Source)); @@ -155,7 +155,7 @@ namespace TUGraz.VectoCore.Tests.XML public void TestXMLInputAngledriveReferencedFile() { var inputDataProvider = new XMLEngineeringInputDataProvider(EngineeringSampleFile, true); - var angledriveInputData = inputDataProvider.JobInputData.Vehicle.AngledriveInputData; + var angledriveInputData = inputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData; Assert.AreEqual("Generic Angledrive", angledriveInputData.Model); @@ -172,7 +172,7 @@ namespace TUGraz.VectoCore.Tests.XML public void TestXMLInputAxlGReferencedFile() { var inputDataProvider = new XMLEngineeringInputDataProvider(EngineeringSampleFile, true); - var axlegearDataProvider = inputDataProvider.JobInputData.Vehicle.AxleGearInputData; + var axlegearDataProvider = inputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData; Assert.AreEqual("Generic 40t Long Haul Truck AxleGear", axlegearDataProvider.Model); @@ -189,7 +189,7 @@ namespace TUGraz.VectoCore.Tests.XML public void TestXMLInputRetarderReferencedFile() { var inputDataProvider = new XMLEngineeringInputDataProvider(EngineeringSampleFile, true); - var retarderDataProvider = inputDataProvider.JobInputData.Vehicle.RetarderInputData; + var retarderDataProvider = inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData; Assert.AreEqual("Generic Retarder", retarderDataProvider.Model); @@ -209,7 +209,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(EngineeringSampleFile, true); var vehicleDataProvider = inputDataProvider.VehicleInputData; - var axles = vehicleDataProvider.Axles; + var axles = vehicleDataProvider.Components.AxleWheels.AxlesEngineering; var tyre = axles[0].Tyre; Assert.AreEqual("315/70 R22.5",tyre.Dimension); @@ -229,7 +229,7 @@ namespace TUGraz.VectoCore.Tests.XML public void TestXMLInputAuxiliariesReferencedFile() { var inputDataProvider = new XMLEngineeringInputDataProvider(EngineeringSampleFile, true); - var auxDataProvider = inputDataProvider.JobInputData.Vehicle.AuxiliaryInputData(); + var auxDataProvider = inputDataProvider.JobInputData.Vehicle.Components.AuxiliaryInputData; var aux = auxDataProvider.Auxiliaries; var aux1 = aux[0]; @@ -270,12 +270,12 @@ namespace TUGraz.VectoCore.Tests.XML Assert.AreEqual(7100.0, vehicleDataProvider.CurbMassChassis.Value()); Assert.AreEqual(18000.0, vehicleDataProvider.GrossVehicleMassRating.Value()); - Assert.AreEqual(6.29, inputDataProvider.JobInputData.Vehicle.AirdragInputData.AirDragArea.Value()); + Assert.AreEqual(6.29, inputDataProvider.JobInputData.Vehicle.Components.AirdragInputData.AirDragArea.Value()); Assert.AreEqual(1500, vehicleDataProvider.Loading.Value()); Assert.AreEqual(500, vehicleDataProvider.CurbMassExtra.Value()); - Assert.AreEqual(1.0, inputDataProvider.JobInputData.Vehicle.RetarderInputData.Ratio); + Assert.AreEqual(1.0, inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData.Ratio); } [Category("LongRunning")] @@ -316,7 +316,7 @@ namespace TUGraz.VectoCore.Tests.XML { var inputDataProvider = new XMLEngineeringInputDataProvider(EngineeringSampleFile, true); - var ptoData = inputDataProvider.JobInputData.Vehicle.PTOTransmissionInputData; + var ptoData = inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData; //Assert.AreEqual("only the drive shaft of the PTO - multi-disc clutch", ptoData.PTOTransmissionType); Assert.AreEqual(2, ptoData.PTOLossMap.Rows.Count); diff --git a/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs b/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs index 3b308d529d84ff5939affff6de62c9fd6a5ba5db..c1687e57ba2e4be94183c302ed6e929609ebce97 100644 --- a/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLEngineeringInputSingleTest.cs @@ -73,7 +73,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var engineDataProvider = inputDataProvider.JobInputData.Vehicle.EngineInputData; + var engineDataProvider = inputDataProvider.JobInputData.Vehicle.Components.EngineInputData; Assert.IsFalse(engineDataProvider.SavedInDeclarationMode); @@ -110,7 +110,7 @@ namespace TUGraz.VectoCore.Tests.XML var reader = File.OpenRead(EngineeringSampleFile); var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.GearboxInputData; + var gearboxDataProvider = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData; Assert.AreEqual("Generic 40t Long Haul Truck Gearbox", gearboxDataProvider.Model); Assert.AreEqual(GearboxType.AMT, gearboxDataProvider.Type); @@ -139,7 +139,7 @@ namespace TUGraz.VectoCore.Tests.XML var reader = File.OpenRead(EngineeringSampleFile); var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var axlegearDataProvider = inputDataProvider.JobInputData.Vehicle.AxleGearInputData; + var axlegearDataProvider = inputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData; Assert.AreEqual("Generic 40t Long Haul Truck AxleGear", axlegearDataProvider.Model); @@ -182,7 +182,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(stream, true); - var axleGear = inputDataProvider.JobInputData.Vehicle.AxleGearInputData; + var axleGear = inputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData; Assert.AreEqual(0.9123, axleGear.Efficiency); } @@ -192,7 +192,7 @@ namespace TUGraz.VectoCore.Tests.XML var reader = File.OpenRead(EngineeringSampleFile); var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var retarderDataProvider = inputDataProvider.JobInputData.Vehicle.RetarderInputData; + var retarderDataProvider = inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData; Assert.AreEqual("Generic Retarder", retarderDataProvider.Model); @@ -214,7 +214,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); var vehicleDataProvider = inputDataProvider.VehicleInputData; - var axles = vehicleDataProvider.Axles; + var axles = vehicleDataProvider.Components.AxleWheels.AxlesEngineering; var tyre = axles[0].Tyre; Assert.AreEqual("315/70 R22.5", tyre.Dimension); @@ -265,7 +265,7 @@ namespace TUGraz.VectoCore.Tests.XML var vehicleDataProvider = inputDataProvider.VehicleInputData; - AssertHelper.Exception<VectoException>(() => { var axles = vehicleDataProvider.Axles; }); + AssertHelper.Exception<VectoException>(() => { var axles = vehicleDataProvider.Components.AxleWheels.AxlesEngineering; }); } [TestCase] @@ -301,7 +301,7 @@ namespace TUGraz.VectoCore.Tests.XML AssertHelper.Exception<VectoException>( () => { var inputDataProvider = new XMLEngineeringInputDataProvider(stream, true); - var axles = inputDataProvider.VehicleInputData.Axles; + var axles = inputDataProvider.VehicleInputData.Components.AxleWheels.AxlesEngineering; }); } @@ -339,7 +339,7 @@ namespace TUGraz.VectoCore.Tests.XML AssertHelper.Exception<VectoException>( () => { var inputDataProvider = new XMLEngineeringInputDataProvider(stream, true); - var axles = inputDataProvider.VehicleInputData.Axles; + var axles = inputDataProvider.VehicleInputData.Components.AxleWheels.AxlesEngineering; }); } @@ -349,7 +349,7 @@ namespace TUGraz.VectoCore.Tests.XML var reader = File.OpenRead(EngineeringSampleFile); var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var auxDataProvider = inputDataProvider.JobInputData.Vehicle.AuxiliaryInputData(); + var auxDataProvider = inputDataProvider.JobInputData.Vehicle.Components.AuxiliaryInputData; var aux = auxDataProvider.Auxiliaries; var aux1 = aux[0]; @@ -390,12 +390,12 @@ namespace TUGraz.VectoCore.Tests.XML Assert.AreEqual(7100.0, vehicleDataProvider.CurbMassChassis.Value()); Assert.AreEqual(40000.0, vehicleDataProvider.GrossVehicleMassRating.Value()); - Assert.AreEqual(6.29, inputDataProvider.JobInputData.Vehicle.AirdragInputData.AirDragArea.Value()); + Assert.AreEqual(6.29, inputDataProvider.JobInputData.Vehicle.Components.AirdragInputData.AirDragArea.Value()); Assert.AreEqual(1500, vehicleDataProvider.Loading.Value()); Assert.AreEqual(500, vehicleDataProvider.CurbMassExtra.Value()); - Assert.AreEqual(1.0, inputDataProvider.JobInputData.Vehicle.RetarderInputData.Ratio); + Assert.AreEqual(1.0, inputDataProvider.JobInputData.Vehicle.Components.RetarderInputData.Ratio); } [TestCase] @@ -426,7 +426,7 @@ namespace TUGraz.VectoCore.Tests.XML var declarationDriverDataProvider = (IDriverDeclarationInputData)inputDataProvider.DriverInputData; - var shiftStrategy = inputDataProvider.JobInputData.Vehicle.GearboxInputData; + var shiftStrategy = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData; Assert.AreEqual(DeclarationData.Gearbox.UpshiftMinAcceleration.Value(), shiftStrategy.UpshiftMinAcceleration.Value(), 1e-6); @@ -444,7 +444,7 @@ namespace TUGraz.VectoCore.Tests.XML AssertHelper.AreRelativeEqual(Constants.DefaultPowerShiftTime, shiftStrategy.PowershiftShiftTime); - var tcShiftStrategy = inputDataProvider.JobInputData.Vehicle.GearboxInputData.TorqueConverter; + var tcShiftStrategy = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData.TorqueConverter; AssertHelper.AreRelativeEqual(DeclarationData.TorqueConverter.CCUpshiftMinAcceleration, tcShiftStrategy.CCUpshiftMinAcceleration); @@ -513,7 +513,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var tcDataProvider = inputDataProvider.JobInputData.Vehicle.TorqueConverterInputData; + var tcDataProvider = inputDataProvider.JobInputData.Vehicle.Components.TorqueConverterInputData; Assert.AreEqual(1000, tcDataProvider.ReferenceRPM.AsRPM, 1e-6); Assert.AreEqual(1.1, tcDataProvider.Inertia.Value()); @@ -536,7 +536,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var angledriveDataProvider = inputDataProvider.JobInputData.Vehicle.AngledriveInputData; + var angledriveDataProvider = inputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData; Assert.AreEqual(1.2, angledriveDataProvider.Ratio); Assert.AreEqual(6, angledriveDataProvider.LossMap.Rows.Count); @@ -576,7 +576,7 @@ namespace TUGraz.VectoCore.Tests.XML Assert.AreEqual("1", driverAcc.Rows[1][1]); Assert.AreEqual("-1", driverAcc.Rows[1][2]); - var shiftStrategy = inputDataProvider.JobInputData.Vehicle.GearboxInputData; + var shiftStrategy = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData; Assert.AreEqual(0.133, shiftStrategy.UpshiftMinAcceleration.Value(), 1e-6); Assert.AreEqual(12, shiftStrategy.DownshiftAfterUpshiftDelay.Value(), 1e-6); @@ -590,7 +590,7 @@ namespace TUGraz.VectoCore.Tests.XML Assert.AreEqual(0.811, shiftStrategy.PowershiftShiftTime.Value(), 1e-6); - var tcShiftStrategy = inputDataProvider.JobInputData.Vehicle.GearboxInputData.TorqueConverter; + var tcShiftStrategy = inputDataProvider.JobInputData.Vehicle.Components.GearboxInputData.TorqueConverter; Assert.AreEqual(0.134, tcShiftStrategy.CCUpshiftMinAcceleration.Value(), 1e-6); Assert.AreEqual(0.133, tcShiftStrategy.CLUpshiftMinAcceleration.Value(), 1e-6); @@ -603,7 +603,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var airdragData = inputDataProvider.JobInputData.Vehicle.AirdragInputData; + var airdragData = inputDataProvider.JobInputData.Vehicle.Components.AirdragInputData; Assert.AreEqual(CrossWindCorrectionMode.SpeedDependentCorrectionFactor, airdragData.CrossWindCorrectionMode); Assert.AreEqual(2, airdragData.CrosswindCorrectionMap.Rows.Count); Assert.AreEqual("100", airdragData.CrosswindCorrectionMap.Rows[1][0]); @@ -617,7 +617,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var ptoData = inputDataProvider.JobInputData.Vehicle.PTOTransmissionInputData; + var ptoData = inputDataProvider.JobInputData.Vehicle.Components.PTOTransmissionInputData; Assert.AreEqual("only the drive shaft of the PTO - multi-disc clutch", ptoData.PTOTransmissionType); Assert.AreEqual(2, ptoData.PTOLossMap.Rows.Count); @@ -637,7 +637,7 @@ namespace TUGraz.VectoCore.Tests.XML var reader = File.OpenRead(EngineeringSampleFileFull); var inputDataProvider = new XMLEngineeringInputDataProvider(reader, true); - var angledriveInputData = inputDataProvider.JobInputData.Vehicle.AngledriveInputData; + var angledriveInputData = inputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData; Assert.AreEqual("Generic Angledrive", angledriveInputData.Model); @@ -680,7 +680,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(stream, true); - var angledrive = inputDataProvider.JobInputData.Vehicle.AngledriveInputData; + var angledrive = inputDataProvider.JobInputData.Vehicle.Components.AngledriveInputData; Assert.AreEqual(0.9124, angledrive.Efficiency); } @@ -716,7 +716,7 @@ namespace TUGraz.VectoCore.Tests.XML var inputDataProvider = new XMLEngineeringInputDataProvider(stream, true); - var auxInput = inputDataProvider.JobInputData.Vehicle.AuxiliaryInputData().Auxiliaries; + var auxInput = inputDataProvider.JobInputData.Vehicle.Components.AuxiliaryInputData.Auxiliaries; Assert.AreEqual(1, auxInput.Count); Assert.AreEqual(AuxiliaryDemandType.Constant, auxInput[0].AuxiliaryType); @@ -914,7 +914,7 @@ namespace TUGraz.VectoCore.Tests.XML AssertHelper.Exception<VectoException>( () => { var inputDataProvider = new XMLEngineeringInputDataProvider(stream, false); - var lossmap = inputDataProvider.JobInputData.Vehicle.AxleGearInputData.LossMap; + var lossmap = inputDataProvider.JobInputData.Vehicle.Components.AxleGearInputData.LossMap; }, "Failed to read TorqueLossMap resource"); } } diff --git a/VectoCore/VectoCoreTest/XML/XMLReportTest.cs b/VectoCore/VectoCoreTest/XML/XMLReportTest.cs index 69d06d3bffcdc330f5ad86b87f02beea92e477bc..2f0066b9dafda5913382e47e3447033ebd56ec7c 100644 --- a/VectoCore/VectoCoreTest/XML/XMLReportTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLReportTest.cs @@ -34,13 +34,16 @@ using System.Collections.Generic; using System.IO; using System.Xml; using System.Xml.Schema; +using Ninject; using NUnit.Framework; using TUGraz.VectoCommon.Models; +using TUGraz.VectoCore.InputData.FileIO.XML; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData.FileIO; using TUGraz.VectoCore.Utils; +using XmlDocumentType = TUGraz.VectoCore.Utils.XmlDocumentType; namespace TUGraz.VectoCore.Tests.XML { @@ -52,10 +55,16 @@ namespace TUGraz.VectoCore.Tests.XML const string SampleVehicleDeclAT = "TestData/XML/XMLReaderDeclaration/vecto_vehicle-sample_AT.xml"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [Category("LongRunning")] @@ -69,7 +78,7 @@ namespace TUGraz.VectoCore.Tests.XML var fileWriter = new FileOutputWriter(filename); var sumWriter = new SummaryDataContainer(fileWriter); var jobContainer = new JobContainer(sumWriter); - var dataProvider = new XMLDeclarationInputDataProvider(XmlReader.Create(filename), true); + var dataProvider = xmlInputReader.CreateDeclaration(XmlReader.Create(filename), true); var runsFactory = new SimulatorFactory(ExecutionMode.Declaration, dataProvider, fileWriter) { ModalResults1Hz = false, WriteModalResults = false, @@ -88,13 +97,13 @@ namespace TUGraz.VectoCore.Tests.XML var validator1 = new XMLValidator(XmlReader.Create(customerRecord), validationErrorAction: (s,e) => { validationMsg1.Add(e.ValidationEventArgs.Message); }); - Assert.IsTrue(validator1.ValidateXML(XMLValidator.XmlDocumentType.CustomerReport), string.Join("\n", validationMsg1)); + Assert.IsTrue(validator1.ValidateXML(XmlDocumentType.CustomerReport), string.Join("\n", validationMsg1)); var validationMsg2 = new List<string> {manufacturerRecord}; var validator2 = new XMLValidator(XmlReader.Create(manufacturerRecord), validationErrorAction: (s,e) => { validationMsg2.Add(e.ValidationEventArgs.Message); }); - Assert.IsTrue(validator2.ValidateXML(XMLValidator.XmlDocumentType.ManufacturerReport), string.Join("\n", validationMsg2)); + Assert.IsTrue(validator2.ValidateXML(XmlDocumentType.ManufacturerReport), string.Join("\n", validationMsg2)); } } } \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/XML/XMLWritingTest.cs b/VectoCore/VectoCoreTest/XML/XMLWritingTest.cs index 3c780b2bd7f258ba26265a1ff8a8af2c26d48aa8..42157905002ad3375ab0d8f0c481ba05a353e7e1 100644 --- a/VectoCore/VectoCoreTest/XML/XMLWritingTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLWritingTest.cs @@ -31,12 +31,14 @@ using System.IO; using System.Xml; +using Ninject; using TUGraz.VectoCommon.InputData; using TUGraz.VectoCore.InputData.FileIO.JSON; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration; using TUGraz.VectoCore.InputData.FileIO.XML.Engineering; using TUGraz.VectoCore.OutputData.XML; using NUnit.Framework; +using TUGraz.VectoCore.InputData.FileIO.XML; namespace TUGraz.VectoCore.Tests.XML { @@ -54,11 +56,17 @@ namespace TUGraz.VectoCore.Tests.XML const string DeclarationJobFull = @"TestData\XML\XMLWriter\DeclarationJob\Class5_Tractor_4x2\Class5_Tractor_DECL-FULL.vecto"; + protected IXMLInputDataReader xmlInputReader; + private IKernel _kernel; + [OneTimeSetUp] public void RunBeforeAnyTests() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + + _kernel = new StandardKernel(new VectoNinjectModule()); + xmlInputReader = _kernel.Get<IXMLInputDataReader>(); } [TestCase] @@ -168,7 +176,7 @@ namespace TUGraz.VectoCore.Tests.XML job.Save(outputFile); var reader = XmlReader.Create(outputFile); - var xml = new XMLDeclarationInputDataProvider(reader, true); + var xml = xmlInputReader.CreateDeclaration(reader, true); Assert.IsNotNull(xml); Assert.AreEqual("VEH-N.A.", xml.JobInputData.JobName); @@ -190,7 +198,7 @@ namespace TUGraz.VectoCore.Tests.XML job.Save(outputFile); var reader = XmlReader.Create(outputFile); - var xml = new XMLDeclarationInputDataProvider(reader, true); + var xml = xmlInputReader.CreateDeclaration(reader, true); Assert.IsNotNull(xml); Assert.AreEqual("VEH-N.A.", xml.JobInputData.JobName); diff --git a/VectoCore/VectoCoreTest/app.config b/VectoCore/VectoCoreTest/app.config index 43a238845e7bd8a93527c89e3623b2bfb0682232..fed7e747cc9ac063ff73b89a4f1895297503aaf9 100644 --- a/VectoCore/VectoCoreTest/app.config +++ b/VectoCore/VectoCoreTest/app.config @@ -24,4 +24,13 @@ <logger name="TUGraz.VectoCore.Models.SimulationComponent.Impl.*" minlevel="Debug" writeTo="LogFile" /> </rules> </nlog>--> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-3.3.4.0" newVersion="3.3.4.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> + </configuration> \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/packages.config b/VectoCore/VectoCoreTest/packages.config index f67fda9fbd8a0eff3166e2a8f325bcb601532734..495af7c4142c5c9559d34f9732758fe66dce3c03 100644 --- a/VectoCore/VectoCoreTest/packages.config +++ b/VectoCore/VectoCoreTest/packages.config @@ -1,6 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <packages> + <package id="Castle.Core" version="4.3.1" targetFramework="net45" /> <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" /> + <package id="Ninject" version="3.3.4" targetFramework="net45" /> <package id="NLog" version="4.5.11" targetFramework="net45" /> <package id="NUnit" version="3.11.0" targetFramework="net45" /> <package id="NUnit3TestAdapter" version="3.12.0" targetFramework="net45" />