Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit fe031a7a authored by Franz KOBER josef's avatar Franz KOBER josef
Browse files

added hash calculation at multistage report

parent 9ceefa82
Branches
Tags
No related merge requests found
......@@ -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;
......
......@@ -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");
}
......
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,
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()),
GetInputdataSignature(multistageId));
GetApplicationInformation()));
var sigXElement = GetSignatureElement(stage);
stage.LastNode.Parent.Add(sigXElement);
return stage;
}
private int GetStageNumber()
......
......@@ -692,6 +692,7 @@ 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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment