diff --git a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs index 49162f70202fa017050312677cb9668aba050efe..d76d3222b802eabe037fafcda5df0f5730772c95 100644 --- a/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs +++ b/VectoCore/VectoCore/InputData/Reader/DrivingCycleDataReader.cs @@ -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; } diff --git a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs index 7749f1bdb7d44d5731215b69e09a3bcb4d86114b..3f1713eb6729c68fa5040546a3f43c392e94f569 100644 --- a/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs +++ b/VectoCore/VectoCore/Models/SimulationComponent/Impl/Retarder.cs @@ -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; diff --git a/VectoCore/VectoCore/OutputData/DeclarationReport.cs b/VectoCore/VectoCore/OutputData/DeclarationReport.cs index ea16cacd54dcf18c68e9fcc85f945da26f0f7a2b..4772a64a63e5c571361b5d76d526ff65c676af14 100644 --- a/VectoCore/VectoCore/OutputData/DeclarationReport.cs +++ b/VectoCore/VectoCore/OutputData/DeclarationReport.cs @@ -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) { diff --git a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs index 8fd64eae4cc3abb982497b2c85403d52ddb84348..09376d879bc36075ecfd60fc6db358169b77806c 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLDeclarationReport.cs @@ -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); } } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs index ece01f690bd035779d7f98956584f689c4781ab0..febcbe21c2329b6445bc5be30e9170f1663cb932 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLVTPReport.cs @@ -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); } } diff --git a/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs b/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs index d4a5acc09a4ac6b49ea5e95fc90f1743dcd32625..908703b4a5b63c7071ee99e510696ed1137bca36 100644 --- a/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs +++ b/VectoCore/VectoCoreTest/Models/Simulation/DrivingCycleTests.cs @@ -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()));