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

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

most testcases work again

parent e6facfb8
No related branches found
No related tags found
No related merge requests found
namespace TUGraz.VectoCore.Configuration
{
public class Constants
{
public class FileExtensions
{
public const string ModDataFile = ".vmod";
public const string SumFile = ".vsum";
public const string VectoJobFile = ".vecto";
public const string EngineDataFile = ".veng";
}
}
}
\ No newline at end of file
......@@ -55,7 +55,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
var segment = GetVehicleClassification((dynamic) Vehicle);
foreach (var mission in segment.Missions) {
foreach (var loading in mission.Loadings) {
var jobData = new VectoRunData() {
var simulationRunData = new VectoRunData() {
VehicleData = CreateVehicleData((dynamic) Vehicle, mission, loading),
EngineData = CreateEngineData((dynamic) Engine),
GearboxData = CreateGearboxData((dynamic) Gearbox),
......@@ -65,7 +65,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
IsEngineOnly = false,
JobFileName = Job.JobFile,
};
yield return jobData;
yield return simulationRunData;
//var builder = new SimulatorFactory.PowertrainBuilder();
}
}
......
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.FileIO.EngineeringFile;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.Impl;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
namespace TUGraz.VectoCore.FileIO.Reader.Impl
{
public class EngineOnlySimulationDataReader : EngineeringModeSimulationDataReader
{
public override IEnumerable<VectoRunData> NextRun()
{
var job = Job as VectoJobFileV2Engineering;
if (job == null) {
Log.Warn("Job-file is null or unsupported version");
yield break;
}
foreach (var cycle in job.Body.Cycles) {
var simulationRunData = new VectoRunData() {
BasePath = job.BasePath,
JobFileName = job.JobFile,
EngineData = CreateEngineData((dynamic) Engine),
Cycle = DrivingCycleData.ReadFromFileEngineOnly(Path.Combine(job.BasePath, cycle)),
IsEngineOnly = true
};
yield return simulationRunData;
}
}
protected override void ProcessJob(VectoJobFile vectoJob)
{
var declaration = vectoJob as VectoJobFileV2Engineering;
if (declaration == null) {
throw new VectoException("Unhandled Job File Format");
}
var job = declaration;
ReadEngine(Path.Combine(job.BasePath, job.Body.EngineFile));
}
}
}
\ No newline at end of file
......@@ -61,12 +61,6 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
}
internal VectoRunData CreateVectoJobData(VectoJobFileV2Engineering data, string basePath)
{
return new VectoRunData();
}
internal VehicleData CreateVehicleData(VehicleFileV5Engineering vehicle)
{
var data = vehicle.Body;
......@@ -91,7 +85,21 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
public override IEnumerable<VectoRunData> NextRun()
{
throw new NotImplementedException();
var job = Job as VectoJobFileV2Engineering;
if (job == null) {
Log.Warn("Job-file is null or unsupported version");
yield break;
}
foreach (var cycle in job.Body.Cycles) {
var simulationRunData = new VectoRunData() {
BasePath = job.BasePath,
JobFileName = job.JobFile,
EngineData = CreateEngineData((dynamic) Engine),
Cycle = DrivingCycleData.ReadFromFile(Path.Combine(job.BasePath, cycle), DrivingCycleData.CycleType.DistanceBased),
IsEngineOnly = false
};
yield return simulationRunData;
}
}
......@@ -124,6 +132,7 @@ namespace TUGraz.VectoCore.FileIO.Reader.Impl
case 2:
Job = JsonConvert.DeserializeObject<VectoJobFileV2Engineering>(json);
Job.BasePath = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar;
Job.JobFile = Path.GetFileName(file);
break;
default:
throw new UnsupportedFileVersionException("Unsupported version of job-file. Got version " + fileInfo.Version);
......
using System;
using System.IO;
using System.Collections.Generic;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.FileIO.Reader;
using TUGraz.VectoCore.FileIO.Reader.Impl;
using TUGraz.VectoCore.Models.Simulation.Data;
......@@ -32,7 +33,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
DataReader = new EngineeringModeSimulationDataReader();
break;
case FactoryMode.EngineOnlyMode:
throw new NotImplementedException();
DataReader = new EngineOnlySimulationDataReader();
break;
}
}
......@@ -67,7 +69,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
IModalDataWriter modWriter = null;
if (_mode != FactoryMode.DeclarationMode) {
var modFileName = "";
var modFileName = Path.Combine(data.BasePath, data.JobFileName.Replace(Constants.FileExtensions.VectoJobFile, "") +
Constants.FileExtensions.ModDataFile);
modWriter = new ModalDataWriter(modFileName, _mode == FactoryMode.EngineOnlyMode);
}
var jobName = string.Format("{0}-{1}", JobNumber, i++);
......
......@@ -106,6 +106,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\Constants.cs" />
<Compile Include="Exceptions\VectoExceptions.cs" />
<Compile Include="Exceptions\VectoSimulationException.cs" />
<Compile Include="FileIO\DeclarationFile\EngineFileDecl.cs" />
......@@ -121,6 +122,7 @@
<Compile Include="FileIO\Reader\Impl\AbstractSimulationDataReader.cs" />
<Compile Include="FileIO\Reader\Impl\DeclarationModeSimulationDataReader.cs" />
<Compile Include="FileIO\Reader\Impl\EngineeringModeSimulationDataReader.cs" />
<Compile Include="FileIO\Reader\Impl\EngineOnlySimulationDataReader.cs" />
<Compile Include="FileIO\Reader\ISimulationDataReader.cs" />
<Compile Include="FileIO\VectoFiles.cs" />
<Compile Include="Models\Connector\Ports\IDriverDemandPort.cs" />
......@@ -195,13 +197,11 @@
<Compile Include="Models\SimulationComponent\Impl\DistanceBasedDrivingCycle.cs" />
<Compile Include="Models\SimulationComponent\Impl\DirectAuxiliary.cs" />
<Compile Include="Models\SimulationComponent\Impl\TimeBasedDrivingCycle.cs" />
<Compile Include="Utils\IMemento.cs" />
<Compile Include="Models\SimulationComponent\Impl\CombustionEngine.cs" />
<Compile Include="Models\SimulationComponent\Impl\EngineOnlyGearbox.cs" />
<Compile Include="Models\SimulationComponent\Impl\Gearbox.cs" />
<Compile Include="Models\SimulationComponent\Impl\Wheels.cs" />
<Compile Include="Models\SimulationComponent\IWheels.cs" />
<Compile Include="Utils\Memento.cs" />
<Compile Include="Models\SimulationComponent\VectoSimulationComponent.cs" />
<Compile Include="Models\SimulationComponent\Impl\EngineOnlyDrivingCycle.cs" />
<Compile Include="Models\Simulation\Data\IModalDataWriter.cs" />
......
......@@ -2,6 +2,7 @@
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Exceptions;
using TUGraz.VectoCore.FileIO.Reader.Impl;
using TUGraz.VectoCore.Models.Simulation;
......@@ -61,12 +62,12 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation
public IVectoRun CreateRun(string resultFileName)
{
var sumFileName = resultFileName.Substring(0, resultFileName.Length - 4) + "vsum";
var sumFileName = resultFileName.Substring(0, resultFileName.Length - 5) + Constants.FileExtensions.SumFile;
var dataWriter = new ModalDataWriter(resultFileName, engineOnly: true);
//var dataWriter = new ModalDataWriter(resultFileName, engineOnly: true);
var sumWriter = new SummaryFileWriter(sumFileName);
var factory = new SimulatorFactory(SimulatorFactory.FactoryMode.EngineOnlyMode) {
SumWriter = sumWriter,
SumWriter = sumWriter,
};
factory.DataReader.SetJobFile(EngineOnlyJob);
......
......@@ -194,33 +194,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
modalData.Finish();
}
[TestMethod]
public void TestEngineMemento()
{
var vehicle = new VehicleContainer();
var engineData = EngineeringModeSimulationDataReader.CreateEngineDataFromFile(CoachEngine);
var origin = new CombustionEngine(vehicle, engineData);
var data = Memento.Serialize(origin);
var restored = new CombustionEngine(vehicle, engineData);
Memento.Deserialize(restored, data);
Assert.AreEqual(origin, restored, "Serialized with Memento, Deserialized with Memento");
data = origin.Serialize();
restored = new CombustionEngine(vehicle, engineData);
Memento.Deserialize(restored, data);
Assert.AreEqual(origin, restored, "Serialized with Object, Deserialized with Memento");
data = origin.Serialize();
restored = new CombustionEngine(vehicle, engineData);
restored.Deserialize(data);
Assert.AreEqual(origin, restored, "Serialized with Object, Deserialized with Object");
}
[TestMethod, Ignore]
public void TestWriteToFile()
......
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