Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 81b18a6f authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

updating writing customer report, manufacturer report, vtp report. consider FWD vehicles

parent 5a5774f1
No related branches found
No related tags found
No related merge requests found
......@@ -234,7 +234,7 @@ namespace TUGraz.VectoCore.OutputData.XML
protected virtual XElement GetADAS(VehicleData.ADASData adasData)
{
if (adasData.InputData.XMLSource == null) {
if (adasData.InputData.XMLSource == null || XMLHelper.GetVersion(adasData.InputData.XMLSource) < 2.0) {
return CreateADAS(adasData);
}
......
......@@ -59,8 +59,10 @@ namespace TUGraz.VectoCore.OutputData.XML
protected readonly XElement Results;
protected readonly XNamespace tns;
protected readonly XNamespace di;
protected readonly XNamespace rootNS = XNamespace.Get("urn:tugraz:ivt:VectoAPI:CustomerOutput");
protected readonly XNamespace tns = XNamespace.Get("urn:tugraz:ivt:VectoAPI:CustomerOutput:v" + CURRENT_SCHEMA_VERSION);
protected readonly XNamespace di = XNamespace.Get("http://www.w3.org/2000/09/xmldsig#");
protected readonly XNamespace xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");
private bool _allSuccess = true;
......@@ -71,8 +73,7 @@ namespace TUGraz.VectoCore.OutputData.XML
public XMLCustomerReport()
{
di = "http://www.w3.org/2000/09/xmldsig#";
tns = "urn:tugraz:ivt:VectoAPI:CustomerOutput:v" + CURRENT_SCHEMA_VERSION;
VehiclePart = new XElement(tns + XMLNames.Component_Vehicle);
Results = new XElement(tns + XMLNames.Report_Results);
}
......@@ -86,30 +87,38 @@ namespace TUGraz.VectoCore.OutputData.XML
new XElement(tns + XMLNames.Component_ManufacturerAddress, modelData.VehicleData.ManufacturerAddress),
new XElement(tns + XMLNames.Vehicle_VIN, modelData.VehicleData.VIN),
new XElement(tns + XMLNames.Vehicle_LegislativeClass, modelData.VehicleData.LegislativeClass.ToXMLFormat()),
new XElement(tns + XMLNames.Vehicle_GrossVehicleMass, XMLHelper.ValueAsUnit(modelData.VehicleData.GrossVehicleMass, XMLNames.Unit_t, 1)),
new XElement(tns + XMLNames.Vehicle_CurbMassChassis, XMLHelper.ValueAsUnit(modelData.VehicleData.CurbMass, XMLNames.Unit_kg)),
new XElement(
tns + XMLNames.Vehicle_GrossVehicleMass,
XMLHelper.ValueAsUnit(modelData.VehicleData.GrossVehicleMass, XMLNames.Unit_t, 1)),
new XElement(
tns + XMLNames.Vehicle_CurbMassChassis, XMLHelper.ValueAsUnit(modelData.VehicleData.CurbMass, XMLNames.Unit_kg)),
new XElement(tns + XMLNames.Vehicle_ZeroEmissionVehicle, modelData.VehicleData.ZeroEmissionVehicle),
new XElement(tns + XMLNames.Vehicle_HybridElectricHDV, modelData.VehicleData.HybridElectricHDV),
new XElement(tns + XMLNames.Vehicle_DualFuelVehicle, modelData.VehicleData.DualFuelVehicle),
new XElement(tns + XMLNames.Vehicle_DualFuelVehicle, modelData.VehicleData.DualFuelVehicle)
);
exempted ? ExemptedData(modelData) : new[] {
if (exempted) {
VehiclePart.Add(new XAttribute(xsi + "type", "ExemptedVehicleType"),
ExemptedData(modelData));
Results.Add(new XElement(tns + XMLNames.Report_ExemptedVehicle));
} else {
VehiclePart.Add(
new XAttribute(xsi + "type", "VehicleType"),
new XElement(tns + XMLNames.Vehicle_AxleConfiguration, modelData.VehicleData.AxleConfiguration.GetName()),
new XElement(tns + XMLNames.Report_Vehicle_VehicleGroup, modelData.VehicleData.VehicleClass.GetClassNumber()),
new XElement(tns + XMLNames.Vehicle_VocationalVehicle, modelData.VehicleData.VocationalVehicle),
new XElement(tns + XMLNames.Vehicle_SleeperCab, modelData.VehicleData.SleeperCab),
GetADAS(modelData.VehicleData.ADAS)
}.Concat(ComponentData(modelData, fuelModes))
);
if (exempted) {
Results.Add(new XElement(tns + XMLNames.Report_ExemptedVehicle));
GetADAS(modelData.VehicleData.ADAS),
ComponentData(modelData, fuelModes)
);
}
InputDataIntegrity = new XElement(tns + XMLNames.Report_InputDataSignature,
modelData.InputDataHash == null ? CreateDummySig() : new XElement(modelData.InputDataHash));
}
private XElement[] ExemptedData(VectoRunData modelData)
private object[] ExemptedData(VectoRunData modelData)
{
return new[] {
return new object[] {
modelData.VehicleData.HybridElectricHDV ? new XElement(tns + XMLNames.Vehicle_MaxNetPower1, XMLHelper.ValueAsUnit(modelData.VehicleData.MaxNetPower1, XMLNames.Unit_W)) : null,
modelData.VehicleData.HybridElectricHDV ? new XElement(tns + XMLNames.Vehicle_MaxNetPower2, XMLHelper.ValueAsUnit(modelData.VehicleData.MaxNetPower2, XMLNames.Unit_W)) : null
};
......@@ -222,7 +231,7 @@ namespace TUGraz.VectoCore.OutputData.XML
public void GenerateReport(XElement resultSignature)
{
var xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");
var retVal = new XDocument();
var results = new XElement(Results);
results.AddFirst(new XElement(tns + XMLNames.Report_Result_Status, _allSuccess ? "success" : "error"));
......@@ -242,14 +251,16 @@ namespace TUGraz.VectoCore.OutputData.XML
var vehicle = new XElement(VehiclePart);
vehicle.Add(InputDataIntegrity);
retVal.Add(new XProcessingInstruction("xml-stylesheet", "href=\"https://webgate.ec.europa.eu/CITnet/svn/VECTO/trunk/Share/XML/CSS/VectoReports.css\""));
retVal.Add(new XElement(tns + XMLNames.VectoCustomerReport,
new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION),
retVal.Add(new XElement(rootNS + XMLNames.VectoCustomerReport,
//new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION),
new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName),
new XAttribute("xmlns", tns),
new XAttribute(XNamespace.Xmlns + "tns", rootNS),
new XAttribute(XNamespace.Xmlns + "di", di),
new XAttribute(xsi + "schemaLocation",
string.Format("{0} {1}VectoOutputCustomer.{2}.xsd", tns, AbstractXMLWriter.SchemaLocationBaseUrl, CURRENT_SCHEMA_VERSION)),
new XElement(tns + XMLNames.Report_DataWrap,
string.Format("{0} {1}VectoOutputCustomer.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)),
new XElement(rootNS + XMLNames.Report_DataWrap,
new XAttribute(xsi + "type", "VectoOutputDataType"),
vehicle,
new XElement(tns + XMLNames.Report_ResultData_Signature, resultSignature),
results,
......
......@@ -59,7 +59,7 @@ namespace TUGraz.VectoCore.OutputData.XML
{
internal class XMLVTPReport : DeclarationReport<XMLVTPReport.ResultEntry>, IVTPReport
{
public const string CURRENT_SCHEMA_VERSION = "0.1";
public const string CURRENT_SCHEMA_VERSION = "0.2";
private const string VTPReportTartetName = "VTPReportTarget";
......@@ -70,7 +70,9 @@ namespace TUGraz.VectoCore.OutputData.XML
protected XElement ResultsPart;
protected XNamespace tns;
protected XNamespace xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");
protected XNamespace rootNS = "urn:tugraz:ivt:VectoAPI:VTPReport";
protected XNamespace tns = "urn:tugraz:ivt:VectoAPI:VTPReport:v" + CURRENT_SCHEMA_VERSION;
private static List<string> LogList = new List<string>();
private LoggingRule cycleChecksRule;
......@@ -118,7 +120,7 @@ namespace TUGraz.VectoCore.OutputData.XML
public XMLVTPReport(IReportWriter writer) : base(writer)
{
//di = "http://www.w3.org/2000/09/xmldsig#";
tns = "urn:tugraz:ivt:VectoAPI:VTPReport:v" + CURRENT_SCHEMA_VERSION;
VehiclePart = new XElement(tns + XMLNames.Component_Vehicle);
GeneralPart = new XElement(tns + "General");
DataIntegrityPart = new XElement(tns + "DataIntegrityCheck");
......@@ -255,24 +257,26 @@ namespace TUGraz.VectoCore.OutputData.XML
private XDocument GenerateReport()
{
var xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");
var retVal = new XDocument();
retVal.Add(
new XProcessingInstruction(
"xml-stylesheet", "href=\"https://webgate.ec.europa.eu/CITnet/svn/VECTO/trunk/Share/XML/CSS/VectoReports.css\""));
retVal.Add(
new XElement(
tns + "VectoVTPReport",
new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION),
rootNS + "VectoVTPReport",
//new XAttribute("schemaVersion", CURRENT_SCHEMA_VERSION),
new XAttribute(XNamespace.Xmlns + "xsi", xsi.NamespaceName),
new XAttribute("xmlns", tns),
new XAttribute(XNamespace.Xmlns + "tns", rootNS),
//new XAttribute(XNamespace.Xmlns + "di", di),
new XAttribute(
xsi + "schemaLocation",
string.Format("{0} {1}VTPReport.{2}.xsd", tns, AbstractXMLWriter.SchemaLocationBaseUrl, CURRENT_SCHEMA_VERSION)),
string.Format("{0} {1}VTPReport.xsd", rootNS, AbstractXMLWriter.SchemaLocationBaseUrl)),
new XElement(
tns + "Data",
rootNS + "Data",
new XAttribute(xsi + "type", "VTPReportDataType"),
new XElement(GeneralPart),
new XElement(VehiclePart),
new XElement(DataIntegrityPart),
......@@ -292,6 +296,7 @@ namespace TUGraz.VectoCore.OutputData.XML
new XElement(tns + XMLNames.Component_Manufacturer, modelData.VehicleData.Manufacturer),
new XElement(tns + XMLNames.Component_ManufacturerAddress, modelData.VehicleData.ManufacturerAddress));
VehiclePart.Add(
new XAttribute(xsi + "type", "VehicleType"),
new XElement(tns + XMLNames.Component_Model, modelData.VehicleData.ModelName),
new XElement(tns + XMLNames.Vehicle_VIN, modelData.VehicleData.VIN),
new XElement(tns + XMLNames.Vehicle_LegislativeClass, modelData.VehicleData.LegislativeClass.ToXMLFormat()),
......@@ -302,20 +307,37 @@ namespace TUGraz.VectoCore.OutputData.XML
modelData.Retarder.Type.IsDedicatedComponent()
? new XElement(tns + XMLNames.Vehicle_RetarderRatio, modelData.Retarder.Ratio.ToXMLFormat(3))
: null,
new XElement(tns + XMLNames.Vehicle_PTO, modelData.PTO != null),
new XElement(
tns + XMLNames.Vehicle_Components,
GetEngineDescription(modelData.EngineData, fuelModes),
GetGearboxDescription(modelData.GearboxData),
GetTorqueConverterDescription(modelData.GearboxData.TorqueConverterData),
GetRetarderDescription(modelData.Retarder),
GetAngledriveDescription(modelData.AngledriveData),
GetAxlegearDescription(modelData.AxleGearData),
GetAirDragDescription(modelData.AirdragData),
GetAxleWheelsDescription(modelData.VehicleData),
GetAuxiliariesDescription(modelData.Aux)
)
);
new XElement(tns + XMLNames.Vehicle_PTO, modelData.PTO != null));
if (modelData.VehicleData.AxleConfiguration.AxlegearIncludedInGearbox()) {
VehiclePart.Add(
new XElement(
tns + XMLNames.Vehicle_Components,
new XAttribute(xsi + "type", "ComponentsTruckFWDType"),
GetEngineDescription(modelData.EngineData, fuelModes),
GetGearboxDescription(modelData.GearboxData, modelData.AxleGearData.AxleGear.Ratio),
GetTorqueConverterDescription(modelData.GearboxData.TorqueConverterData),
GetRetarderDescription(modelData.Retarder),
GetAngledriveDescription(modelData.AngledriveData),
GetAirDragDescription(modelData.AirdragData),
GetAxleWheelsDescription(modelData.VehicleData),
GetAuxiliariesDescription(modelData.Aux)
));
} else {
VehiclePart.Add(
new XElement(
tns + XMLNames.Vehicle_Components,
new XAttribute(xsi + "type", "ComponentsTruckType"),
GetEngineDescription(modelData.EngineData, fuelModes),
GetGearboxDescription(modelData.GearboxData),
GetTorqueConverterDescription(modelData.GearboxData.TorqueConverterData),
GetRetarderDescription(modelData.Retarder),
GetAngledriveDescription(modelData.AngledriveData),
GetAxlegearDescription(modelData.AxleGearData),
GetAirDragDescription(modelData.AirdragData),
GetAxleWheelsDescription(modelData.VehicleData),
GetAuxiliariesDescription(modelData.Aux)
));
}
if (InputDataHash == null) {
return;
......@@ -497,6 +519,20 @@ namespace TUGraz.VectoCore.OutputData.XML
);
}
private XElement GetGearboxDescription(GearboxData gearboxData, double axlegearRatio)
{
return new XElement(
tns + XMLNames.Component_Gearbox,
GetCommonDescription(gearboxData),
new XElement(tns + XMLNames.Gearbox_TransmissionType, gearboxData.Type.ToXMLFormat()),
new XElement(tns + XMLNames.Report_GetGearbox_GearsCount, gearboxData.Gears.Count),
new XElement(tns + XMLNames.Gearbox_AxlegearRatio, axlegearRatio.ToXMLFormat(3)),
new XElement(
tns + XMLNames.Report_Gearbox_TransmissionRatioFinalGear,
gearboxData.Gears.Last().Value.Ratio.ToXMLFormat(3))
);
}
private XElement GetTorqueConverterDescription(TorqueConverterData torqueConverterData)
{
if (torqueConverterData == null) {
......
......@@ -14,8 +14,8 @@ namespace TUGraz.VectoCore.Utils
EngineeringComponentData = 1 << 5,
ManufacturerReport = 1 << 6,
CustomerReport = 1 << 7,
MonitoringReport = 1 << 8
MonitoringReport = 1 << 8,
VTPReport = 1 << 9
}
......@@ -91,6 +91,7 @@ namespace TUGraz.VectoCore.Utils
{XmlDocumentType.ManufacturerReport, "VectoOutputManufacturer.xsd" },
{XmlDocumentType.CustomerReport , "VectoOutputCustomer.xsd"},
{XmlDocumentType.MonitoringReport , "VectoMonitoring.xsd"},
{XmlDocumentType.VTPReport , "VTPReport.xsd"},
};
public static XNamespace DECLARATION_OUTPUT_PRIMARY_HEAVY_BUS = "urn:tugraz:ivt:VectoAPI:DeclarationOutput:PrimaryVehicleInformation:HeavyBus:v0.1";
......
......@@ -266,5 +266,12 @@ namespace TUGraz.VectoCore.Utils
{
return string.Join(":", schemaInfoSchemaType.QualifiedName.Namespace, schemaInfoSchemaType.QualifiedName.Name);
}
public static double GetVersion(XmlNode node)
{
const string versionPrefix = "v";
var namesp = node.SchemaInfo.SchemaType.QualifiedName.Namespace;
return namesp.Split(':').Last(x => x.StartsWith(versionPrefix)).Replace(versionPrefix, string.Empty).ToDouble();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment