diff --git a/VectoCommon/VectoCommon/Hashing/VectoComponents.cs b/VectoCommon/VectoCommon/Hashing/VectoComponents.cs index 35a31ccf3383a8df574e312cd846a63c280233f9..11c5729b957f4bf77ccb849ce480e173255c48cb 100644 --- a/VectoCommon/VectoCommon/Hashing/VectoComponents.cs +++ b/VectoCommon/VectoCommon/Hashing/VectoComponents.cs @@ -127,6 +127,7 @@ namespace TUGraz.VectoCommon.Hashing case VectoComponents.VectoCustomerInformation: case VectoComponents.VectoOutput: case VectoComponents.VectoPrimaryVehicleInformation: + case VectoComponents.VectoManufacturingStage: return true; default: return false; diff --git a/VectoCommon/VectoHashing/VectoHash.cs b/VectoCommon/VectoHashing/VectoHash.cs index 2a6a8d221870ebd03cc53589f0cf7b94d01e18a9..f4d9e03b24aeb0ffa36f6b7147ff51b851c1a5ff 100644 --- a/VectoCommon/VectoHashing/VectoHash.cs +++ b/VectoCommon/VectoHashing/VectoHash.cs @@ -305,6 +305,9 @@ namespace TUGraz.VectoHashing if (Document.DocumentElement.LocalName.Equals("VectoOutputPrimaryVehicle")) { return VectoComponents.VectoPrimaryVehicleInformation; } + if (Document.DocumentElement.LocalName.Equals(XMLNames.ManufacturingStage)) { + return VectoComponents.VectoManufacturingStage; + } throw new Exception("unknown document structure! neither input data nor output data format"); } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLMultistageBusReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLMultistageBusReport.cs index f56be26ea50bb31236162ebf5baf9a99661d3c4a..ce6de4a3804e55b595105358b2d5707265b7cc17 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLMultistageBusReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLMultistageBusReport.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; @@ -15,6 +16,7 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Utils; +using TUGraz.VectoHashing; namespace TUGraz.VectoCore.OutputData.XML @@ -161,20 +163,37 @@ namespace TUGraz.VectoCore.OutputData.XML #region Generate new manfuacturing Stage + private XElement GetSignatureElement(XElement stage) + { + var stream = new MemoryStream(); + var writer = new StreamWriter(stream); + writer.Write(stage); + writer.Flush(); + stream.Seek(0, SeekOrigin.Begin); + + return new XElement(tns + XMLNames.DI_Signature, + VectoHash.Load(stream).ComputeXmlHash + (VectoHash.DefaultCanonicalizationMethod, VectoHash.DefaultDigestMethod)); + } + + private XElement GenerateInputManufacturingStage() { var multistageId = $"{VectoComponents.VectoManufacturingStage.HashIdPrefix()}{GetGUID()}"; var vehicleId = $"{VectoComponents.Vehicle.HashIdPrefix()}{GetGUID()}"; - return new XElement(tns + XMLNames.ManufacturingStage, - new XAttribute("stageCount", GetStageNumber()), - new XElement(tns + XMLNames.Report_DataWrap, - new XAttribute(xsi + XMLNames.Attr_Type, "BusManufacturingStageDataType"), - new XAttribute(XMLNames.Component_ID_Attr, multistageId), - GetHashPreviousStageElement(), - GetVehicleElement(vehicleId), - GetApplicationInformation()), - GetInputdataSignature(multistageId)); + var stage = new XElement(tns + XMLNames.ManufacturingStage, + new XAttribute("stageCount", GetStageNumber()), + new XElement(tns + XMLNames.Report_DataWrap, + new XAttribute(xsi + XMLNames.Attr_Type, "BusManufacturingStageDataType"), + new XAttribute(XMLNames.Component_ID_Attr, multistageId), + GetHashPreviousStageElement(), + GetVehicleElement(vehicleId), + GetApplicationInformation())); + + var sigXElement = GetSignatureElement(stage); + stage.LastNode.Parent.Add(sigXElement); + return stage; } private int GetStageNumber() diff --git a/VectoCore/VectoCoreTest/Integration/Multistage/MultistageVehicleTest.cs b/VectoCore/VectoCoreTest/Integration/Multistage/MultistageVehicleTest.cs index ec837b65c65e031d025390bdbb22639938e6ed4e..305c2a461dbb4837cff635618cc1f2ac3c462323 100644 --- a/VectoCore/VectoCoreTest/Integration/Multistage/MultistageVehicleTest.cs +++ b/VectoCore/VectoCoreTest/Integration/Multistage/MultistageVehicleTest.cs @@ -691,7 +691,8 @@ namespace TUGraz.VectoCore.Tests.Integration.Multistage Assert.AreEqual(1, aux.SteeringPumpTechnology.Count); Assert.AreEqual("Variable displacement elec. controlled", aux.SteeringPumpTechnology[0]); - + + //ToDo SupplyFromHEVPossible to interface and reader? Assert.AreEqual(AlternatorType.Smart, aux.ElectricSupply.AlternatorTechnology); Assert.AreEqual(1, aux.ElectricSupply.Alternators.Count); @@ -713,7 +714,7 @@ namespace TUGraz.VectoCore.Tests.Integration.Multistage Assert.AreEqual(3.SI<Volt>(), capacitor.Voltage); Assert.AreEqual("Large Supply 2-stage", aux.PneumaticSupply.CompressorSize);//SizeOfAirSupply - Assert.AreEqual(CompressorDrive.mechanically, aux.PneumaticSupply.CompressorDrive); + Assert.AreEqual(CompressorDrive.electrically, aux.PneumaticSupply.CompressorDrive); Assert.AreEqual("none", aux.PneumaticSupply.Clutch); Assert.AreEqual(1.000, aux.PneumaticSupply.Ratio); Assert.AreEqual(false, aux.PneumaticSupply.SmartAirCompression);