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

Skip to content
Snippets Groups Projects
Commit d8311292 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

added csv reader, added many methods for reading input data

parent 3f3e9327
No related branches found
No related tags found
No related merge requests found
Showing
with 23451 additions and 87 deletions
{
"Header": {
"CreatedBy": "Raphael Luz IVT TU-Graz (85407225-fc3f-48a8-acda-c84a05df6837)",
"Date": "29.07.2014 16:58:58",
"AppVersion": "2.0.4-beta",
"CreatedBy": " ()",
"Date": "3/4/2015 12:31:06 PM",
"AppVersion": "2.0.4-beta3",
"FileVersion": 2
},
"Body": {
"SavedInDeclMode": true,
"SavedInDeclMode": false,
"VehicleFile": "12t Delivery Truck.vveh",
"EngineFile": "12t Delivery Truck.veng",
"GearboxFile": "12t Delivery Truck.vgbx",
......@@ -20,36 +20,36 @@
"ID": "FAN",
"Type": "Fan",
"Path": "<NOFILE>",
"Technology": "Belt driven or driven via transm. - Discrete step clutch"
"Technology": ""
},
{
"ID": "STP",
"Type": "Steering pump",
"Path": "<NOFILE>",
"Technology": "Variable displacement"
"Technology": ""
},
{
"ID": "AC",
"Type": "HVAC",
"Path": "<NOFILE>",
"Technology": "Default"
"Technology": ""
},
{
"ID": "ES",
"Type": "Electric System",
"Path": "<NOFILE>",
"Technology": "Custom Technology List",
"Technology": "",
"TechList": []
},
{
"ID": "PS",
"Type": "Pneumatic System",
"Path": "<NOFILE>",
"Technology": "Default"
"Technology": ""
}
],
"VACC": "<NOFILE>",
"EngineOnlyMode": false,
"EngineOnlyMode": true,
"StartStop": {
"Enabled": false,
"MaxSpeed": 5.0,
......
{
"Header": {
"CreatedBy": "Raphael Luz IVT TU-Graz (85407225-fc3f-48a8-acda-c84a05df6837)",
"Date": "29.07.2014 16:58:53",
"AppVersion": "2.0.4-beta",
"CreatedBy": " ()",
"Date": "3/4/2015 12:31:04 PM",
"AppVersion": "2.0.4-beta3",
"FileVersion": 2
},
"Body": {
"SavedInDeclMode": true,
"SavedInDeclMode": false,
"ModelName": "Generic 12t Delivery Truck",
"Displacement": 7700.0,
"IdlingSpeed": 600.0,
......
Job [-],Input File [-],Cycle [-],time [s],Ppos [kW],Pneg [kW],FC [g/h],FC-AUXc [g/h],FC-WHTCc [g/h]
1,12t Delivery Truck.vecto,Long Haul,Aborted due to Error!
1,12t Delivery Truck.vecto,Regional Delivery,Aborted due to Error!
1,12t Delivery Truck.vecto,Urban Delivery,Aborted due to Error!
{
"Header": {
"CreatedBy": " ()",
"Date": "3/4/2015 12:31:07 PM",
"AppVersion": "2.0.4-beta3",
"FileVersion": 1
},
"Body": {
"Settings": {
"Air Density [kg/m3]": 1.188,
"CO2/FC [-]": 3.16,
"Fuel Density [kg/l]": 0.832,
"Distance Correction": true
},
"Results": [
{
"Job": "12t Delivery Truck.vecto",
"Cycle": "Long Haul",
"Loading": "User-defined Loading",
"AbortedByError": true
},
{
"Job": "12t Delivery Truck.vecto",
"Cycle": "Regional Delivery",
"Loading": "User-defined Loading",
"AbortedByError": true
},
{
"Job": "12t Delivery Truck.vecto",
"Cycle": "Urban Delivery",
"Loading": "User-defined Loading",
"AbortedByError": true
}
]
}
}
\ No newline at end of file
{
"Header": {
"CreatedBy": "Raphael Luz IVT TU-Graz (85407225-fc3f-48a8-acda-c84a05df6837)",
"Date": "29.07.2014 16:59:17",
"AppVersion": "2.0.4-beta",
"CreatedBy": " ()",
"Date": "3/4/2015 2:09:13 PM",
"AppVersion": "2.0.4-beta3",
"FileVersion": 2
},
"Body": {
......@@ -11,7 +11,7 @@
"EngineFile": "24t Coach.veng",
"GearboxFile": "24t Coach.vgbx",
"Cycles": [
"Coach.vdri"
"W:\\VECTO\\CITnet\\VECTO\\bin\\Debug\\Declaration\\MissionCycles\\LOT2_rural Engine Only.vdri"
],
"Aux": [
{
......@@ -34,7 +34,7 @@
}
],
"VACC": "Coach.vacc",
"EngineOnlyMode": false,
"EngineOnlyMode": true,
"StartStop": {
"Enabled": false,
"MaxSpeed": 5.0,
......
{
"Header": {
"CreatedBy": "Raphael Luz IVT TU-Graz (85407225-fc3f-48a8-acda-c84a05df6837)",
"Date": "29.07.2014 16:59:15",
"AppVersion": "2.0.4-beta",
"CreatedBy": " ()",
"Date": "3/4/2015 12:26:24 PM",
"AppVersion": "2.0.4-beta3",
"FileVersion": 2
},
"Body": {
......

\ No newline at end of file
{
"Header": {
"CreatedBy": " ()",
"Date": "3/4/2015 2:10:52 PM",
"AppVersion": "2.0.4-beta3",
"FileVersion": 1
},
"Body": {
"Settings": {
"Air Density [kg/m3]": 1.188,
"CO2/FC [-]": 3.16,
"Fuel Density [kg/l]": 0.832,
"Distance Correction": true
},
"Results": [
{
"Job": "24t Coach.vecto",
"Cycle": "LOT2_rural Engine Only.vdri",
"Loading": "User-defined Loading",
"AbortedByError": false,
"Results": {
"time": {
"Value": 3951,
"Unit": "[s]"
},
"Ppos": {
"Value": 29.599963484631711,
"Unit": "[kW]"
},
"Pneg": {
"Value": -1.6357945519695312,
"Unit": "[kW]"
},
"FC": {
"Value": "ERROR",
"Unit": "[g/h]"
},
"FC-AUXc": {
"Value": "-",
"Unit": "[g/h]"
},
"FC-WHTCc": {
"Value": "-",
"Unit": "[g/h]"
}
}
}
]
}
}
\ No newline at end of file
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
namespace TUGraz.VectoCore.Models.SimulationComponent
{
public interface IInPort
{
}
}
\ No newline at end of file
namespace TUGraz.VectoCore.Models.SimulationComponent
{
public interface IOutPort
{
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TUGraz.VectoCore.Models.SimulationComponent;
namespace TUGraz.VectoCore.Models.Connector.Ports
{
......@@ -10,12 +11,12 @@ namespace TUGraz.VectoCore.Models.Connector.Ports
{
}
public interface ITnInPort : ITnPort
public interface ITnInPort : ITnPort, IInPort
{
}
public interface ITnOutPort : ITnPort
public interface ITnOutPort : ITnPort, IOutPort
{
void Request(TimeSpan absTime, TimeSpan dt, double torque, double engineSpeed);
}
......
namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
using TUGraz.VectoCore.Models.SimulationComponent;
namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
{
public abstract class InPort
public abstract class InPort: IInPort
{
}
}
namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
using TUGraz.VectoCore.Models.SimulationComponent;
namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
{
public abstract class OutPort
public abstract class OutPort: IOutPort
{
}
}
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TUGraz.VectoCore.Models.SimulationComponent;
namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
{
......
......@@ -3,11 +3,19 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TUGraz.VectoCore.Models.SimulationComponent;
namespace TUGraz.VectoCore.Models.Connector.Ports.Impl
{
public class TnOutPort : OutPort, ITnOutPort
{
private VectoSimulationComponent _component;
public TnOutPort(VectoSimulationComponent component)
{
_component = component;
}
public void Request(TimeSpan absTime, TimeSpan dt, double torque, double engineSpeed)
{
throw new NotImplementedException();
......
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Runtime.CompilerServices;
using Newtonsoft.Json;
using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine;
......@@ -37,63 +40,95 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
/// }
/// }
/// </code>
public class CombustionEngineData : SimulationComponentData
{
private readonly Dictionary<uint, FullLoadCurve> _fullLoadCurves = new Dictionary<uint, FullLoadCurve>();
public class CombustionEngineData : SimulationComponentData
{
private readonly Dictionary<string, FullLoadCurve> _fullLoadCurves = new Dictionary<string, FullLoadCurve>();
public CombustionEngineData(string fileName)
{
public static CombustionEngineData ReadFromFile(string fileName)
{
//todo: file exception handling: file not readable, wrong file format
using (StreamReader r = new StreamReader(fileName))
{
var json = r.ReadToEnd();
var results = JsonConvert.DeserializeObject<dynamic>(json);
var body = results.Body;
return ReadFromJson(File.ReadAllText(fileName));
}
ModelName = body.ModelName;
Displacement = body.Displacement;
IdleSpeed = body.IdlingSpeed;
Inertia = body.Inertia;
public static CombustionEngineData ReadFromJson(string json)
{
CombustionEngineData engine = new CombustionEngineData();
var results = JsonConvert.DeserializeObject<dynamic>(json);
foreach (dynamic loadCurve in body.FullLoadCurves)
{
string[] gears = loadCurve.Gears.ToString().Split('-');
var firstGear = uint.Parse(gears.First().Trim());
var lastGear = uint.Parse(gears.Last().Trim());
for (var i = firstGear; i <= lastGear; i++)
{
_fullLoadCurves[i] = new FullLoadCurve(loadCurve.Path.ToString());
}
}
//todo: handle error when fields not exist
var header = results["Header"];
ConsumptionMap = new FuelConsumptionMap(body.FuelMap.ToString());
}
}
if (header["FileVersion"] > 2)
throw new Exception("Unsupported Version of .veng file. Got Version: " + header["FileVersion"]);
var body = results["Body"];
if (header["FileVersion"] > 1)
engine.SavedInDeclarationMode = body["SavedInDeclMode"];
engine.ModelName = body["ModelName"];
engine.Displacement = body["Displacement"];
engine.IdleSpeed = body["IdlingSpeed"];
engine.Inertia = body["Inertia"];
foreach (dynamic loadCurve in body["FullLoadCurves"])
engine._fullLoadCurves[loadCurve["Gears"].Value] = FullLoadCurve.ReadFromFile(loadCurve["Path"].Value);
engine.ConsumptionMap = FuelConsumptionMap.ReadFromFile(body["FuelMap"].Value);
if (body["WHTC-Urban"] != null)
WHTCUrban = body["WHTC-Urban"].Value;
if (body["WHTC-Rural"] != null)
WHTCRural = body["WHTC-Rural"].Value;
/// <summary>
/// Engine description (e.g., mode, type, etc.
/// </summary>
public String ModelName { get; protected set; }
/// <summary>
/// Engine displacement [ccm]
/// </summary>
public double Displacement { get; protected set; }
if (body["WHTC-Motorway"] != null)
WHTCMotorway = body["WHTC-Motorway"].Value;
public double IdleSpeed { get; protected set; }
return engine;
}
public double RatedSpeed { get; protected set; }
public static double WHTCMotorway { get; set; }
public double Inertia { get; protected set; }
public static double WHTCRural { get; set; }
public double MaxPower { get; set; }
public static double WHTCUrban { get; set; }
public FuelConsumptionMap ConsumptionMap { get; protected set; }
public bool SavedInDeclarationMode { get; set; }
public FullLoadCurve FullLoadCurve(uint gear)
{
return _fullLoadCurves[gear];
}
}
/// <summary>
/// Engine description (e.g., mode, type, etc.
/// </summary>
public String ModelName { get; set; }
/// <summary>
/// Engine displacement [ccm]
/// </summary>
public double Displacement { get; set; }
public double IdleSpeed { get; set; }
public double RatedSpeed { get; set; }
public double Inertia { get; set; }
public double MaxPower { get; set; }
public FuelConsumptionMap ConsumptionMap { get; set; }
public FullLoadCurve GetFullLoadCurve(uint gear)
{
foreach (var gear_range in _fullLoadCurves.Keys)
{
var low = uint.Parse(gear_range.Split('-').First().Trim());
if (low <= gear)
{
var high = uint.Parse(gear_range.Split('-').Last().Trim());
if (high >= gear)
return _fullLoadCurves[gear_range];
}
}
throw new KeyNotFoundException(string.Format("Gear '{0}' was not found in the FullLoadCurves.", gear));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine
{
public class FuelConsumptionMap
{
public FuelConsumptionMap(string fileName)
{
}
}
public class FuelConsumptionMap
{
public static FuelConsumptionMap ReadFromFile(string fileName)
{
return ReadFromJson(File.ReadAllText(fileName));
}
public static FuelConsumptionMap ReadFromJson(string json)
{
//todo implement ReadFromJson
return new FuelConsumptionMap();
}
}
}
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