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

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

fixes for GUI: saving works

parent 2a12a972
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
using TUGraz.VectoCommon.InputData;
namespace TUGraz.VectoCore.InputData.FileIO.JSON {
public interface IJSONVehicleComponents {
IGearboxEngineeringInputData Gearbox { get; }
ITorqueConverterEngineeringInputData TorqueConverter { get; }
IAxleGearInputData AxleGear { get; }
IEngineEngineeringInputData Engine { get; }
IAuxiliariesEngineeringInputData EngineeringAuxiliaries { get; }
IAuxiliariesDeclarationInputData DeclarationAuxiliaries { get; }
}
}
\ No newline at end of file
......@@ -58,13 +58,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
private string _filename;
public JSONComponentInputData(string filename, bool tolerateMissing = false)
public JSONComponentInputData(string filename, IJSONVehicleComponents job, bool tolerateMissing = false)
{
var extension = Path.GetExtension(filename);
object tmp = null;
switch (extension) {
case Constants.FileExtensions.VehicleDataFile:
tmp = JSONInputDataFactory.ReadJsonVehicle(filename, null, tolerateMissing);
tmp = JSONInputDataFactory.ReadJsonVehicle(filename, job, tolerateMissing);
break;
case Constants.FileExtensions.EngineDataFile:
tmp = JSONInputDataFactory.ReadEngine(filename, tolerateMissing);
......
......@@ -124,38 +124,50 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
/// </summary>
public class JSONInputDataV2 : JSONFile, IEngineeringInputDataProvider, IDeclarationInputDataProvider,
IEngineeringJobInputData, IDriverEngineeringInputData, IAuxiliariesEngineeringInputData,
IAuxiliariesDeclarationInputData
IAuxiliariesDeclarationInputData, IJSONVehicleComponents
{
public IGearboxEngineeringInputData Gearbox { get; internal set; }
public JSONInputDataV2(JObject data, string filename, bool tolerateMissing = false)
: base(data, filename, tolerateMissing)
{
_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();
}
public IGearboxEngineeringInputData Gearbox { get; internal set; }
public IAxleGearInputData AxleGear { get; internal set; }
public ITorqueConverterEngineeringInputData TorqueConverter { get; internal set; }
public IEngineEngineeringInputData Engine { get; internal set; }
protected readonly IVehicleEngineeringInputData VehicleData;
protected readonly IVehicleEngineeringInputData VehicleData;
private readonly string _jobname;
public JSONInputDataV2(JObject data, string filename, bool tolerateMissing = false)
: base(data, filename, tolerateMissing)
{
_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;
public IAuxiliariesEngineeringInputData EngineeringAuxiliaries
{
get { return this; }
}
VehicleData = ReadVehicle();
}
public IAuxiliariesDeclarationInputData DeclarationAuxiliaries
{
get { return this; }
}
private IVehicleEngineeringInputData ReadVehicle()
private IVehicleEngineeringInputData ReadVehicle()
{
try {
var vehicleFile = Body.GetEx(JsonKeys.Vehicle_VehicleFile).Value<string>();
......
......@@ -57,7 +57,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
if (Constants.FileExtensions.VectoJobFile.Equals(Path.GetExtension(filename), StringComparison.OrdinalIgnoreCase)) {
return ReadJsonJob(filename, true);
}
return new JSONComponentInputData(filename, true);
return new JSONComponentInputData(filename, null, true);
}
public static IInputDataProvider ReadJsonJob(string filename, bool tolerateMissing = false)
......@@ -77,7 +77,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
}
}
public static IVehicleEngineeringInputData ReadJsonVehicle(string filename, JSONInputDataV2 job, bool tolerateMissing = false)
public static IVehicleEngineeringInputData ReadJsonVehicle(string filename, IJSONVehicleComponents job, bool tolerateMissing = false)
{
var json = ReadFile(filename);
var version = ReadVersion(json);
......
......@@ -45,13 +45,13 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
public class JSONVehicleDataV7 : JSONFile, IVehicleEngineeringInputData, IRetarderInputData, IAngledriveInputData,
IPTOTransmissionInputData, IAirdragEngineeringInputData
{
public JSONVehicleDataV7(JObject data, string fileName, JSONInputDataV2 job, bool tolerateMissing = false)
public JSONVehicleDataV7(JObject data, string fileName, IJSONVehicleComponents job, bool tolerateMissing = false)
: base(data, fileName, tolerateMissing)
{
Job = job;
}
private JSONInputDataV2 Job;
private IJSONVehicleComponents Job;
#region IVehicleInputData
......@@ -239,7 +239,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
IAuxiliariesDeclarationInputData IVehicleDeclarationInputData.AuxiliaryInputData()
{
return Job;
return Job.DeclarationAuxiliaries;
}
IRetarderInputData IVehicleEngineeringInputData.RetarderInputData
......@@ -254,7 +254,7 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
IAuxiliariesEngineeringInputData IVehicleEngineeringInputData.AuxiliaryInputData()
{
return Job;
return Job.EngineeringAuxiliaries;
}
IRetarderInputData IVehicleDeclarationInputData.RetarderInputData
......
......@@ -35,10 +35,8 @@ using System.Data;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using DocumentFormat.OpenXml.Spreadsheet;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
......
......@@ -109,6 +109,7 @@
<ItemGroup>
<Compile Include="Configuration\Constants.cs" />
<Compile Include="InputData\AuxiliaryFileHelper.cs" />
<Compile Include="InputData\FileIO\JSON\IJSONVehicleComponents.cs" />
<Compile Include="InputData\FileIO\JSON\JSONComponentInputData.cs" />
<Compile Include="InputData\FileIO\JSON\JsonExtensionMethods.cs" />
<Compile Include="InputData\FileIO\XML\Declaration\AbstractDeclarationXMLComponentDataProvider.cs" />
......@@ -312,9 +313,7 @@
<Compile Include="Models\SimulationComponent\IWheels.cs" />
<Compile Include="Models\SimulationComponent\VectoSimulationComponent.cs" />
<Compile Include="Models\SimulationComponent\Impl\PowertrainDrivingCycle.cs" />
<Compile Include="Models\Simulation\Data\ModalResult.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Models\Simulation\Data\ModalResult.cs" />
<Compile Include="Models\Simulation\IVectoRun.cs" />
<Compile Include="Models\Simulation\Impl\SimulatorFactory.cs" />
<Compile Include="Models\Simulation\Impl\VectoRun.cs" />
......@@ -337,11 +336,6 @@
</Compile>
<Compile Include="Utils\XmlResourceResolver.cs" />
<Compile Include="Utils\XPathHelper.cs" />
<Compile Include="VersionNumber1.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>VersionNumber.t4</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
......
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