diff --git a/Generic Vehicles/Declaration Mode/Class2_RigidTruck_4x2/175kW.vmap b/Generic Vehicles/Declaration Mode/Class2_RigidTruck_4x2/175kW.vmap index 2cb356074807c6c2a1576af4a68ae166746eaf06..ee4a0b831191bf4590860901947ae30e249e69f4 100644 --- a/Generic Vehicles/Declaration Mode/Class2_RigidTruck_4x2/175kW.vmap +++ b/Generic Vehicles/Declaration Mode/Class2_RigidTruck_4x2/175kW.vmap @@ -1,4 +1,5 @@ engine speed [rpm], torque [Nm], fuel consumption [g/h] +500,-131,0 500,-31,0 500,0,508 500,95.6,1814.959 @@ -7,6 +8,7 @@ 500,382.4,6036.866 500,478,7983 500,573.6,9771.095 +600,-135,0 600,-35,0 600,0,508 600,95.6,1814.959 @@ -15,6 +17,7 @@ 600,382.4,6036.866 600,478,7983 600,573.6,9771.095 +808,-143.24,0 808,-43.24,0 808.5,0,737.35 808.5,95.6,2156.667 @@ -26,6 +29,7 @@ 808.5,669.2,13292.96 808.5,673.905,13387.96 808,769.505,15319.69 +1017,-149.85,0 1017,-49.85,0 1017,0,966.7 1017,95.6,2499.359 @@ -39,6 +43,7 @@ 1017,860.4,19211.62 1017,860.84,19221.39 1017,956.44,21357.58 +1225,-160.125,0 1225,-60.125,0 1225.4,0,1216.133 1225.4,95.6,2867.396 @@ -52,6 +57,7 @@ 1225.4,860.4,21380.34 1225.4,956,23976.15 1225,1051.6,26399.12 +1434,-169.53,0 1434,-69.53,0 1433.9,0,1607.511 1433.9,95.6,3422.282 @@ -65,6 +71,7 @@ 1433.9,860.4,24706.84 1433.9,956,27415.66 1434,1051.6,30063.37 +1662,-178.55,0 1662,-78.55,0 1661.8,0,2026.982 1661.8,95.6,4054.852 @@ -78,6 +85,7 @@ 1661.8,860.4,28788.1 1661.8,937.151,31372.42 1662,1032.751,34529.97 +1835,-183.05,0 1835,-83.05,0 1834.7,0,2385.627 1834.7,95.6,4596.783 @@ -91,6 +99,7 @@ 1834.7,860.4,32191.22 1834.7,883.0285,33047.82 1835,978.6285,36639.92 +2008,-188.44,0 2008,-88.44,0 2007.5,0,2806.425 2007.5,95.6,5238.11 @@ -103,6 +112,7 @@ 2007.5,764.8,31692.9 2007.5,823.525,34019.71 2008,919.125,37924.6 +2180,-197.9,0 2180,-97.9,0 2180.3,0,3323.097 2180.3,95.6,5859.055 @@ -115,6 +125,7 @@ 2180.3,764.8,34924.28 2180.3,766.501,35000.3 2180,862.101,39256.51 +2353,-205.12,0 2353,-105.12,0 2353.2,0,3807.896 2353.2,95.6,6495.978 @@ -125,6 +136,7 @@ 2353.2,573.6,29311.43 2353.2,669.2,34144.93 2353,764.8,39097.94 +2453,-209.12,0 2453,-109.12,0 2453.2,0,3807.896 2453.2,95.6,6495.978 diff --git a/Generic Vehicles/Declaration Mode/Class5_Tractor_4x2/325kW.vmap b/Generic Vehicles/Declaration Mode/Class5_Tractor_4x2/325kW.vmap index eea08f963f4b23b49f15d030db630b52edc1d4e3..0ecbc8ff14634e2ef3c86c90fb21bdcb0997dec2 100644 --- a/Generic Vehicles/Declaration Mode/Class5_Tractor_4x2/325kW.vmap +++ b/Generic Vehicles/Declaration Mode/Class5_Tractor_4x2/325kW.vmap @@ -1,4 +1,5 @@ engine speed [rpm], torque [Nm], fuel consumption [g/h] +500,-235.5,0 500,-135.5,0 500,0,1355 500,213.4,3412.291 @@ -8,6 +9,7 @@ 500,1067,12823.69 500,1188,14228.79 500,1401.4,16628.66 +600,-238,0 600,-138,0 600,0,1355 600,213.4,3412.291 @@ -17,6 +19,7 @@ 600,1067,12823.69 600,1188,14228.79 600,1401.4,16628.66 +751,-241.775,0 751,-141.775,0 750.9,0,1649.255 750.9,213.4,4157.795 @@ -28,6 +31,7 @@ 750.9,1493.8,22400.17 750.9,1544.879,23213.92 751,1758.279,26392.93 +902,-247.59,0 902,-147.59,0 901.8,0,2210.735 901.8,213.4,5204.867 @@ -40,6 +44,7 @@ 901.8,1707.2,30534.68 901.8,1901.757,34352.75 902,2115.157,38403.27 +1053,-255.445,0 1053,-155.445,0 1052.7,0,2768.035 1052.7,213.4,6228.407 @@ -53,7 +58,7 @@ 1052.7,1920.6,39913.3 1052.7,2134,45438.16 1053,2347.4,50542.53 -1204,-165.44,0 +1204,-265.44,0 1203.6,0,3086.704 1203.6,213.4,6943.027 1203.6,426.8,11040.37 @@ -66,6 +71,7 @@ 1203.6,1920.6,45254.8 1203.6,2134,51129.03 1204,2347.4,56732.88 +1367,-283.37,0 1367,-183.37,0 1367.1,0,3845.344 1367.1,213.4,7981.742 @@ -79,6 +85,7 @@ 1367.1,1920.6,52078.71 1367.1,2134,58296.41 1367,2347.4,64530.56 +1490,-300.5,0 1490,-200.5,0 1489.6,0,4373.424 1489.6,213.4,8861.484 @@ -92,6 +99,7 @@ 1489.6,1920.6,57035.25 1489.6,2041.712,60609.5 1490,2255.112,67311.83 +1612,-318.62,0 1612,-218.62,0 1612.2,0,4904.015 1612.2,213.4,9810.482 @@ -104,6 +112,7 @@ 1612.2,1707.2,54666.14 1612.2,1915.434,61862.91 1612,2128.834,69491.99 +1735,-335.225,0 1735,-235.225,0 1734.7,0,5586.953 1734.7,213.4,11041.15 @@ -116,6 +125,7 @@ 1734.7,1707.2,59469.31 1734.7,1789.259,62731.31 1735,2002.659,70935.23 +1857,-353.69,0 1857,-253.69,0 1857.3,0,6673.839 1857.3,213.4,12518.56 @@ -127,6 +137,7 @@ 1857.3,1493.8,55848.59 1857.3,1587.631,59434.17 1857,1801.031,67215.39 +1957,-370.69,0 1957,-270.69,0 1957.3,0,6673.839 1957.3,213.4,12518.56 diff --git a/Generic Vehicles/Declaration Mode/Class9_RigidTruck_6x2/350kW.vmap b/Generic Vehicles/Declaration Mode/Class9_RigidTruck_6x2/350kW.vmap index 4ae21e4b8e35fadfbc04b5a17e06365cb6128c4f..51c6010f1fc8f162e6293e6b6f0cb1aec8834f10 100644 --- a/Generic Vehicles/Declaration Mode/Class9_RigidTruck_6x2/350kW.vmap +++ b/Generic Vehicles/Declaration Mode/Class9_RigidTruck_6x2/350kW.vmap @@ -1,4 +1,5 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] +600,-250,0 600,-150,0 600,0,1459 600,200,3358 @@ -8,6 +9,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 600,1000,12071 600,1200,14400 600,1282,15350 +800,-255,0 800,-155,0 800,0,1879 800,200,4286 @@ -19,6 +21,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 800,1400,22426 800,1600,25600 800,1791,28905 +1000,-265,0 1000,-165,0 1000,0,2865 1000,200,5963 @@ -33,6 +36,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1000,2000,39360 1000,2200,44120 1000,2300,46836 +1200,-279,0 1200,-179,0 1200,0,3307 1200,200,6897 @@ -47,6 +51,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1200,2000,46915 1200,2200,51783 1200,2300,54932 +1400,-303,0 1400,-203,0 1400,0,4306 1400,200,8143 @@ -61,6 +66,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1400,2000,55750 1400,2200,61072 1400,2300,64377 +1600,-335,0 1600,-235,0 1600,0,5209 1600,200,9669 @@ -74,6 +80,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1600,1800,57020 1600,2000,63914 1600,2079,66520 +1800,-364,0 1800,-264,0 1800,0,6409 1800,200,11777 @@ -86,6 +93,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1800,1600,57436 1800,1800,65157 1800,1857,67574 +2000,-401,0 2000,-301,0 2000,0,9127 2000,200,14822 @@ -95,6 +103,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 2000,1000,42837 2000,1200,51018 2000,1352,56618 +2100,-420,0 2100,-320,0 2100,0,10470 2100,200,16332 diff --git a/Generic Vehicles/Declaration Mode/Class9_RigidTruck_AT_6x2/Engine_220kW.vmap b/Generic Vehicles/Declaration Mode/Class9_RigidTruck_AT_6x2/Engine_220kW.vmap index 7ae025ef1f2a8fd8d8e070eb5dcf42ecb49be07b..f2716b6edb08e4ad8bf3647c529b5252c542a5c4 100644 --- a/Generic Vehicles/Declaration Mode/Class9_RigidTruck_AT_6x2/Engine_220kW.vmap +++ b/Generic Vehicles/Declaration Mode/Class9_RigidTruck_AT_6x2/Engine_220kW.vmap @@ -1,4 +1,5 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] +600,-144.579,0 600,-44.579,0 600,0,638 600,70,1601.24 @@ -8,6 +9,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 600,400,5962.41176470588 600,500,7979.12 600,600,10025.1176470588 +800,-154.659,0 800,-54.659,0 800,0,914.256225905983 800,70,1862.23669744703 @@ -20,6 +22,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 800,700,13773.9770410575 800,800,15797.4270742006 800,836,16529.9195199215 +1000,-163.6310565,0 1000,-63.6310565,0 1000,0,1190.51245181197 1000,70,2123.23339489406 @@ -34,6 +37,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1000,900,19910.3154481575 1000,1000,22137.4733292159 1000,1070,23687.7506196206 +1200,-174.94288,0 1200,-74.94288,0 1200,0,1466.76867771795 1200,70,2384.23009234109 @@ -49,6 +53,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1200,1000,24410.5499938238 1200,1100,26818.115111918 1200,1200,29600.8460156484 +1400,-186.2547035,0 1400,-86.2547035,0 1400,0,1943.23102011723 1400,70,2867.47013233511 @@ -64,6 +69,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1400,1000,28133.1269579571 1400,1100,30822.6887344662 1400,1200,33616.5017759808 +1600,-197.566527,0 1600,-97.566527,0 1600,0,2390.6835686806 1600,70,3375.40160192783 @@ -79,6 +85,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1600,1000,32050.2297249921 1600,1100,35223.8264822578 1600,1200,38415.2311208446 +1800,-204.414737,0 1800,-104.414737,0 1800,0,2890.45579554627 1800,70,3985.0324218874 @@ -94,6 +101,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 1800,1000,36567.9831510803 1800,1100,40354.8768962419 1800,1124,41263.456024854 +2000,-211.72677,0 2000,-111.72677,0 2000,0,3496.10145365531 2000,70,4806.78887658531 @@ -108,6 +116,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 2000,900,37186.4876337875 2000,1000,41216.6584804945 2000,1038,42697.6298262953 +2200,-225.56264,0 2200,-125.56264,0 2200,0,4247.17502566154 2200,70,5534.02108620948 @@ -121,6 +130,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 2200,800,37123.6305457812 2200,900,41612.3079508872 2200,955,44050.2046085433 +2400,-235.718847,0 2400,-135.718847,0 2400,0,4945.09679719305 2400,70,6234.18143404208 @@ -133,6 +143,7 @@ engine speed [rpm],torque [Nm],fuel consumption [g/h] 2400,700,36716.1939552295 2400,800,42106.7959841282 2400,815,42844.1063139178 +2500,-240.183674,0 2500,-140.183674,0 2500,0,5337.86693039768 2500,70,6286.75667605001 diff --git a/HashingCmd/Program.cs b/HashingCmd/Program.cs index 5ce77962cb62ff18c7860874a6acd59af3f2c361..89e4fa896363391aacb673b9869aadf39a222b93 100644 --- a/HashingCmd/Program.cs +++ b/HashingCmd/Program.cs @@ -57,7 +57,7 @@ hashingcmd.exe -h: print help -v: verify hashed file -s: create hashed file --x: validate generated XML against VECTO XML schema +-x: validate XML file against VECTO XML schema -c: compute hash and write to stdout -r: read hash from file and write to stdout "; @@ -70,7 +70,7 @@ hashingcmd.exe }; static bool _validateXML; - private static bool xmlValid = true; + static int Main(string[] args) { @@ -158,68 +158,36 @@ hashingcmd.exe writer.Close(); if (_validateXML) { - ValidateXML(destination); + new XMLValidator(XmlReader.Create(destination), null, ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType + .DeclarationComponentData); + WriteLine("Valid", ConsoleColor.Green); + } } - private static void ValidateXML(string filename) + private static void ValidationCallBack(XmlSeverityType severity, ValidationEvent evt) { - try { - var settings = new XmlReaderSettings { - ValidationType = ValidationType.Schema, - ValidationFlags = //XmlSchemaValidationFlags.ProcessInlineSchema | - //XmlSchemaValidationFlags.ProcessSchemaLocation | - XmlSchemaValidationFlags.ReportValidationWarnings - }; - settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack); - settings.Schemas.Add(GetXMLSchema("")); - - var vreader = XmlReader.Create(filename, settings); - var doc = new XmlDocument(); - doc.Load(vreader); - doc.Validate(ValidationCallBack); - //while (vreader.Read()) { - // Console.WriteLine(vreader.Value); - //} - if (xmlValid) { - WriteLine("Valid", ConsoleColor.Green); - } - } catch (Exception e) { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("Failed to validate hashed XML file!"); - Console.Error.WriteLine(e.Message); - if (e.InnerException != null) { - Console.Error.WriteLine(e.InnerException.Message); - } - Console.ResetColor(); - } - } - - private static void ValidationCallBack(object sender, ValidationEventArgs args) - { - xmlValid = false; - if (args.Severity == XmlSeverityType.Error) { + var args = evt.ValidationEventArgs; + if (severity == XmlSeverityType.Error) { throw new Exception(string.Format("Validation error: {0}" + Environment.NewLine + - "Line: {1}", args.Message, args.Exception.LineNumber)); + "Line: {1}", args.Message, args.Exception.LineNumber), evt.Exception); } else { - Console.Error.WriteLine(string.Format("Validation warning: {0}" + Environment.NewLine + - "Line: {1}", args.Message, args.Exception.LineNumber)); + Console.Error.WriteLine("Validation warning: {0}" + Environment.NewLine + + "Line: {1}", args.Message, args.Exception.LineNumber); } } - private static XmlSchemaSet GetXMLSchema(string version) + private static void ValidateFile(string filename) { - var resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, "VectoComponent.xsd"); - var xset = new XmlSchemaSet() { XmlResolver = new XmlResourceResolver() }; - var reader = XmlReader.Create(resource, new XmlReaderSettings(), "schema://"); - xset.Add(XmlSchema.Read(reader, null)); - xset.Compile(); - return xset; + new XMLValidator(XmlReader.Create(filename),null, ValidationCallBack).ValidateXML( + XMLValidator.XmlDocumentType.DeclarationJobData | XMLValidator.XmlDocumentType.CustomerReport | + XMLValidator.XmlDocumentType.ManufacturerReport | XMLValidator.XmlDocumentType.DeclarationComponentData); } - + private static void ReadHashAction(string filename, VectoHash h) { WriteLine("reading hashes"); + ValidateFile(filename); var components = h.GetContainigComponents().GroupBy(s => s) .Select(g => new { Entry = g.Key, Count = g.Count() }); @@ -237,6 +205,7 @@ hashingcmd.exe private static void ComputeHashAction(string filename, VectoHash h) { WriteLine("computing hashes"); + ValidateFile(filename); var components = h.GetContainigComponents(); if (components.Count > 1) { @@ -262,7 +231,7 @@ hashingcmd.exe private static void VerifyHashAction(string filename, VectoHash h) { WriteLine("validating hashes"); - + ValidateFile(filename); var components = h.GetContainigComponents().GroupBy(s => s) .Select(g => new { Entry = g.Key, Count = g.Count() }); foreach (var component in components) { diff --git a/HashingTool/HashingTool.csproj b/HashingTool/HashingTool.csproj index 371a4c2c0d3ca73df43a790739d28d96be5a4ca9..937009645db203268994f0c2e884d8d01e919042 100644 --- a/HashingTool/HashingTool.csproj +++ b/HashingTool/HashingTool.csproj @@ -84,6 +84,7 @@ <Compile Include="ViewModel\ObservableObject.cs" /> <Compile Include="ViewModel\RelayCommand.cs" /> <Compile Include="ViewModel\HashComponentDataViewModel.cs" /> + <Compile Include="ViewModel\UserControl\CustomerReportXMLFile.cs" /> <Compile Include="ViewModel\UserControl\HashedXMLFile.cs" /> <Compile Include="ViewModel\UserControl\ManufacturerReportXMLFile.cs" /> <Compile Include="ViewModel\UserControl\ReportXMLFile.cs" /> @@ -92,7 +93,7 @@ <Compile Include="ViewModel\VerifyJobInputDataViewModel.cs" /> <Compile Include="ViewModel\VerifyComponentInputDataViewModel.cs" /> <Compile Include="ViewModel\UserControl\XMLFileSelector.cs" /> - <Compile Include="Util\XMLValidator.cs" /> + <Compile Include="Util\AsyncXMLValidator.cs" /> <Compile Include="ViewModel\VerifyResultDataViewModel.cs" /> <Compile Include="Views\AboutDialog.xaml.cs"> <DependentUpon>AboutDialog.xaml</DependentUpon> diff --git a/HashingTool/Util/AsyncXMLValidator.cs b/HashingTool/Util/AsyncXMLValidator.cs new file mode 100644 index 0000000000000000000000000000000000000000..4c531174a4392f54d2b54dcd35fb2b3167bc5c7d --- /dev/null +++ b/HashingTool/Util/AsyncXMLValidator.cs @@ -0,0 +1,58 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2017 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.Threading.Tasks; +using System.Xml; +using System.Xml.Schema; +using TUGraz.VectoCore.Utils; + +namespace HashingTool.Util +{ + public class AsyncXMLValidator + { + private XMLValidator _validator; + + public AsyncXMLValidator(XmlReader xml, Action<bool> resultaction, Action<XmlSeverityType, ValidationEvent> validationErrorAction) + { + _validator = new XMLValidator(xml, resultaction, validationErrorAction); + } + + public Task<bool> ValidateXML(TUGraz.VectoCore.Utils.XMLValidator.XmlDocumentType docType) + { + var task = new Task<bool>(() => _validator.ValidateXML(docType)); + task.Start(); + return task; + } + } + + +} diff --git a/HashingTool/Util/XMLValidator.cs b/HashingTool/Util/XMLValidator.cs deleted file mode 100644 index 3d222adb33579dbb6f0aaba00528e6bcb477e9bc..0000000000000000000000000000000000000000 --- a/HashingTool/Util/XMLValidator.cs +++ /dev/null @@ -1,109 +0,0 @@ -/* -* This file is part of VECTO. -* -* Copyright © 2012-2017 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.Threading.Tasks; -using System.Xml; -using System.Xml.Schema; -using TUGraz.VectoCore.Utils; - -namespace HashingTool.Util -{ - public class XMLValidator - { - private readonly Action<XmlSeverityType, ValidationEvent> _validationErrorAction; - private readonly Action<bool> _resultAction; - private bool _valid; - - public XMLValidator(Action<bool> resultaction, Action<XmlSeverityType, ValidationEvent> validationErrorAction) - { - _validationErrorAction = validationErrorAction ?? ((x, y) => { }); - _resultAction = resultaction ?? (x => { }); - _valid = false; - } - - public Task<bool> ValidateXML(XmlReader hashedComponent) - { - var task = new Task<bool>(() => DoValidation(hashedComponent)); - task.Start(); - return task; - } - - private bool DoValidation(XmlReader hashedComponent) - { - _valid = true; - try { - var settings = new XmlReaderSettings { - ValidationType = ValidationType.Schema, - ValidationFlags = //XmlSchemaValidationFlags.ProcessInlineSchema | - //XmlSchemaValidationFlags.ProcessSchemaLocation | - XmlSchemaValidationFlags.ReportValidationWarnings - }; - settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack); - settings.Schemas.Add(GetXMLSchema("")); - - var vreader = XmlReader.Create(hashedComponent, settings); - var doc = new XmlDocument(); - doc.Load(vreader); - doc.Validate(ValidationCallBack); - } catch (Exception e) { - _validationErrorAction(XmlSeverityType.Error, new ValidationEvent() { Exception = e }); - } - return _valid; - } - - private void ValidationCallBack(object sender, ValidationEventArgs args) - { - _resultAction(false); - _valid = false; - _validationErrorAction(args.Severity, new ValidationEvent { ValidationEventArgs = args }); - } - - private static XmlSchemaSet GetXMLSchema(string version) - { - var xset = new XmlSchemaSet() { XmlResolver = new XmlResourceResolver() }; - foreach (var schema in new[] {"VectoComponent.xsd", "VectoInput.xsd", "VectoOutputManufacturer.xsd", "VectoOutputCustomer.xsd"}) { - var resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, schema); - - var reader = XmlReader.Create(resource, new XmlReaderSettings(), "schema://"); - xset.Add(XmlSchema.Read(reader, null)); - } - xset.Compile(); - return xset; - } - } - - public class ValidationEvent - { - public Exception Exception; - public ValidationEventArgs ValidationEventArgs; - } -} diff --git a/HashingTool/ViewModel/HashComponentDataViewModel.cs b/HashingTool/ViewModel/HashComponentDataViewModel.cs index e3c02db878a5bbf0d3ca5ad6748cb6b891993ed4..bd38c7a713d749e11429803a3eb897164e708c78 100644 --- a/HashingTool/ViewModel/HashComponentDataViewModel.cs +++ b/HashingTool/ViewModel/HashComponentDataViewModel.cs @@ -43,6 +43,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; @@ -59,6 +60,7 @@ namespace HashingTool.ViewModel private bool? _componentDataValid; private bool _busy; + private DateTime? _date; public HashComponentDataViewModel() : base("Hash Component Data", false, HashingHelper.IsComponentFile) @@ -150,7 +152,7 @@ namespace HashingTool.ViewModel var h = VectoHash.Load(_xmlFile.Document); _result = h.AddHash(); - + Date = h.GetCertificationDate(h.GetContainigComponents().First(), 0); // validate generated component file using (MemoryStream ms = new MemoryStream()) { using (XmlWriter xw = XmlWriter.Create(ms, new XmlWriterSettings { Indent = true })) { @@ -160,7 +162,7 @@ namespace HashingTool.ViewModel ms.Flush(); ms.Seek(0, SeekOrigin.Begin); ComponentDataValid = true; - var validator = new XMLValidator(r => { ComponentDataValid = r; }, + var validator = new AsyncXMLValidator(XmlReader.Create(ms), r => { ComponentDataValid = r; }, (s, e) => { Application.Current.Dispatcher.Invoke(() => _xmlFile.LogError( string.Format("Validation {0} Line {2}: {1}", s == XmlSeverityType.Warning ? "WARNING" : "ERROR", @@ -170,7 +172,7 @@ namespace HashingTool.ViewModel : e.ValidationEventArgs.Message, e.ValidationEventArgs == null ? 0 : e.ValidationEventArgs.Exception.LineNumber))); }); - await validator.ValidateXML(XmlReader.Create(ms)); + await validator.ValidateXML(XMLValidator.XmlDocumentType.DeclarationComponentData); } if (ComponentDataValid != null && ComponentDataValid.Value) { //var c14N = XMLHashProvider.DefaultCanonicalizationMethod.ToArray(); @@ -195,10 +197,24 @@ namespace HashingTool.ViewModel _xmlFile.LogError(e.Message); SetCanonicalizationMethod(new string[] { }); DigestMethod = ""; + Date = null; } finally { _busy = false; _saveCommand.RaiseCanExecuteChanged(); } } + + public DateTime? Date + { + get { return _date; } + set + { + if (_date == value) { + return; + } + _date = value; + RaisePropertyChanged("Date"); + } + } } } diff --git a/HashingTool/ViewModel/UserControl/CustomerReportXMLFile.cs b/HashingTool/ViewModel/UserControl/CustomerReportXMLFile.cs new file mode 100644 index 0000000000000000000000000000000000000000..5c93c318e2007d21fe35424eab2c3699a8e04225 --- /dev/null +++ b/HashingTool/ViewModel/UserControl/CustomerReportXMLFile.cs @@ -0,0 +1,177 @@ +using System; +using System.ComponentModel; +using System.Linq; +using System.Xml; +using TUGraz.VectoHashing; + +namespace HashingTool.ViewModel.UserControl +{ + public class CustomerReportXMLFile : ReportXMLFile + { + private ManufacturerReportXMLFile _manufacturerReport; + private string[] _manufacturerReportCanonicalizationMethodRead; + private string _manufacturerReportDigestMethodRead; + private string _manufacturerReportDigestValueRead; + private bool _manufacturerReportMatchesReport; + private string _manufacturerReportDigestValueComputed; + private bool _manufacturerReportDigestValid; + + public CustomerReportXMLFile(string name, Func<XmlDocument, IErrorLogger, bool?> contentCheck, + Action<XmlDocument, VectoXMLFile> hashValidation = null) : base(name, contentCheck, hashValidation) + { + + } + + + public ManufacturerReportXMLFile ManufacturerReport + { + get { return _manufacturerReport; } + set { + if (_manufacturerReport == value) { + return; + } + _manufacturerReport = value; + _manufacturerReport.PropertyChanged += ManufacturerReportChanged; + } + } + + public string[] ManufacturerReportCanonicalizationMethodRead + { + get { return _manufacturerReportCanonicalizationMethodRead; } + set + { + if (_manufacturerReportCanonicalizationMethodRead == value) { + return; + } + _manufacturerReportCanonicalizationMethodRead = value; + RaisePropertyChanged("ManufacturerReportCanonicalizationMethodRead"); + } + } + + public string ManufacturerReportDigestMethodRead + { + get { return _manufacturerReportDigestMethodRead; } + set + { + if (_manufacturerReportDigestMethodRead == value) { + return; + } + _manufacturerReportDigestMethodRead = value; + RaisePropertyChanged("ManufacturerReportDigestMethodRead"); + } + } + + public string ManufacturerReportDigestValueRead + { + get { return _manufacturerReportDigestValueRead; } + set + { + if (_manufacturerReportDigestValueRead == value) { + return; + } + _manufacturerReportDigestValueRead = value; + RaisePropertyChanged("ManufacturerReportDigestValueRead"); + } + } + + public bool ManufacturerReportMatchesReport + { + get { return _manufacturerReportMatchesReport; } + set + { + if (_manufacturerReportMatchesReport == value) { + return; + } + _manufacturerReportMatchesReport = value; + RaisePropertyChanged("ManufacturerReportMatchesReport"); + } + } + + public string ManufacturerReportDigestValueComputed + { + get { return _manufacturerReportDigestValueComputed; } + set + { + if (_manufacturerReportDigestValueComputed == value) { + return; + } + _manufacturerReportDigestValueComputed = value; + RaisePropertyChanged("ManufacturerReportDigestValueComputed"); + } + } + + public bool ManufacturerReportDigestValid + { + get { return _manufacturerReportDigestValid; } + set { + if (_manufacturerReportDigestValid == value) { + return; + } + _manufacturerReportDigestValid = value; + RaisePropertyChanged("ManufacturerReportDigestValid"); + } + } + + protected virtual void ManufacturerReportChanged(object sender, PropertyChangedEventArgs e) + { + if (sender == _manufacturerReport && e.PropertyName == GeneralUpdate) { + VerifyManufacturerReport(); + } + } + + protected override void ReportChanged(object sender, PropertyChangedEventArgs e) + { + base.ReportChanged(sender, e); + if (sender == _xmlFile && e.PropertyName == GeneralUpdate) { + VerifyManufacturerReport(); + } + } + + + protected virtual void VerifyManufacturerReport() + { + var manufacturerReportDigestValueRead = ""; + var manufacturerReportDigestMethodRead = ""; + var manufacturerReportCanonicalizationMethodRead = new string[] { }; + + var manufacturerReportDigestValueComputed = ""; + var digestMatch = false; + + if (_xmlFile.Document != null && _xmlFile.Document.DocumentElement != null) { + var digestValueNode = + _xmlFile.Document.SelectSingleNode("//*[local-name()='ResultDataSignature']//*[local-name()='DigestValue']"); + if (digestValueNode != null) { + manufacturerReportDigestValueRead = digestValueNode.InnerText; + } + var digestMethodNode = + _xmlFile.Document.SelectSingleNode( + "//*[local-name()='ResultDataSignature']//*[local-name()='DigestMethod']/@Algorithm"); + if (digestMethodNode != null) { + manufacturerReportDigestMethodRead = digestMethodNode.InnerText; + } + + var c14NtMethodNodes = + _xmlFile.Document.SelectNodes("//*[local-name()='ResultDataSignature']//*[local-name()='Transform']/@Algorithm"); + if (c14NtMethodNodes != null) { + manufacturerReportCanonicalizationMethodRead = (from XmlNode node in c14NtMethodNodes select node.InnerText).ToArray(); + } + + if (_manufacturerReport != null && _manufacturerReport.XMLFile != null && _manufacturerReport.XMLFile.IsValid == XmlFileStatus.ValidXML) { + var h = VectoHash.Load(_manufacturerReport.XMLFile.Document); + manufacturerReportDigestValueComputed = h.ComputeHash(manufacturerReportCanonicalizationMethodRead, + manufacturerReportDigestMethodRead); + digestMatch = manufacturerReportDigestValueRead == manufacturerReportDigestValueComputed; + } + } + ManufacturerReportDigestMethodRead = manufacturerReportDigestMethodRead; + ManufacturerReportCanonicalizationMethodRead = manufacturerReportCanonicalizationMethodRead; + ManufacturerReportDigestValueRead = manufacturerReportDigestValueRead; + ManufacturerReportDigestValueComputed = manufacturerReportDigestValueComputed; + + ManufacturerReportMatchesReport = FileIntegrityValid != null && FileIntegrityValid.Value && digestMatch; + + ManufacturerReportDigestValid = digestMatch; + } + + } +} \ No newline at end of file diff --git a/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs b/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs index 4ede443676f6cce405d8aec93134190d87108553..d6adf8d54833c391facafe6eb6e52afd8b023bb1 100644 --- a/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs +++ b/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs @@ -103,7 +103,6 @@ namespace HashingTool.ViewModel.UserControl if (entry.Component.StartsWith("Axle ")) { entry.Component = entry.Component.Replace("Axle", "Tyre"); entry.CertificationNumber = ReadElementValue(node, XMLNames.Report_Tyre_TyreCertificationNumber); - entry.DigestValue = "Not Available"; } else { entry.CertificationNumber = ReadElementValue(node, XMLNames.Report_Component_CertificationNumber) ?? ReadElementValue(node, XMLNames.Report_Component_CertificationMethod); @@ -116,9 +115,7 @@ namespace HashingTool.ViewModel.UserControl if (!jobComponent.Any()) { continue; } - entry.DigestValueMatchesJobComponent = entry.Component.StartsWith("Tyre ") - ? (bool?)null - : (jobComponent.First().DigestValueComputed == entry.DigestValue); + entry.DigestValueMatchesJobComponent = jobComponent.First().DigestValueComputed == entry.DigestValue; entry.DigestValueExpected = jobComponent.First().DigestValueComputed; if (entry.CertificationMethod == CertificationMethod.StandardValues.ToXMLFormat()) { @@ -134,9 +131,7 @@ namespace HashingTool.ViewModel.UserControl var certificationNumberMismatch = componentData.Where( x => x.CertificationNumberMatchesJobComponent != null && !x.CertificationNumberMatchesJobComponent.Value).ToArray(); - var digestMismatch = - componentData.Where(x => !x.Component.StartsWith("Tyre ")) - .Where(x => x.DigestValueMatchesJobComponent == null || !x.DigestValueMatchesJobComponent.Value).ToArray(); + var digestMismatch = componentData.Where(x => x.DigestValueMatchesJobComponent == null || !x.DigestValueMatchesJobComponent.Value).ToArray(); if (jobComponents.Any()) { foreach (var entry in certificationNumberMismatch) { _validationErrors.Add( @@ -152,7 +147,7 @@ namespace HashingTool.ViewModel.UserControl } } - ManufacturerReportValid = JobDigestMatchesReport && hasComponentsFromJob && !certificationNumberMismatch.Any() && !digestMismatch.Any(); + ManufacturerReportValid = FileIntegrityValid != null && FileIntegrityValid.Value && hasComponentsFromJob && !certificationNumberMismatch.Any() && !digestMismatch.Any(); } public bool ManufacturerReportValid diff --git a/HashingTool/ViewModel/UserControl/ReportXMLFile.cs b/HashingTool/ViewModel/UserControl/ReportXMLFile.cs index eec1eb659759eac515764eb0f0c7ac76db7418bc..770390873b789d6cee01e40dfeab85d178af0d5c 100644 --- a/HashingTool/ViewModel/UserControl/ReportXMLFile.cs +++ b/HashingTool/ViewModel/UserControl/ReportXMLFile.cs @@ -74,7 +74,7 @@ namespace HashingTool.ViewModel.UserControl } } - private void ReportChanged(object sender, PropertyChangedEventArgs e) + protected virtual void ReportChanged(object sender, PropertyChangedEventArgs e) { if (sender == _xmlFile && e.PropertyName == GeneralUpdate) { ReadReportData(); diff --git a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs index ea4d2142fad8181ca8aab714cb1416514ad95cc0..3d016b14742a713d9f969925d89c3112ac7fadb9 100644 --- a/HashingTool/ViewModel/UserControl/XMLFileSelector.cs +++ b/HashingTool/ViewModel/UserControl/XMLFileSelector.cs @@ -40,6 +40,7 @@ using System.Xml; using System.Xml.Schema; using HashingTool.Helper; using HashingTool.Util; +using TUGraz.VectoCore.Utils; namespace HashingTool.ViewModel.UserControl { @@ -269,7 +270,7 @@ namespace HashingTool.ViewModel.UserControl { var valid = true; try { - var validator = new XMLValidator(r => { valid = r; }, + var validator = new AsyncXMLValidator(xml, r => { valid = r; }, (s, e) => { Application.Current.Dispatcher.Invoke( () => @@ -281,7 +282,7 @@ namespace HashingTool.ViewModel.UserControl : e.ValidationEventArgs.Message, e.ValidationEventArgs == null ? 0 : e.ValidationEventArgs.Exception.LineNumber))); }); - await validator.ValidateXML(xml); + await validator.ValidateXML(XMLValidator.XmlDocumentType.DeclarationComponentData | XMLValidator.XmlDocumentType.DeclarationJobData | XMLValidator.XmlDocumentType.CustomerReport | XMLValidator.XmlDocumentType.ManufacturerReport); } catch (Exception e) { LogError(e.Message); } diff --git a/HashingTool/ViewModel/VerifyResultDataViewModel.cs b/HashingTool/ViewModel/VerifyResultDataViewModel.cs index 8ec7876911640525b5effc27e9eae05e0f5a23af..1b8b5104d5374bce8c2ec0d446be076026fef45b 100644 --- a/HashingTool/ViewModel/VerifyResultDataViewModel.cs +++ b/HashingTool/ViewModel/VerifyResultDataViewModel.cs @@ -46,7 +46,7 @@ namespace HashingTool.ViewModel public class VerifyResultDataViewModel : ObservableObject, IMainView { private readonly VectoJobFile _jobFile; - private readonly ReportXMLFile _customerReport; + private readonly CustomerReportXMLFile _customerReport; private readonly ManufacturerReportXMLFile _manufacturerReport; @@ -56,9 +56,10 @@ namespace HashingTool.ViewModel _manufacturerReport = new ManufacturerReportXMLFile("Manufacturer Report", HashingHelper.IsManufacturerReport, HashingHelper.ValidateDocumentHash); _manufacturerReport.JobData = _jobFile; - _customerReport = new ReportXMLFile("Customer Report", HashingHelper.IsCustomerReport, + _customerReport = new CustomerReportXMLFile("Customer Report", HashingHelper.IsCustomerReport, HashingHelper.ValidateDocumentHash); _customerReport.JobData = _jobFile; + _customerReport.ManufacturerReport = _manufacturerReport; Files = new ObservableCollection<VectoXMLFile> { _jobFile, _manufacturerReport, _customerReport }; ErrorsAndWarnings = new CompositeCollection(); @@ -105,7 +106,7 @@ namespace HashingTool.ViewModel } - public ReportXMLFile CustomerReport + public CustomerReportXMLFile CustomerReport { get { return _customerReport; } } diff --git a/HashingTool/Views/HashComponentData.xaml b/HashingTool/Views/HashComponentData.xaml index 92d951df4bd127c74771d079d788955d56474632..8c31dd041a7ebac3873575abfdea73ed0c607cc8 100644 --- a/HashingTool/Views/HashComponentData.xaml +++ b/HashingTool/Views/HashComponentData.xaml @@ -7,7 +7,7 @@ xmlns:local="clr-namespace:HashingTool.Views" x:Class="HashingTool.Views.HashComponentData" mc:Ignorable="d" - d:DesignHeight="368.125" d:DesignWidth="666"> + d:DesignHeight="445.581" d:DesignWidth="666"> <UserControl.Resources> <Helper:CollectionConverter x:Key="CollectionConverter" /> </UserControl.Resources> @@ -18,14 +18,18 @@ <DockPanel> <Label DockPanel.Dock="Top" Name="lblHeader" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Top" Content="{Binding Name}" FontWeight="Bold" FontSize="18" /> - <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0"> - <Button Content="Save Component Data" HorizontalAlignment="Right" Margin="0,0,15,10" Width="143" Height="22" + <DockPanel DockPanel.Dock="Bottom" Margin="0,10,0,0"> + <Button DockPanel.Dock="Right" Name="btnBack" Content="Back" Command="{Binding ShowHomeViewCommand}" Margin="0,0,10,10" + HorizontalAlignment="Right" + Width="75" Height="22" VerticalAlignment="Bottom" /> + <Button DockPanel.Dock="Right" Content="Save Component Data" HorizontalAlignment="Right" Margin="0,0,15,10" Width="143" Height="22" VerticalAlignment="Bottom" Command="{Binding SaveHashedDocument, Mode=OneWay}" /> - <Button Name="btnBack" Content="Back" Command="{Binding ShowHomeViewCommand}" Margin="0,0,10,10" - HorizontalAlignment="Right" - Width="75" Height="22" VerticalAlignment="Bottom" /> - </StackPanel> + <TextBlock DockPanel.Dock="Left" Text="Note: " HorizontalAlignment="Right" VerticalAlignment="Top" FontWeight="Bold" Margin="10,2,5,2"/> + <TextBlock DockPanel.Dock="Left" TextWrapping="WrapWithOverflow" Text="The generated component file contains the current date (and in most cases a random identifier). Thus, the digest value is different every time the file is hashed!" Margin="5,2,20,2"/> + </DockPanel> + + <ScrollViewer VerticalScrollBarVisibility="Auto"> <DockPanel DockPanel.Dock="Bottom"> <Label DockPanel.Dock="Top" x:Name="lblFileSelect" Content="Component data:" HorizontalAlignment="Left" Margin="10,0" @@ -41,8 +45,9 @@ <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> - <RowDefinition Height="Auto" /> - </Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> @@ -78,17 +83,22 @@ </Button> </StackPanel> - <Label Grid.Row="1" Grid.Column="0" Name="lblC14N" Content="Canonicalization:" HorizontalAlignment="Left" + <Label Grid.Row="1" Grid.Column="0" Name="lblDate" Content="Date:" HorizontalAlignment="Left" + Margin="0" /> + <TextBox Grid.Row="1" Grid.Column="1" Name="tbDate" IsReadOnly="True" + Text="{Helper:CultureAwareBinding Path=Date, StringFormat='g'}" + Margin="10,2" /> + <Label Grid.Row="2" Grid.Column="0" Name="lblC14N" Content="Canonicalization:" HorizontalAlignment="Left" Margin="0" /> - <TextBox Grid.Row="1" Grid.Column="1" Name="lblC14NList" IsReadOnly="True" + <TextBox Grid.Row="2" Grid.Column="1" Name="lblC14NList" IsReadOnly="True" Text="{Binding CanonicalizationMethods, Mode=OneWay, Converter={StaticResource CollectionConverter}}" Margin="10,2" /> - <Label Grid.Row="2" Grid.Column="0" Name="lblDigestMethod" Content="Digest Method:" HorizontalAlignment="Left" + <Label Grid.Row="3" Grid.Column="0" Name="lblDigestMethod" Content="Digest Method:" HorizontalAlignment="Left" Margin="0" /> - <TextBox Grid.Row="2" Grid.Column="1" Name="tbDigestMethod" IsReadOnly="True" + <TextBox Grid.Row="3" Grid.Column="1" Name="tbDigestMethod" IsReadOnly="True" Text="{Binding DigestMethod}" Margin="10,2" /> - <Button Grid.Row="3" Grid.Column="2" Content="Copy" Margin="10,2,0,2" HorizontalAlignment="Right" Width="75" + <Button Grid.Row="4" Grid.Column="2" Content="Copy" Margin="10,2,0,2" HorizontalAlignment="Right" Width="75" Click="Button_Click_1"> <Button.Style> <Style TargetType="Button"> @@ -101,13 +111,13 @@ </Style> </Button.Style> </Button> - <Label Grid.Row="3" Grid.Column="0" x:Name="lblDigestValue" Content="Digest Value:" HorizontalAlignment="Left" + <Label Grid.Row="4" Grid.Column="0" x:Name="lblDigestValue" Content="Digest Value:" HorizontalAlignment="Left" Margin="0" Style="{StaticResource DigestValueLabelStyle}" /> - <TextBox Grid.Row="3" Grid.Column="1" x:Name="tbDigestValue" Text="{Binding DigestValue}" Margin="10,2" + <TextBox Grid.Row="4" Grid.Column="1" x:Name="tbDigestValue" Text="{Binding DigestValue}" Margin="10,2" IsReadOnly="True" VerticalAlignment="Top" RenderTransformOrigin="4.1,-2.1" Style="{StaticResource DigestValueTextboxStyle}" Foreground="{StaticResource Color.SuccessGreen}" /> - <ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="0,0,0,0" + <ContentControl Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top" Width="66" Height="64"> <ContentControl.LayoutTransform> <ScaleTransform ScaleX="1.5" ScaleY="1.5" /> @@ -132,5 +142,6 @@ </Grid> </DockPanel> + </ScrollViewer> </DockPanel> </UserControl> \ No newline at end of file diff --git a/HashingTool/Views/VerifyResults.xaml b/HashingTool/Views/VerifyResults.xaml index 3f50f7d5151411d17ade3861303af51ab1d3f3d4..6dbecb27c9133442f21a95f5ee7215a82f52c3aa 100644 --- a/HashingTool/Views/VerifyResults.xaml +++ b/HashingTool/Views/VerifyResults.xaml @@ -212,13 +212,14 @@ </Grid> </DataTemplate> - <DataTemplate x:Key="ExpanderContentReport" DataType="userControl:ReportXMLFile"> + <DataTemplate x:Key="ExpanderContentCustomerReport" DataType="userControl:CustomerReportXMLFile"> <Grid Grid.IsSharedSizeScope="True"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> <RowDefinition /> <RowDefinition /> + <RowDefinition/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" SharedSizeGroup="LabelsShareGroup"/> @@ -290,7 +291,63 @@ </Grid> </GroupBox> - <GroupBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Header="Job Integrity" Style="{DynamicResource CustomGroupboxStyle}"> + <GroupBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Header="Manufacturer Report Integrity" Style="{DynamicResource CustomGroupboxStyle}"> + <Grid> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto" SharedSizeGroup="LabelsShareGroup" /> + <ColumnDefinition Width="*" /> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition /> + <RowDefinition /> + <RowDefinition /> + <RowDefinition /> + + </Grid.RowDefinitions> + <Label Grid.Row="0" Grid.Column="0" Content="CanonicalizationMethod:" /> + <TextBox Grid.Row="0" Grid.Column="1" + Text="{Binding ManufacturerReportCanonicalizationMethodRead, Mode=OneWay, Converter={StaticResource CollectionConverter}}" + Margin="10,2" IsReadOnly="True" /> + + <Label Grid.Row="1" Grid.Column="0" Content="Digest Method:" /> + <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding ManufacturerReportDigestMethodRead, Mode=OneWay}" + Margin="10,2" IsReadOnly="True" /> + + <Label Grid.Row="2" Grid.Column="0" Content="Digest Value Read:" + Style="{StaticResource DigestValueLabelStyle}" /> + <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding ManufacturerReportDigestValueRead, Mode=OneWay}" + Margin="10,2" IsReadOnly="True"> + <TextBox.Style> + <Style TargetType="TextBox" BasedOn="{StaticResource DigestValueTextboxStyle}"> + <Setter Property="Foreground" Value="{StaticResource Color.ErrorRed}" /> + <Style.Triggers> + <DataTrigger Binding="{Binding ManufacturerReportDigestValid}" Value="True"> + <Setter Property="Foreground" Value="{StaticResource Color.SuccessGreen}" /> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBox.Style> + </TextBox> + + <Label Grid.Row="3" Grid.Column="0" Content="Digest Value Computed:" + Style="{StaticResource DigestValueLabelStyle}" /> + <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding ManufacturerReportDigestValueComputed, Mode=OneWay}" + Margin="10,2" IsReadOnly="True"> + <TextBox.Style> + <Style TargetType="TextBox" BasedOn="{StaticResource DigestValueTextboxStyle}"> + <Setter Property="Foreground" Value="{StaticResource Color.ErrorRed}" /> + <Style.Triggers> + <DataTrigger Binding="{Binding ManufacturerReportDigestValid}" Value="True"> + <Setter Property="Foreground" Value="{StaticResource Color.SuccessGreen}" /> + </DataTrigger> + </Style.Triggers> + </Style> + </TextBox.Style> + </TextBox> + </Grid> + </GroupBox> + + <GroupBox Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" Header="Job Integrity" Style="{DynamicResource CustomGroupboxStyle}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" SharedSizeGroup="LabelsShareGroup" /> @@ -682,7 +739,7 @@ <Border BorderBrush="White" BorderThickness="1" CornerRadius="2" Margin="0,0,3,0"> <Expander Margin="2" Header="{Binding}" HorizontalAlignment="Stretch" Style="{DynamicResource HeaderStretchExpanderStyle}" - HeaderTemplate="{DynamicResource ExpanderHeader}" ContentTemplate="{DynamicResource ExpanderContentReport}" + HeaderTemplate="{DynamicResource ExpanderHeader}" ContentTemplate="{DynamicResource ExpanderContentCustomerReport}" Content="{Binding}" /> </Border> @@ -761,7 +818,7 @@ <TextBlock Grid.Row="0" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" Margin="5" FontSize="14" FontWeight="Bold"> - Job-Data matches<LineBreak /> Customer Report + Manufacturer Report<LineBreak/> matches<LineBreak /> Customer Report </TextBlock> <ContentControl Grid.Row="1" Grid.Column="4" Width="50" Height="50" Margin="10,10,10,0"> <ContentControl.LayoutTransform> @@ -771,7 +828,7 @@ <Style TargetType="ContentControl"> <Setter Property="ContentTemplate" Value="{StaticResource Icon_NOK}" /> <Style.Triggers> - <DataTrigger Binding="{Binding CustomerReport.JobDigestMatchesReport}" Value="True"> + <DataTrigger Binding="{Binding CustomerReport.ManufacturerReportMatchesReport}" Value="True"> <Setter Property="ContentTemplate" Value="{StaticResource Icon_OK}" /> </DataTrigger> </Style.Triggers> diff --git a/VectoCommon/VectoCommon/Utils/SI.cs b/VectoCommon/VectoCommon/Utils/SI.cs index 344db00e282a75e3ba81cafd55cd6ebdb241abfb..658a9a8b3244e427321b99adf62ca896b26d114b 100644 --- a/VectoCommon/VectoCommon/Utils/SI.cs +++ b/VectoCommon/VectoCommon/Utils/SI.cs @@ -104,7 +104,9 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private Newton(double val) : base(val, Units) { } - [DebuggerHidden] + public override string UnitString { get { return "N"; } } + + [DebuggerHidden] public static NewtonMeter operator *(Newton newton, Meter meter) { return SIBase<NewtonMeter>.Create(newton.Val * meter.Value()); @@ -224,6 +226,8 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private KilogramPerMeter(double val) : base(val, Units) { } + public override string UnitString { get { return "kg/m"; } } + public static KilogramPerMeterMass operator /(KilogramPerMeter kpm, Kilogram kg) { return SIBase<KilogramPerMeterMass>.Create(kpm.Val / kg.Value()); @@ -244,6 +248,8 @@ namespace TUGraz.VectoCommon.Utils private LiterPerSecond(double val) : base(val, 0.001, Units) { } + public override string UnitString { get { return "l/s"; } } + [DebuggerHidden] public static Liter operator *(LiterPerSecond l, Second second) { @@ -273,11 +279,11 @@ namespace TUGraz.VectoCommon.Utils return SIBase<KilogramPerSecond>.Create(kg.Val / second.Value()); } - [DebuggerHidden] - public static SI operator /(Kilogram kg, Joule j) - { - return (kg as SI) / j; - } + //[DebuggerHidden] + //public static SI operator /(Kilogram kg, Joule j) + //{ + // return (kg as SI) / j; + //} [DebuggerHidden] public static Scalar operator /(Kilogram kg, Kilogram kg2) @@ -291,7 +297,13 @@ namespace TUGraz.VectoCommon.Utils return SIBase<KilogramPerMeter>.Create(kg.Val / m.Value()); } - [DebuggerHidden] + [DebuggerHidden] + public static SpecificFuelConsumption operator /(Kilogram kg, WattSecond ws) + { + return SIBase<SpecificFuelConsumption>.Create(kg.Val / ws.Value()); + } + + [DebuggerHidden] public static Newton operator *(Kilogram kg, MeterPerSquareSecond m) { return SIBase<Newton>.Create(kg.Val * m.Value()); @@ -323,7 +335,9 @@ namespace TUGraz.VectoCommon.Utils //[DebuggerHidden] private Liter(double val) : base(val , 0.001, Units) { } - public static Kilogram operator *(Liter liter, KilogramPerCubicMeter kilogramPerCubicMeter) + public override string UnitString { get { return "l"; } } + + public static Kilogram operator *(Liter liter, KilogramPerCubicMeter kilogramPerCubicMeter) { return SIBase<Kilogram>.Create(liter.AsBasicUnit * kilogramPerCubicMeter.Value()); } @@ -339,7 +353,9 @@ namespace TUGraz.VectoCommon.Utils //[DebuggerHidden] private NormLiter(double val) : base(val , 0.001, Units) { } - public static NormLiterPerSecond operator /(NormLiter nl, Second s) + public override string UnitString { get { return "Nl"; } } + + public static NormLiterPerSecond operator /(NormLiter nl, Second s) { return SIBase<NormLiterPerSecond>.Create(nl.Val / s.Value()); } @@ -355,7 +371,9 @@ namespace TUGraz.VectoCommon.Utils //[DebuggerHidden] private NormLiterPerSecond(double val) : base(val, 0.001, Units) { } - public static NormLiter operator *(NormLiterPerSecond nips, Second s) + public override string UnitString { get { return "Nl/s"; } } + + public static NormLiter operator *(NormLiterPerSecond nips, Second s) { return SIBase<NormLiter>.Create(nips.Val * s.Value()); } @@ -381,7 +399,7 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private KilogramPerSecond(double value) : base(value, Units) { } - [DebuggerHidden] + [DebuggerHidden] public static Kilogram operator *(KilogramPerSecond kilogramPerSecond, Second second) { return SIBase<Kilogram>.Create(kilogramPerSecond.Val * second.Value()); @@ -429,7 +447,7 @@ namespace TUGraz.VectoCommon.Utils } /// <summary> - /// SI Class for Kilogram Square Meter [kgm^2]. + /// SI Class for Kilogram per Cubic Meter [kg/m^3]. /// </summary> public class KilogramPerCubicMeter : SIBase<KilogramPerCubicMeter> { @@ -438,7 +456,9 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private KilogramPerCubicMeter(double value) : base(value, Units) { } - [DebuggerHidden] + public override string UnitString { get { return "kg/m^3"; } } + + [DebuggerHidden] public static Kilogram operator *(KilogramPerCubicMeter kilogramPerCubicMeter, CubicMeter cubicMeter) { return SIBase<Kilogram>.Create(kilogramPerCubicMeter.Val * cubicMeter.Value()); @@ -456,7 +476,9 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private KilogramPerWattSecond(double val) : base(val, Units) { } - } + + public override string UnitString { get { return "kg/Ws"; } } + } /// <summary> /// SI Class for watt second [Ws]. @@ -469,7 +491,9 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private WattSecond(double val) : base(val, Units) { } - [DebuggerHidden] + public override string UnitString { get { return "Ws"; } } + + [DebuggerHidden] public static Watt operator /(WattSecond wattSecond, Second second) { return SIBase<Watt>.Create(wattSecond.Val / second.Value()); @@ -486,15 +510,17 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private Watt(double val) : base(val, Units) { } - /// <summary> - /// Implements the operator /. - /// </summary> - /// <param name="watt">The watt.</param> - /// <param name="newtonMeter">The newton meter.</param> - /// <returns> - /// The result of the operator. - /// </returns> - [DebuggerHidden] + public override string UnitString { get { return "W"; } } + + /// <summary> + /// Implements the operator /. + /// </summary> + /// <param name="watt">The watt.</param> + /// <param name="newtonMeter">The newton meter.</param> + /// <returns> + /// The result of the operator. + /// </returns> + [DebuggerHidden] public static PerSecond operator /(Watt watt, NewtonMeter newtonMeter) { return SIBase<PerSecond>.Create(watt.Val / newtonMeter.Value()); @@ -544,6 +570,8 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private Joule(double val) : base(val, Units) { } + public override string UnitString { get { return "J"; } } + public static implicit operator Joule(WattSecond self) { return Create(self.Value()); @@ -566,9 +594,7 @@ namespace TUGraz.VectoCommon.Utils } /// <summary> - /// SI Class for Watt [W]. - /// J = Ws - /// W = kgm^2/s^3 + /// SI Class for Joule / kg. /// </summary> public class JoulePerKilogramm : SIBase<JoulePerKilogramm> { @@ -576,7 +602,9 @@ namespace TUGraz.VectoCommon.Utils private JoulePerKilogramm(double val) : base(val, Units) { } - public static Joule operator *(Kilogram kg, JoulePerKilogramm jpg) + public override string UnitString { get { return "J/kg"; } } + + public static Joule operator *(Kilogram kg, JoulePerKilogramm jpg) { return SIBase<Joule>.Create(kg.Value() * jpg.Val); } @@ -593,7 +621,9 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private JoulePerMeter(double val) : base(val, Units) { } - } + + public override string UnitString { get { return "J/m"; } } + } /// <summary> /// SI Class for one per second [1/s]. @@ -700,7 +730,9 @@ namespace TUGraz.VectoCommon.Utils [DebuggerHidden] private NewtonMeter(double val) : base(val, Units) { } - [DebuggerHidden] + public override string UnitString { get { return "Nm"; } } + + [DebuggerHidden] public static Watt operator *(NewtonMeter newtonMeter, PerSecond perSecond) { return SIBase<Watt>.Create(newtonMeter.Val * perSecond.Value()); @@ -751,7 +783,9 @@ namespace TUGraz.VectoCommon.Utils { private static readonly int[] Units = { 1, 2, -1, 0, 0, 0, 0 }; private NewtonMeterSecond(double val) : base(val, Units) { } - } + + public override string UnitString { get { return "Nms"; } } + } /// <summary> /// SI Class for Amperer [A]. @@ -786,7 +820,9 @@ namespace TUGraz.VectoCommon.Utils private static readonly int[] Units = { 1, 2, -2, -1, 0, 0, 0 }; private Volt(double val) : base(val, Units) { } - public static Watt operator *(Volt volt, Ampere ampere) + public override string UnitString { get { return "V"; } } + + public static Watt operator *(Volt volt, Ampere ampere) { return SIBase<Watt>.Create(volt.Val * ampere.Value()); } @@ -802,6 +838,8 @@ namespace TUGraz.VectoCommon.Utils private static readonly int[] Units = { 0, 2, 0, 0, 0, 0, 0 }; private VolumePerMeter(double val) : base(val, Units) { } + public override string UnitString { get { return "m^3/m"; } } + public static VolumePerMeterMass operator /(VolumePerMeter vpm, Kilogram kg) { return SIBase<VolumePerMeterMass>.Create(vpm.Val / kg.Value()); @@ -819,6 +857,8 @@ namespace TUGraz.VectoCommon.Utils private static readonly int[] Units = { -1, 2, 0, 0, 0, 0, 0 }; private VolumePerMeterMass(double val) : base (val, Units) { } + + public override string UnitString { get { return "m^3/kgm"; } } } public class VolumePerMeterVolume : SIBase<VolumePerMeterVolume> @@ -826,6 +866,8 @@ namespace TUGraz.VectoCommon.Utils private static readonly int[] Units = { 0, -1, 0, 0, 0, 0, 0 }; private VolumePerMeterVolume(double val) : base (val, Units) { } + + public override string UnitString { get { return "m^3/kgm^3"; } } } public class KilogramPerMeterCubicMeter : SIBase<KilogramPerMeterCubicMeter> @@ -833,13 +875,25 @@ namespace TUGraz.VectoCommon.Utils private static readonly int[] Units = { 1, -4, 0, 0, 0, 0, 0 }; private KilogramPerMeterCubicMeter(double val) : base(val, Units) { } + + public override string UnitString { get { return "kg/(m m^3)"; } } } + public class KilogramPerMeterMass : SIBase<KilogramPerMeterMass> { private static readonly int[] Units = { 0, -1, 0, 0, 0, 0, 0 }; private KilogramPerMeterMass(double val) : base(val, Units) { } + + public override string UnitString { get { return "kg/(m kg)"; } } + } + + public class SpecificFuelConsumption : SIBase<SpecificFuelConsumption> + { + private static readonly int[] Units = { 0, -2,2, 0, 0, 0, 0 }; + + private SpecificFuelConsumption(double val) : base(val, Units) { } } /// <summary> @@ -1047,7 +1101,7 @@ namespace TUGraz.VectoCommon.Utils /// <remarks> /// Usage: new SI(1.0).Newton.Meter, new SI(2.3).Rounds.Per.Minute /// </remarks> - [DebuggerDisplay("{Val}")] + [DebuggerDisplay("{Val} [{UnitString}]")] public class SI : IComparable { /// <summary> @@ -1219,7 +1273,7 @@ namespace TUGraz.VectoCommon.Utils } } catch (DivideByZeroException ex) { throw new VectoException( - string.Format("Can not compute division by zero ([{0}] / 0[{1}])", si1.GetUnitString(), si2.GetUnitString()), ex); + string.Format("Can not compute division by zero ([{0}] / 0[{1}])", si1.UnitString, si2.UnitString), ex); } var unitArray = SIUtils.CombineUnits(si1._units, SIUtils.MultiplyUnits(si2._units, -1)); @@ -1231,7 +1285,7 @@ namespace TUGraz.VectoCommon.Utils public static SI operator /(SI si1, double d) { if (d.IsEqual(0)) { - throw new VectoException(string.Format("Can not compute division by zero ([{0}] / 0)", si1.GetUnitString()), new DivideByZeroException()); + throw new VectoException(string.Format("Can not compute division by zero ([{0}] / 0)", si1.UnitString), new DivideByZeroException()); } return new SI(si1.Val / d, si1); @@ -1241,7 +1295,7 @@ namespace TUGraz.VectoCommon.Utils public static SI operator /(double d, SI si1) { if (si1.IsEqual(0)) { - throw new VectoException(string.Format("Can not compute division by zero (x / 0[{0}])", si1.GetUnitString()), + throw new VectoException(string.Format("Can not compute division by zero (x / 0[{0}])", si1.UnitString), new DivideByZeroException()); } @@ -1363,11 +1417,11 @@ namespace TUGraz.VectoCommon.Utils /// <summary> /// Returns the Unit Part of the SI Unit Expression. /// </summary> - public string GetUnitString(int[] units = null) + public static string GetUnitString(int[] units = null) { if (units == null) { - units = _units; - } + return ""; + } return Unit.GetUnitString(units); } @@ -1376,13 +1430,18 @@ namespace TUGraz.VectoCommon.Utils return ToString(null); } + public virtual string UnitString + { + get { return GetUnitString(_units); } + } + private string ToString(string format) { if (string.IsNullOrEmpty(format)) { format = "F4"; } - return string.Format(CultureInfo.InvariantCulture, "{0:" + format + "} [{2}]", Val, format, GetUnitString()); + return string.Format(CultureInfo.InvariantCulture, "{0:" + format + "} [{2}]", Val, format, UnitString); } #endregion @@ -1662,7 +1721,7 @@ namespace TUGraz.VectoCommon.Utils if (showUnit.Value) { return (Val * outputFactor.Value).ToString("F" + decimals.Value, CultureInfo.InvariantCulture) + " [" + - GetUnitString() + "]"; + UnitString + "]"; } return (Val * outputFactor.Value).ToString("F" + decimals.Value, CultureInfo.InvariantCulture); diff --git a/VectoCommon/VectoCommon/Utils/SIConvertExtensionMethods.cs b/VectoCommon/VectoCommon/Utils/SIConvertExtensionMethods.cs index d3cf90a5130a2776ba02dbeb30ecc87b6c1c5a20..923dc0bfebd89ec8c181ad82225e3a80b1b16ad1 100644 --- a/VectoCommon/VectoCommon/Utils/SIConvertExtensionMethods.cs +++ b/VectoCommon/VectoCommon/Utils/SIConvertExtensionMethods.cs @@ -77,7 +77,7 @@ namespace TUGraz.VectoCommon.Utils public static implicit operator ConvertedSI(SI self) { - return self == null ? null : new ConvertedSI(self.Value(), self.GetUnitString()); + return self == null ? null : new ConvertedSI(self.Value(), self.UnitString); } public override string ToString() @@ -128,7 +128,13 @@ namespace TUGraz.VectoCommon.Utils return value == null ? null : new ConvertedSI(value.Value() * Kilo * Kilo, "g/km"); } - public static ConvertedSI ConvertToLiterPer100Kilometer(this VolumePerMeter value) + public static ConvertedSI ConvertToGramPerKiloWattHour(this SpecificFuelConsumption value) + { + return new ConvertedSI(value.Value() * 3600e6, "g/kWh"); + } + + + public static ConvertedSI ConvertToLiterPer100Kilometer(this VolumePerMeter value) { return value == null ? null : new ConvertedSI(value.Value() * (10*10*10) * (100*1000), "l/100km"); } diff --git a/VectoCommon/VectoCommon/Utils/SIUtils.cs b/VectoCommon/VectoCommon/Utils/SIUtils.cs index bea72ab8ad91e64f2c15f536d556bb4464b804ae..8516ee8955620793a9109d7560f2d04c270de1d7 100644 --- a/VectoCommon/VectoCommon/Utils/SIUtils.cs +++ b/VectoCommon/VectoCommon/Utils/SIUtils.cs @@ -102,7 +102,9 @@ namespace TUGraz.VectoCommon.Utils } } string result; - + if (numerator == "" && denominator == "") { + return "-"; + } if (numerator == "") { if (denominator == "") { result = "-"; diff --git a/VectoCommon/VectoCommon/Utils/Validation.cs b/VectoCommon/VectoCommon/Utils/Validation.cs index c927e9356815b7f7c669a7469b7038d2385f289e..f5abe7f8a8a383070a4d207ee6fe6d235a6a989c 100644 --- a/VectoCommon/VectoCommon/Utils/Validation.cs +++ b/VectoCommon/VectoCommon/Utils/Validation.cs @@ -395,7 +395,7 @@ namespace TUGraz.VectoCommon.Utils var si = value as SI; if (si != null) { - _unit = si.GetUnitString(); + _unit = si.UnitString; } var validationService = validationContext.GetService(typeof(VectoValidationModeServiceContainer)) as VectoValidationModeServiceContainer; diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_engine-input.xml b/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_engine-input.xml index 4bebaa2369d14d8c374e94651fee329492463e5e..499da0ab5c91f552b0c4f37269874cbba10c07b5 100644 --- a/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_engine-input.xml +++ b/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_engine-input.xml @@ -2,7 +2,7 @@ <tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.8" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v0.8" - xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="0.6" + xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v0.8 ../XSD/VectoComponent.xsd"> <tns:Engine> diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_engine_withid-input.xml b/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_engine_withid-input.xml index 663762376f28cd0593b068c6ddd4884a62edbdfd..d036f868bacc680a1a9ff1e27617f1bff306413e 100644 --- a/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_engine_withid-input.xml +++ b/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_engine_withid-input.xml @@ -2,7 +2,7 @@ <tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.8" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v0.8" - xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="0.6" + xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v0.8 ../XSD/VectoComponent.xsd"> <tns:Engine> diff --git a/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_gearbox-input.xml b/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_gearbox-input.xml index 83a5f29092c7b6e11d31fd4d9c0c7e4cf145947a..0f0883a338b57330b53420d6df79e48c70402415 100644 --- a/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_gearbox-input.xml +++ b/VectoCommon/VectoHashingTest/Testdata/XML/ToHash/vecto_gearbox-input.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.8" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v0.8" xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v0.8 ../XSD/VectoComponent.xsd"> +<tns:VectoInputDeclaration xmlns="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.8" xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v0.8" xmlns:di="http://www.w3.org/2000/09/xmldsig#" schemaVersion="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v0.8 ../XSD/VectoComponent.xsd"> <tns:Gearbox> <Data> <Manufacturer>Generic Gearbox Manufacturer</Manufacturer> diff --git a/VectoCommon/VectoHashingTest/VectoHashTest.cs b/VectoCommon/VectoHashingTest/VectoHashTest.cs index 986e32cb7511e57b2c872106d370a76d045d07f7..163bff91ce847268ef8aed8f8e784e81f6e6f884 100644 --- a/VectoCommon/VectoHashingTest/VectoHashTest.cs +++ b/VectoCommon/VectoHashingTest/VectoHashTest.cs @@ -414,16 +414,8 @@ namespace VectoHashingTest Assert.IsTrue(h2.ValidateHash()); // re-load generated XML and perform XSD validation - var settings = new XmlReaderSettings() { - ValidationType = ValidationType.Schema, - ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | - //XmlSchemaValidationFlags.ProcessSchemaLocation | - XmlSchemaValidationFlags.ReportValidationWarnings - }; - settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack); - settings.Schemas.Add(GetXMLSchema(false)); - var xmlValidator = XmlReader.Create(destination, settings); - var xmlDoc = XDocument.Load(xmlValidator); + var validator = new XMLValidator(XmlReader.Create(destination)); + Assert.IsTrue(validator.ValidateXML(XMLValidator.XmlDocumentType.DeclarationComponentData)); } @@ -505,24 +497,5 @@ namespace VectoHashingTest { AssertHelper.Exception<ArgumentOutOfRangeException>(() => ((VectoComponents)9999).HashIdPrefix()); } - - private static XmlSchemaSet GetXMLSchema(bool job) - { - var resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, - job ? "VectoInput.xsd" : "VectoComponent.xsd"); - var xset = new XmlSchemaSet() { XmlResolver = new XmlResourceResolver() }; - var reader = XmlReader.Create(resource, new XmlReaderSettings(), "schema://"); - xset.Add(XmlSchema.Read(reader, null)); - xset.Compile(); - return xset; - } - - private static void ValidationCallBack(object sender, ValidationEventArgs args) - { - if (args.Severity == XmlSeverityType.Error) { - throw new Exception(string.Format("Validation error: {0}" + Environment.NewLine + - "Line: {1}", args.Message, args.Exception.LineNumber)); - } - } } } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationEngineDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationEngineDataProvider.cs index fecfe5799402fcfe825ea32f3286c681c49ee2ca..7c48145fe1f7a0a884d49a3dea401950155618e9 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationEngineDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationEngineDataProvider.cs @@ -29,100 +29,100 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using TUGraz.IVT.VectoXML; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Resources; -using TUGraz.VectoCommon.Utils; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration -{ - public class XMLDeclarationEngineDataProvider : AbstractDeclarationXMLComponentDataProvider, - IEngineDeclarationInputData - { - public XMLDeclarationEngineDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) - : base(xmlInputDataProvider) - { - XBasePath = Helper.Query(VehiclePath, - XMLNames.Vehicle_Components, - XMLNames.Component_Engine, - XMLNames.ComponentDataWrapper); - } - +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration +{ + public class XMLDeclarationEngineDataProvider : AbstractDeclarationXMLComponentDataProvider, + IEngineDeclarationInputData + { + public XMLDeclarationEngineDataProvider(XMLDeclarationInputDataProvider xmlInputDataProvider) + : base(xmlInputDataProvider) + { + XBasePath = Helper.Query(VehiclePath, + XMLNames.Vehicle_Components, + XMLNames.Component_Engine, + XMLNames.ComponentDataWrapper); + } + 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 { return GetElementValue(XMLNames.Engine_FuelType).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); } - } - - public double CorrectionFactorNCV - { - get { return GetDoubleElementValue(XMLNames.Engine_CorrecionFactor_NCV); } - } - } + } + + public PerSecond IdleSpeed + { + get { return GetDoubleElementValue(XMLNames.Engine_IdlingSpeed).RPMtoRad(); } + } + + public FuelType FuelType + { + get { return GetElementValue(XMLNames.Engine_FuelType).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); } + } + + public double CorrectionFactorNCV + { + get { return GetDoubleElementValue(XMLNames.Engine_CorrecionFactor_NCV); } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationInputDataProvider.cs index 6e8b95b5732bfe188958eaafcd9e76b963b388e1..63ad01d6dd44a51b61f11623da1f677426b7f3f8 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationInputDataProvider.cs @@ -30,6 +30,7 @@ */ using System; +using System.IO; using System.Xml; using System.Xml.Linq; using System.Xml.Schema; @@ -61,21 +62,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration protected XMLDeclarationInputDataProvider(XmlReader inputData, string source, bool verifyXml) { Source = source; - if (verifyXml) { - var settings = new XmlReaderSettings { - ValidationType = ValidationType.Schema, - ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | - //XmlSchemaValidationFlags.ProcessSchemaLocation | - XmlSchemaValidationFlags.ReportValidationWarnings - }; - settings.ValidationEventHandler += ValidationCallBack; - settings.Schemas.Add(GetXMLSchema("")); + var xmldoc = new XmlDocument(); + xmldoc.Load(inputData); - inputData = XmlReader.Create(inputData, settings); + if (verifyXml) { + new XMLValidator(xmldoc, null, ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType.DeclarationJobData); } - var xmldoc = new XmlDocument(); - xmldoc.Load(inputData); var h = VectoHash.Load(xmldoc); XMLHash = h.ComputeXmlHash(); Document = new XPathDocument(new XmlNodeReader(xmldoc)); @@ -85,24 +78,15 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration public string Source { get; protected set; } - private static void ValidationCallBack(object sender, ValidationEventArgs args) + private static void ValidationCallBack(XmlSeverityType severity, ValidationEvent evt) { - if (args.Severity == XmlSeverityType.Error) { + if (severity == XmlSeverityType.Error) { + var args = evt.ValidationEventArgs; throw new VectoException("Validation error: {0}" + Environment.NewLine + "Line: {1}", args.Message, args.Exception.LineNumber); } } - private static XmlSchemaSet GetXMLSchema(string version) - { - var resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, "VectoInput.xsd"); - var xset = new XmlSchemaSet() { XmlResolver = new XmlResourceResolver() }; - var reader = XmlReader.Create(resource, new XmlReaderSettings(), XmlResourceResolver.BaseUri); - xset.Add(XmlSchema.Read(reader, null)); - xset.Compile(); - return xset; - } - public IDeclarationJobInputData JobInputData { get { return _xmlJobData; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs index 1fadee42c387e8536c84b15d1bd79557baeaa94e..c4a8d1c726e8bfbf3aadc5337de42958a141b363 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Declaration/XMLDeclarationVehicleDataProvider.cs @@ -139,6 +139,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration 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); + var digestValue = tyre.SelectSingleNode(Helper.Query("..//*[local-name()='DigestValue']"), Manager); retVal[axleNumber - 1] = new AxleInputData { AxleType = axleType == null ? AxleType.VehicleNonDriven : axleType.Value.ParseEnum<AxleType>(), TwinTyres = twinTyres != null && XmlConvert.ToBoolean(twinTyres.Value), @@ -148,7 +149,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration RollResistanceCoefficient = rollResistance == null ? double.NaN : rollResistance.Value.ToDouble(), Dimension = dimension == null ? null : dimension.Value, CertificationNumber = certirficationNumber == null ? null : certirficationNumber.Value, - CertificationMethod = CertificationMethod.Measured + CertificationMethod = CertificationMethod.Measured, + DigestValue = digestValue == null ? "" : digestValue.Value } }; } diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs index 68cbf355d3996fdbf13dd3fd0c1b09e41e2b88b7..b4bc0fb6f90006db1a633465dfd6596b9da8af59 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/AbstractEngineeringXMLComponentDataProvider.cs @@ -48,11 +48,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering protected readonly string FSBasePath; - protected readonly XPathDocument XMLDocument; + protected readonly XmlDocument XMLDocument; protected AbstractEngineeringXMLComponentDataProvider( XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, - XPathDocument document, string xmlBasePath, string fsBasePath) + XmlDocument document, string xmlBasePath, string fsBasePath) { XMLDocument = document; XBasePath = xmlBasePath; diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAirdragDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAirdragDataProvider.cs index ed40f61f058801fc414b04046610088f61e232b5..d57c472d918aa3508fcc1b196b35045dcd0ba5aa 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAirdragDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAirdragDataProvider.cs @@ -29,38 +29,39 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Xml.XPath; -using TUGraz.IVT.VectoXML; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Resources; -using TUGraz.VectoCommon.Utils; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering -{ - public class XMLEngineeringAirdragDataProvider : AbstractEngineeringXMLComponentDataProvider, - IAirdragEngineeringInputData - { - public XMLEngineeringAirdragDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, - XPathDocument axlegearDocument, string xmlBasePath, string fsBasePath) - : base(xmlEngineeringJobInputDataProvider, axlegearDocument, xmlBasePath, fsBasePath) {} - - public SquareMeter AirDragArea - { - get { return GetDoubleElementValue(XMLNames.Vehicle_AirDragArea).SI<SquareMeter>(); } - } - - public CrossWindCorrectionMode CrossWindCorrectionMode - { - get { return GetElementValue(XMLNames.Vehicle_CrossWindCorrectionMode).ParseEnum<CrossWindCorrectionMode>(); } - } - - public TableData CrosswindCorrectionMap - { - get { - return ReadTableData(AttributeMappings.CrossWindCorrectionMapping, - Helper.Query(XMLNames.Vehicle_CrosswindCorrectionData, XMLNames.Vehicle_CrosswindCorrectionData_Entry)); - } - } - } +using System.Xml; +using System.Xml.XPath; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public class XMLEngineeringAirdragDataProvider : AbstractEngineeringXMLComponentDataProvider, + IAirdragEngineeringInputData + { + public XMLEngineeringAirdragDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, + XmlDocument axlegearDocument, string xmlBasePath, string fsBasePath) + : base(xmlEngineeringJobInputDataProvider, axlegearDocument, xmlBasePath, fsBasePath) {} + + public SquareMeter AirDragArea + { + get { return GetDoubleElementValue(XMLNames.Vehicle_AirDragArea).SI<SquareMeter>(); } + } + + public CrossWindCorrectionMode CrossWindCorrectionMode + { + get { return GetElementValue(XMLNames.Vehicle_CrossWindCorrectionMode).ParseEnum<CrossWindCorrectionMode>(); } + } + + public TableData CrosswindCorrectionMap + { + get { + return ReadTableData(AttributeMappings.CrossWindCorrectionMapping, + Helper.Query(XMLNames.Vehicle_CrosswindCorrectionData, XMLNames.Vehicle_CrosswindCorrectionData_Entry)); + } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAngledriveDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAngledriveDataProvider.cs index cbc9d310edd04d11c6136b5c08d492d01da045e1..b1c575b1f594d662260164f73d18204b58c2bca6 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAngledriveDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAngledriveDataProvider.cs @@ -29,45 +29,45 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Xml.XPath; -using TUGraz.IVT.VectoXML; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Resources; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering -{ - public class XMLEngineeringAngledriveDataProvider : AbstractEngineeringXMLComponentDataProvider, IAngledriveInputData - { - public XMLEngineeringAngledriveDataProvider(XMLEngineeringInputDataProvider jobInputData, XPathDocument xmlDocument, - string xBasePath, string fsBasePath) : base(jobInputData, xmlDocument, xBasePath, fsBasePath) {} - - public AngledriveType Type - { - get { return InputData.VehicleData.AngledriveType; } - } - - public double Ratio - { - get { return GetDoubleElementValue(XMLNames.AngleDrive_Ratio); } - } - - public TableData LossMap - { - get { - if (ElementExists(Helper.Query(XMLNames.AngleDrive_TorqueLossMap, XMLNames.Angledrive_LossMap_Entry))) { - return ReadTableData(AttributeMappings.TransmissionLossmapMapping, - Helper.Query(XMLNames.AngleDrive_TorqueLossMap, XMLNames.Angledrive_LossMap_Entry)); - } - return ReadCSVResourceFile(XMLNames.AngleDrive_TorqueLossMap); - } - } - - public double Efficiency - { - get { - return GetDoubleElementValue(Helper.Query(XMLNames.AngleDrive_TorqueLossMap, XMLNames.AngleDrive_Efficiency)); - } - } - } +using System.Xml; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public class XMLEngineeringAngledriveDataProvider : AbstractEngineeringXMLComponentDataProvider, IAngledriveInputData + { + public XMLEngineeringAngledriveDataProvider(XMLEngineeringInputDataProvider jobInputData, XmlDocument xmlDocument, + string xBasePath, string fsBasePath) : base(jobInputData, xmlDocument, xBasePath, fsBasePath) {} + + public AngledriveType Type + { + get { return InputData.VehicleData.AngledriveType; } + } + + public double Ratio + { + get { return GetDoubleElementValue(XMLNames.AngleDrive_Ratio); } + } + + public TableData LossMap + { + get { + if (ElementExists(Helper.Query(XMLNames.AngleDrive_TorqueLossMap, XMLNames.Angledrive_LossMap_Entry))) { + return ReadTableData(AttributeMappings.TransmissionLossmapMapping, + Helper.Query(XMLNames.AngleDrive_TorqueLossMap, XMLNames.Angledrive_LossMap_Entry)); + } + return ReadCSVResourceFile(XMLNames.AngleDrive_TorqueLossMap); + } + } + + public double Efficiency + { + get { + return GetDoubleElementValue(Helper.Query(XMLNames.AngleDrive_TorqueLossMap, XMLNames.AngleDrive_Efficiency)); + } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAuxiliaryDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAuxiliaryDataProvider.cs index 88d19a8bdaa490f1cb83cb0b994d1c71c2c9578f..5ded5d655b5239734dace4ae3e8fa76d4c403742 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAuxiliaryDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAuxiliaryDataProvider.cs @@ -29,110 +29,111 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Collections.Generic; -using System.IO; -using System.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.InputData.Impl; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering -{ - public class XMLEngineeringAuxiliaryDataProvider : AbstractEngineeringXMLComponentDataProvider, - IAuxiliariesEngineeringInputData - { - public XMLEngineeringAuxiliaryDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, - XPathDocument auxDocument, string xmlBasePath, string fsBasePath) - : base(xmlEngineeringJobInputDataProvider, auxDocument, xmlBasePath, fsBasePath) {} - - - public IList<IAuxiliaryDeclarationInputData> Auxiliaries - { - get { return AuxiliaryInputData().Cast<IAuxiliaryDeclarationInputData>().ToList(); } - } - - IList<IAuxiliaryEngineeringInputData> IAuxiliariesEngineeringInputData.Auxiliaries - { - get { return AuxiliaryInputData().Cast<IAuxiliaryEngineeringInputData>().ToList(); } - } - - private IEnumerable<AuxiliaryDataInputData> AuxiliaryInputData() - { - var retVal = new List<AuxiliaryDataInputData>(); - var auxiliaries = Navigator.Select(Helper.Query(XBasePath, XMLNames.Auxiliaries_Auxiliary), Manager); - while (auxiliaries.MoveNext()) { - var constantAux = auxiliaries.Current.SelectSingleNode(Helper.Query(XMLNames.Auxiliaries_Auxiliary_ConstantAuxLoad), Manager); - if (constantAux == null) { - retVal.Add(CreateMappingAuxiliary(auxiliaries)); - } else { - retVal.Add(new AuxiliaryDataInputData() { - ID = "ConstantAux", - AuxiliaryType = AuxiliaryDemandType.Constant, - ConstantPowerDemand = constantAux.ValueAsDouble.SI<Watt>() - }); - } - } - return retVal; - } - - protected AuxiliaryDataInputData CreateMappingAuxiliary(XPathNodeIterator auxiliaries) - { - var auxData = new AuxiliaryDataInputData { - AuxiliaryType = AuxiliaryDemandType.Mapping, - ID = auxiliaries.Current.GetAttribute("id", ""), - }; - var node = - auxiliaries.Current.SelectSingleNode(ExtCsvResourceTag, Manager); - if (node != null) { - var auxFile = node.GetAttribute(XMLNames.ExtResource_File_Attr, ""); - - if (!File.Exists(Path.Combine(FSBasePath, auxFile))) { - throw new VectoException("Auxiliary resource file {0} not found! Aux: {1}", auxFile, auxData.ID); - } - AuxiliaryFileHelper.FillAuxiliaryDataInputData(auxData, Path.Combine(FSBasePath, auxFile)); - } else { - var transmissionRatio = - auxiliaries.Current.SelectSingleNode(Helper.Query(XMLNames.Auxiliaries_Auxiliary_TransmissionRatioToEngine), - Manager); - if (transmissionRatio != null) { - auxData.TransmissionRatio = transmissionRatio.ValueAsDouble; - } - var efficiencyEngine = - auxiliaries.Current.SelectSingleNode(Helper.Query(XMLNames.Auxiliaries_Auxiliary_EfficiencyToEngine), Manager); - if (efficiencyEngine != null) { - auxData.EfficiencyToEngine = efficiencyEngine.ValueAsDouble; - } - var efficiencyAuxSupply = - auxiliaries.Current.SelectSingleNode(Helper.Query(XMLNames.Auxiliaries_Auxiliary_EfficiencyAuxSupply), Manager); - if (efficiencyAuxSupply != null) { - auxData.EfficiencyToSupply = efficiencyAuxSupply.ValueAsDouble; - } - auxData.DemandMap = ReadTableData(AttributeMappings.AuxMapMapping, - Helper.Query(XMLNames.Auxiliaries_Auxiliary_AuxMap, XMLNames.Auxiliaries_Auxiliary_AuxMap_Entry), - auxiliaries.Current); - - } - return auxData; - } - - public AuxiliaryModel AuxiliaryAssembly - { - get { return AuxiliaryModel.Classic; } - } - - public string AuxiliaryVersion - { - get { return ""; } - } - - public string AdvancedAuxiliaryFilePath - { - get { return ""; } - } - } +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Xml; +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.InputData.Impl; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public class XMLEngineeringAuxiliaryDataProvider : AbstractEngineeringXMLComponentDataProvider, + IAuxiliariesEngineeringInputData + { + public XMLEngineeringAuxiliaryDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, + XmlDocument auxDocument, string xmlBasePath, string fsBasePath) + : base(xmlEngineeringJobInputDataProvider, auxDocument, xmlBasePath, fsBasePath) {} + + + public IList<IAuxiliaryDeclarationInputData> Auxiliaries + { + get { return AuxiliaryInputData().Cast<IAuxiliaryDeclarationInputData>().ToList(); } + } + + IList<IAuxiliaryEngineeringInputData> IAuxiliariesEngineeringInputData.Auxiliaries + { + get { return AuxiliaryInputData().Cast<IAuxiliaryEngineeringInputData>().ToList(); } + } + + private IEnumerable<AuxiliaryDataInputData> AuxiliaryInputData() + { + var retVal = new List<AuxiliaryDataInputData>(); + var auxiliaries = Navigator.Select(Helper.Query(XBasePath, XMLNames.Auxiliaries_Auxiliary), Manager); + while (auxiliaries.MoveNext()) { + var constantAux = auxiliaries.Current.SelectSingleNode(Helper.Query(XMLNames.Auxiliaries_Auxiliary_ConstantAuxLoad), Manager); + if (constantAux == null) { + retVal.Add(CreateMappingAuxiliary(auxiliaries)); + } else { + retVal.Add(new AuxiliaryDataInputData() { + ID = "ConstantAux", + AuxiliaryType = AuxiliaryDemandType.Constant, + ConstantPowerDemand = constantAux.ValueAsDouble.SI<Watt>() + }); + } + } + return retVal; + } + + protected AuxiliaryDataInputData CreateMappingAuxiliary(XPathNodeIterator auxiliaries) + { + var auxData = new AuxiliaryDataInputData { + AuxiliaryType = AuxiliaryDemandType.Mapping, + ID = auxiliaries.Current.GetAttribute("id", ""), + }; + var node = + auxiliaries.Current.SelectSingleNode(ExtCsvResourceTag, Manager); + if (node != null) { + var auxFile = node.GetAttribute(XMLNames.ExtResource_File_Attr, ""); + + if (!File.Exists(Path.Combine(FSBasePath, auxFile))) { + throw new VectoException("Auxiliary resource file {0} not found! Aux: {1}", auxFile, auxData.ID); + } + AuxiliaryFileHelper.FillAuxiliaryDataInputData(auxData, Path.Combine(FSBasePath, auxFile)); + } else { + var transmissionRatio = + auxiliaries.Current.SelectSingleNode(Helper.Query(XMLNames.Auxiliaries_Auxiliary_TransmissionRatioToEngine), + Manager); + if (transmissionRatio != null) { + auxData.TransmissionRatio = transmissionRatio.ValueAsDouble; + } + var efficiencyEngine = + auxiliaries.Current.SelectSingleNode(Helper.Query(XMLNames.Auxiliaries_Auxiliary_EfficiencyToEngine), Manager); + if (efficiencyEngine != null) { + auxData.EfficiencyToEngine = efficiencyEngine.ValueAsDouble; + } + var efficiencyAuxSupply = + auxiliaries.Current.SelectSingleNode(Helper.Query(XMLNames.Auxiliaries_Auxiliary_EfficiencyAuxSupply), Manager); + if (efficiencyAuxSupply != null) { + auxData.EfficiencyToSupply = efficiencyAuxSupply.ValueAsDouble; + } + auxData.DemandMap = ReadTableData(AttributeMappings.AuxMapMapping, + Helper.Query(XMLNames.Auxiliaries_Auxiliary_AuxMap, XMLNames.Auxiliaries_Auxiliary_AuxMap_Entry), + auxiliaries.Current); + + } + return auxData; + } + + public AuxiliaryModel AuxiliaryAssembly + { + get { return AuxiliaryModel.Classic; } + } + + public string AuxiliaryVersion + { + get { return ""; } + } + + public string AdvancedAuxiliaryFilePath + { + get { return ""; } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAxlegearDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAxlegearDataProvider.cs index 83a15cc185a262428ca0b6558693ede7089a0f61..50bb256c65f8e496d86696420fc5ae2fe9a5b07f 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAxlegearDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringAxlegearDataProvider.cs @@ -29,49 +29,49 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Xml.XPath; -using TUGraz.IVT.VectoXML; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Resources; -using TUGraz.VectoCommon.Utils; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering -{ - public class XMLEngineeringAxlegearDataProvider : AbstractEngineeringXMLComponentDataProvider, IAxleGearInputData - { - public XMLEngineeringAxlegearDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, - XPathDocument axlegearDocument, string xmlBasePath, string fsBasePath) - : base(xmlEngineeringJobInputDataProvider, axlegearDocument, xmlBasePath, fsBasePath) {} - - public double Ratio - { - get { return GetDoubleElementValue(XMLNames.Axlegear_Ratio); } - } - - public TableData LossMap - { - get { - if (ElementExists(Helper.Query(XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry))) { - return ReadTableData(AttributeMappings.TransmissionLossmapMapping, - Helper.Query(XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry)); - } - return ReadCSVResourceFile(XMLNames.Axlegear_TorqueLossMap); - } - } - - public double Efficiency - { - get { return GetDoubleElementValue(Helper.Query(XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_Efficiency)); } - } - - public AxleLineType LineType - { - get { - return ElementExists(XMLNames.Axlegear_LineType) - ? GetElementValue(XMLNames.Axlegear_LineType).ParseEnum<AxleLineType>() - : AxleLineType.SinglePortalAxle; - } - } - } +using System.Xml; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public class XMLEngineeringAxlegearDataProvider : AbstractEngineeringXMLComponentDataProvider, IAxleGearInputData + { + public XMLEngineeringAxlegearDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, + XmlDocument axlegearDocument, string xmlBasePath, string fsBasePath) + : base(xmlEngineeringJobInputDataProvider, axlegearDocument, xmlBasePath, fsBasePath) {} + + public double Ratio + { + get { return GetDoubleElementValue(XMLNames.Axlegear_Ratio); } + } + + public TableData LossMap + { + get { + if (ElementExists(Helper.Query(XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry))) { + return ReadTableData(AttributeMappings.TransmissionLossmapMapping, + Helper.Query(XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_TorqueLossMap_Entry)); + } + return ReadCSVResourceFile(XMLNames.Axlegear_TorqueLossMap); + } + } + + public double Efficiency + { + get { return GetDoubleElementValue(Helper.Query(XMLNames.Axlegear_TorqueLossMap, XMLNames.Axlegear_Efficiency)); } + } + + public AxleLineType LineType + { + get { + return ElementExists(XMLNames.Axlegear_LineType) + ? GetElementValue(XMLNames.Axlegear_LineType).ParseEnum<AxleLineType>() + : AxleLineType.SinglePortalAxle; + } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringDriverDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringDriverDataProvider.cs index bfa2fcfa3079805a78338c28764dda165be3b88c..cc87c768a73f3ca0b23d70e3d84119083b5b3ba7 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringDriverDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringDriverDataProvider.cs @@ -29,164 +29,164 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System; -using System.IO; -using System.Xml; -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.InputData.Impl; -using TUGraz.VectoCore.Models.Declaration; -using TUGraz.VectoCore.Models.SimulationComponent.Data; -using TUGraz.VectoCore.Utils; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering -{ - public class XMLEngineeringDriverDataProvider : AbstractEngineeringXMLComponentDataProvider, - IDriverEngineeringInputData - { - public XMLEngineeringDriverDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, - XPathDocument driverDocument, string xmlBasePath, string fsBasePath) - : base(xmlEngineeringJobInputDataProvider, driverDocument, xmlBasePath, fsBasePath) {} - - IOverSpeedEcoRollEngineeringInputData IDriverEngineeringInputData.OverSpeedEcoRoll - { - get { - var minSpeedPath = Helper.Query(XMLNames.Component_DriverModel, - XMLNames.DriverModel_Overspeed, XMLNames.DriverModel_Overspeed_MinSpeed); - var overSpeedPath = Helper.Query(XMLNames.Component_DriverModel, - XMLNames.DriverModel_Overspeed, XMLNames.DriverModel_Overspeed_AllowedOverspeed); - var underSpeedPath = Helper.Query(XMLNames.Component_DriverModel, - XMLNames.DriverModel_Overspeed, XMLNames.DriverModel_Overspeed_AllowedUnderspeed); - var retVal = new OverSpeedEcoRollInputData { - Mode = GetElementValue(Helper.Query(XMLNames.Component_DriverModel, - XMLNames.DriverModel_Overspeed, XMLNames.DriverModel_Overspeed_Mode)).ParseEnum<DriverMode>(), - MinSpeed = ElementExists(minSpeedPath) - ? GetDoubleElementValue(minSpeedPath).KMPHtoMeterPerSecond() - : DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed, - OverSpeed = ElementExists(overSpeedPath) - ? GetDoubleElementValue(overSpeedPath).KMPHtoMeterPerSecond() - : DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed, - UnderSpeed = ElementExists(underSpeedPath) - ? GetDoubleElementValue(underSpeedPath).KMPHtoMeterPerSecond() - : DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed - }; - - return retVal; - } - } - - public TableData AccelerationCurve - { - get { - if (ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_DriverAccelerationCurve))) { - return - ReadTableData(AttributeMappings.DriverAccelerationCurveMapping, - Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_DriverAccelerationCurve, - XMLNames.DriverModel_DriverAccelerationCurve_Entry)); - } - //Log.Warn("Could not find file for acceleration curve. Trying lookup in declaration data."); - try { - var resourceName = DeclarationData.DeclarationDataResourcePrefix + ".VACC.Truck" + - Constants.FileExtensions.DriverAccelerationCurve; - return VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceName), source: resourceName); - } catch (Exception e) { - throw new VectoException("Failed to read Driver Acceleration Curve: " + e.Message, e); - } - } - } - - public ILookaheadCoastingInputData Lookahead - { - get { - var lookAheadXmlPath = Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_LookAheadCoasting); - - var retVal = new LookAheadCoastingInputData { - Enabled = - XmlConvert.ToBoolean( - GetElementValue(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_Enabled))), - LookaheadDistanceFactor = - ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_PreviewDistanceFactor)) - ? GetDoubleElementValue(Helper.Query(lookAheadXmlPath, - XMLNames.DriverModel_LookAheadCoasting_PreviewDistanceFactor)) - : DeclarationData.Driver.LookAhead.LookAheadDistanceFactor, - CoastingDecisionFactorOffset = - ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_DecisionFactorOffset)) - ? GetDoubleElementValue(Helper.Query(lookAheadXmlPath, - XMLNames.DriverModel_LookAheadCoasting_DecisionFactorOffset)) - : DeclarationData.Driver.LookAhead.DecisionFactorCoastingOffset, - CoastingDecisionFactorScaling = - ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_DecisionFactorScaling)) - ? GetDoubleElementValue(Helper.Query(lookAheadXmlPath, - XMLNames.DriverModel_LookAheadCoasting_DecisionFactorScaling)) - : DeclarationData.Driver.LookAhead.DecisionFactorCoastingScaling, - MinSpeed = ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_MinSpeed)) - ? GetDoubleElementValue(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_MinSpeed)) - .KMPHtoMeterPerSecond() - : DeclarationData.Driver.LookAhead.MinimumSpeed - }; - - if ( - ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, - XMLNames.LookAheadCoasting_SpeedDependentDecisionFactor_Entry))) { - retVal.CoastingDecisionFactorTargetSpeedLookup = ReadTableData( - AttributeMappings.CoastingDFTargetSpeedLookupMapping, - Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, - XMLNames.LookAheadCoasting_SpeedDependentDecisionFactor_Entry)); - } else if ( - ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, - XMLNames.ExternalResource))) { - var node = Navigator.SelectSingleNode(Helper.Query(XBasePath, lookAheadXmlPath, - XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, XMLNames.ExternalResource), Manager); - if (node != null && - XMLNames.ExtResource_Type_Value_CSV.Equals(node.GetAttribute(XMLNames.ExtResource_Type_Attr, ""))) { - retVal.CoastingDecisionFactorTargetSpeedLookup = - VectoCSVFile.Read(Path.Combine(FSBasePath, node.GetAttribute(XMLNames.ExtResource_File_Attr, ""))); - } - } else { - retVal.CoastingDecisionFactorTargetSpeedLookup = null; - } - - if ( - ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, - XMLNames.LookAheadCoasting_VelocityDropDecisionFactor_Entry))) { - retVal.CoastingDecisionFactorVelocityDropLookup = - ReadTableData(AttributeMappings.CoastingDFVelocityDropLookupMapping, - Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, - XMLNames.LookAheadCoasting_VelocityDropDecisionFactor_Entry)); - } else if ( - ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, - XMLNames.ExternalResource))) { - var node = - Navigator.SelectSingleNode(Helper.Query(XBasePath, lookAheadXmlPath, - XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, XMLNames.ExternalResource), Manager); - if (node != null && - XMLNames.ExtResource_Type_Value_CSV.Equals(node.GetAttribute(XMLNames.ExtResource_Type_Attr, ""))) { - retVal.CoastingDecisionFactorVelocityDropLookup = - VectoCSVFile.Read(Path.Combine(FSBasePath, node.GetAttribute(XMLNames.ExtResource_File_Attr, ""))); - } - } else { - retVal.CoastingDecisionFactorVelocityDropLookup = null; - } - return retVal; - } - } - - public IOverSpeedEcoRollDeclarationInputData OverSpeedEcoRoll - { - get { - var node = - Navigator.SelectSingleNode(Helper.Query(XBasePath, XMLNames.Component_DriverModel, XMLNames.DriverModel_Overspeed, - XMLNames.DriverModel_Overspeed_Mode), Manager); - return new OverSpeedEcoRollInputData() { - Mode = node != null ? DriverData.ParseDriverMode(node.Value) : DriverMode.Off - }; - } - } - } +using System; +using System.IO; +using System.Xml; +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.InputData.Impl; +using TUGraz.VectoCore.Models.Declaration; +using TUGraz.VectoCore.Models.SimulationComponent.Data; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public class XMLEngineeringDriverDataProvider : AbstractEngineeringXMLComponentDataProvider, + IDriverEngineeringInputData + { + public XMLEngineeringDriverDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, + XmlDocument driverDocument, string xmlBasePath, string fsBasePath) + : base(xmlEngineeringJobInputDataProvider, driverDocument, xmlBasePath, fsBasePath) {} + + IOverSpeedEcoRollEngineeringInputData IDriverEngineeringInputData.OverSpeedEcoRoll + { + get { + var minSpeedPath = Helper.Query(XMLNames.Component_DriverModel, + XMLNames.DriverModel_Overspeed, XMLNames.DriverModel_Overspeed_MinSpeed); + var overSpeedPath = Helper.Query(XMLNames.Component_DriverModel, + XMLNames.DriverModel_Overspeed, XMLNames.DriverModel_Overspeed_AllowedOverspeed); + var underSpeedPath = Helper.Query(XMLNames.Component_DriverModel, + XMLNames.DriverModel_Overspeed, XMLNames.DriverModel_Overspeed_AllowedUnderspeed); + var retVal = new OverSpeedEcoRollInputData { + Mode = GetElementValue(Helper.Query(XMLNames.Component_DriverModel, + XMLNames.DriverModel_Overspeed, XMLNames.DriverModel_Overspeed_Mode)).ParseEnum<DriverMode>(), + MinSpeed = ElementExists(minSpeedPath) + ? GetDoubleElementValue(minSpeedPath).KMPHtoMeterPerSecond() + : DeclarationData.Driver.OverSpeedEcoRoll.MinSpeed, + OverSpeed = ElementExists(overSpeedPath) + ? GetDoubleElementValue(overSpeedPath).KMPHtoMeterPerSecond() + : DeclarationData.Driver.OverSpeedEcoRoll.OverSpeed, + UnderSpeed = ElementExists(underSpeedPath) + ? GetDoubleElementValue(underSpeedPath).KMPHtoMeterPerSecond() + : DeclarationData.Driver.OverSpeedEcoRoll.UnderSpeed + }; + + return retVal; + } + } + + public TableData AccelerationCurve + { + get { + if (ElementExists(Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_DriverAccelerationCurve))) { + return + ReadTableData(AttributeMappings.DriverAccelerationCurveMapping, + Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_DriverAccelerationCurve, + XMLNames.DriverModel_DriverAccelerationCurve_Entry)); + } + //Log.Warn("Could not find file for acceleration curve. Trying lookup in declaration data."); + try { + var resourceName = DeclarationData.DeclarationDataResourcePrefix + ".VACC.Truck" + + Constants.FileExtensions.DriverAccelerationCurve; + return VectoCSVFile.ReadStream(RessourceHelper.ReadStream(resourceName), source: resourceName); + } catch (Exception e) { + throw new VectoException("Failed to read Driver Acceleration Curve: " + e.Message, e); + } + } + } + + public ILookaheadCoastingInputData Lookahead + { + get { + var lookAheadXmlPath = Helper.Query(XMLNames.Component_DriverModel, XMLNames.DriverModel_LookAheadCoasting); + + var retVal = new LookAheadCoastingInputData { + Enabled = + XmlConvert.ToBoolean( + GetElementValue(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_Enabled))), + LookaheadDistanceFactor = + ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_PreviewDistanceFactor)) + ? GetDoubleElementValue(Helper.Query(lookAheadXmlPath, + XMLNames.DriverModel_LookAheadCoasting_PreviewDistanceFactor)) + : DeclarationData.Driver.LookAhead.LookAheadDistanceFactor, + CoastingDecisionFactorOffset = + ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_DecisionFactorOffset)) + ? GetDoubleElementValue(Helper.Query(lookAheadXmlPath, + XMLNames.DriverModel_LookAheadCoasting_DecisionFactorOffset)) + : DeclarationData.Driver.LookAhead.DecisionFactorCoastingOffset, + CoastingDecisionFactorScaling = + ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_DecisionFactorScaling)) + ? GetDoubleElementValue(Helper.Query(lookAheadXmlPath, + XMLNames.DriverModel_LookAheadCoasting_DecisionFactorScaling)) + : DeclarationData.Driver.LookAhead.DecisionFactorCoastingScaling, + MinSpeed = ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_MinSpeed)) + ? GetDoubleElementValue(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_MinSpeed)) + .KMPHtoMeterPerSecond() + : DeclarationData.Driver.LookAhead.MinimumSpeed + }; + + if ( + ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, + XMLNames.LookAheadCoasting_SpeedDependentDecisionFactor_Entry))) { + retVal.CoastingDecisionFactorTargetSpeedLookup = ReadTableData( + AttributeMappings.CoastingDFTargetSpeedLookupMapping, + Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, + XMLNames.LookAheadCoasting_SpeedDependentDecisionFactor_Entry)); + } else if ( + ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, + XMLNames.ExternalResource))) { + var node = Navigator.SelectSingleNode(Helper.Query(XBasePath, lookAheadXmlPath, + XMLNames.DriverModel_LookAheadCoasting_SpeedDependentDecisionFactor, XMLNames.ExternalResource), Manager); + if (node != null && + XMLNames.ExtResource_Type_Value_CSV.Equals(node.GetAttribute(XMLNames.ExtResource_Type_Attr, ""))) { + retVal.CoastingDecisionFactorTargetSpeedLookup = + VectoCSVFile.Read(Path.Combine(FSBasePath, node.GetAttribute(XMLNames.ExtResource_File_Attr, ""))); + } + } else { + retVal.CoastingDecisionFactorTargetSpeedLookup = null; + } + + if ( + ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, + XMLNames.LookAheadCoasting_VelocityDropDecisionFactor_Entry))) { + retVal.CoastingDecisionFactorVelocityDropLookup = + ReadTableData(AttributeMappings.CoastingDFVelocityDropLookupMapping, + Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, + XMLNames.LookAheadCoasting_VelocityDropDecisionFactor_Entry)); + } else if ( + ElementExists(Helper.Query(lookAheadXmlPath, XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, + XMLNames.ExternalResource))) { + var node = + Navigator.SelectSingleNode(Helper.Query(XBasePath, lookAheadXmlPath, + XMLNames.DriverModel_LookAheadCoasting_VelocityDropDecisionFactor, XMLNames.ExternalResource), Manager); + if (node != null && + XMLNames.ExtResource_Type_Value_CSV.Equals(node.GetAttribute(XMLNames.ExtResource_Type_Attr, ""))) { + retVal.CoastingDecisionFactorVelocityDropLookup = + VectoCSVFile.Read(Path.Combine(FSBasePath, node.GetAttribute(XMLNames.ExtResource_File_Attr, ""))); + } + } else { + retVal.CoastingDecisionFactorVelocityDropLookup = null; + } + return retVal; + } + } + + public IOverSpeedEcoRollDeclarationInputData OverSpeedEcoRoll + { + get { + var node = + Navigator.SelectSingleNode(Helper.Query(XBasePath, XMLNames.Component_DriverModel, XMLNames.DriverModel_Overspeed, + XMLNames.DriverModel_Overspeed_Mode), Manager); + return new OverSpeedEcoRollInputData() { + Mode = node != null ? DriverData.ParseDriverMode(node.Value) : DriverMode.Off + }; + } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringEngineDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringEngineDataProvider.cs index e8787885ee401cdcc127622561f77093bc0d8e4d..fce8b3645497783a0a8504840d6823a24d78125d 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringEngineDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringEngineDataProvider.cs @@ -29,122 +29,122 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -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; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering -{ - public class XMLEngineeringEngineDataProvider : AbstractEngineeringXMLComponentDataProvider, - IEngineEngineeringInputData - { - public XMLEngineeringEngineDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, - XPathDocument engineDocument, string xmlBasePath, string fsBasePath) - : base(xmlEngineeringJobInputDataProvider, engineDocument, xmlBasePath, fsBasePath) {} - +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; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public class XMLEngineeringEngineDataProvider : AbstractEngineeringXMLComponentDataProvider, + IEngineEngineeringInputData + { + public XMLEngineeringEngineDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, + XmlDocument engineDocument, string xmlBasePath, string fsBasePath) + : base(xmlEngineeringJobInputDataProvider, engineDocument, xmlBasePath, fsBasePath) {} + 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 double WHTCEngineering - { - get { return GetDoubleElementValue(XMLNames.Engine_WHTCEngineering); } - } - - public double WHTCMotorway - { - get { throw new VectoException("Property not available in Engineering Mode"); } - } - - public double WHTCRural - { - get { throw new VectoException("Property not available in Engineering Mode"); } - } - - public double WHTCUrban - { - get { throw new VectoException("Property not available in Engineering Mode"); } - } - - public double ColdHotBalancingFactor - { - get { throw new VectoException("Property not available in Engineering Mode"); } - } - - public double CorrectionFactorRegPer - { - get { - return 1; - //GetDoubleElementValue(XMLNames.Engine_CorrectionFactor_RegPer); - } - } - - public double CorrectionFactorNCV - { - get { return 1; //GetDoubleElementValue(XMLNames.Engine_CorrecionFactor_NCV); - } - } - - public FuelType FuelType - { - get { return FuelType.DieselCI; //GetElementValue(XMLNames.Engine_FuelType).ParseEnum<FuelType>(); - } - } - - public TableData FuelConsumptionMap - { - get { - if (!ElementExists(Helper.Query(XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry))) { - return ReadCSVResourceFile(XMLNames.Engine_FuelConsumptionMap); - } - return ReadTableData(AttributeMappings.FuelConsumptionMapMapping, - Helper.Query(XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry)); - } - } - - public TableData FullLoadCurve - { - get { - if (!ElementExists(Helper.Query(XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FuelConsumptionMap_Entry))) { - return ReadCSVResourceFile(XMLNames.Engine_FullLoadAndDragCurve); - } - - return ReadTableData(AttributeMappings.EngineFullLoadCurveMapping, - Helper.Query(XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FuelConsumptionMap_Entry)); - } - } - - public Watt RatedPowerDeclared - { - get { return null; //GetDoubleElementValue(XMLNames.Engine_RatedPower).SI<Watt>(); - } - } - - public PerSecond RatedSpeedDeclared - { - get { return null; //GetDoubleElementValue(XMLNames.Engine_RatedSpeed).RPMtoRad(); - } - } - - public NewtonMeter MaxTorqueDeclared - { - get { return null; //GetDoubleElementValue(XMLNames.Engine_MaxTorque).SI<NewtonMeter>(); - } - } - - public KilogramSquareMeter Inertia - { - get { return GetDoubleElementValue(XMLNames.Engine_Inertia).SI<KilogramSquareMeter>(); } - } - } + } + + public PerSecond IdleSpeed + { + get { return GetDoubleElementValue(XMLNames.Engine_IdlingSpeed).RPMtoRad(); } + } + + public double WHTCEngineering + { + get { return GetDoubleElementValue(XMLNames.Engine_WHTCEngineering); } + } + + public double WHTCMotorway + { + get { throw new VectoException("Property not available in Engineering Mode"); } + } + + public double WHTCRural + { + get { throw new VectoException("Property not available in Engineering Mode"); } + } + + public double WHTCUrban + { + get { throw new VectoException("Property not available in Engineering Mode"); } + } + + public double ColdHotBalancingFactor + { + get { throw new VectoException("Property not available in Engineering Mode"); } + } + + public double CorrectionFactorRegPer + { + get { + return 1; + //GetDoubleElementValue(XMLNames.Engine_CorrectionFactor_RegPer); + } + } + + public double CorrectionFactorNCV + { + get { return 1; //GetDoubleElementValue(XMLNames.Engine_CorrecionFactor_NCV); + } + } + + public FuelType FuelType + { + get { return FuelType.DieselCI; //GetElementValue(XMLNames.Engine_FuelType).ParseEnum<FuelType>(); + } + } + + public TableData FuelConsumptionMap + { + get { + if (!ElementExists(Helper.Query(XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry))) { + return ReadCSVResourceFile(XMLNames.Engine_FuelConsumptionMap); + } + return ReadTableData(AttributeMappings.FuelConsumptionMapMapping, + Helper.Query(XMLNames.Engine_FuelConsumptionMap, XMLNames.Engine_FuelConsumptionMap_Entry)); + } + } + + public TableData FullLoadCurve + { + get { + if (!ElementExists(Helper.Query(XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FuelConsumptionMap_Entry))) { + return ReadCSVResourceFile(XMLNames.Engine_FullLoadAndDragCurve); + } + + return ReadTableData(AttributeMappings.EngineFullLoadCurveMapping, + Helper.Query(XMLNames.Engine_FullLoadAndDragCurve, XMLNames.Engine_FuelConsumptionMap_Entry)); + } + } + + public Watt RatedPowerDeclared + { + get { return null; //GetDoubleElementValue(XMLNames.Engine_RatedPower).SI<Watt>(); + } + } + + public PerSecond RatedSpeedDeclared + { + get { return null; //GetDoubleElementValue(XMLNames.Engine_RatedSpeed).RPMtoRad(); + } + } + + public NewtonMeter MaxTorqueDeclared + { + get { return null; //GetDoubleElementValue(XMLNames.Engine_MaxTorque).SI<NewtonMeter>(); + } + } + + public KilogramSquareMeter Inertia + { + get { return GetDoubleElementValue(XMLNames.Engine_Inertia).SI<KilogramSquareMeter>(); } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringGearboxDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringGearboxDataProvider.cs index 3440ad834b7ea7bbcd83aa9cef7f086c6183eda0..b88a7003579dd8499247d5bb08897c6cdea696e4 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringGearboxDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringGearboxDataProvider.cs @@ -29,146 +29,146 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Collections.Generic; -using System.Xml; -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.InputData.Impl; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering -{ - public class XMLEngineeringGearboxDataProvider : AbstractEngineeringXMLComponentDataProvider, - IGearboxEngineeringInputData - { - public XMLEngineeringGearboxDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, - XPathDocument gbxDocument, string xmlBasePath, string fsBasePath) - : base(xmlEngineeringJobInputDataProvider, gbxDocument, xmlBasePath, fsBasePath) {} - - public GearboxType Type - { - get { return GetElementValue(XMLNames.Gearbox_TransmissionType).ParseEnum<GearboxType>(); } - } - - - public KilogramSquareMeter Inertia - { - get { return GetDoubleElementValue(XMLNames.Gearbox_Inertia).SI<KilogramSquareMeter>(); } - } - - public Second TractionInterruption - { - get { return GetDoubleElementValue(XMLNames.Gearbox_TractionInterruption).SI<Second>(); } - } - - 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; - } - } - - 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); - if ( - ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry))) { - retVal.LossMap = ReadTableData(AttributeMappings.TransmissionLossmapMapping, - Helper.Query(gearPath, XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry)); - } else { - retVal.LossMap = ReadCSVResourceFile(Helper.Query(gearPath, XMLNames.Gearbox_Gear_TorqueLossMap)); - } - - if ( - ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon, - XMLNames.Gearbox_Gears_Gear_ShiftPolygon_Entry))) { - retVal.ShiftPolygon = ReadTableData(AttributeMappings.ShiftPolygonMapping, - Helper.Query(gearPath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon, XMLNames.Gearbox_Gears_Gear_ShiftPolygon_Entry)); - } - if ( - ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon, ExtCsvResourceTag))) { - retVal.ShiftPolygon = ReadCSVResourceFile(Helper.Query(gearPath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon)); - } - - retVal.MaxTorque = ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque)) - ? GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque)).SI<NewtonMeter>() - : null; - return retVal; - } - - public Second MinTimeBetweenGearshift - { - get { return InputData.XMLEngineeringJobData.MinTimeBetweenGearshift; } - } - - public double TorqueReserve - { - get { return InputData.XMLEngineeringJobData.TorqueReserve; } - } - - public MeterPerSecond StartSpeed - { - get { return InputData.XMLEngineeringJobData.StartSpeed; } - } - - public MeterPerSquareSecond StartAcceleration - { - get { return InputData.XMLEngineeringJobData.StartAcceleration; } - } - - public double StartTorqueReserve - { - get { return InputData.XMLEngineeringJobData.StartTorqueReserve; } - } - - - ITorqueConverterDeclarationInputData IGearboxDeclarationInputData.TorqueConverter - { - get { return TorqueConverter; } - } - - public ITorqueConverterEngineeringInputData TorqueConverter - { - get - { - return new XMLEngineeringTorqueConverterDataProvider(InputData, XMLDocument, - Helper.Query(XBasePath, "parent::*", XMLNames.Component_TorqueConverter, XMLNames.ComponentDataWrapper), FSBasePath); - } - } - - public Second DownshiftAfterUpshiftDelay - { - get { return InputData.XMLEngineeringJobData.DownshiftAfterUpshiftDelay; } - } - - public Second UpshiftAfterDownshiftDelay - { - get { return InputData.XMLEngineeringJobData.UpshiftAfterDownshiftDelay; } - } - - public MeterPerSquareSecond UpshiftMinAcceleration - { - get { return InputData.XMLEngineeringJobData.UpshiftMinAcceleration; } - } - - public Second PowershiftShiftTime - { - get { return InputData.XMLEngineeringJobData.PowershiftShiftTime; } - } - - } +using System.Collections.Generic; +using System.Xml; +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.InputData.Impl; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public class XMLEngineeringGearboxDataProvider : AbstractEngineeringXMLComponentDataProvider, + IGearboxEngineeringInputData + { + public XMLEngineeringGearboxDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, + XmlDocument gbxDocument, string xmlBasePath, string fsBasePath) + : base(xmlEngineeringJobInputDataProvider, gbxDocument, xmlBasePath, fsBasePath) {} + + public GearboxType Type + { + get { return GetElementValue(XMLNames.Gearbox_TransmissionType).ParseEnum<GearboxType>(); } + } + + + public KilogramSquareMeter Inertia + { + get { return GetDoubleElementValue(XMLNames.Gearbox_Inertia).SI<KilogramSquareMeter>(); } + } + + public Second TractionInterruption + { + get { return GetDoubleElementValue(XMLNames.Gearbox_TractionInterruption).SI<Second>(); } + } + + 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; + } + } + + 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); + if ( + ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry))) { + retVal.LossMap = ReadTableData(AttributeMappings.TransmissionLossmapMapping, + Helper.Query(gearPath, XMLNames.Gearbox_Gear_TorqueLossMap, XMLNames.Gearbox_Gear_TorqueLossMap_Entry)); + } else { + retVal.LossMap = ReadCSVResourceFile(Helper.Query(gearPath, XMLNames.Gearbox_Gear_TorqueLossMap)); + } + + if ( + ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon, + XMLNames.Gearbox_Gears_Gear_ShiftPolygon_Entry))) { + retVal.ShiftPolygon = ReadTableData(AttributeMappings.ShiftPolygonMapping, + Helper.Query(gearPath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon, XMLNames.Gearbox_Gears_Gear_ShiftPolygon_Entry)); + } + if ( + ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon, ExtCsvResourceTag))) { + retVal.ShiftPolygon = ReadCSVResourceFile(Helper.Query(gearPath, XMLNames.Gearbox_Gears_Gear_ShiftPolygon)); + } + + retVal.MaxTorque = ElementExists(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque)) + ? GetDoubleElementValue(Helper.Query(gearPath, XMLNames.Gearbox_Gears_MaxTorque)).SI<NewtonMeter>() + : null; + return retVal; + } + + public Second MinTimeBetweenGearshift + { + get { return InputData.XMLEngineeringJobData.MinTimeBetweenGearshift; } + } + + public double TorqueReserve + { + get { return InputData.XMLEngineeringJobData.TorqueReserve; } + } + + public MeterPerSecond StartSpeed + { + get { return InputData.XMLEngineeringJobData.StartSpeed; } + } + + public MeterPerSquareSecond StartAcceleration + { + get { return InputData.XMLEngineeringJobData.StartAcceleration; } + } + + public double StartTorqueReserve + { + get { return InputData.XMLEngineeringJobData.StartTorqueReserve; } + } + + + ITorqueConverterDeclarationInputData IGearboxDeclarationInputData.TorqueConverter + { + get { return TorqueConverter; } + } + + public ITorqueConverterEngineeringInputData TorqueConverter + { + get + { + return new XMLEngineeringTorqueConverterDataProvider(InputData, XMLDocument, + Helper.Query(XBasePath, "parent::*", XMLNames.Component_TorqueConverter, XMLNames.ComponentDataWrapper), FSBasePath); + } + } + + public Second DownshiftAfterUpshiftDelay + { + get { return InputData.XMLEngineeringJobData.DownshiftAfterUpshiftDelay; } + } + + public Second UpshiftAfterDownshiftDelay + { + get { return InputData.XMLEngineeringJobData.UpshiftAfterDownshiftDelay; } + } + + public MeterPerSquareSecond UpshiftMinAcceleration + { + get { return InputData.XMLEngineeringJobData.UpshiftMinAcceleration; } + } + + public Second PowershiftShiftTime + { + get { return InputData.XMLEngineeringJobData.PowershiftShiftTime; } + } + + } } \ 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 e7083336b72004a21083836fd9b776b7dd9193e8..ba7ed582a47aacd2806cb5b4ebd0d20f9c63bf2c 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringInputDataProvider.cs @@ -46,28 +46,30 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering { public readonly string FileName; - internal XPathDocument Document; + internal XmlDocument Document; protected internal XMLEngineeringJobInputDataProvider XMLEngineeringJobData; protected internal XMLEngineeringVehicleDataProvider VehicleData; protected internal XMLEngineeringDriverDataProvider XMLEngineeringDriverData; - public XmlReaderSettings Settings { get; private set; } + public bool VerifyXml { get; protected set; } public XMLEngineeringInputDataProvider(string filename, bool verifyXml) { + VerifyXml = verifyXml; FileName = filename; - ReadXMLDocument(File.OpenRead(filename), verifyXml); + ReadXMLDocument(File.OpenRead(filename)); - InitializeComponentDataProvider(verifyXml); + InitializeComponentDataProvider(); } public XMLEngineeringInputDataProvider(Stream inputData, bool verifyXml) { FileName = "."; - ReadXMLDocument(inputData, verifyXml); + VerifyXml = verifyXml; + ReadXMLDocument(inputData); var nav = Document.CreateNavigator(); var manager = new XmlNamespaceManager(nav.NameTable); @@ -82,43 +84,23 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering throw new VectoException("XML input data with file references can not be read via stream!"); } - InitializeComponentDataProvider(verifyXml); + InitializeComponentDataProvider(); } - private void ReadXMLDocument(Stream inputData, bool verifyXml) + private void ReadXMLDocument(Stream inputData) { - XmlReaderSettings settings = null; - if (verifyXml) { - settings = new XmlReaderSettings { - ValidationType = ValidationType.Schema, - ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | - //XmlSchemaValidationFlags.ProcessSchemaLocation | - XmlSchemaValidationFlags.ReportValidationWarnings - }; - settings.ValidationEventHandler += ValidationCallBack; - settings.Schemas.Add(GetXMLSchema("")); - } - try { - Document = new XPathDocument(XmlReader.Create(inputData, settings)); - } catch (XmlSchemaValidationException validationException) { - throw new VectoException("Validation of input data failed", validationException); + + var xmldoc = new XmlDocument(); + xmldoc.Load(inputData); + if (VerifyXml) { + new XMLValidator(xmldoc, null, ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType.EngineeringData); } + Document = xmldoc; } - private void InitializeComponentDataProvider(bool verifyXml) + private void InitializeComponentDataProvider() { - Settings = null; - if (verifyXml) { - Settings = new XmlReaderSettings { - ValidationType = ValidationType.Schema, - ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | - //XmlSchemaValidationFlags.ProcessSchemaLocation | - XmlSchemaValidationFlags.ReportValidationWarnings - }; - Settings.Schemas.Add(GetXMLSchema("")); - } - var helper = new XPathHelper(ExecutionMode.Engineering); XMLEngineeringJobData = new XMLEngineeringJobInputDataProvider(this, Document, helper.QueryAbs(helper.NSPrefix(XMLNames.VectoInputEngineering, Constants.XML.RootNSPrefix)), @@ -130,19 +112,19 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering XMLNames.ComponentDataWrapper), Path.GetDirectoryName(Path.GetFullPath(FileName))); return; } - ReadVehicle(Settings); + ReadVehicle(); XMLEngineeringDriverData = XMLEngineeringJobData.GetDriverData(); } - private static void ValidationCallBack(object sender, ValidationEventArgs args) + internal static void ValidationCallBack(XmlSeverityType severity, ValidationEvent evt) { - if (args.Severity == XmlSeverityType.Error) { - throw new VectoException("Validation error: {0}", args.Message); + if (severity == XmlSeverityType.Error) { + throw new VectoException("Validation error: {0}", evt.ValidationEventArgs.Message); } } - private void ReadVehicle(XmlReaderSettings settings) + private void ReadVehicle() { var helper = new XPathHelper(ExecutionMode.Engineering); @@ -166,9 +148,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering if (extVehicle != null) { try { var vehicleFile = extVehicle.GetAttribute(XMLNames.ExtResource_File_Attr, ""); - var vehicleDocument = new XPathDocument( - XmlReader.Create(Path.Combine(Path.GetDirectoryName(FileName) ?? "./", vehicleFile), - settings)); + 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); + } var vehicleCompPath = helper.QueryAbs( helper.NSPrefix("VectoComponentEngineering", Constants.XML.RootNSPrefix), diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringJobInputDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringJobInputDataProvider.cs index 324054616a2a41207b09eaf43bb792a195a8c119..553a5ff0569caa2d5f55010e87027deefb2befba 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringJobInputDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringJobInputDataProvider.cs @@ -48,7 +48,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering public class XMLEngineeringJobInputDataProvider : AbstractEngineeringXMLComponentDataProvider, IEngineeringJobInputData { public XMLEngineeringJobInputDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, - XPathDocument jobDocument, string xmlBasePath, string fsBasePath) + XmlDocument jobDocument, string xmlBasePath, string fsBasePath) : base(xmlEngineeringJobInputDataProvider, jobDocument, xmlBasePath, fsBasePath) {} @@ -62,11 +62,6 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering get { return InputData.VehicleInputData; } } - //IEngineEngineeringInputData EngineInputData - //{ - // get { return new XMLEngineeringEngineDataProvider(InputData, XMLDocument, Helper.Query(XBasePath, XMLNames.Component_Engine, XMLNames.ComponentDataWrapper) ,FSBasePath); } - //} - public IList<ICycleData> Cycles { get { diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringRetarderDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringRetarderDataProvider.cs index 082df62445e03740890803f62b4fec7fa265ea70..ccd8c51df2769187957bf25703f8a5587c2dc6df 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringRetarderDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringRetarderDataProvider.cs @@ -29,40 +29,40 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Xml.XPath; -using TUGraz.IVT.VectoXML; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Models; -using TUGraz.VectoCommon.Resources; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering -{ - public class XMLEngineeringRetarderDataProvider : AbstractEngineeringXMLComponentDataProvider, IRetarderInputData - { - public XMLEngineeringRetarderDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, - XPathDocument retarderDocument, string xmlBasePath, string fsBasePath) - : base(xmlEngineeringJobInputDataProvider, retarderDocument, xmlBasePath, fsBasePath) {} - - public RetarderType Type - { - get { return InputData.VehicleData.RetarderType; } - } - - public double Ratio - { - get { return InputData.VehicleData.RetarderRatio; } - } - - public TableData LossMap - { - get - { - if (ElementExists(Helper.Query(XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry))) { - return ReadTableData(AttributeMappings.RetarderLossmapMapping, - Helper.Query(XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry)); - } - return ReadCSVResourceFile(XMLNames.Retarder_RetarderLossMap); - } - } - } +using System.Xml; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Models; +using TUGraz.VectoCommon.Resources; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public class XMLEngineeringRetarderDataProvider : AbstractEngineeringXMLComponentDataProvider, IRetarderInputData + { + public XMLEngineeringRetarderDataProvider(XMLEngineeringInputDataProvider xmlEngineeringJobInputDataProvider, + XmlDocument retarderDocument, string xmlBasePath, string fsBasePath) + : base(xmlEngineeringJobInputDataProvider, retarderDocument, xmlBasePath, fsBasePath) {} + + public RetarderType Type + { + get { return InputData.VehicleData.RetarderType; } + } + + public double Ratio + { + get { return InputData.VehicleData.RetarderRatio; } + } + + public TableData LossMap + { + get + { + if (ElementExists(Helper.Query(XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry))) { + return ReadTableData(AttributeMappings.RetarderLossmapMapping, + Helper.Query(XMLNames.Retarder_RetarderLossMap, XMLNames.Retarder_RetarderLossMap_Entry)); + } + return ReadCSVResourceFile(XMLNames.Retarder_RetarderLossMap); + } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringTorqueConverterDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringTorqueConverterDataProvider.cs index dec48e55ba2d8bb076983f0b171e7eeb0c6d4bce..fa71b69239760e4302ec99af6c537774fb07ae06 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringTorqueConverterDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringTorqueConverterDataProvider.cs @@ -29,83 +29,83 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Xml.XPath; -using TUGraz.IVT.VectoXML; -using TUGraz.VectoCommon.InputData; -using TUGraz.VectoCommon.Resources; -using TUGraz.VectoCommon.Utils; - -namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering -{ - public class XMLEngineeringTorqueConverterDataProvider : AbstractEngineeringXMLComponentDataProvider, - ITorqueConverterEngineeringInputData - { - public XMLEngineeringTorqueConverterDataProvider(XMLEngineeringInputDataProvider jobInputData, - XPathDocument xmlDocument, - string xBasePath, string fsBasePath) - : base(jobInputData, xmlDocument, xBasePath, fsBasePath) {} - - public TableData TCData - { - get - { - if ( - ElementExists(Helper.Query(XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry))) { - return ReadTableData(AttributeMappings.TorqueConverterDataMapping, - Helper.Query(XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry)); - } - return ReadCSVResourceFile(XMLNames.TorqueConverter_Characteristics); - } - } - - public PerSecond ReferenceRPM - { - get { return GetDoubleElementValue(XMLNames.TorqueConverter_ReferenceRPM).RPMtoRad(); } - } - - public KilogramSquareMeter Inertia - { - get { return GetDoubleElementValue(XMLNames.TorqueConverter_Inertia).SI<KilogramSquareMeter>(); } - } - - - public TableData ShiftPolygon - { - get - { - if (ElementExists(Helper.Query(XMLNames.TorqueConverter_ShiftPolygon, XMLNames.TorqueConverter_ShiftPolygon_Entry))) { - return ReadTableData(AttributeMappings.ShiftPolygonMapping, - Helper.Query(XMLNames.TorqueConverter_ShiftPolygon, XMLNames.TorqueConverter_ShiftPolygon_Entry)); - } - if ( - ElementExists(Helper.Query(XMLNames.TorqueConverter_ShiftPolygon, ExtCsvResourceTag))) { - return ReadCSVResourceFile(XMLNames.TorqueConverter_ShiftPolygon); - } - return null; - } - } - - public PerSecond MaxInputSpeed - { - get - { - return ElementExists(Helper.Query("MaxInputSpeed")) - ? GetDoubleElementValue("MaxInputSpeed").RPMtoRad() - : 5000.RPMtoRad(); - } - } - - public MeterPerSquareSecond CLUpshiftMinAcceleration - { - get { return InputData.XMLEngineeringJobData.CLUpshiftMinAcceleration; } - } - - public MeterPerSquareSecond CCUpshiftMinAcceleration - { - get - { - return InputData.XMLEngineeringJobData.CCUpshiftMinAcceleration; - } - } - } +using System.Xml; +using TUGraz.IVT.VectoXML; +using TUGraz.VectoCommon.InputData; +using TUGraz.VectoCommon.Resources; +using TUGraz.VectoCommon.Utils; + +namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering +{ + public class XMLEngineeringTorqueConverterDataProvider : AbstractEngineeringXMLComponentDataProvider, + ITorqueConverterEngineeringInputData + { + public XMLEngineeringTorqueConverterDataProvider(XMLEngineeringInputDataProvider jobInputData, + XmlDocument xmlDocument, + string xBasePath, string fsBasePath) + : base(jobInputData, xmlDocument, xBasePath, fsBasePath) {} + + public TableData TCData + { + get + { + if ( + ElementExists(Helper.Query(XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry))) { + return ReadTableData(AttributeMappings.TorqueConverterDataMapping, + Helper.Query(XMLNames.TorqueConverter_Characteristics, XMLNames.TorqueConverter_Characteristics_Entry)); + } + return ReadCSVResourceFile(XMLNames.TorqueConverter_Characteristics); + } + } + + public PerSecond ReferenceRPM + { + get { return GetDoubleElementValue(XMLNames.TorqueConverter_ReferenceRPM).RPMtoRad(); } + } + + public KilogramSquareMeter Inertia + { + get { return GetDoubleElementValue(XMLNames.TorqueConverter_Inertia).SI<KilogramSquareMeter>(); } + } + + + public TableData ShiftPolygon + { + get + { + if (ElementExists(Helper.Query(XMLNames.TorqueConverter_ShiftPolygon, XMLNames.TorqueConverter_ShiftPolygon_Entry))) { + return ReadTableData(AttributeMappings.ShiftPolygonMapping, + Helper.Query(XMLNames.TorqueConverter_ShiftPolygon, XMLNames.TorqueConverter_ShiftPolygon_Entry)); + } + if ( + ElementExists(Helper.Query(XMLNames.TorqueConverter_ShiftPolygon, ExtCsvResourceTag))) { + return ReadCSVResourceFile(XMLNames.TorqueConverter_ShiftPolygon); + } + return null; + } + } + + public PerSecond MaxInputSpeed + { + get + { + return ElementExists(Helper.Query("MaxInputSpeed")) + ? GetDoubleElementValue("MaxInputSpeed").RPMtoRad() + : 5000.RPMtoRad(); + } + } + + public MeterPerSquareSecond CLUpshiftMinAcceleration + { + get { return InputData.XMLEngineeringJobData.CLUpshiftMinAcceleration; } + } + + public MeterPerSquareSecond CCUpshiftMinAcceleration + { + get + { + return InputData.XMLEngineeringJobData.CCUpshiftMinAcceleration; + } + } + } } \ No newline at end of file diff --git a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs index 8a3c606876260db20c7cd74086722becddd43983..287678bfd017a7ade7ae3346bd1b23d7b3b0373e 100644 --- a/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs +++ b/VectoCore/VectoCore/InputData/FileIO/XML/Engineering/XMLEngineeringVehicleDataProvider.cs @@ -44,6 +44,7 @@ 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.Engineering { @@ -55,18 +56,18 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering protected internal XMLEngineeringAxlegearDataProvider AxlegearData; public XMLEngineeringVehicleDataProvider(XMLEngineeringInputDataProvider jobProvider, - XPathDocument vehicleDocument, string xmlBasePath, string fsBasePath) + XmlDocument vehicleDocument, string xmlBasePath, string fsBasePath) : base(jobProvider, vehicleDocument, xmlBasePath, fsBasePath) { - AxlegearData = GetAxleGearInputData(jobProvider.Settings); + AxlegearData = GetAxleGearInputData(jobProvider.VerifyXml); AngledriveInputData = GetAngularGearInputData(); - EngineInputData = GetEngineInputData(jobProvider.Settings); - RetarderInputData = GetRetarderInputData(jobProvider.Settings); - XMLEngineeringAuxiliaryData = GetAuxiliaryData(jobProvider.Settings); - GearboxInputData = GetGearboxData(jobProvider.Settings); + EngineInputData = GetEngineInputData(jobProvider.VerifyXml); + RetarderInputData = GetRetarderInputData(jobProvider.VerifyXml); + XMLEngineeringAuxiliaryData = GetAuxiliaryData(jobProvider.VerifyXml); + GearboxInputData = GetGearboxData(jobProvider.VerifyXml); TorqueConverterInputData = GearboxInputData.TorqueConverter; PTOTransmissionInputData = GetPTOData(); - AirdragInputData = GetAirdragInputData(jobProvider.Settings); + AirdragInputData = GetAirdragInputData(jobProvider.VerifyXml); } public string GetVehicleID @@ -215,8 +216,8 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering Steered = steered != null && XmlConvert.ToBoolean(steered.Value), AxleWeightShare = weightShare == null ? 0 : weightShare.ValueAsDouble, Tyre = new TyreInputData() { - TyreTestLoad = tyreTestLoad == null ? null : tyreTestLoad.ValueAsDouble.SI<Newton>(), - RollResistanceCoefficient = rollResistance == null ? double.NaN : rollResistance.ValueAsDouble, + TyreTestLoad = tyreTestLoad == null ? null : tyreTestLoad.Value.ToDouble().SI<Newton>(), + RollResistanceCoefficient = rollResistance == null ? double.NaN : rollResistance.Value.ToDouble(), Dimension = dimension == null ? null : dimension.Value, Inertia = inertia == null ? null : inertia.ValueAsDouble.SI<KilogramSquareMeter>(), } @@ -291,25 +292,25 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering #region "FactoryMethods" - private IAirdragEngineeringInputData GetAirdragInputData(XmlReaderSettings settings) + private IAirdragEngineeringInputData GetAirdragInputData(bool verifyXml) { - return CreateComponentInput(XMLNames.Component_AirDrag, settings, + return CreateComponentInput(XMLNames.Component_AirDrag, verifyXml, (a, b, c, d) => new XMLEngineeringAirdragDataProvider(a, b, c, d)); } - private XMLEngineeringAxlegearDataProvider GetAxleGearInputData(XmlReaderSettings settings) + private XMLEngineeringAxlegearDataProvider GetAxleGearInputData(bool verifyXml) { - return CreateComponentInput(XMLNames.Component_Axlegear, settings, + return CreateComponentInput(XMLNames.Component_Axlegear, verifyXml, (a, b, c, d) => new XMLEngineeringAxlegearDataProvider(a, b, c, d)); } - private XMLEngineeringEngineDataProvider GetEngineInputData(XmlReaderSettings settings) + private XMLEngineeringEngineDataProvider GetEngineInputData(bool verifyXml) { - return CreateComponentInput(XMLNames.Component_Engine, settings, + return CreateComponentInput(XMLNames.Component_Engine, verifyXml, (a, b, c, d) => new XMLEngineeringEngineDataProvider(a, b, c, d)); } - private XMLEngineeringRetarderDataProvider GetRetarderInputData(XmlReaderSettings settings) + private XMLEngineeringRetarderDataProvider GetRetarderInputData(bool verifyXml) { if (!RetarderType.IsDedicatedComponent()) { return new XMLEngineeringRetarderDataProvider(InputData, XMLDocument, @@ -317,25 +318,25 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering FSBasePath); } - return CreateComponentInput(XMLNames.Component_Retarder, settings, + return CreateComponentInput(XMLNames.Component_Retarder, verifyXml, (a, b, c, d) => new XMLEngineeringRetarderDataProvider(a, b, c, d)); } - private XMLEngineeringGearboxDataProvider GetGearboxData(XmlReaderSettings settings) + private XMLEngineeringGearboxDataProvider GetGearboxData(bool verifyXml) { - return CreateComponentInput(XMLNames.Component_Gearbox, settings, + return CreateComponentInput(XMLNames.Component_Gearbox, verifyXml, (a, b, c, d) => new XMLEngineeringGearboxDataProvider(a, b, c, d)); } - private XMLEngineeringAuxiliaryDataProvider GetAuxiliaryData(XmlReaderSettings settings) + private XMLEngineeringAuxiliaryDataProvider GetAuxiliaryData(bool verifyXml) { - return CreateComponentInput(XMLNames.Component_Auxiliaries, settings, + return CreateComponentInput(XMLNames.Component_Auxiliaries, verifyXml, (a, b, c, d) => new XMLEngineeringAuxiliaryDataProvider(a, b, c, d)); } - private T CreateComponentInput<T>(string componentName, XmlReaderSettings settings, - Func<XMLEngineeringInputDataProvider, XPathDocument, string, string, T> creator) + private T CreateComponentInput<T>(string componentName, bool verifyXml, + Func<XMLEngineeringInputDataProvider, XmlDocument, string, string, T> creator) { if (ElementExists(Helper.Query(XMLNames.Vehicle_Components, componentName))) { return creator(InputData, XMLDocument, @@ -352,7 +353,12 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering if (componentNode != null) { try { var componentFile = componentNode.GetAttribute(XMLNames.ExtResource_File_Attr, ""); - var componentDocument = new XPathDocument(XmlReader.Create(Path.Combine(FSBasePath, componentFile), settings)); + var componentDocument = new XmlDocument(); + componentDocument.Load(XmlReader.Create(Path.Combine(FSBasePath, componentFile))); + if (verifyXml) { + new XMLValidator(componentDocument, null, XMLEngineeringInputDataProvider.ValidationCallBack).ValidateXML(XMLValidator.XmlDocumentType + .EngineeringData); + } return creator(InputData, componentDocument, Helper.QueryAbs(Helper.NSPrefix(XMLNames.VectoComponentEngineering, Constants.XML.RootNSPrefix), componentName, XMLNames.ComponentDataWrapper), diff --git a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs index f5066419c2287d25bd536ca81c17af65d4030b53..c5803432b4a36e04193e76f99a2b533b6a533ae1 100644 --- a/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs +++ b/VectoCore/VectoCore/InputData/Reader/DataObjectAdapter/DeclarationDataAdapter.cs @@ -119,7 +119,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter RollResistanceCoefficient = axleInput.Tyre.RollResistanceCoefficient, TyreTestLoad = axleInput.Tyre.TyreTestLoad, Inertia = DeclarationData.Wheels.Lookup(axleInput.Tyre.Dimension.RemoveWhitespace()).Inertia, - CertificationNumber = axleInput.Tyre.CertificationNumber + CertificationNumber = axleInput.Tyre.CertificationNumber, + DigestValueInput = axleInput.Tyre.DigestValue, }; axleData.Add(axle); } diff --git a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index 148899b410a44306dce012881ee9a697167342f1..ce9a92b600ffcaddf7c7b009f242f07389cea3e8 100644 --- a/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -134,7 +134,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl } var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data }; - var gearbox = new CycleGearbox(container, data); + var gearbox = new VTPGearbox(container, data); // VTPCycle --> AxleGear --> Clutch --> Engine <-- Aux var powertrain = new VTPCycle(container, data.Cycle, data.AxleGearData.AxleGear.Ratio, data.VehicleData, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs index ab488ae867df7ec8734cc941d4dfe200d29b01fa..e2175d10804d9711fcfbd89e6a01173c6a5e6175 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Clutch.cs @@ -48,6 +48,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private readonly PerSecond _idleSpeed; private readonly PerSecond _ratedSpeed; + private bool firstInitialize = true; + public IIdleController IdleController { get { return _idleController; } @@ -77,9 +79,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl engineSpeedIn = _idleSpeed; torqueIn = 0.SI<NewtonMeter>(); } else { - AddClutchLoss(outTorque, outAngularVelocity, true, out torqueIn, out engineSpeedIn); + AddClutchLoss(outTorque, outAngularVelocity, firstInitialize || DataBus.VehicleStopped, out torqueIn, out engineSpeedIn); } - PreviousState.SetState(torqueIn, outAngularVelocity, outTorque, outAngularVelocity); + PreviousState.SetState(torqueIn, engineSpeedIn, outTorque, outAngularVelocity); + //if (!firstInitialize) { + // PreviousState. + //} var retVal = NextComponent.Initialize(torqueIn, engineSpeedIn); retVal.ClutchPowerRequest = outTorque * outAngularVelocity; @@ -89,6 +94,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl public IResponse Request(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, bool dryRun = false) { + firstInitialize = false; var startClutch = DataBus.VehicleStopped || !PreviousState.ClutchLoss.IsEqual(0); if (!DataBus.ClutchClosed(absTime) && !dryRun) { Log.Debug("Invoking IdleController..."); diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 94f85088e9c18441cc1ec94697686a8cd043c9b2..032a25d0a6a5a49ef4d60bcead23aa470a5f13d4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -314,7 +314,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl : VectoMath.Min(DataBus.GetGearData(DataBus.Gear).MaxSpeed, ModelData.FullLoadCurves[0].N95hSpeed); } - public IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) + public virtual IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) { if (outAngularVelocity == null) { outAngularVelocity = EngineIdleSpeed; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs index a0294af47544181cf6622e07836ee207bb1e454d..e4d3288a6a7fcafde6f7f148e5bfb7f0eb438b0d 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/CycleGearbox.cs @@ -81,7 +81,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var dt = Constants.SimulationSettings.TargetTimeInterval; - Gear = DataBus.CycleData.LeftSample.Gear; + Gear = GetGearFromCycle(); TorqueConverterActive = DataBus.CycleData.LeftSample.TorqueConverterActive; if (TorqueConverter != null && TorqueConverterActive == null) { @@ -158,7 +158,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return retVal; } - private uint GetGearFromCycle() + protected virtual uint GetGearFromCycle() { return DataBus.DriverBehavior == DrivingBehavior.Braking ? DataBus.CycleData.LeftSample.Gear @@ -362,10 +362,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var avgInAngularSpeed = (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0; var avgOutAngularSpeed = (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; + var inPower = CurrentState.InTorque * avgInAngularSpeed; + var outPower = CurrentState.OutTorque * avgOutAngularSpeed; container[ModalResultField.Gear] = Disengaged != null ? 0 : Gear; - container[ModalResultField.P_gbx_loss] = CurrentState.TransmissionTorqueLoss * avgOutAngularSpeed; + container[ModalResultField.P_gbx_loss] = inPower - outPower; container[ModalResultField.P_gbx_inertia] = CurrentState.InertiaTorqueLossOut * avgOutAngularSpeed; - container[ModalResultField.P_gbx_in] = CurrentState.InTorque * avgInAngularSpeed; + container[ModalResultField.P_gbx_in] = inPower; container[ModalResultField.n_gbx_out_avg] = (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; container[ModalResultField.T_gbx_out] = CurrentState.OutTorque; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs index b2ef8c304e8fb6c60b14af01b8ee8300cc982c77..74f8018540815a815ac74c57e3c99ac3f0f56e83 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/DrivingCycleEnumerator.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System; using System.Collections.Generic; using TUGraz.VectoCore.Models.SimulationComponent.Data; @@ -39,11 +40,18 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl private int _currentCycleIndex; private readonly IDrivingCycleData _data; - public DrivingCycleEnumerator(IDrivingCycleData data) - { - _currentCycleIndex = 0; - _data = data; - LastEntry = false; + public DrivingCycleEnumerator(IDrivingCycleData data) + { + _currentCycleIndex = 0; + _data = data; + LastEntry = false; + } + + public DrivingCycleEnumerator Previous() + { + var retVal = new DrivingCycleEnumerator(_data); + retVal._currentCycleIndex = Math.Max(0, _currentCycleIndex - 1); + return retVal; } public DrivingCycleEnumerator Clone() diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 55bef61985f88a1599528efbb53e7ee8fdbac931..565fabc1c82ba402b22b4a101507dd30e46753e4 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -390,13 +390,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { var avgInAngularSpeed = (PreviousState.InAngularVelocity + CurrentState.InAngularVelocity) / 2.0; var avgOutAngularSpeed = (PreviousState.OutAngularVelocity + CurrentState.OutAngularVelocity) / 2.0; - // (PreviousState.OutAngularVelocity + - //CurrentState.OutAngularVelocity) / 2.0 * ModelData.Gears[Gear].Ratio; var inPower = CurrentState.InTorque * avgInAngularSpeed; var outPower = CurrentState.OutTorque * avgOutAngularSpeed; container[ModalResultField.Gear] = Disengaged || DataBus.VehicleStopped ? 0 : Gear; container[ModalResultField.P_gbx_loss] = inPower - outPower; - //CurrentState.TransmissionTorqueLoss * avgOutAngularSpeed; container[ModalResultField.P_gbx_inertia] = CurrentState.InertiaTorqueLossOut * avgOutAngularSpeed; container[ModalResultField.P_gbx_in] = inPower; container[ModalResultField.n_gbx_out_avg] = (PreviousState.OutAngularVelocity + diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index 17fd58fa9018e5ff64a3141adff58c6234ecf1bd..8ab87a9c102d883a436ec4923fe447674cf7320a 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -51,7 +51,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl StatefulProviderComponent<SimpleComponentState, ISimulationOutPort, ITnInPort, ITnOutPort>, IDrivingCycleInfo, ISimulationOutPort, ITnInProvider, ITnInPort { - protected readonly IDrivingCycleData Data; + internal readonly IDrivingCycleData Data; protected internal readonly DrivingCycleEnumerator CycleIterator; protected Second AbsTime { get; set; } @@ -134,6 +134,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl criterion: y => ((ResponseDryRun)y).DeltaFullLoad.Value()); response = NextComponent.Request(absTime, dt, torque, angularVelocity); CurrentState.InAngularVelocity = angularVelocity; + CurrentState.InTorque = torque; }) .Case<ResponseEngineSpeedTooHigh>(r => { angularVelocity = SearchAlgorithm.Search(angularVelocity, r.DeltaEngineSpeed, diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs index 2ad3c5a8b72dee75b4be2725d3d8f60c2243311b..2aa7ea01550d29c885f4a7db3a876878748e5fb7 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCombustionEngine.cs @@ -45,11 +45,39 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { public class VTPCombustionEngine : CombustionEngine { + private bool firstInit = true; + public VTPCombustionEngine(IVehicleContainer container, CombustionEngineData modelData, bool pt1Disabled = false) : base(container, modelData, pt1Disabled) { } + public override IResponse Initialize(NewtonMeter outTorque, PerSecond outAngularVelocity) + { + if (outAngularVelocity == null) { + outAngularVelocity = EngineIdleSpeed; + } + var auxDemand = EngineAux == null ? 0.SI<NewtonMeter>() : EngineAux.Initialize(outTorque, outAngularVelocity); + if (firstInit) { + PreviousState = new EngineState { + EngineSpeed = outAngularVelocity, + dt = 1.SI<Second>(), + InertiaTorqueLoss = 0.SI<NewtonMeter>(), + StationaryFullLoadTorque = ModelData.FullLoadCurves[DataBus.Gear].FullLoadStationaryTorque(outAngularVelocity), + FullDragTorque = ModelData.FullLoadCurves[DataBus.Gear].DragLoadStationaryTorque(outAngularVelocity), + EngineTorque = outTorque + auxDemand, + EnginePower = (outTorque + auxDemand) * outAngularVelocity, + }; + PreviousState.DynamicFullLoadTorque = PreviousState.StationaryFullLoadTorque; + } + return new ResponseSuccess { + Source = this, + EnginePowerRequest = PreviousState.EnginePower, + EngineSpeed = outAngularVelocity + }; + } + protected override IResponse DoHandleRequest(Second absTime, Second dt, NewtonMeter torqueReq, PerSecond angularVelocity, bool dryRun) { + firstInit = false; var powerDemand = angularVelocity * torqueReq; var avgEngineSpeed = GetEngineSpeed(angularVelocity); @@ -63,10 +91,13 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Formulas.InertiaPower(angularVelocity, PreviousState.EngineSpeed, ModelData.Inertia, dt) / avgEngineSpeed; + if (EngineAux != null) { + EngineAux.Initialize(0.SI<NewtonMeter>(), avgEngineSpeed); + } var auxTorqueDemand = EngineAux == null ? 0.SI<NewtonMeter>() : EngineAux.TorqueDemand(absTime, dt, torqueOut, - torqueOut + inertiaTorqueLoss, angularVelocity, dryRun); + torqueOut + inertiaTorqueLoss, avgEngineSpeed, dryRun); // compute the torque the engine has to provide. powertrain + aux + its own inertia var totalTorqueDemand = torqueOut + auxTorqueDemand + inertiaTorqueLoss; diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs index c556de1b25f04232b53adbe7cccd08ae9dc2fb7c..212b4689bdac5c8cf19056ce6c83a3df5a174701 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPCycle.cs @@ -143,14 +143,15 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var cardanSpeed = entry.WheelAngularVelocity * RunData.AxleGearData.AxleGear.Ratio * (RunData.AngledriveData?.Angledrive.Ratio ?? 1); - if (cardanSpeed.IsEqual(0.RPMtoRad(), 1.RPMtoRad())) { + if (cardanSpeed.IsEqual(0.RPMtoRad(), 1.RPMtoRad()) || entry.AngularVelocity.IsEqual(0.RPMtoRad(), 1.RPMtoRad())) { entry.Gear = 0; continue; } var ratio = (entry.EngineSpeed / cardanSpeed).Value(); var gear = gearRatios.Aggregate((x, y) => - Math.Abs(x.Value / ratio - 1) < Math.Abs(y.Value / ratio - 1) ? x : y).Key; - + Math.Abs(ratio/x.Value - 1) < Math.Abs(ratio/y.Value - 1) ? x : y).Key; + while (gear > 0 && cardanSpeed * gearRatios[gear] < RunData.EngineData.IdleSpeed) + gear--; //entry.Gear = entry.EngineSpeed < (RunData.EngineData.IdleSpeed + 50.RPMtoRad()) && entry.VehicleTargetSpeed < 5.KMPHtoMeterPerSecond() ? 0 : gear; if (stopped && gear <= StartGear) { @@ -166,27 +167,38 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } + public override IResponse Request(Second absTime, Second dt) + { + if (CycleIterator.LastEntry && CycleIterator.RightSample.Time == absTime) { + return new ResponseCycleFinished { Source = this }; + } + + // interval exceeded + if (CycleIterator.RightSample != null && (absTime + dt).IsGreater(CycleIterator.RightSample.Time)) { + return new ResponseFailTimeInterval { + AbsTime = absTime, + Source = this, + DeltaT = CycleIterator.RightSample.Time - absTime + }; + } + var tmp = NextComponent.Initialize(CycleIterator.LeftSample.Torque, CycleIterator.LeftSample.WheelAngularVelocity); + + return DoHandleRequest(absTime, dt, CycleIterator.LeftSample.WheelAngularVelocity); + } + public override bool VehicleStopped { get { - if (CycleIterator.LeftSample.Gear == 0) - return true; - if (CycleIterator.LeftSample.Gear != StartGear) - return false; - - var transmissionRatio = RunData.AxleGearData.AxleGear.Ratio * - (RunData.AngledriveData?.Angledrive.Ratio ?? 1.0); - return CycleIterator.LeftSample.WheelAngularVelocity * transmissionRatio * - RunData.GearboxData.Gears[CycleIterator.LeftSample.Gear].Ratio < DataBus.EngineIdleSpeed; - //return CycleIterator.LeftSample.VehicleTargetSpeed.IsEqual(0.KMPHtoMeterPerSecond(), - // 0.3.KMPHtoMeterPerSecond()); + return CycleIterator.Previous().LeftSample.VehicleTargetSpeed + .IsEqual(0.KMPHtoMeterPerSecond(), 0.3.KMPHtoMeterPerSecond()); } } protected override void DoWriteModalResults(IModalDataContainer container) { base.DoWriteModalResults(container); + container[ModalResultField.P_wheel_in] = CurrentState.InTorque * CurrentState.InAngularVelocity; container[ModalResultField.v_act] = CycleIterator.LeftSample.VehicleTargetSpeed; } } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPGearbox.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPGearbox.cs new file mode 100644 index 0000000000000000000000000000000000000000..c255a8b188c9e5727d54f407205907804753c5ce --- /dev/null +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/VTPGearbox.cs @@ -0,0 +1,21 @@ +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Models.Simulation; +using TUGraz.VectoCore.Models.Simulation.Data; + +namespace TUGraz.VectoCore.Models.SimulationComponent.Impl +{ + public class VTPGearbox : CycleGearbox + { + public VTPGearbox(IVehicleContainer container, VectoRunData runData) : base(container, runData) { } + + protected override uint GetGearFromCycle() + { + return DataBus.CycleData.LeftSample.Gear; + } + + public override bool ClutchClosed(Second absTime) + { + return DataBus.CycleData.LeftSample.Gear != 0; + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs index 43f16c5b77dce3f83871ed5e2d82ea74cdc20baf..897874f494e0cfff669b4227e2d9400c26cc34cf 100644 --- a/VectoCore/VectoCore/OutputData/IModalDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/IModalDataContainer.cs @@ -225,6 +225,16 @@ namespace TUGraz.VectoCore.OutputData return data.TimeIntegral<WattSecond>(ModalResultField.P_gbx_loss); } + public static WattSecond WorkWheels(this IModalDataContainer data) + { + return data.TimeIntegral<WattSecond>(ModalResultField.P_wheel_in); + } + + public static WattSecond WorkWheelsPos(this IModalDataContainer data) + { + return data.TimeIntegral<WattSecond>(ModalResultField.P_wheel_in, x => x > 0); + } + public static WattSecond WorkAxlegear(this IModalDataContainer data) { return data.TimeIntegral<WattSecond>(ModalResultField.P_axle_loss); @@ -306,7 +316,7 @@ namespace TUGraz.VectoCore.OutputData public static Watt PowerWheelPositive(this IModalDataContainer data) { - return data.TimeIntegral<WattSecond>(ModalResultField.P_wheel_in, x => x > 0) / data.Duration(); + return data.WorkWheelsPos() / data.Duration(); } public static KilogramPerMeter FuelConsumptionWHTC(this IModalDataContainer data) @@ -394,9 +404,14 @@ namespace TUGraz.VectoCore.OutputData return data.TimeIntegral<Kilogram>(ModalResultField.FCFinal) * data.FuelData.LowerHeatingValue / distance; } + public static Kilogram TotalFuelConsumption(this IModalDataContainer data) + { + return data.TimeIntegral<Kilogram>(ModalResultField.FCMap); + } + public static KilogramPerSecond FCMapPerSecond(this IModalDataContainer data) { - return data.TimeIntegral<Kilogram>(ModalResultField.FCMap) / data.Duration(); + return data.TotalFuelConsumption() / data.Duration(); } public static KilogramPerMeter FCMapPerMeter(this IModalDataContainer data) @@ -405,7 +420,7 @@ namespace TUGraz.VectoCore.OutputData if (distance == null || distance.IsEqual(0)) { return null; } - return data.TimeIntegral<Kilogram>(ModalResultField.FCMap) / distance; + return data.TotalFuelConsumption() / distance; } diff --git a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs index bff31b09126e7a747289744894f02b9eb48de98b..4786be4b9dcf0e2f9d76c465c0d827337fcb5094 100644 --- a/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs +++ b/VectoCore/VectoCore/OutputData/SummaryDataContainer.cs @@ -149,6 +149,7 @@ namespace TUGraz.VectoCore.OutputData public const string E_GRAD = "E_grad [kWh]"; public const string E_VEHICLE_INERTIA = "E_vehi_inertia [kWh]"; public const string E_POWERTRAIN_INERTIA = "E_powertrain_inertia [kWh]"; + public const string E_WHEEL = "E_wheel [kWh]"; public const string E_BRAKE = "E_brake [kWh]"; public const string E_GBX_LOSS = "E_gbx_loss [kWh]"; public const string E_SHIFT_LOSS = "E_shift_loss [kWh]"; @@ -160,6 +161,8 @@ namespace TUGraz.VectoCore.OutputData public const string E_FCMAP_POS = "E_fcmap_pos [kWh]"; public const string E_FCMAP_NEG = "E_fcmap_neg [kWh]"; + public const string SPECIFIC_FC = "Specific FC [g/kWh] wheel pos."; + public const string ACC = "a [m/s^2]"; public const string ACC_POS = "a_pos [m/s^2]"; public const string ACC_NEG = "a_neg [m/s^2]"; @@ -190,17 +193,17 @@ namespace TUGraz.VectoCore.OutputData internal readonly DataTable Table; private readonly ISummaryWriter _sumWriter; - protected SummaryDataContainer() {} /// <summary> /// Initializes a new instance of the <see cref="SummaryDataContainer"/> class. /// </summary> /// <param name="writer"></param> + public SummaryDataContainer(ISummaryWriter writer) { _sumWriter = writer; - + Table = new DataTable(); Table.Columns.AddRange(new[] { @@ -270,12 +273,12 @@ namespace TUGraz.VectoCore.OutputData FCWHTCC_H, FCWHTCC_KM, FCAAUX_H, FCAAUX_KM, FCFINAL_H, FCFINAL_KM, - FCFINAL_LITERPER100KM, FCFINAL_LITERPER100TKM, FCFINAL_LiterPer100M3KM, + FCFINAL_LITERPER100KM, FCFINAL_LITERPER100TKM, FCFINAL_LiterPer100M3KM,SPECIFIC_FC, CO2_KM, CO2_TKM, CO2_M3KM, P_WHEEL_POS, P_FCMAP_POS, E_FCMAP_POS, E_FCMAP_NEG, E_POWERTRAIN_INERTIA, E_AUX, E_CLUTCH_LOSS, E_TC_LOSS, E_SHIFT_LOSS, E_GBX_LOSS, - E_RET_LOSS, E_ANGLE_LOSS, E_AXL_LOSS, E_BRAKE, E_VEHICLE_INERTIA, E_AIR, E_ROLL, E_GRAD, + E_RET_LOSS, E_ANGLE_LOSS, E_AXL_LOSS, E_BRAKE, E_VEHICLE_INERTIA, E_WHEEL , E_AIR, E_ROLL, E_GRAD , ACC, ACC_POS, ACC_NEG, ACC_TIMESHARE, DEC_TIMESHARE, CRUISE_TIMESHARE, MAX_SPEED, MAX_ACCELERATION, MAX_DECELERATION, AVG_ENGINE_SPEED, MAX_ENGINE_SPEED, NUM_GEARSHIFTS, STOP_TIMESHARE, ENGINE_FULL_LOAD_TIME_SHARE, COASTING_TIME_SHARE, BRAKING_TIME_SHARE @@ -292,6 +295,12 @@ namespace TUGraz.VectoCore.OutputData var view = new DataView(Table, "", SORT, DataViewRowState.CurrentRows).ToTable(); var toRemove = view.Columns.Cast<DataColumn>().Where(column => column.ColumnName.StartsWith(INTERNAL_PREFIX)).ToList(); + foreach (var colName in new[] { E_WHEEL, SPECIFIC_FC }) { + var column = view.Columns[colName]; + if (view.AsEnumerable().All(dr => dr.IsNull(column))) { + toRemove.Add(column); + } + } foreach (var dataColumn in toRemove) { view.Columns.Remove(dataColumn); } @@ -342,7 +351,7 @@ namespace TUGraz.VectoCore.OutputData row[ALTITUDE_DELTA] = (ConvertedSI)modData.AltitudeDelta(); - WriteFuelconsumptionEntries(modData, row, vehicleLoading, cargoVolume); + WriteFuelconsumptionEntries(modData, row, vehicleLoading, cargoVolume, runData.Cycle.CycleType == CycleType.VTP); var kilogramPerMeter = modData.CO2PerMeter(); if (kilogramPerMeter != null) { @@ -361,7 +370,7 @@ namespace TUGraz.VectoCore.OutputData WriteAuxiliaries(modData, row); - WriteWorkEntries(modData, row); + WriteWorkEntries(modData, row, runData.Cycle.CycleType == CycleType.VTP); WritePerformanceEntries(modData, row); @@ -377,7 +386,7 @@ namespace TUGraz.VectoCore.OutputData } private static void WriteFuelconsumptionEntries(IModalDataContainer modData, DataRow row, Kilogram vehicleLoading, - CubicMeter cargoVolume) + CubicMeter cargoVolume, bool vtpCycle) { var tmp = modData.FCMapPerSecond(); row[FCMAP_H] = tmp.ConvertToGrammPerHour(); @@ -410,6 +419,10 @@ namespace TUGraz.VectoCore.OutputData if (cargoVolume > 0 && fcFinal != null) { row[FCFINAL_LiterPer100M3KM] = (fcFinal / cargoVolume).ConvertToLiterPerCubicMeter100KiloMeter(); } + + if (vtpCycle) { + row[SPECIFIC_FC] = (modData.TotalFuelConsumption() / modData.WorkWheelsPos()).ConvertToGramPerKiloWattHour(); + } } @@ -478,7 +491,7 @@ namespace TUGraz.VectoCore.OutputData } } - private static void WriteWorkEntries(IModalDataContainer modData, DataRow row) + private static void WriteWorkEntries(IModalDataContainer modData, DataRow row, bool vtpMode) { row[E_FCMAP_POS] = modData.TotalEngineWorkPositive().ConvertToKiloWattHour(); row[E_FCMAP_NEG] = (-modData.TotalEngineWorkNegative()).ConvertToKiloWattHour(); @@ -496,6 +509,9 @@ namespace TUGraz.VectoCore.OutputData row[E_AIR] = modData.WorkAirResistance().ConvertToKiloWattHour(); row[E_ROLL] = modData.WorkRollingResistance().ConvertToKiloWattHour(); row[E_GRAD] = modData.WorkRoadGradientResistance().ConvertToKiloWattHour(); + if (vtpMode) { + row[E_WHEEL] = modData.WorkWheels().ConvertToKiloWattHour(); + } } private void WriteFullPowertrain(VectoRunData runData, DataRow row) diff --git a/VectoCore/VectoCore/OutputData/XML/AbstractXMLWriter.cs b/VectoCore/VectoCore/OutputData/XML/AbstractXMLWriter.cs index 33dac0d7cb6bb4618099c556cdd43c03cc51f4ab..9334f831dece7b70c146fa08710d5f2248025a21 100644 --- a/VectoCore/VectoCore/OutputData/XML/AbstractXMLWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/AbstractXMLWriter.cs @@ -43,7 +43,8 @@ namespace TUGraz.IVT.VectoXML.Writer { //protected const string SchemaLocationBaseUrl = "http://markus.quaritsch.at/VECTO/"; public const string SchemaLocationBaseUrl = "https://webgate.ec.europa.eu/CITnet/svn/VECTO/trunk/Share/XML/XSD/"; - protected const string SchemaVersion = "1.0"; + + protected string SchemaVersion; // = "1.0"; protected XNamespace tns; protected XNamespace rootNamespace; diff --git a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs index c26fbfec89a6f42b65e16be2f533e83442f32909..3f47fff9c026cf6b4c3d1e5b0887c7a52d156410 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs @@ -50,6 +50,8 @@ namespace TUGraz.VectoCore.OutputData.XML { public class XMLCustomerReport { + public const string CURRENT_SCHEMA_VERSION = "0.4"; + protected readonly XElement VehiclePart; protected XElement InputDataIntegrity; @@ -63,7 +65,7 @@ namespace TUGraz.VectoCore.OutputData.XML public XMLCustomerReport() { di = "http://www.w3.org/2000/09/xmldsig#"; - tns = "urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.4"; + tns = "urn:tugraz:ivt:VectoAPI:CustomerOutput:v" + CURRENT_SCHEMA_VERSION; VehiclePart = new XElement(tns + XMLNames.Component_Vehicle); Results = new XElement(tns + "Results"); } @@ -82,7 +84,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XElement(tns + XMLNames.Vehicle_CurbMassChassis, modelData.VehicleData.CurbWeight.ToXMLFormat(0)), new XElement(tns + XMLNames.Report_Vehicle_EngineRatedPower, modelData.EngineData.RatedPowerDeclared.ToXMLFormat(0)), new XElement(tns + XMLNames.Report_Vehicle_EngineDisplacement, - modelData.EngineData.Displacement.ConvertToCubicCentiMeter().ToXMLFormat(0)), + modelData.EngineData.Displacement.ConvertToCubicCentiMeter().ToXMLFormat(0)), new XElement(tns + XMLNames.Engine_FuelType, modelData.EngineData.FuelType.ToXMLFormat()), new XElement(tns + XMLNames.Report_Vehicle_TransmissionCertificationMethod, modelData.GearboxData.CertificationMethod.ToXMLFormat()), @@ -164,12 +166,12 @@ namespace TUGraz.VectoCore.OutputData.XML var vehicle = new XElement(VehiclePart); vehicle.Add(InputDataIntegrity); retVal.Add(new XElement(tns + XMLNames.VectoCustomerReport, - new XAttribute("schemaVersion", "0.4"), + new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION), new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName), new XAttribute("xmlns", tns), new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}VectoOutputCustomer.xsd", tns, AbstractXMLWriter.SchemaLocationBaseUrl)), + string.Format("{0} {1}VectoOutputCustomer.{2}.xsd", tns, AbstractXMLWriter.SchemaLocationBaseUrl, CURRENT_SCHEMA_VERSION)), new XElement(tns + "Data", vehicle, new XElement(tns + "ResultDataSignature", resultSignature), diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs index 0c5c8112f8a52c061e6d737e1301b8e8bc0ae0f4..fd57f7e22e68e3a6086f40fd8d54a4dc38d7be6d 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationWriter.cs @@ -56,6 +56,7 @@ namespace TUGraz.VectoCore.OutputData.XML tns = "urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0"; rootNamespace = "urn:tugraz:ivt:VectoAPI:DeclarationInput:v1.0"; componentNamespace = "urn:tugraz:ivt:VectoAPI:DeclarationComponent:v1.0"; + SchemaVersion = "1.0"; } public XDocument GenerateVectoJob(IDeclarationInputDataProvider data) diff --git a/VectoCore/VectoCore/OutputData/XML/XMLEngineeringWriter.cs b/VectoCore/VectoCore/OutputData/XML/XMLEngineeringWriter.cs index 2bfb4dc48906f201af74774826db9255bd08f932..f4ae584bf3784dcde5fd8d67f55159d14575b478 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLEngineeringWriter.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLEngineeringWriter.cs @@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.OutputData.XML public XMLEngineeringWriter(string basePath, bool singleFile, string vendor) : base(basePath, vendor) { _singleFile = singleFile; - + SchemaVersion = "0.7"; tns = Constants.XML.VectoEngineeringDefinitionsNS; // "urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.6"; rootNamespace = Constants.XML.VectoEngineeringInputNS; // "urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.6"; _declarationNamespace = Constants.XML.VectoDeclarationDefinitionsNS; diff --git a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs index b6e27f794aacf35f62ad1ed17242804fe3c9713c..65cf2403e73f05e7da0ff5310bec03a57a990722 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs @@ -52,8 +52,10 @@ namespace TUGraz.VectoCore.OutputData.XML { public class XMLManufacturerReport { + public const string CURRENT_SCHEMA_VERSION = "0.4"; + protected XElement VehiclePart; - + protected XElement InputDataIntegrity; protected XElement Results; @@ -65,7 +67,7 @@ namespace TUGraz.VectoCore.OutputData.XML public XMLManufacturerReport() { di = "http://www.w3.org/2000/09/xmldsig#"; - tns = "urn:tugraz:ivt:VectoAPI:DeclarationOutput:v0.4"; + tns = "urn:tugraz:ivt:VectoAPI:DeclarationOutput:v" + CURRENT_SCHEMA_VERSION; VehiclePart = new XElement(tns + XMLNames.Component_Vehicle); Results = new XElement(tns + "Results"); } @@ -219,6 +221,7 @@ namespace TUGraz.VectoCore.OutputData.XML new XAttribute(XMLNames.AxleWheels_Axles_Axle_AxleNumber_Attr, i), new XElement(tns + XMLNames.Report_Tyre_TyreDimension, axle.WheelsDimension), new XElement(tns + XMLNames.Report_Tyre_TyreCertificationNumber, axle.CertificationNumber), + new XElement(tns+XMLNames.DI_Signature_Reference_DigestValue, axle.DigestValueInput), new XElement(tns + XMLNames.Report_Tyre_TyreRRCDeclared, axle.RollResistanceCoefficient.ToXMLFormat(4)), new XElement(tns + XMLNames.AxleWheels_Axles_Axle_TwinTyres, axle.TwinTyres)); } @@ -346,12 +349,12 @@ namespace TUGraz.VectoCore.OutputData.XML var vehicle = new XElement(VehiclePart); vehicle.Add(InputDataIntegrity); retVal.Add(new XElement(tns + XMLNames.VectoManufacturerReport, - new XAttribute("schemaVersion", "0.4"), + new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION), new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName), new XAttribute("xmlns", tns), new XAttribute(XNamespace.Xmlns + "di", di), new XAttribute(xsi + "schemaLocation", - string.Format("{0} {1}VectoOutputManufacturer.xsd", tns, AbstractXMLWriter.SchemaLocationBaseUrl)), + string.Format("{0} {1}VectoOutputManufacturer.{2}.xsd", tns, AbstractXMLWriter.SchemaLocationBaseUrl, CURRENT_SCHEMA_VERSION)), new XElement(tns + "Data", vehicle, results, diff --git a/VectoCore/VectoCore/Resources/XSD/VectoComponent.1.0.xsd b/VectoCore/VectoCore/Resources/XSD/VectoComponent.1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..b62069047069413f0953db5a11dfed979e3015cf --- /dev/null +++ b/VectoCore/VectoCore/Resources/XSD/VectoComponent.1.0.xsd @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- edited with XMLSpy v2016 rel. 2 (x64) (http://www.altova.com) by Helmut Eichlseder (TU Graz/Inst. f. VKM und THD) --> +<xs:schema xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vectoParam="urn:tugraz:ivt:VectoAPI:ParameterDocumentation" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" targetNamespace="urn:tugraz:ivt:VectoAPI:DeclarationComponent:v1.0" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:ParameterDocumentation ParameterDocumentation.xsd"> + <xs:import namespace="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" schemaLocation="VectoDeclarationDefinitions.1.0.xsd"/> + <xs:element name="VectoInputDeclaration"> + <xs:annotation> + <xs:documentation>Root Node Declaration Data</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:choice> + <xs:element name="Engine" type="vdecdef:EngineComponentDeclarationType"/> + <xs:element name="Gearbox" type="vdecdef:GearboxComponentDeclarationType"/> + <xs:element name="TorqueConverter" type="vdecdef:TorqueConverterComponentDeclarationType"/> + <xs:element name="Retarder" type="vdecdef:RetarderComponentDeclarationType"/> + <xs:element name="Axlegear" type="vdecdef:AxlegearComponentDeclarationType"/> + <xs:element name="Tyre" type="vdecdef:TyreDeclarationType"/> + <xs:element name="Auxiliaries" type="vdecdef:AuxiliariesComponentDeclarationType"/> + <xs:element name="Angledrive" type="vdecdef:AngledriveComponentDeclarationType"/> + <xs:element name="AirDrag" type="vdecdef:AirDragComponentDeclarationType"/> + </xs:choice> + <xs:attribute name="schemaVersion" use="required"> + <xs:simpleType> + <xs:restriction base="xs:decimal"> + <xs:minExclusive value="0"/> + <xs:fractionDigits value="1"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:complexType> + </xs:element> +</xs:schema> diff --git a/VectoCore/VectoCore/Resources/XSD/VectoEngineeringInput.0.7.xsd b/VectoCore/VectoCore/Resources/XSD/VectoEngineeringInput.0.7.xsd new file mode 100644 index 0000000000000000000000000000000000000000..9737f6812ba749f909518ac0be00bb2237039248 --- /dev/null +++ b/VectoCore/VectoCore/Resources/XSD/VectoEngineeringInput.0.7.xsd @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- edited with XMLSpy v2016 rel. 2 (x64) (http://www.altova.com) by Helmut Eichlseder (TU Graz/Inst. f. VKM und THD) --> +<xs:schema xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vectoParam="urn:tugraz:ivt:VectoAPI:ParameterDocumentation" xmlns:vengdef="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" targetNamespace="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.7" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:ParameterDocumentation ParameterDocumentation.xsd"> + <xs:import namespace="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" schemaLocation="VectoEngineeringDefinitions.0.7.xsd"/> + <xs:element name="VectoComponentEngineering" type="vengdef:VectoComponentEngineeringType"> + <xs:annotation> + <xs:documentation>Root Node Engineering Component Data</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="VectoInputEngineering" type="vengdef:VectoJobEngineeringType"> + <xs:annotation> + <xs:documentation>Root Node Engineering Job</xs:documentation> + </xs:annotation> + </xs:element> +</xs:schema> diff --git a/VectoCore/VectoCore/Resources/XSD/VectoInput.1.0.xsd b/VectoCore/VectoCore/Resources/XSD/VectoInput.1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..bafee4d8c7c551e73eaa5b7ced639252a500f9a5 --- /dev/null +++ b/VectoCore/VectoCore/Resources/XSD/VectoInput.1.0.xsd @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- edited with XMLSpy v2016 rel. 2 (x64) (http://www.altova.com) by Helmut Eichlseder (TU Graz/Inst. f. VKM und THD) --> +<xs:schema xmlns:tns="urn:tugraz:ivt:VectoAPI:DeclarationInput:v1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vectoParam="urn:tugraz:ivt:VectoAPI:ParameterDocumentation" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" targetNamespace="urn:tugraz:ivt:VectoAPI:DeclarationInput:v1.0" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:ParameterDocumentation ParameterDocumentation.xsd"> + <xs:import namespace="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" schemaLocation="VectoDeclarationDefinitions.1.0.xsd"/> + <xs:element name="VectoInputDeclaration" type="vdecdef:VectoDeclarationJobType"> + <xs:annotation> + <xs:documentation>Root Node Declaration Data</xs:documentation> + </xs:annotation> + </xs:element> +</xs:schema> diff --git a/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.0.4.xsd b/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.0.4.xsd new file mode 100644 index 0000000000000000000000000000000000000000..79393a75b6829cf913625c1964d90837b8d62828 --- /dev/null +++ b/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.0.4.xsd @@ -0,0 +1,258 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- edited with XMLSpy v2016 rel. 2 (x64) (http://www.altova.com) by Helmut Eichlseder (TU Graz/Inst. f. VKM und THD) --> +<!--W3C XML Schema generated by XMLSpy vXMLSpy Professional Edition v2016 rel. 2 (x64) (http://www.altova.com)--> +<xs:schema xmlns="urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.4" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" targetNamespace="urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.4" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.4"> + <xs:import namespace="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" schemaLocation="VectoDeclarationDefinitions.1.0.xsd"/> + <xs:element name="VectoCustomerInformation"> + <xs:annotation> + <xs:documentation>Comment describing your root element</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:sequence> + <xs:element name="Data"> + <xs:complexType> + <xs:complexContent> + <xs:extension base="VectoOutputDataType"/> + </xs:complexContent> + </xs:complexType> + </xs:element> + <xs:element name="Signature" type="vdecdef:SignatureType"/> + </xs:sequence> + <xs:attribute name="schemaVersion" type="xs:decimal" use="required"/> + </xs:complexType> + </xs:element> + <xs:complexType name="CO2Type"> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="CO2UnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <xs:complexType name="FuelConsumptionType"> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="FuelConsumptionUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <xs:complexType name="ResultType"> + <xs:sequence> + <xs:element name="Mission" type="MissionTypeType"/> + <xs:choice> + <xs:sequence> + <xs:element name="Payload"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="MassUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="FuelType" type="vdecdef:FuelTypeType"/> + <xs:element name="AverageSpeed"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="SpeedUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="FuelConsumption" type="FuelConsumptionType" maxOccurs="unbounded"/> + <xs:element name="CO2" type="CO2Type" maxOccurs="unbounded"/> + </xs:sequence> + <xs:element name="Error"/> + </xs:choice> + </xs:sequence> + <xs:attribute name="status" use="required"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="success"/> + <xs:enumeration value="error"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:complexType> + <xs:complexType name="VectoOutputDataType"> + <xs:sequence> + <xs:element name="Vehicle" type="VehicleType"/> + <xs:element name="ResultDataSignature" type="vdecdef:SignatureType"/> + <xs:element name="Results"> + <xs:complexType> + <xs:sequence> + <xs:element name="Status"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="success"/> + <xs:enumeration value="error"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Result" type="ResultType" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="ApplicationInformation"> + <xs:complexType> + <xs:sequence> + <xs:element name="SimulationToolVersion"/> + <xs:element name="Date"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + <xs:attribute name="id" use="required"/> + </xs:complexType> + <xs:complexType name="VehiclePerformanceType"> + <xs:sequence/> + </xs:complexType> + <xs:complexType name="VehicleType"> + <xs:sequence> + <xs:element name="Model" type="vdecdef:ModelType"/> + <xs:element name="Manufacturer" type="vdecdef:ManufacturerType"/> + <xs:element name="ManufacturerAddress" type="vdecdef:ManufacturerAddressType"/> + <xs:element name="VIN"> + <xs:annotation> + <xs:documentation>P238</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="LegislativeClass" type="vdecdef:LegislativeClassDeclarationType"> + <xs:annotation> + <xs:documentation>P251</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="VehicleGroup" type="VehicleGroupType"> + <xs:annotation> + <xs:documentation>VECTO</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="AxleConfiguration" type="vdecdef:VehicleAxleConfigurationDeclarationType"> + <xs:annotation> + <xs:documentation>P037</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="GrossVehicleMass" type="vdecdef:VehicleGrossVehicleMassType"> + <xs:annotation> + <xs:documentation>P041</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="CurbMassChassis" type="vdecdef:VehicleCurbMassChassisType"> + <xs:annotation> + <xs:documentation>P038</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="EngineRatedPower" type="vdecdef:EngineRatedPower"> + <xs:annotation> + <xs:documentation>P250</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="EngineDisplacement" type="vdecdef:EngineDisplacementType"> + <xs:annotation> + <xs:documentation>P061</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="FuelType" type="vdecdef:FuelTypeType"> + <xs:annotation> + <xs:documentation>P193</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="TransmissionMainCertificationMethod" type="vdecdef:GearboxCertificationOptionType"> + <xs:annotation> + <xs:documentation>P154</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="TransmissionType" type="vdecdef:GearboxTransmissionTypeType"> + <xs:annotation> + <xs:documentation>P076</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="GearsCount"> + <xs:annotation> + <xs:documentation>P199</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:int"> + <xs:minInclusive value="1"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Retarder" type="xs:boolean"> + <xs:annotation> + <xs:documentation>P052</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="AxleRatio" type="vdecdef:AxlegearRatioType"> + <xs:annotation> + <xs:documentation>P150</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="AverageRRC" type="vdecdef:TyreRRCISOType"/> + <xs:element name="InputDataSignature" type="vdecdef:SignatureType"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="AccelerationUnitType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="m/s²"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="AirdragCertificationOptionType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="Measured"/> + <xs:enumeration value="Standard values"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="CO2UnitType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="g/km"/> + <xs:enumeration value="g/t-km"/> + <xs:enumeration value="g/p-km"/> + <xs:enumeration value="g/m³-km"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="DistanceUnitType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="km"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="FuelConsumptionUnitType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="g/km"/> + <xs:enumeration value="g/t-km"/> + <xs:enumeration value="g/p-km"/> + <xs:enumeration value="g/m³-km"/> + <xs:enumeration value="l/100km"/> + <xs:enumeration value="l/t-km"/> + <xs:enumeration value="l/p-km"/> + <xs:enumeration value="l/m³-km"/> + <xs:enumeration value="MJ/km"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="MassUnitType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="kg"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="MissionTypeType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="Long Haul EMS"/> + <xs:enumeration value="Long Haul"/> + <xs:enumeration value="Regional Delivery EMS"/> + <xs:enumeration value="Regional Delivery"/> + <xs:enumeration value="Urban Delivery"/> + <xs:enumeration value="Municipal Utility"/> + <xs:enumeration value="Construction"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="SpeedUnitType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="km/h"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="VehicleGroupType"> + <xs:restriction base="xs:int"> + <xs:minInclusive value="1"/> + <xs:maxInclusive value="16"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.xsd b/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.xsd index 79393a75b6829cf913625c1964d90837b8d62828..044e6c7007d04487bed31c427862ef558675e5e7 100644 --- a/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.xsd +++ b/VectoCore/VectoCore/Resources/XSD/VectoOutputCustomer.xsd @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- edited with XMLSpy v2016 rel. 2 (x64) (http://www.altova.com) by Helmut Eichlseder (TU Graz/Inst. f. VKM und THD) --> <!--W3C XML Schema generated by XMLSpy vXMLSpy Professional Edition v2016 rel. 2 (x64) (http://www.altova.com)--> -<xs:schema xmlns="urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.4" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" targetNamespace="urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.4" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.4"> +<xs:schema xmlns="urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.5" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" targetNamespace="urn:tugraz:ivt:VectoAPI:CustomerOutput:v0.5" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.5"> <xs:import namespace="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" schemaLocation="VectoDeclarationDefinitions.1.0.xsd"/> <xs:element name="VectoCustomerInformation"> <xs:annotation> diff --git a/VectoCore/VectoCore/Resources/XSD/VectoOutputManufacturer.0.4.xsd b/VectoCore/VectoCore/Resources/XSD/VectoOutputManufacturer.0.4.xsd new file mode 100644 index 0000000000000000000000000000000000000000..22abd15020cf4d935675ef3b7b2e2c517c6fcc47 --- /dev/null +++ b/VectoCore/VectoCore/Resources/XSD/VectoOutputManufacturer.0.4.xsd @@ -0,0 +1,541 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- edited with XMLSpy v2016 rel. 2 sp1 (x64) (http://www.altova.com) by Helmut Eichlseder (TU Graz/Inst. f. VKM und THD) --> +<!--W3C XML Schema generated by XMLSpy vXMLSpy Professional Edition v2016 rel. 2 (x64) (http://www.altova.com)--> +<xs:schema xmlns="urn:tugraz:ivt:VectoAPI:DeclarationOutput:v0.4" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" targetNamespace="urn:tugraz:ivt:VectoAPI:DeclarationOutput:v0.4" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.4"> + <xs:import namespace="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" schemaLocation="VectoDeclarationDefinitions.1.0.xsd"/> + <xs:element name="VectoOutput"> + <xs:annotation> + <xs:documentation>Comment describing your root element</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:sequence> + <xs:element name="Data"> + <xs:complexType> + <xs:complexContent> + <xs:extension base="VectoOutputDataType"/> + </xs:complexContent> + </xs:complexType> + </xs:element> + <xs:element name="Signature" type="vdecdef:SignatureType"/> + </xs:sequence> + <xs:attribute name="schemaVersion" type="xs:decimal" use="required"/> + </xs:complexType> + </xs:element> + <xs:complexType name="AirdragType"> + <xs:sequence> + <xs:element name="Model" minOccurs="0"/> + <xs:element name="CertificationMethod" type="AirdragCertificationOptionType"/> + <xs:element name="CertificationNumber" minOccurs="0"/> + <xs:element name="DigestValue" minOccurs="0"/> + <xs:element name="CdxA" type="vdecdef:AirdragCdxAType"> + <xs:annotation> + <xs:documentation>P245</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:complexType name="AngledriveType"> + <xs:sequence> + <xs:element name="Model" type="vdecdef:ModelType"/> + <xs:element name="CertificationMethod" type="vdecdef:AngledriveCertificationOptionType"> + <xs:annotation> + <xs:documentation>P258</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="CertificationNumber" type="vdecdef:CertificationNumberType" minOccurs="0"/> + <xs:element name="DigestValue" type="xs:token"/> + <xs:element name="Ratio" type="vdecdef:AngledriveRatioType"> + <xs:annotation> + <xs:documentation>P176</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:complexType name="AuxiliariesType"> + <xs:sequence> + <xs:element name="FanTechnology" type="vdecdef:AuxFanTechnologyType"> + <xs:annotation> + <xs:documentation>P181</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="SteeringPumpTechnology" maxOccurs="4"> + <xs:annotation> + <xs:documentation>P182</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="vdecdef:AuxSPTechnologyType"/> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="ElectricSystemTechnology" type="vdecdef:AuxESTechnologyType"> + <xs:annotation> + <xs:documentation>P183</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="PneumaticSystemTechnology" type="vdecdef:AuxPSTechnologyType"> + <xs:annotation> + <xs:documentation>P184</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="HVACTechnology" type="vdecdef:AuxHVACTechnologyType"> + <xs:annotation> + <xs:documentation>P185</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:complexType name="AxlegearType"> + <xs:sequence> + <xs:element name="Model" type="vdecdef:ModelType"/> + <xs:element name="CertificationMethod" type="vdecdef:AxlegearCertificationOptionType"> + <xs:annotation> + <xs:documentation>P256</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="CertificationNumber" type="vdecdef:CertificationNumberType" minOccurs="0"/> + <xs:element name="DigestValue" type="xs:token"/> + <xs:element name="LineType" type="vdecdef:AxlegearLineTypeType"> + <xs:annotation> + <xs:documentation>P253</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="Ratio" type="vdecdef:AxlegearRatioType"> + <xs:annotation> + <xs:documentation>P150</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:complexType name="AxleType"> + <xs:sequence> + <xs:element name="TyreDimension" type="vdecdef:TyreDimensionType"> + <xs:annotation> + <xs:documentation>P108</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="TyreCertificationNumber" type="vdecdef:CertificationNumberType"> + <xs:annotation> + <xs:documentation>P267</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="DigestValue" type="xs:token"/> + <xs:element name="TyreRRCDeclared" type="vdecdef:TyreRRCISOType"> + <xs:annotation> + <xs:documentation>P046</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="TwinTyres" type="vdecdef:AxleTwinTyresType"> + <xs:annotation> + <xs:documentation>P045</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + <xs:attribute name="axleNumber" use="required"/> + </xs:complexType> + <xs:complexType name="AxleWheelsType"> + <xs:sequence minOccurs="2" maxOccurs="4"> + <xs:element name="Axle" type="AxleType"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="CO2Type"> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="CO2UnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <xs:complexType name="ComponentDescriptionType"> + <xs:sequence> + <xs:element name="Model" type="vdecdef:ModelType"/> + <xs:element name="CertificationNumber" type="vdecdef:CertificationNumberType"/> + <xs:element name="DigestValue" type="xs:token"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="EngineType"> + <xs:complexContent> + <xs:extension base="ComponentDescriptionType"> + <xs:sequence> + <xs:element name="RatedPower" type="vdecdef:EngineRatedPower"> + <xs:annotation> + <xs:documentation>P250</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="IdlingSpeed" type="vdecdef:EngineDeclaredSpeedType"> + <xs:annotation> + <xs:documentation>P063 / P198</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="RatedSpeed" type="vdecdef:EngineDeclaredSpeedType"> + <xs:annotation> + <xs:documentation>P249</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="Displacement" type="vdecdef:EngineDisplacementType"> + <xs:annotation> + <xs:documentation>P061</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="FuelType" type="vdecdef:FuelTypeType"> + <xs:annotation> + <xs:documentation>P193</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + <xs:complexType name="FuelConsumptionType"> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="FuelConsumptionUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <xs:complexType name="GearboxType"> + <xs:sequence> + <xs:element name="Model" type="vdecdef:ModelType"/> + <xs:element name="CertificationMethod" type="vdecdef:GearboxCertificationOptionType"> + <xs:annotation> + <xs:documentation>P154</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="CertificationNumber" type="vdecdef:CertificationNumberType" minOccurs="0"/> + <xs:element name="DigestValue" type="xs:token"/> + <xs:element name="TransmissionType" type="vdecdef:GearboxTransmissionTypeType"> + <xs:annotation> + <xs:documentation>P076</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="GearsCount"> + <xs:annotation> + <xs:documentation>P199</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:int"> + <xs:minInclusive value="1"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="TransmissionRatioFinalGear" type="vdecdef:GearboxGearRatioType"> + <xs:annotation> + <xs:documentation>P078</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:complexType name="ResultType"> + <xs:sequence> + <xs:element name="Mission" type="MissionTypeType"/> + <xs:choice> + <xs:sequence> + <xs:element name="Distance"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="DistanceUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="SimulationParameters" type="SimulationParametersType"/> + <xs:element name="VehiclePerformance" type="VehiclePerformanceType"/> + <xs:element name="FuelConsumption" type="FuelConsumptionType" maxOccurs="unbounded"/> + <xs:element name="CO2" type="CO2Type" maxOccurs="unbounded"/> + </xs:sequence> + <xs:sequence> + <xs:element name="Error" type="xs:string"/> + <xs:element name="ErrorDetails" type="xs:string"/> + </xs:sequence> + </xs:choice> + </xs:sequence> + <xs:attribute name="status" use="required"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="success"/> + <xs:enumeration value="error"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + </xs:complexType> + <xs:complexType name="RetarderType"> + <xs:sequence> + <xs:element name="RetarderType" type="vdecdef:RetarderTypeType"> + <xs:annotation> + <xs:documentation>P052</xs:documentation> + </xs:annotation> + </xs:element> + <xs:sequence minOccurs="0"> + <xs:element name="Model" type="vdecdef:ModelType"/> + <xs:element name="CertificationMethod" type="vdecdef:RetarderCertificationOptionType"> + <xs:annotation> + <xs:documentation>P255</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="CertificationNumber" type="vdecdef:CertificationNumberType" minOccurs="0"/> + <xs:element name="DigestValue" type="xs:token"/> + </xs:sequence> + </xs:sequence> + </xs:complexType> + <xs:complexType name="SimulationParametersType"> + <xs:sequence> + <xs:element name="TotalVehicleMass"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="MassUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="Payload"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="MassUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="FuelType" type="vdecdef:FuelTypeType"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TorqueconverterType"> + <xs:sequence> + <xs:element name="Model" type="vdecdef:ModelType"/> + <xs:element name="CertificationMethod" type="vdecdef:TorqueConverterCertificationOptionType"> + <xs:annotation> + <xs:documentation>P257</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="CertificationNumber" type="vdecdef:CertificationNumberType" minOccurs="0"/> + <xs:element name="DigestValue" type="xs:token"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="TorqueLimitsEntryType"> + <xs:attribute name="gear" type="vdecdef:GearboxGearNumberType" use="required"> + <xs:annotation> + <xs:documentation>P196</xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="torqueLimit" type="vdecdef:TorqueLimitEntryMaxTorqueType" use="required"> + <xs:annotation> + <xs:documentation>P197 / P194</xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:complexType> + <xs:complexType name="TorqueLimitsType"> + <xs:sequence> + <xs:element name="Entry" type="TorqueLimitsEntryType"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="VectoOutputDataType"> + <xs:sequence> + <xs:element name="Vehicle" type="VehicleType"/> + <xs:element name="Results"> + <xs:complexType> + <xs:sequence> + <xs:element name="Status"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="success"/> + <xs:enumeration value="error"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="Result" type="ResultType" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="ApplicationInformation"> + <xs:complexType> + <xs:sequence> + <xs:element name="SimulationToolVersion"/> + <xs:element name="Date"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + <xs:attribute name="id" use="required"/> + </xs:complexType> + <xs:complexType name="VehiclePerformanceType"> + <xs:sequence> + <xs:element name="AverageSpeed"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="SpeedUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="MinSpeed"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="SpeedUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="MaxSpeed"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="SpeedUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="MaxDeceleration"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="AccelerationUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="MaxAcceleration"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:double"> + <xs:attribute name="unit" type="AccelerationUnitType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="FullLoadDrivingtimePercentage"> + <xs:simpleType> + <xs:restriction base="xs:double"> + <xs:minInclusive value="0"/> + <xs:maxInclusive value="100"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="GearshiftCount" type="xs:int"/> + </xs:sequence> + </xs:complexType> + <xs:complexType name="VehicleType"> + <xs:sequence> + <xs:element name="VIN"> + <xs:annotation> + <xs:documentation>P238</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="LegislativeClass" type="vdecdef:LegislativeClassDeclarationType"> + <xs:annotation> + <xs:documentation>P251</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="VehicleGroup" type="VehicleGroupType"> + <xs:annotation> + <xs:documentation>VECTO</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="AxleConfiguration" type="vdecdef:VehicleAxleConfigurationDeclarationType"> + <xs:annotation> + <xs:documentation>P037</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="GrossVehicleMass" type="vdecdef:VehicleGrossVehicleMassType"> + <xs:annotation> + <xs:documentation>P041</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="CurbMassChassis" type="vdecdef:VehicleCurbMassChassisType"> + <xs:annotation> + <xs:documentation>P038</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="PTO" type="xs:boolean"> + <xs:annotation> + <xs:documentation>P247</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="TorqueLimits" type="TorqueLimitsType" minOccurs="0"/> + <xs:element name="Components"> + <xs:complexType> + <xs:sequence> + <xs:element name="Engine" type="EngineType"/> + <xs:element name="Gearbox" type="GearboxType"/> + <xs:element name="Torqueconverter" type="TorqueconverterType" minOccurs="0"/> + <xs:element name="Retarder" type="RetarderType"/> + <xs:element name="Angledrive" type="AngledriveType" minOccurs="0"/> + <xs:element name="Axlegear" type="AxlegearType"/> + <xs:element name="AirDrag" type="AirdragType"/> + <xs:element name="AxleWheels" type="AxleWheelsType"/> + <xs:element name="Auxiliaries" type="AuxiliariesType"/> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="InputDataSignature" type="vdecdef:SignatureType"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="AccelerationUnitType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="m/s²"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="AirdragCertificationOptionType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="Measured"/> + <xs:enumeration value="Standard values"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="CO2UnitType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="g/km"/> + <xs:enumeration value="g/t-km"/> + <xs:enumeration value="g/p-km"/> + <xs:enumeration value="g/m³-km"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="DistanceUnitType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="km"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="FuelConsumptionUnitType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="g/km"/> + <xs:enumeration value="g/t-km"/> + <xs:enumeration value="g/p-km"/> + <xs:enumeration value="g/m³-km"/> + <xs:enumeration value="l/100km"/> + <xs:enumeration value="l/t-km"/> + <xs:enumeration value="l/p-km"/> + <xs:enumeration value="l/m³-km"/> + <xs:enumeration value="MJ/km"/> + <xs:enumeration value="MJ/t-km"/> + <xs:enumeration value="MJ/m³-km"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="MassUnitType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="kg"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="MissionTypeType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="Long Haul EMS"/> + <xs:enumeration value="Long Haul"/> + <xs:enumeration value="Regional Delivery EMS"/> + <xs:enumeration value="Regional Delivery"/> + <xs:enumeration value="Urban Delivery"/> + <xs:enumeration value="Municipal Utility"/> + <xs:enumeration value="Construction"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="SpeedUnitType"> + <xs:restriction base="xs:token"> + <xs:enumeration value="km/h"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="VehicleGroupType"> + <xs:restriction base="xs:int"> + <xs:minInclusive value="1"/> + <xs:maxInclusive value="16"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/VectoCore/VectoCore/Resources/XSD/VectoOutputManufacturer.xsd b/VectoCore/VectoCore/Resources/XSD/VectoOutputManufacturer.xsd index 2efd70f2fc1146a9ebf12e46faaf3220aa667a05..22abd15020cf4d935675ef3b7b2e2c517c6fcc47 100644 --- a/VectoCore/VectoCore/Resources/XSD/VectoOutputManufacturer.xsd +++ b/VectoCore/VectoCore/Resources/XSD/VectoOutputManufacturer.xsd @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- edited with XMLSpy v2016 rel. 2 (x64) (http://www.altova.com) by Helmut Eichlseder (TU Graz/Inst. f. VKM und THD) --> +<!-- edited with XMLSpy v2016 rel. 2 sp1 (x64) (http://www.altova.com) by Helmut Eichlseder (TU Graz/Inst. f. VKM und THD) --> <!--W3C XML Schema generated by XMLSpy vXMLSpy Professional Edition v2016 rel. 2 (x64) (http://www.altova.com)--> <xs:schema xmlns="urn:tugraz:ivt:VectoAPI:DeclarationOutput:v0.4" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" targetNamespace="urn:tugraz:ivt:VectoAPI:DeclarationOutput:v0.4" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.4"> <xs:import namespace="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v1.0" schemaLocation="VectoDeclarationDefinitions.1.0.xsd"/> @@ -119,6 +119,7 @@ <xs:documentation>P267</xs:documentation> </xs:annotation> </xs:element> + <xs:element name="DigestValue" type="xs:token"/> <xs:element name="TyreRRCDeclared" type="vdecdef:TyreRRCISOType"> <xs:annotation> <xs:documentation>P046</xs:documentation> diff --git a/VectoCore/VectoCore/Utils/XMLValidator.cs b/VectoCore/VectoCore/Utils/XMLValidator.cs new file mode 100644 index 0000000000000000000000000000000000000000..6685d58442405759cae3df16c565011f0c43cf4b --- /dev/null +++ b/VectoCore/VectoCore/Utils/XMLValidator.cs @@ -0,0 +1,153 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2017 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.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Xml; +using System.Xml.Schema; +using TUGraz.VectoCommon.Utils; + +namespace TUGraz.VectoCore.Utils +{ + public class XMLValidator + { + private readonly Action<XmlSeverityType, ValidationEvent> _validationErrorAction; + private readonly Action<bool> _resultAction; + 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"}) }, + { XmlDocumentType.CustomerReport , Tuple.Create("VectoOutputCustomer{0}.xsd", new [] {"0.4"})}, + }; + + private XMLValidator(Action<bool> resultaction, Action<XmlSeverityType, ValidationEvent> validationErrorAction) + { + _validationErrorAction = validationErrorAction ?? ((x, y) => { }); + _resultAction = resultaction ?? (x => { }); + _valid = false; + } + + public XMLValidator(XmlReader document, Action<bool> resultaction = null, Action<XmlSeverityType, ValidationEvent> validationErrorAction = null):this(resultaction,validationErrorAction) + { + _doc = new XmlDocument(); + _doc.Load(document); + } + + public XMLValidator(XmlDocument document, Action<bool> resultaction = null, Action<XmlSeverityType, ValidationEvent> validationErrorAction = null) : this(resultaction, validationErrorAction) + { + _doc = document; + } + + public bool ValidateXML(XmlDocumentType docType) + { + _valid = true; + //try { + if (_doc.DocumentElement == null) { + throw new Exception("empty XML document"); + } + var version = _doc.DocumentElement.GetAttribute("schemaVersion"); + _doc.Schemas = GetXMLSchema(docType, version); + _doc.Validate(ValidationCallBack); + //} catch (Exception e) { + // _valid = false; + // _validationErrorAction(XmlSeverityType.Error, new ValidationEvent() { + + // Exception = e + // }); + //} + return _valid; + } + + private void ValidationCallBack(object sender, ValidationEventArgs args) + { + _resultAction(false); + _valid = false; + _validationErrorAction(args.Severity, new ValidationEvent { ValidationEventArgs = args }); + } + + private static XmlSchemaSet GetXMLSchema(XmlDocumentType docType, string version) + { + var xset = new XmlSchemaSet() { XmlResolver = new XmlResourceResolver() }; + + foreach (var entry in EnumHelper.GetValues<XmlDocumentType>()) { + 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 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, + } + } + + public class ValidationEvent + { + public Exception Exception; + public ValidationEventArgs ValidationEventArgs; + } +} diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 858f6ac925714ee3bb24b1f643f165c7ed32f262..c34c5b71c3537df17a374a0591790da86e47a73f 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -188,6 +188,7 @@ <Compile Include="Models\SimulationComponent\Impl\PWheelCycle.cs" /> <Compile Include="Models\SimulationComponent\Impl\TorqueConverter.cs" /> <Compile Include="Models\SimulationComponent\Impl\IdleControllerSwitcher.cs" /> + <Compile Include="Models\SimulationComponent\Impl\VTPGearbox.cs" /> <Compile Include="Models\Simulation\Data\ModalResultField.cs" /> <Compile Include="InputData\Reader\Impl\EngineeringVTPModeVectoRunDataFactory.cs" /> <Compile Include="Models\SimulationComponent\Impl\VTPCycle.cs" /> @@ -339,6 +340,7 @@ <DependentUpon>VectoVersionCore.tt</DependentUpon> </Compile> <Compile Include="Utils\XmlResourceResolver.cs" /> + <Compile Include="Utils\XMLValidator.cs" /> <Compile Include="Utils\XPathHelper.cs" /> </ItemGroup> <ItemGroup> @@ -425,6 +427,21 @@ <EmbeddedResource Include="Resources\XSD\VectoOutputCustomer.xsd"> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoInput.1.0.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoOutputCustomer.0.4.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoOutputManufacturer.0.4.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoEngineeringInput.0.7.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="Resources\XSD\VectoComponent.1.0.xsd"> + <SubType>Designer</SubType> + </EmbeddedResource> <None Include="Utils\VectoVersionCore.tt"> <Generator>TextTemplatingFileGenerator</Generator> <LastGenOutput>VectoVersionCore.cs</LastGenOutput> diff --git a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs index ec9121a26a12ef3781b4a04459890b9ca008c35b..1826542ecd7ccbdcd62fd30fdb5738dc30628041 100644 --- a/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs +++ b/VectoCore/VectoCoreTest/Integration/SimulationRuns/FullPowertrain.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using TUGraz.VectoCommon.Models; using TUGraz.VectoCommon.Utils; @@ -67,6 +68,12 @@ namespace TUGraz.VectoCore.Tests.Integration.SimulationRuns //public const string GearboxFullLoadCurveFile = @"TestData\Components\Gearbox.vfld"; private static readonly LoggingObject Log = LogManager.GetLogger(typeof(FullPowerTrain).ToString()); + [OneTimeSetUp] + public void Init() + { + Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + } + [TestCase, Category("LongRunning")] public void Test_FullPowertrain_SimpleGearbox() { diff --git a/VectoCore/VectoCoreTest/Integration/XMLReportTest.cs b/VectoCore/VectoCoreTest/Integration/XMLReportTest.cs index 16efba12c17b746b63a5c7adcc7a269292417e5d..ebddab88bad7fc96d8ab90b3e5b8cb1516efb6b0 100644 --- a/VectoCore/VectoCoreTest/Integration/XMLReportTest.cs +++ b/VectoCore/VectoCoreTest/Integration/XMLReportTest.cs @@ -86,6 +86,13 @@ namespace TUGraz.VectoCore.Tests.Integration foreach (var axleDeclarationInputData in dataProvider.JobInputData.Vehicle.Axles) { Assert.AreEqual(axleDeclarationInputData.Tyre.CertificationNumber, reportWheels[i++].Value); } + + var digestWheels = manufacturerReport.XPathSelectElements("//*[local-name()='Axle']/*[local-name()='DigestValue']").ToArray(); + Assert.NotNull(digestWheels); + Assert.AreEqual(2, digestWheels.Count()); + foreach (var digestWheel in digestWheels) { + Assert.IsFalse(string.IsNullOrWhiteSpace(digestWheel.Value)); + } } } } diff --git a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs index 4336f8b271b557b8d2a189a1c1922d6c884270b8..9717eec19852867112ea8a7ad6388600a1266919 100644 --- a/VectoCore/VectoCoreTest/Reports/ModDataTest.cs +++ b/VectoCore/VectoCoreTest/Reports/ModDataTest.cs @@ -85,7 +85,7 @@ namespace TUGraz.VectoCore.Tests.Reports run.Run(); Assert.IsTrue(run.FinishedWithoutErrors); - AssertModDataIntegrity(modData, auxKeys, cycle.Entries.Last().Distance, engineData.ConsumptionMap); + AssertModDataIntegrity(modData, auxKeys, cycle.Entries.Last().Distance.Value(), engineData.ConsumptionMap, true); } [TestCase(@"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto")] @@ -113,6 +113,13 @@ namespace TUGraz.VectoCore.Tests.Reports RunSimulation(jobName, ExecutionMode.Engineering); } + + [TestCase(@"TestData\Integration\VTPMode\GenericVehicle\class_5_generic vehicle.vecto")] + public void TestVTPModeDataIntegrity(string jobName) + { + RunSimulation(jobName, ExecutionMode.Engineering); + } + private void AssertModDataFormat(string modFilename) { var lineCnt = 0; @@ -171,11 +178,17 @@ namespace TUGraz.VectoCore.Tests.Reports var runsFactory = new SimulatorFactory(mode, inputData, fileWriter) { WriteModalResults = true }; jobContainer.AddRuns(runsFactory); - var modData = new List<Tuple<ModalResults, Meter>>(); + var modData = new List<Tuple<ModalResults, double>>(); foreach (var run in jobContainer.Runs) { - modData.Add(Tuple.Create(((ModalDataContainer)run.Run.GetContainer().ModalData).Data, - ((DistanceBasedDrivingCycle)((VehicleContainer)run.Run.GetContainer()).DrivingCycle).Data.Entries.Last() - .Distance)); + var distanceCycle = ((VehicleContainer)run.Run.GetContainer()).DrivingCycle as DistanceBasedDrivingCycle; + if (distanceCycle != null) { + modData.Add(Tuple.Create(((ModalDataContainer)run.Run.GetContainer().ModalData).Data, + distanceCycle.Data.Entries.Last().Distance.Value())); + } + var cycle = ((VehicleContainer)run.Run.GetContainer()).DrivingCycle as PowertrainDrivingCycle; + if (cycle != null) + modData.Add(Tuple.Create(((ModalDataContainer)run.Run.GetContainer().ModalData).Data, + cycle.Data.Entries.Last().Time.Value())); } var auxKeys = new Dictionary<string, DataColumn>( @@ -188,15 +201,27 @@ namespace TUGraz.VectoCore.Tests.Reports //fileWriter.WriteModData(Path.GetFileName(jobName), "0", "0", modData[0].Item1); //fileWriter.WriteModData(Path.GetFileName(jobName), "1", "1", modData[1].Item1); + var engInput = inputData as IEngineeringInputDataProvider; + FuelConsumptionMap fcMap = null; + if (engInput != null) { + fcMap = FuelConsumptionMapReader.Create(engInput.JobInputData.Vehicle + .EngineInputData.FuelConsumptionMap); + } + var vtpInput = inputData as IVTPInputDataProvider; + if (vtpInput != null ) { + fcMap = FuelConsumptionMapReader.Create(vtpInput.JobInputData.Vehicle + .EngineInputData.FuelConsumptionMap); + } + var disatanceBased = + ((VehicleContainer)(jobContainer.Runs.First().Run.GetContainer())).DrivingCycle is DistanceBasedDrivingCycle; foreach (var modalResults in modData) { - AssertModDataIntegrity(modalResults.Item1, auxKeys, modalResults.Item2, - FuelConsumptionMapReader.Create(((IEngineeringInputDataProvider)inputData).JobInputData.Vehicle.EngineInputData.FuelConsumptionMap)); + AssertModDataIntegrity(modalResults.Item1, auxKeys, modalResults.Item2,fcMap, disatanceBased); } - AssertSumDataIntegrity(sumData, mode); + AssertSumDataIntegrity(sumData, mode, disatanceBased); } - private static void AssertSumDataIntegrity(SummaryDataContainer sumData, ExecutionMode mode) + private static void AssertSumDataIntegrity(SummaryDataContainer sumData, ExecutionMode mode, bool distanceBased) { Assert.IsTrue(sumData.Table.Rows.Count > 0); @@ -227,31 +252,40 @@ namespace TUGraz.VectoCore.Tests.Reports var eAxlLoss = ((ConvertedSI)row[SummaryDataContainer.E_AXL_LOSS]); var eBrakeLoss = ((ConvertedSI)row[SummaryDataContainer.E_BRAKE]); var eVehInertia = ((ConvertedSI)row[SummaryDataContainer.E_VEHICLE_INERTIA]); + var eWheel = !distanceBased ? ((ConvertedSI)row[SummaryDataContainer.E_WHEEL]) : null ; var eAir = ((ConvertedSI)row[SummaryDataContainer.E_AIR]); var eRoll = ((ConvertedSI)row[SummaryDataContainer.E_ROLL]); var eGrad = ((ConvertedSI)row[SummaryDataContainer.E_GRAD]); var cargoVolume = mode == ExecutionMode.Engineering ? 0.0 : ((ConvertedSI)row[SummaryDataContainer.CARGO_VOLUME]); var loadingValue = ((ConvertedSI)row[SummaryDataContainer.LOADING]) / 1000; - var fcPer100km = ((ConvertedSI)row[SummaryDataContainer.FCFINAL_LITERPER100KM]); + var fcPer100km = distanceBased ? ((ConvertedSI)row[SummaryDataContainer.FCFINAL_LITERPER100KM]) : null; var fcPerVolume = mode == ExecutionMode.Engineering ? 0.0 : ((ConvertedSI)row[SummaryDataContainer.FCFINAL_LiterPer100M3KM]); var fcPerLoad = loadingValue > 0 ? ((ConvertedSI)row[SummaryDataContainer.FCFINAL_LITERPER100TKM]) : 0.0; - var co2PerKm = ((ConvertedSI)row[SummaryDataContainer.CO2_KM]); + var co2PerKm = distanceBased? ((ConvertedSI)row[SummaryDataContainer.CO2_KM]) : null; var co2PerVolume = mode == ExecutionMode.Engineering ? 0.0 : ((ConvertedSI)row[SummaryDataContainer.CO2_M3KM]); var co2PerLoad = loadingValue > 0 ? ((ConvertedSI)row[SummaryDataContainer.CO2_TKM]) : 0.0; var ePTOtransm = ptoTransmissionColumn != null ? ((ConvertedSI)row[ptoTransmissionColumn]) : 0.0; var ePTOconsumer = ptoConsumerColumn != null ? ((ConvertedSI)row[ptoConsumerColumn]) : 0.0; - // E_fcmap_pos = E_fcmap_neg + E_powertrain_inertia + E_aux_xxx + E_aux_sum + E_clutch_loss + E_tc_loss + E_gbx_loss + E_shift_loss + E_ret_loss + E_angle_loss + E_axl_loss + E_brake + E_vehicle_inertia + E_air + E_roll + E_grad + E_PTO_CONSUM + E_PTO_TRANSM - Assert.AreEqual(eFcMapPos, - eFcMapNeg + ePowertrainInertia + eAux + eClutchLoss + eTcLoss + eGbxLoss + eRetLoss + eAngleLoss + - eAxlLoss + eBrakeLoss + eVehInertia + eAir + eRoll + eGrad + ePTOconsumer + ePTOtransm, 1e-5, - "input file: {0} cycle: {1} loading: {2}", - inputFile, cycle, loading); - + if (distanceBased) { + // E_fcmap_pos = E_fcmap_neg + E_powertrain_inertia + E_aux_xxx + E_aux_sum + E_clutch_loss + E_tc_loss + E_gbx_loss + E_shift_loss + E_ret_loss + E_angle_loss + E_axl_loss + E_brake + E_vehicle_inertia + E_air + E_roll + E_grad + E_PTO_CONSUM + E_PTO_TRANSM + Assert.AreEqual(eFcMapPos, + eFcMapNeg + ePowertrainInertia + eAux + eClutchLoss + eTcLoss + eGbxLoss + eRetLoss + eAngleLoss + + eAxlLoss + eBrakeLoss + eVehInertia + eAir + eRoll + eGrad + ePTOconsumer + ePTOtransm, 1e-5, + "input file: {0} cycle: {1} loading: {2}", + inputFile, cycle, loading); + } else { + // E_fcmap_pos = E_fcmap_neg + E_powertrain_inertia + E_aux_xxx + E_aux_sum + E_clutch_loss + E_tc_loss + E_gbx_loss + E_shift_loss + E_ret_loss + E_angle_loss + E_axl_loss + E_brake + E_vehicle_inertia + E_wheel + E_PTO_CONSUM + E_PTO_TRANSM + Assert.AreEqual(eFcMapPos, + eFcMapNeg + ePowertrainInertia + eAux + eClutchLoss + eTcLoss + eGbxLoss + eRetLoss + eAngleLoss + + eAxlLoss + eBrakeLoss + eVehInertia + eWheel + ePTOconsumer + ePTOtransm, 1e-5, + "input file: {0} cycle: {1} loading: {2}", + inputFile, cycle, loading); + } var pFcmapPos = ((ConvertedSI)row[SummaryDataContainer.P_FCMAP_POS]); var time = ((ConvertedSI)row[SummaryDataContainer.TIME]); @@ -259,7 +293,7 @@ namespace TUGraz.VectoCore.Tests.Reports Assert.AreEqual(eFcMapPos, pFcmapPos * (time / 3600), 1e-3, "input file: {0} cycle: {1} loading: {2}", inputFile, cycle, loading); - if (cargoVolume > 0) { + if (distanceBased && cargoVolume > 0) { Assert.AreEqual(fcPerVolume, fcPer100km / cargoVolume, 1e-3, "input file: {0} cycle: {1} loading: {2}", inputFile, cycle, loading); @@ -268,7 +302,7 @@ namespace TUGraz.VectoCore.Tests.Reports cycle, loading); } - if (loadingValue > 0) { + if (distanceBased && loadingValue > 0) { Assert.AreEqual(co2PerLoad, co2PerKm / loadingValue, 1e-3, "input file: {0} cycle: {1} loading: {2}", inputFile, cycle, loading); Assert.AreEqual(fcPerLoad, fcPer100km / loadingValue, 1e-3, "input file: {0} cycle: {1} loading: {2}", @@ -283,9 +317,10 @@ namespace TUGraz.VectoCore.Tests.Reports Assert.AreEqual(100, stopTimeShare + accTimeShare + decTimeShare + cruiseTimeShare, 1e-3, "input file: {0} cycle: {1} loading: {2}", inputFile, cycle, loading); - Assert.IsTrue(((ConvertedSI)row[SummaryDataContainer.ACC_POS]) > 0); - Assert.IsTrue(((ConvertedSI)row[SummaryDataContainer.ACC_NEG]) < 0); - + if (distanceBased) { + Assert.IsTrue(((ConvertedSI)row[SummaryDataContainer.ACC_POS]) > 0); + Assert.IsTrue(((ConvertedSI)row[SummaryDataContainer.ACC_NEG]) < 0); + } var gearshifts = ((ConvertedSI)row[SummaryDataContainer.NUM_GEARSHIFTS]); Assert.IsTrue(gearshifts > 0); @@ -294,7 +329,7 @@ namespace TUGraz.VectoCore.Tests.Reports } private static void AssertModDataIntegrity(ModalResults modData, Dictionary<string, DataColumn> auxKeys, - Meter totalDistance, FuelConsumptionMap consumptionMap) + double totalDistance, FuelConsumptionMap consumptionMap, bool distanceBased) { Assert.IsTrue(modData.Rows.Count > 0); @@ -305,20 +340,23 @@ namespace TUGraz.VectoCore.Tests.Reports ? auxKeys[Constants.Auxiliaries.IDs.PTOConsumer] : null; foreach (DataRow row in modData.Rows) { - if (totalDistance.IsEqual(((Meter)row[(int)ModalResultField.dist]))) { + if (distanceBased && totalDistance.IsEqual(((Meter)row[(int)ModalResultField.dist]).Value())) { continue; } var gear = (uint)row[(int)ModalResultField.Gear]; var time = (Second)row[(int)ModalResultField.time]; - var distance = (Meter)row[(int)ModalResultField.dist]; + Meter distance = 0.SI<Meter>(); + if (distanceBased) { + distance = (Meter)row[(int)ModalResultField.dist]; + } var tqEngFcmap = (NewtonMeter)row[(int)ModalResultField.T_eng_fcmap]; var nEngFcMap = (PerSecond)row[(int)ModalResultField.n_eng_avg]; // check fuel consumption interpolation var fuelConsumption = (SI)row[(int)ModalResultField.FCMap]; Assert.AreEqual(fuelConsumption.Value(), - consumptionMap.GetFuelConsumption(tqEngFcmap, nEngFcMap).Value.Value(), 1E-3, "time: {0} distance: {1}", + consumptionMap.GetFuelConsumption(tqEngFcmap, nEngFcMap,true).Value.Value(), 1E-3, "time: {0} distance: {1}", time, distance); // check P_eng_FCmap = T_eng_fcmap * n_eng @@ -327,11 +365,11 @@ namespace TUGraz.VectoCore.Tests.Reports distance); var pWheelIn = (Watt)row[(int)ModalResultField.P_wheel_in]; - var pAir = (Watt)row[(int)ModalResultField.P_air]; - var pRoll = (Watt)row[(int)ModalResultField.P_roll]; - var pGrad = (Watt)row[(int)ModalResultField.P_slope]; - var pVehInertia = (Watt)row[(int)ModalResultField.P_veh_inertia]; - var pTrac = (Watt)row[(int)ModalResultField.P_trac]; + var pAir = distanceBased ? (Watt)row[(int)ModalResultField.P_air] : 0.SI<Watt>(); + var pRoll = distanceBased ? (Watt)row[(int)ModalResultField.P_roll] : 0.SI<Watt>(); + var pGrad = distanceBased ? (Watt)row[(int)ModalResultField.P_slope] : 0.SI<Watt>(); + var pVehInertia = distanceBased ? (Watt)row[(int)ModalResultField.P_veh_inertia] : 0.SI<Watt>(); + var pTrac = distanceBased ? (Watt)row[(int)ModalResultField.P_trac] : pWheelIn; // P_eng_out = P_wheel + P_lossgearbox + P_lossaxle + P_lossretarder + P_agbx + Pa_eng + P_aux - P_brake_loss var pEngOut = (Watt)row[(int)ModalResultField.P_eng_out]; @@ -351,27 +389,32 @@ namespace TUGraz.VectoCore.Tests.Reports var pEngInertia = (Watt)row[(int)ModalResultField.P_eng_inertia]; var pAux = (Watt)(row[(int)ModalResultField.P_aux] != DBNull.Value ? row[(int)ModalResultField.P_aux] : 0.SI<Watt>()); - var pBrakeLoss = (Watt)row[(int)ModalResultField.P_brake_loss]; - var pBrakeIn = (Watt)row[(int)ModalResultField.P_brake_in]; + var pBrakeLoss = distanceBased ? (Watt)row[(int)ModalResultField.P_brake_loss] : 0.SI<Watt>(); + var pBrakeIn = distanceBased ? (Watt)row[(int)ModalResultField.P_brake_in] : pWheelIn; - var pWheelInertia = (Watt)row[(int)ModalResultField.P_wheel_inertia]; + var pWheelInertia = distanceBased ? (Watt)row[(int)ModalResultField.P_wheel_inertia] : 0.SI<Watt>(); var pPTOconsumer = ptoConsumerColumn == null || row[ptoConsumerColumn.ColumnName] is DBNull ? 0.SI<Watt>() : (Watt)row[ptoConsumerColumn.ColumnName]; var pPTOtransm = ptoTransmissionColumn == null || row[ptoTransmissionColumn.ColumnName] is DBNull ? 0.SI<Watt>() : (Watt)row[ptoTransmissionColumn.ColumnName]; - // P_trac = P_veh_inertia + P_roll + P_air + P_slope - Assert.AreEqual(pTrac.Value(), (pAir + pRoll + pGrad + pVehInertia).Value(), 1E-3, "time: {0} distance: {1}", time, - distance); - // P_wheel_in = P_trac + P_wheel_inertia - Assert.AreEqual(pWheelIn.Value(), (pTrac + pWheelInertia).Value(), 1E-3, "time: {0} distance: {1}", time, - distance); + if (distanceBased) { + // P_trac = P_veh_inertia + P_roll + P_air + P_slope + Assert.AreEqual(pTrac.Value(), (pAir + pRoll + pGrad + pVehInertia).Value(), 1E-3, "time: {0} distance: {1}", + time, + distance); + } + if (distanceBased) { + // P_wheel_in = P_trac + P_wheel_inertia + Assert.AreEqual(pWheelIn.Value(), (pTrac + pWheelInertia).Value(), 1E-3, "time: {0} distance: {1}", time, + distance); + } Assert.AreEqual(pBrakeIn.Value(), (pWheelIn + pBrakeLoss).Value(), 1E-3, "time: {0} distance: {1}", time, - distance); - + distance); + Assert.AreEqual(pAxleIn.Value(), (pBrakeIn + pLossAxle).Value(), 1E-3, "time: {0} distance: {1}", time, distance); Assert.AreEqual(pRetIn.Value(), (pAxleIn + pLossRet).Value(), 1E-3, "time: {0} distance: {1}", time, distance); @@ -410,8 +453,8 @@ namespace TUGraz.VectoCore.Tests.Reports "time: {0} distance: {1}", time, distance); // P_eng_fcmap = sum(Losses Powertrain) - var pLossTot = pClutchLoss + pTC_Loss + pLossGbx + pLossRet + pGbxInertia + pLossAngle + pLossAxle + pBrakeLoss + - pWheelInertia + pAir + pRoll + pGrad + pVehInertia + pPTOconsumer + pPTOtransm; + var pLossTot = pClutchLoss + pTC_Loss + pLossGbx + pLossRet + pGbxInertia + pLossAngle + pLossAxle + (distanceBased ? (pBrakeLoss + + pWheelInertia + pAir + pRoll + pGrad + pVehInertia) : pTrac) + pPTOconsumer + pPTOtransm; var pEngFcmapCalc = (pLossTot + pEngInertia + pAux).Value(); Assert.AreEqual(pEngFcmap.Value(), pEngFcmapCalc, 0.5, "time: {0} distance: {1}", time, distance); @@ -453,7 +496,7 @@ namespace TUGraz.VectoCore.Tests.Reports FuelConsumptionMapReader.Create(((IEngineeringInputDataProvider)inputData).JobInputData.Vehicle.EngineInputData.FuelConsumptionMap)); } - AssertSumDataIntegrity(sumData, ExecutionMode.Engineering); + AssertSumDataIntegrity(sumData, ExecutionMode.Engineering, true); } private static void AssertModDataIntegrityAT(ModalResults modData, Dictionary<string, DataColumn> auxKeys, diff --git a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/Class5_Tractor_4x2_TopTorque/Class5_Tractor_topTorque.vveh b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/Class5_Tractor_4x2_TopTorque/Class5_Tractor_topTorque.vveh index 9ba3943c0f399fd8c861462b17693997df9dcd3a..068a03771d65276caad20ceffcee2b81d4e44362 100644 --- a/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/Class5_Tractor_4x2_TopTorque/Class5_Tractor_topTorque.vveh +++ b/VectoCore/VectoCoreTest/TestData/Integration/DeclarationMode/Class5_Tractor_4x2_TopTorque/Class5_Tractor_topTorque.vveh @@ -42,7 +42,7 @@ "8": 1950, "9": 1950, "10": 1950, - "11": 1950, + "11": 1950 }, "AxleConfig": { "Type": "4x2", diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_axlegear-sample_ref.xml b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_axlegear-sample_ref.xml index 0bf25d250352fa1482ae97ae55578599a045a76d..0abb244641089e1ba447c72a7ebe784ca21b07c5 100644 --- a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_axlegear-sample_ref.xml +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_axlegear-sample_ref.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> +<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> <Axlegear> <Data id="AXL-EC3ohnoh"> <Manufacturer>Generic Gearbox Vendor</Manufacturer> diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_engine-sample_ref.xml b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_engine-sample_ref.xml index 6bf427cdf2dd1274b0254b5f6551679f632bb1d4..42959f54f43962ae2350db423796b0848098d7fe 100644 --- a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_engine-sample_ref.xml +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_engine-sample_ref.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> +<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> <Engine> <Data id="ENG-gooZah3D"> <Manufacturer>Generic Engine Vendor</Manufacturer> diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_gearbox-sample_ref.xml b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_gearbox-sample_ref.xml index 8f15d664a9abadde9766f545ad670be1635fb31d..219327ca0e50c446fdb3abd88b4a46156e1051cb 100644 --- a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_gearbox-sample_ref.xml +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_gearbox-sample_ref.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> +<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> <Gearbox> <Data id="gbx-vi2Oak2N"> <Manufacturer>Generic Gearbox Vendor</Manufacturer> diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-engine_only-sample_ref.xml b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-engine_only-sample_ref.xml index db948389875df5608e3c16a86e31a97eb2dc4e35..44644a3f72638e573f123e2efdad2ae2084d1369 100644 --- a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-engine_only-sample_ref.xml +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-engine_only-sample_ref.xml @@ -2,7 +2,7 @@ <tns:VectoInputEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" - xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.6" + xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> <EngineOnlyMode>false</EngineOnlyMode> diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample.xml b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample.xml index ceb0cf63ff4b2f9bc3186aff4e045a1680903482..d3c33d3f414f2d1a7ff4628da63157c8a4777b93 100644 --- a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample.xml +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoInputEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> +<tns:VectoInputEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> <EngineOnlyMode>false</EngineOnlyMode> <Vehicle id="VEH-1234567890"> <Manufacturer>Generic Truck Manufacturer</Manufacturer> diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample_FULL.xml b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample_FULL.xml index 7e6407b19de067f1b70b673a942c90c571e45296..79c860cf538ed653e9cf7443f7bd459019e4dd05 100644 --- a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample_FULL.xml +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample_FULL.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoInputEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.8" schemaVersion="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> +<tns:VectoInputEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.8" schemaVersion="0.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> <EngineOnlyMode>false</EngineOnlyMode> <Vehicle id="VEH-1234567890"> <Manufacturer>Generic Truck Manufacturer</Manufacturer> diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample_ref.xml b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample_ref.xml index bf13d0edd98ef2165a433d694afd832388e6f2bd..9d7de168f8566e398d6b7a619a7ffc45601169ce 100644 --- a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample_ref.xml +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_job-sample_ref.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoInputEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> +<tns:VectoInputEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> <EngineOnlyMode>false</EngineOnlyMode> <Resource type="xml" component="Vehicle" file="engineering_vehicle_ref.xml"/> <Signature> diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_retarder-sample_ref.xml b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_retarder-sample_ref.xml index c002b38bc22ea66d1e267478412aea91cd211e62..e3eb7f44fd0d4ba2e0c1d1fcb478e90c01d6b197 100644 --- a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_retarder-sample_ref.xml +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_retarder-sample_ref.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> +<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> <Retarder> <Data id="RET-Shai9imi"> <Manufacturer>Generic Retarder Vendor</Manufacturer> diff --git a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_vehicle_ref.xml b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_vehicle_ref.xml index b7453290a94d077bd1de78b720b69c985179c02e..6b9257ba1874c2ada0712d062ed2535865d6ba07 100644 --- a/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_vehicle_ref.xml +++ b/VectoCore/VectoCoreTest/TestData/XML/XMLReaderEngineering/engineering_vehicle_ref.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> +<tns:VectoComponentEngineering xmlns="urn:tugraz:ivt:VectoAPI:EngineeringDefinitions:v0.7" xmlns:tns="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7" xmlns:vdecdef="urn:tugraz:ivt:VectoAPI:DeclarationDefinitions:v0.6" schemaVersion="0.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:tugraz:ivt:VectoAPI:EngineeringInput:v0.7 ../XSD/VectoEngineeringInput.xsd"> <Vehicle id="VEH-1234567890"> <Manufacturer>Generic Truck Manufacturer</Manufacturer> <Model>Generic LongHaul Truck</Model> diff --git a/VectoCore/VectoCoreTest/Utils/AssertHelper.cs b/VectoCore/VectoCoreTest/Utils/AssertHelper.cs index e48b4d21a9d75041044350b7f14fa7d8873e5c37..ff45cf7277ab7d3c6c7d80d9c9e9ef046c49cef7 100644 --- a/VectoCore/VectoCoreTest/Utils/AssertHelper.cs +++ b/VectoCore/VectoCoreTest/Utils/AssertHelper.cs @@ -144,7 +144,7 @@ namespace TUGraz.VectoCore.Tests.Utils Assert.AreEqual(expectedVal, actualVal); } else if (propertyType == typeof(SI)) { Assert.AreEqual((expectedVal as SI).Value(), (actualVal as SI).Value()); - Assert.AreEqual((expectedVal as SI).GetUnitString(), (actualVal as SI).GetUnitString()); + Assert.AreEqual((expectedVal as SI).UnitString, (actualVal as SI).UnitString); } else if (expectedVal is IEnumerable<object>) { Assert.IsTrue(actualVal is IList); var expectedEnumerable = (expectedVal as IEnumerable<object>).ToArray(); diff --git a/VectoCore/VectoCoreTest/Utils/SITest.cs b/VectoCore/VectoCoreTest/Utils/SITest.cs index 5d384d4befbf0806074e172337d432214e15ec5f..0f33c29dde7675d1c3565dbd7abd0bc3bc5fb2e2 100644 --- a/VectoCore/VectoCoreTest/Utils/SITest.cs +++ b/VectoCore/VectoCoreTest/Utils/SITest.cs @@ -154,16 +154,18 @@ namespace TUGraz.VectoCore.Tests.Utils var v4 = 100.SI<Watt>(); var d = 700; + v1.ToString(); + Assert.IsTrue(v1 > v2); Assert.IsFalse(v1 < v2); AssertHelper.Exception<VectoException>(() => { var x = v1 < v4; }, - "Operator '<' can only operate on SI Objects with the same unit. Got: 600.0000 [kgm^2/s^2] < 100.0000 [kgm^2/s^3]"); + "Operator '<' can only operate on SI Objects with the same unit. Got: 600.0000 [Nm] < 100.0000 [W]"); AssertHelper.Exception<VectoException>(() => { var x = v1 > v4; }, - "Operator '>' can only operate on SI Objects with the same unit. Got: 600.0000 [kgm^2/s^2] > 100.0000 [kgm^2/s^3]"); + "Operator '>' can only operate on SI Objects with the same unit. Got: 600.0000 [Nm] > 100.0000 [W]"); AssertHelper.Exception<VectoException>(() => { var x = v1 <= v4; }, - "Operator '<=' can only operate on SI Objects with the same unit. Got: 600.0000 [kgm^2/s^2] <= 100.0000 [kgm^2/s^3]"); + "Operator '<=' can only operate on SI Objects with the same unit. Got: 600.0000 [Nm] <= 100.0000 [W]"); AssertHelper.Exception<VectoException>(() => { var x = v1 >= v4; }, - "Operator '>=' can only operate on SI Objects with the same unit. Got: 600.0000 [kgm^2/s^2] >= 100.0000 [kgm^2/s^3]"); + "Operator '>=' can only operate on SI Objects with the same unit. Got: 600.0000 [Nm] >= 100.0000 [W]"); SI si = null; Assert.IsFalse(si > 3); @@ -420,7 +422,7 @@ namespace TUGraz.VectoCore.Tests.Utils Assert.AreEqual("3.0000 [-]", 3.SI().ToOutputFormat(showUnit: true)); Assert.AreEqual("3.5000", 3.5.SI().ToOutputFormat()); Assert.AreEqual("3.5000", 3.5.SI<Newton>().ToOutputFormat()); - Assert.AreEqual("3.50 [kgm/s^2]", 3.5.SI<Newton>().ToOutputFormat(2, showUnit: true)); + Assert.AreEqual("3.50 [N]", 3.5.SI<Newton>().ToOutputFormat(2, showUnit: true)); Assert.AreEqual("18.00 [m/s]", 5.SI<MeterPerSecond>().ToOutputFormat(2, 3.6, true)); Assert.AreEqual("18.0000", 5.SI<MeterPerSecond>().ToOutputFormat(outputFactor: 3.6)); @@ -529,16 +531,16 @@ namespace TUGraz.VectoCore.Tests.Utils public void SI_NewTests() { UnitInstance sikg = Unit.SI.Kilo.Gramm; - Assert.AreEqual("kg", 1.SI().GetUnitString(sikg.GetSIUnits())); + Assert.AreEqual("kg", SI.GetUnitString(sikg.GetSIUnits())); UnitInstance ui1 = Unit.SI.Kilo.Gramm.Meter.Per.Square.Second; - Assert.AreEqual("kgm/s^2", 1.SI().GetUnitString(ui1.GetSIUnits())); + Assert.AreEqual("kgm/s^2", SI.GetUnitString(ui1.GetSIUnits())); UnitInstance ui3 = Unit.SI.Kilo.Gramm.Per.Watt.Second; - Assert.AreEqual("s^2/m^2", 1.SI().GetUnitString(ui3.GetSIUnits())); + Assert.AreEqual("s^2/m^2", SI.GetUnitString(ui3.GetSIUnits())); Assert.AreEqual(1, ui3.Factor); - var kg = 3000.SI(Unit.SI.Kilo.Gramm); + var kg = 3000.SI(Unit.SI.Kilo.Gramm).Cast<Kilogram>(); Assert.AreEqual("3000.0000 [kg]", kg.ToOutputFormat(showUnit: true)); var ton = 3.SI(Unit.SI.Ton); @@ -548,15 +550,15 @@ namespace TUGraz.VectoCore.Tests.Utils Assert.AreEqual("0.0070 [m^3]", val1.ToOutputFormat(showUnit: true)); var uni = Unit.SI.Cubic.Dezi.Meter; - Assert.AreEqual("m^3", 1.SI().GetUnitString(uni.GetSIUnits())); + Assert.AreEqual("m^3", SI.GetUnitString(uni.GetSIUnits())); AssertHelper.AreRelativeEqual(0.001, uni.Factor); var uni2 = Unit.SI.Cubic.Centi.Meter; - Assert.AreEqual("m^3", 1.SI().GetUnitString(uni2.GetSIUnits())); + Assert.AreEqual("m^3", SI.GetUnitString(uni2.GetSIUnits())); AssertHelper.AreRelativeEqual(0.000001, uni2.Factor); var uni1 = Unit.SI.Kilo.Meter.Per.Hour; - Assert.AreEqual("m/s", 1.SI().GetUnitString(uni1.GetSIUnits())); + Assert.AreEqual("m/s", SI.GetUnitString(uni1.GetSIUnits())); AssertHelper.AreRelativeEqual(0.2777777777, uni1.Factor); NewtonMeter newtonMeter = 5.SI<NewtonMeter>(); @@ -568,7 +570,7 @@ namespace TUGraz.VectoCore.Tests.Utils AssertHelper.AreRelativeEqual((6.0/3600).SI<Liter>(), (2.SI<Second>() * 3.SI(Unit.SI.Liter.Per.Hour)).Cast<Liter>()); AssertHelper.AreRelativeEqual(2.13093, 2.13093.SI(Unit.SI.Liter).Cast<Liter>().Value()); - Assert.AreEqual("m^3", 2.13093.SI(Unit.SI.Liter).GetUnitString()); + Assert.AreEqual("m^3", 2.13093.SI(Unit.SI.Liter).UnitString); } //[TestCase] diff --git a/VectoCore/VectoCoreTest/XML/XMLReportTest.cs b/VectoCore/VectoCoreTest/XML/XMLReportTest.cs index 3273e35fb43e6c8221a89b1a1ac61c9908f8d5bc..1c3e85a08d492b4595204d98c94a7deb54257af6 100644 --- a/VectoCore/VectoCoreTest/XML/XMLReportTest.cs +++ b/VectoCore/VectoCoreTest/XML/XMLReportTest.cs @@ -73,44 +73,11 @@ namespace TUGraz.VectoCore.Tests.XML var customerRecord = fileWriter.XMLCustomerReportName; var manufacturerRecord = fileWriter.XMLFullReportName; - Assert.IsTrue(DoValidation(XmlReader.Create(customerRecord))); - Assert.IsTrue(DoValidation(XmlReader.Create(manufacturerRecord))); - } - - private bool DoValidation(XmlReader hashedComponent) - { - var settings = new XmlReaderSettings { - ValidationType = ValidationType.Schema, - ValidationFlags = //XmlSchemaValidationFlags.ProcessInlineSchema | - //XmlSchemaValidationFlags.ProcessSchemaLocation | - XmlSchemaValidationFlags.ReportValidationWarnings - }; - //settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack); - settings.Schemas.Add(GetXMLSchema("")); - - var vreader = XmlReader.Create(hashedComponent, settings); - var doc = new XmlDocument(); - doc.Load(vreader); - doc.Validate(ValidationCallBack); - return true; - } - - private void ValidationCallBack(object sender, ValidationEventArgs args) - { - throw new Exception("Validation failed"); - } - - private static XmlSchemaSet GetXMLSchema(string version) - { - var xset = new XmlSchemaSet() { XmlResolver = new XmlResourceResolver() }; - foreach (var schema in new[] { "VectoComponent.xsd", "VectoInput.xsd", "VectoOutputManufacturer.xsd", "VectoOutputCustomer.xsd" }) { - var resource = RessourceHelper.LoadResourceAsStream(RessourceHelper.ResourceType.XMLSchema, schema); + var validator1 = new XMLValidator(XmlReader.Create(customerRecord)); + Assert.IsTrue(validator1.ValidateXML(XMLValidator.XmlDocumentType.CustomerReport)); - var reader = XmlReader.Create(resource, new XmlReaderSettings(), "schema://"); - xset.Add(XmlSchema.Read(reader, null)); - } - xset.Compile(); - return xset; + var validator2 = new XMLValidator(XmlReader.Create(manufacturerRecord)); + Assert.IsTrue(validator2.ValidateXML(XMLValidator.XmlDocumentType.ManufacturerReport)); } } } \ No newline at end of file