Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

Merge pull request #785 in VECTO/vecto-sim from...

Merge pull request #785 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:bugfix/VECTO-1067-vair-and-beta-correction-for-aerodynamics to develop

* commit 'f6dc937d':
  fix for refactoring moving report writer to base class
  adding testcases for filtering 'duplicate' entries in driving cycle. if vair_res and vail_beta are provided intermediate cycle entries must not be deleted.
  refactoring: declaration report - move writer from xmlreport to base class
parents 7ec41880 f6dc937d
No related branches found
No related tags found
No related merge requests found
......@@ -306,6 +306,15 @@ namespace TUGraz.VectoCore.InputData.Reader
return false;
}
if (first.AirSpeedRelativeToVehicle != null && second.AirSpeedRelativeToVehicle != null &&
!first.AirSpeedRelativeToVehicle.IsEqual(second.AirSpeedRelativeToVehicle)) {
return false;
}
if (!first.WindYawAngle.IsEqual(second.WindYawAngle)) {
return false;
}
return true;
}
......
......@@ -44,8 +44,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// Retarder component.
/// </summary>
public class Retarder : StatefulProviderComponent<SimpleComponentState, ITnOutPort, ITnInPort, ITnOutPort>,
IPowerTrainComponent, ITnInPort,
ITnOutPort
IPowerTrainComponent, ITnInPort, ITnOutPort
{
private readonly RetarderLossMap _lossMap;
private readonly double _ratio;
......
......@@ -97,6 +97,14 @@ namespace TUGraz.VectoCore.OutputData
/// </summary>
private int _resultCount;
protected readonly IReportWriter Writer;
protected DeclarationReport(IReportWriter writer)
{
Writer = writer;
}
[MethodImpl(MethodImplOptions.Synchronized)]
public void PrepareResult(LoadingType loading, Mission mission, VectoRunData runData)
{
......
......@@ -54,7 +54,6 @@ namespace TUGraz.VectoCore.OutputData.XML
private readonly XMLCustomerReport _customerReport;
private readonly XMLMonitoringReport _monitoringReport;
private readonly IOutputDataWriter _writer;
private IDictionary<Tuple<MissionType, LoadingType>, double> _weightingFactors;
......@@ -168,13 +167,11 @@ namespace TUGraz.VectoCore.OutputData.XML
}
}
public XMLDeclarationReport(IOutputDataWriter writer = null)
public XMLDeclarationReport(IReportWriter writer = null) : base(writer)
{
_manufacturerReport = new XMLManufacturerReport();
_customerReport = new XMLCustomerReport();
_monitoringReport = new XMLMonitoringReport(_manufacturerReport);
_writer = writer;
}
public XDocument FullReport
......@@ -210,10 +207,10 @@ namespace TUGraz.VectoCore.OutputData.XML
var fullReportHash = GetSignature(_manufacturerReport.Report);
_customerReport.GenerateReport(fullReportHash);
if (_writer != null) {
_writer.WriteReport(ReportType.DeclarationReportCustomerXML, _customerReport.Report);
_writer.WriteReport(ReportType.DeclarationReportManufacturerXML, _manufacturerReport.Report);
_writer.WriteReport(ReportType.DeclarationReportMonitoringXML, _monitoringReport.Report);
if (Writer != null) {
Writer.WriteReport(ReportType.DeclarationReportCustomerXML, _customerReport.Report);
Writer.WriteReport(ReportType.DeclarationReportManufacturerXML, _manufacturerReport.Report);
Writer.WriteReport(ReportType.DeclarationReportMonitoringXML, _monitoringReport.Report);
}
}
......
......@@ -71,7 +71,6 @@ namespace TUGraz.VectoCore.OutputData.XML
protected XNamespace tns;
private IOutputDataWriter _writer;
private static List<string> LogList = new List<string>();
private LoggingRule cycleChecksRule;
......@@ -115,7 +114,7 @@ namespace TUGraz.VectoCore.OutputData.XML
#endregion
}
public XMLVTPReport(IOutputDataWriter writer)
public XMLVTPReport(IReportWriter writer) : base(writer)
{
//di = "http://www.w3.org/2000/09/xmldsig#";
tns = "urn:tugraz:ivt:VectoAPI:VTPReport:v" + CURRENT_SCHEMA_VERSION;
......@@ -125,9 +124,6 @@ namespace TUGraz.VectoCore.OutputData.XML
TestConditionsPart = new XElement(tns + "TestConditions");
Results = new XElement(tns + "Results");
_writer = writer;
AddLogging();
}
......@@ -175,8 +171,8 @@ namespace TUGraz.VectoCore.OutputData.XML
GenerateResults();
var report = GenerateReport();
if (_writer != null) {
_writer.WriteReport(ReportType.DeclarationVTPReportXML, report);
if (Writer != null) {
Writer.WriteReport(ReportType.DeclarationVTPReportXML, report);
}
}
......
......@@ -379,6 +379,62 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
TestCycleRead(cycle, type, entryCount);
}
[TestCase()]
public void DrivingCycleRead_CompressEntries_TargetSpeedOnly()
{
var cycle = "<s>,<v>,<Grad>,<STOP>\n" +
" 1, 0,0,1\n" +
" 2,50,0,0\n" +
" 5,50,0,0\n" +
"50,50,0,0\n" +
"99,50,0,0";
var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycle.ToStream(), CycleType.DistanceBased, "", false);
Assert.AreEqual(3, drivingCycle.Entries.Count);
Assert.AreEqual(1, drivingCycle.Entries[0].Distance.Value());
Assert.AreEqual(1, drivingCycle.Entries[1].Distance.Value());
Assert.AreEqual(99, drivingCycle.Entries[2].Distance.Value());
}
[TestCase()]
public void DrivingCycleRead_CompressEntries_TargetSpeedVAirBeta1()
{
var cycle = "<s>,<v>,<Grad>,<STOP>,vair_res,vair_beta\n" +
" 1, 0,0,1,30,10\n" +
" 2,50,0,0,30,10\n" +
" 5,50,0,0,30,15\n" +
"50,50,0,0,30,10\n" +
"99,50,0,0,30,15";
var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycle.ToStream(), CycleType.DistanceBased, "", true);
Assert.AreEqual(5, drivingCycle.Entries.Count);
Assert.AreEqual(1, drivingCycle.Entries[0].Distance.Value());
Assert.AreEqual(1, drivingCycle.Entries[1].Distance.Value());
Assert.AreEqual(5, drivingCycle.Entries[2].Distance.Value());
Assert.AreEqual(50, drivingCycle.Entries[3].Distance.Value());
Assert.AreEqual(99, drivingCycle.Entries[4].Distance.Value());
}
[TestCase()]
public void DrivingCycleRead_CompressEntries_TargetSpeedVAirBeta2()
{
var cycle = "<s>,<v>,<Grad>,<STOP>,vair_res,vair_beta\n" +
" 1, 0,0,1,30,10\n" +
" 2,50,0,0,30,10\n" +
" 5,50,0,0,35,10\n" +
"50,50,0,0,30,10\n" +
"99,50,0,0,33,10";
var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycle.ToStream(), CycleType.DistanceBased, "", true);
Assert.AreEqual(5, drivingCycle.Entries.Count);
Assert.AreEqual(1, drivingCycle.Entries[0].Distance.Value());
Assert.AreEqual(1, drivingCycle.Entries[1].Distance.Value());
Assert.AreEqual(5, drivingCycle.Entries[2].Distance.Value());
Assert.AreEqual(50, drivingCycle.Entries[3].Distance.Value());
Assert.AreEqual(99, drivingCycle.Entries[4].Distance.Value());
}
private static void TestCycleDetect(string inputData, CycleType cycleType)
{
var cycleTypeCalc = DrivingCycleDataReader.DetectCycleType(VectoCSVFile.ReadStream(inputData.ToStream()));
......
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