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

Skip to content
Snippets Groups Projects
Commit 82c5fd79 authored by Markus QUARITSCH's avatar Markus QUARITSCH
Browse files

fix: reading engine-only jobs

parent 9ce50f92
No related branches found
No related tags found
No related merge requests found
...@@ -117,49 +117,65 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON ...@@ -117,49 +117,65 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
protected readonly IGearboxEngineeringInputData Gearbox; protected readonly IGearboxEngineeringInputData Gearbox;
protected readonly IAxleGearInputData AxleGear; protected readonly IAxleGearInputData AxleGear;
protected readonly ITorqueConverterEngineeringInputData TorqueConverter; protected readonly ITorqueConverterEngineeringInputData TorqueConverter;
protected readonly IAngledriveInputData Angledrive; protected IAngledriveInputData Angledrive;
protected readonly IEngineEngineeringInputData Engine; protected readonly IEngineEngineeringInputData Engine;
protected readonly IVehicleEngineeringInputData VehicleData; protected IVehicleEngineeringInputData VehicleData;
protected readonly IRetarderInputData Retarder; protected IRetarderInputData Retarder;
protected readonly IPTOTransmissionInputData PTOTransmission; protected IPTOTransmissionInputData PTOTransmission;
private readonly string _jobname; private readonly string _jobname;
public JSONInputDataV2(JObject data, string filename) : base(data, filename) public JSONInputDataV2(JObject data, string filename) : base(data, filename)
{ {
_jobname = Path.GetFileNameWithoutExtension(filename); _jobname = Path.GetFileNameWithoutExtension(filename);
Engine = ReadEngine();
if (Body.GetEx(JsonKeys.Job_EngineOnlyMode).Value<bool>()) {
return;
}
Gearbox = ReadGearbox();
AxleGear = Gearbox as IAxleGearInputData;
TorqueConverter = Gearbox as ITorqueConverterEngineeringInputData;
VehicleData = ReadVehicle();
Angledrive = VehicleData as IAngledriveInputData;
Retarder = VehicleData as IRetarderInputData;
PTOTransmission = VehicleData as IPTOTransmissionInputData;
}
private IVehicleEngineeringInputData ReadVehicle()
{
try { try {
var gearboxFile = Body.GetEx(JsonKeys.Vehicle_GearboxFile).Value<string>(); var vehicleFile = Body.GetEx(JsonKeys.Vehicle_VehicleFile).Value<string>();
if (!EmptyOrInvalidFileName(gearboxFile)) { return JSONInputDataFactory.ReadJsonVehicle(
Gearbox = JSONInputDataFactory.ReadGearbox(Path.Combine(BasePath, gearboxFile)); Path.Combine(BasePath, vehicleFile));
}
AxleGear = Gearbox as IAxleGearInputData;
TorqueConverter = Gearbox as ITorqueConverterEngineeringInputData;
} catch (Exception e) { } catch (Exception e) {
throw new VectoException("JobFile: Failed to read Gearbox file '{0}': {1}", e, Body[JsonKeys.Vehicle_GearboxFile], throw new VectoException("JobFile: Failed to read Vehicle file '{0}': {1}", e, Body[JsonKeys.Vehicle_VehicleFile],
e.Message); e.Message);
} }
}
private IGearboxEngineeringInputData ReadGearbox()
{
try { try {
Engine = JSONInputDataFactory.ReadEngine( var gearboxFile = Body.GetEx(JsonKeys.Vehicle_GearboxFile).Value<string>();
Path.Combine(BasePath, Body.GetEx(JsonKeys.Vehicle_EngineFile).Value<string>()));
return JSONInputDataFactory.ReadGearbox(Path.Combine(BasePath, gearboxFile));
} catch (Exception e) { } catch (Exception e) {
throw new VectoException("JobFile: Failed to read Engine file '{0}': {1}", e, Body[JsonKeys.Vehicle_EngineFile], throw new VectoException("JobFile: Failed to read Gearbox file '{0}': {1}", e, Body[JsonKeys.Vehicle_GearboxFile],
e.Message); e.Message);
} }
}
private IEngineEngineeringInputData ReadEngine()
{
try { try {
var vehicleFile = Body.GetEx(JsonKeys.Vehicle_VehicleFile).Value<string>(); return JSONInputDataFactory.ReadEngine(
if (!EmptyOrInvalidFileName(vehicleFile)) { Path.Combine(BasePath, Body.GetEx(JsonKeys.Vehicle_EngineFile).Value<string>()));
VehicleData = JSONInputDataFactory.ReadJsonVehicle(
Path.Combine(BasePath, vehicleFile));
Angledrive = VehicleData as IAngledriveInputData;
Retarder = VehicleData as IRetarderInputData;
PTOTransmission = VehicleData as IPTOTransmissionInputData;
}
} catch (Exception e) { } catch (Exception e) {
throw new VectoException("JobFile: Failed to read Vehicle file '{0}': {1}", e, Body[JsonKeys.Vehicle_VehicleFile], throw new VectoException("JobFile: Failed to read Engine file '{0}': {1}", e, Body[JsonKeys.Vehicle_EngineFile],
e.Message); e.Message);
} }
} }
......
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