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..8d280f73a9d8e4382d35dd4ef295d0326d66853e 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; @@ -160,7 +161,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 +171,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(); 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..b1dcad74f18fca55a3d0af8478d5bdba11a78dc6 100644 --- a/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs +++ b/HashingTool/ViewModel/UserControl/ManufacturerReportXMLFile.cs @@ -152,7 +152,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/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/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/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/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/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..e6cabff5b6376f20211488eaac59f0d60cef6a40 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"); } @@ -346,12 +348,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..2efd70f2fc1146a9ebf12e46faaf3220aa667a05 --- /dev/null +++ b/VectoCore/VectoCore/Resources/XSD/VectoOutputManufacturer.0.4.xsd @@ -0,0 +1,540 @@ +<?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: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="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/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 688a3f6ed0145886926bd51c7353e132d745c098..c34c5b71c3537df17a374a0591790da86e47a73f 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -340,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> @@ -426,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/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/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