diff --git a/VectoCore/Models/Simulation/Data/VectoJobData.cs b/VectoCore/Models/Simulation/Data/VectoJobData.cs new file mode 100644 index 0000000000000000000000000000000000000000..0a5eb86db4f4e9d4f25c251f6f9b1b7edce683d9 --- /dev/null +++ b/VectoCore/Models/Simulation/Data/VectoJobData.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using TUGraz.VectoCore.Exceptions; +using TUGraz.VectoCore.Models.SimulationComponent.Data; + +namespace TUGraz.VectoCore.Models.Simulation.Data +{ + /// <summary> + /// Represents the Vecto Job File. Fileformat: .vecto + /// </summary> + /// <code> + ///{ + /// "Header": { + /// "CreatedBy": " ()", + /// "Date": "3/4/2015 2:09:13 PM", + /// "AppVersion": "2.0.4-beta3", + /// "FileVersion": 2 + /// }, + /// "Body": { + /// "SavedInDeclMode": false, + /// "VehicleFile": "24t Coach.vveh", + /// "EngineFile": "24t Coach.veng", + /// "GearboxFile": "24t Coach.vgbx", + /// "Cycles": [ + /// "W:\\VECTO\\CITnet\\VECTO\\bin\\Debug\\Declaration\\MissionCycles\\LOT2_rural Engine Only.vdri" + /// ], + /// "Aux": [ + /// { + /// "ID": "ALT1", + /// "Type": "Alternator", + /// "Path": "24t_Coach_ALT.vaux", + /// "Technology": "" + /// }, + /// { + /// "ID": "ALT2", + /// "Type": "Alternator", + /// "Path": "24t_Coach_ALT.vaux", + /// "Technology": "" + /// }, + /// { + /// "ID": "ALT3", + /// "Type": "Alternator", + /// "Path": "24t_Coach_ALT.vaux", + /// "Technology": "" + /// } + /// ], + /// "AccelerationLimitingFile": "Coach.vacc", + /// "IsEngineOnly": true, + /// "StartStop": { + /// "Enabled": false, + /// "MaxSpeed": 5.0, + /// "MinTime": 0.0, + /// "Delay": 0 + /// }, + /// "LookAheadCoasting": { + /// "Enabled": true, + /// "Dec": -0.5, + /// "MinSpeed": 50.0 + /// }, + /// "OverSpeedEcoRoll": { + /// "Mode": "OverSpeed", + /// "MinSpeed": 70.0, + /// "OverSpeed": 5.0, + /// "UnderSpeed": 5.0 + /// } + /// } + ///} + /// </code> + [DataContract] + public class VectoJobData : SimulationComponentData + { + /// <summary> + /// A class which represents the json data format for serializing and deserializing the Job Data files. + /// </summary> + public class Data + { + [JsonProperty(Required = Required.Always)] public DataHeader Header; + [JsonProperty(Required = Required.Always)] public DataBody Body; + + public class DataHeader + { + [JsonProperty(Required = Required.Always)] public string CreatedBy; + [JsonProperty(Required = Required.Always)] public DateTime Date; + [JsonProperty(Required = Required.Always)] public string AppVersion; + [JsonProperty(Required = Required.Always)] public double FileVersion; + } + + public class DataBody + { + [JsonProperty("SavedInDeclMode")] public bool SavedInDeclarationMode; + + [JsonProperty(Required = Required.Always)] public string VehicleFile; + [JsonProperty(Required = Required.Always)] public string EngineFile; + [JsonProperty(Required = Required.Always)] public string GearboxFile; + [JsonProperty(Required = Required.Always)] public IList<string> Cycles; + [JsonProperty(Required = Required.Always)] public IList<AuxData> Aux; + [JsonProperty(Required = Required.Always)] public string VACC; + [JsonProperty(Required = Required.Always)] public bool EngineOnlyMode; + [JsonProperty(Required = Required.Always)] public StartStopData StartStop; + [JsonProperty(Required = Required.Always)] public LACData LAC; + [JsonProperty(Required = Required.Always)] public OverSpeedEcoRollData OverSpeedEcoRoll; + + public class AuxData + { + [JsonProperty(Required = Required.Always)] public string ID; + [JsonProperty(Required = Required.Always)] public string Type; + [JsonProperty(Required = Required.Always)] public string Path; + [JsonProperty(Required = Required.Always)] public string Technology; + } + + public class StartStopData + { + [JsonProperty(Required = Required.Always)] public bool Enabled; + [JsonProperty(Required = Required.Always)] public double MaxSpeed; + [JsonProperty(Required = Required.Always)] public double MinTime; + [JsonProperty(Required = Required.Always)] public double Delay; + } + + public class LACData + { + [JsonProperty(Required = Required.Always)] public bool Enabled; + [JsonProperty(Required = Required.Always)] public double Dec; + [JsonProperty(Required = Required.Always)] public double MinSpeed; + } + + public class OverSpeedEcoRollData + { + [JsonProperty(Required = Required.Always)] public string Mode; + [JsonProperty(Required = Required.Always)] public double MinSpeed; + [JsonProperty(Required = Required.Always)] public double OverSpeed; + [JsonProperty(Required = Required.Always)] public double UnderSpeed; + } + } + } + + [DataMember] private Data _data; + + + public string VehicleFile + { + get { return _data.Body.VehicleFile; } + } + + public string EngineFile + { + get { return _data.Body.EngineFile; } + } + + public string GearboxFile + { + get { return _data.Body.GearboxFile; } + } + + public IList<string> Cycles + { + get { return _data.Body.Cycles; } + } + + public IList<Data.DataBody.AuxData> Aux + { + get { return _data.Body.Aux; } + } + + public string AccelerationLimitingFile + { + get { return _data.Body.VACC; } + } + + public bool IsEngineOnly + { + get { return _data.Body.EngineOnlyMode; } + } + + public Data.DataBody.StartStopData StartStop + { + get { return _data.Body.StartStop; } + } + + public Data.DataBody.LACData LookAheadCoasting + { + get { return _data.Body.LAC; } + } + + public Data.DataBody.OverSpeedEcoRollData OverSpeedEcoRoll + { + get { return _data.Body.OverSpeedEcoRoll; } + } + + public string FileName { get; set; } + + public static VectoJobData ReadFromFile(string fileName) + { + return ReadFromJson(File.ReadAllText(fileName), Path.GetDirectoryName(fileName), fileName); + } + + public static VectoJobData ReadFromJson(string json, string basePath = "", string fileName = "") + { + var data = new VectoJobData(); + data.FileName = fileName; + //todo handle conversion errors + var d = JsonConvert.DeserializeObject<Data>(json); + + data._data = d; + + if (d.Header.FileVersion > 2) { + throw new UnsupportedFileVersionException("Unsupported Version of .vecto file. Got Version: " + d.Header.FileVersion); + } + return data; + } + + public void WriteToFile(string fileName) + { + //todo handle file exceptions + File.WriteAllText(fileName, ToJson()); + } + + public string ToJson() + { + _data.Header.Date = DateTime.Now; + _data.Header.FileVersion = 2; + _data.Header.AppVersion = "3.0.0"; // todo: get current app version! + _data.Header.CreatedBy = ""; // todo: get current user + _data.Body.SavedInDeclarationMode = false; //todo: get declaration mode setting + return JsonConvert.SerializeObject(_data, Formatting.Indented); + } + } +} \ No newline at end of file diff --git a/VectoCore/Models/Simulation/Impl/JobContainer.cs b/VectoCore/Models/Simulation/Impl/JobContainer.cs index fe546184601dcdad8a25cbda96621c0a8429ef25..728b8cb6ff17dc6b5346a925e56ed042074ffa52 100644 --- a/VectoCore/Models/Simulation/Impl/JobContainer.cs +++ b/VectoCore/Models/Simulation/Impl/JobContainer.cs @@ -2,32 +2,41 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Common.Logging; +using TUGraz.VectoCore.Models.Simulation.Data; namespace TUGraz.VectoCore.Models.Simulation.Impl { - //todo: add job tracking (state of jobs, iteration, ...) - //todo: add job control (pause, stop) - - - /// <summary> - /// Container for simulation jobs. - /// </summary> - public class JobContainer - { - private readonly List<IVectoSimulator> _simulators = new List<IVectoSimulator>(); - - public void AddJob(IVectoSimulator sim) - { - _simulators.Add(sim); - } - - /// <summary> - /// Runs all jobs, waits until finished. - /// </summary> - public void RunSimulation() - { - LogManager.GetLogger(GetType()).Info("VectoSimulator started running. Starting Jobs."); - Task.WaitAll(_simulators.Select(job => Task.Factory.StartNew(job.Run)).ToArray()); - } - } + //todo: add job tracking (state of jobs, iteration, ...) + //todo: add job control (pause, stop) + + + /// <summary> + /// Container for simulation jobs. + /// </summary> + public class JobContainer + { + private readonly List<IVectoSimulator> _simulators = new List<IVectoSimulator>(); + + public JobContainer() {} + + public JobContainer(VectoJobData data) + { + _simulators.AddRange(SimulatorFactory.BuildJobs(data)); + } + + + public void AddJob(IVectoSimulator sim) + { + _simulators.Add(sim); + } + + /// <summary> + /// Runs all jobs, waits until finished. + /// </summary> + public void RunSimulation() + { + LogManager.GetLogger(GetType()).Info("VectoSimulator started running. Starting Jobs."); + Task.WaitAll(_simulators.Select(job => Task.Factory.StartNew(job.Run)).ToArray()); + } + } } \ No newline at end of file diff --git a/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs b/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs index ea7f928f131f3c577c63053b395cd223fb1589ab..55a360ac7faadee2165ad5c7b820311a05b3e5eb 100644 --- a/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs +++ b/VectoCore/Models/Simulation/Impl/SimulatorFactory.cs @@ -1,6 +1,7 @@ using System; -using Common.Logging; +using System.Collections.Generic; using TUGraz.VectoCore.Models.Simulation.Data; +using TUGraz.VectoCore.Models.SimulationComponent; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Impl; @@ -11,48 +12,109 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl /// <summary> /// Creates a time based engine only powertrain and simulation job for the given files. /// </summary> - /// <param name="engineFile"></param> - /// <param name="cycleFile"></param> - /// <param name="resultFile"></param> - /// <returns></returns> public static IVectoSimulator CreateTimeBasedEngineOnlyJob(string engineFile, string cycleFile, string resultFile) { - Action<string> debug = LogManager.GetLogger<SimulatorFactory>().Debug; + var builder = new SimulatorBuilder(engineOnly: true); - debug("Creating VehicleContainer."); - var container = new VehicleContainer(); + builder.AddEngine(engineFile); + builder.AddGearbox(); - debug("Creating cycle."); - var cycleData = DrivingCycleData.ReadFromFileEngineOnly(cycleFile); - var cycle = new EngineOnlyDrivingCycle(container, cycleData); + var simulator = builder.Build(cycleFile, resultFile, jobName: "", jobFileName: ""); + return simulator; + } + + public static IEnumerable<IVectoSimulator> BuildJobs(VectoJobData data) + { + foreach (var cycle in data.Cycles) { + var builder = new SimulatorBuilder(data.IsEngineOnly); + builder.AddVehicle(data.VehicleFile); + builder.AddEngine(data.EngineFile); + builder.AddGearbox(data.GearboxFile); + foreach (var aux in data.Aux) { + builder.AddAux(aux); + } - debug("Creating engine."); - var engineData = CombustionEngineData.ReadFromFile(engineFile); - var engine = new CombustionEngine(container, engineData); + builder.AddDriver(data.StartStop, data.OverSpeedEcoRoll, data.LookAheadCoasting, + data.AccelerationLimitingFile); - debug("Creating gearbox."); - var gearBox = new EngineOnlyGearbox(container); + var job = builder.Build(cycle, resultFile: "", jobName: "", jobFileName: data.FileName); - debug("Creating auxiliary"); - var aux = new EngineOnlyAuxiliary(container, new AuxiliariesDemandAdapter(cycleData)); + yield return job; + } + } + + public class SimulatorBuilder + { + private bool _engineOnly; + private VehicleContainer _container; + private ICombustionEngine _engine; + private IGearbox _gearBox; - debug("Connecting auxiliary with engine."); - aux.InShaft().Connect(engine.OutShaft()); + public SimulatorBuilder(bool engineOnly) + { + _engineOnly = engineOnly; + _container = new VehicleContainer(); + } - debug("Connecting gearbox with auxiliary."); - gearBox.InShaft().Connect(aux.OutShaft()); + public void AddVehicle(string vehicleFile) + { + throw new NotImplementedException(); + } - debug("Connecting cycle with gearbox."); - cycle.InShaft().Connect(gearBox.OutShaft()); + public void AddEngine(string engineFile) + { + var engineData = CombustionEngineData.ReadFromFile(engineFile); + _engine = new CombustionEngine(_container, engineData); + } - var dataWriter = new ModalDataWriter(resultFile); + public void AddGearbox(string gearboxFile = null) + { + if (_engineOnly) { + _gearBox = new EngineOnlyGearbox(_container); + } else { + _gearBox = new Gearbox(_container); + } + } - debug("Creating Simulator."); - //todo: load job file? - var simulator = new VectoSimulator("", "", container, cycle, dataWriter); + public void AddAux(VectoJobData.Data.DataBody.AuxData aux) + { + throw new NotImplementedException(); + } - return simulator; + public void AddDriver(VectoJobData.Data.DataBody.StartStopData startStop, + VectoJobData.Data.DataBody.OverSpeedEcoRollData overSpeedEcoRoll, + VectoJobData.Data.DataBody.LACData lookAheadCoasting, string accelerationLimitingFile) + { + throw new NotImplementedException(); + } + + public IVectoSimulator Build(string cycleFile, string resultFile, string jobName, string jobFileName) + { + var cycleData = DrivingCycleData.ReadFromFileEngineOnly(cycleFile); + var cycle = new EngineOnlyDrivingCycle(_container, cycleData); + + var aux = new EngineOnlyAuxiliary(_container, new AuxiliariesDemandAdapter(cycleData)); + aux.InShaft().Connect(_engine.OutShaft()); + + //todo: connect other auxiliaries + + // todo: connect retarder + // todo: connect clutch + + _gearBox.InShaft().Connect(aux.OutShaft()); + + // todo: connect Axle Gear + // todo: connect wheels + // todo: connect vehicle + // todo: connect driver + + cycle.InShaft().Connect(_gearBox.OutShaft()); + + var dataWriter = new ModalDataWriter(resultFile); + var simulator = new VectoSimulator(jobName, jobFileName, _container, cycle, dataWriter); + return simulator; + } } } } \ No newline at end of file diff --git a/VectoCore/Models/Simulation/Impl/VectoSimulator.cs b/VectoCore/Models/Simulation/Impl/VectoSimulator.cs index aaa18edd7ff2c3529bf1ecc487ca8fc85ef960da..e1bb0f6755404beeb323725b7f397fd056575722 100644 --- a/VectoCore/Models/Simulation/Impl/VectoSimulator.cs +++ b/VectoCore/Models/Simulation/Impl/VectoSimulator.cs @@ -1,141 +1,12 @@ using System; -using System.Collections.Generic; using System.Data; using Common.Logging; -using Newtonsoft.Json; using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Simulation.Data; -using TUGraz.VectoCore.Models.SimulationComponent; namespace TUGraz.VectoCore.Models.Simulation.Impl { - public class VectoJob - { - /// <summary> - /// A class which represents the json data format for serializing and deserializing the VectoJob files. - /// </summary> - /// <remarks> - ///{ - /// "Header": { - /// "CreatedBy": " ()", - /// "Date": "3/4/2015 2:09:13 PM", - /// "AppVersion": "2.0.4-beta3", - /// "FileVersion": 2 - /// }, - /// "Body": { - /// "SavedInDeclMode": false, - /// "VehicleFile": "24t Coach.vveh", - /// "EngineFile": "24t Coach.veng", - /// "GearboxFile": "24t Coach.vgbx", - /// "Cycles": [ - /// "W:\\VECTO\\CITnet\\VECTO\\bin\\Debug\\Declaration\\MissionCycles\\LOT2_rural Engine Only.vdri" - /// ], - /// "Aux": [ - /// { - /// "ID": "ALT1", - /// "Type": "Alternator", - /// "Path": "24t_Coach_ALT.vaux", - /// "Technology": "" - /// }, - /// { - /// "ID": "ALT2", - /// "Type": "Alternator", - /// "Path": "24t_Coach_ALT.vaux", - /// "Technology": "" - /// }, - /// { - /// "ID": "ALT3", - /// "Type": "Alternator", - /// "Path": "24t_Coach_ALT.vaux", - /// "Technology": "" - /// } - /// ], - /// "VACC": "Coach.vacc", - /// "EngineOnlyMode": true, - /// "StartStop": { - /// "Enabled": false, - /// "MaxSpeed": 5.0, - /// "MinTime": 0.0, - /// "Delay": 0 - /// }, - /// "LAC": { - /// "Enabled": true, - /// "Dec": -0.5, - /// "MinSpeed": 50.0 - /// }, - /// "OverSpeedEcoRoll": { - /// "Mode": "OverSpeed", - /// "MinSpeed": 70.0, - /// "OverSpeed": 5.0, - /// "UnderSpeed": 5.0 - /// } - /// } - /// } - /// </remarks> - public class Data - { - [JsonProperty(Required = Required.Always)] public DataHeader Header; - [JsonProperty(Required = Required.Always)] public DataBody Body; - - public class DataHeader - { - [JsonProperty(Required = Required.Always)] public string CreatedBy; - [JsonProperty(Required = Required.Always)] public DateTime Date; - [JsonProperty(Required = Required.Always)] public string AppVersion; - [JsonProperty(Required = Required.Always)] public double FileVersion; - } - - public class DataBody - { - [JsonProperty("SavedInDeclMode")] public bool SavedInDeclarationMode; - - [JsonProperty(Required = Required.Always)] public string VehicleFile; - [JsonProperty(Required = Required.Always)] public string EngineFile; - [JsonProperty(Required = Required.Always)] public string GearboxFile; - [JsonProperty(Required = Required.Always)] public IList<string> Cycles; - [JsonProperty(Required = Required.Always)] public IList<AuxData> Aux; - [JsonProperty(Required = Required.Always)] public string VACC; - [JsonProperty(Required = Required.Always)] public bool EngineOnlyMode; - [JsonProperty(Required = Required.Always)] public StartStopData StartStop; - [JsonProperty(Required = Required.Always)] public LACData LAC; - [JsonProperty(Required = Required.Always)] public OverSpeedEcoRollData OverSpeedEcoRoll; - - public class AuxData - { - [JsonProperty(Required = Required.Always)] public string ID; - [JsonProperty(Required = Required.Always)] public string Type; - [JsonProperty(Required = Required.Always)] public string Path; - [JsonProperty(Required = Required.Always)] public string Technology; - } - - public class StartStopData - { - [JsonProperty(Required = Required.Always)] public bool Enabled; - [JsonProperty(Required = Required.Always)] public double MaxSpeed; - [JsonProperty(Required = Required.Always)] public double MinTime; - [JsonProperty(Required = Required.Always)] public double Delay; - } - - public class LACData - { - [JsonProperty(Required = Required.Always)] public bool Enabled; - [JsonProperty(Required = Required.Always)] public double Dec; - [JsonProperty(Required = Required.Always)] public double MinSpeed; - } - - public class OverSpeedEcoRollData - { - [JsonProperty(Required = Required.Always)] public string Mode; - [JsonProperty(Required = Required.Always)] public double MinSpeed; - [JsonProperty(Required = Required.Always)] public double OverSpeed; - [JsonProperty(Required = Required.Always)] public double UnderSpeed; - } - } - } - } - - /// <summary> /// Simulator for one vecto simulation job. /// </summary> @@ -144,19 +15,19 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private TimeSpan _absTime = new TimeSpan(seconds: 0, minutes: 0, hours: 0); private TimeSpan _dt = new TimeSpan(seconds: 1, minutes: 0, hours: 0); - public VectoSimulator(string name, string fileName, IVehicleContainer container, IDrivingCycleOutPort cyclePort, + public VectoSimulator(string jobName, string jobFileName, IVehicleContainer container, IDrivingCycleOutPort cyclePort, IModalDataWriter dataWriter) { - Name = name; - FileName = fileName; + JobName = jobName; + JobFileName = jobFileName; Container = container; CyclePort = cyclePort; DataWriter = dataWriter; } - public string FileName { get; set; } + public string JobFileName { get; set; } - protected string Name { get; set; } + protected string JobName { get; set; } protected IDrivingCycleOutPort CyclePort { get; set; } protected IModalDataWriter DataWriter { get; set; } @@ -202,10 +73,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl /* - Name Unit Description + jobName Unit Description Job [-] Job number. Format is "x-y" with x = file number and y = cycle number - Input File [-] Name of the input file - Cycle [-] Name of the cycle file + Input File [-] jobName of the input file + Cycle [-] jobName of the cycle file time [s] Total simulation time distance [km] Total travelled distance speed [km/h] Average vehicle speed @@ -246,40 +117,40 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl static SummaryFile() { table = new DataTable(); - table.Columns.Add("Job [-]", typeof (string)); - table.Columns.Add("Input File [-]", typeof (string)); - table.Columns.Add("Cycle [-]", typeof (string)); - table.Columns.Add("Time [s]", typeof (double)); - table.Columns.Add("distance [km]", typeof (double)); - table.Columns.Add("speed [km/h]", typeof (double)); - table.Columns.Add("∆altitude [m]", typeof (double)); - table.Columns.Add("Ppos [kw]", typeof (double)); - table.Columns.Add("Pneg [kw]", typeof (double)); - table.Columns.Add("FC [g/km]", typeof (double)); - table.Columns.Add("FC-AUXc [g/km]", typeof (double)); - table.Columns.Add("FC-WHTCc [g/km]", typeof (double)); - table.Columns.Add("Pbrake [kw]", typeof (double)); - table.Columns.Add("EposICE [kwh]", typeof (double)); - table.Columns.Add("EnegICE [kwh]", typeof (double)); - table.Columns.Add("Eair [kwh]", typeof (double)); - table.Columns.Add("Eroll [kwh]", typeof (double)); - table.Columns.Add("Egrad [kwh]", typeof (double)); - table.Columns.Add("Eacc [kwh]", typeof (double)); - table.Columns.Add("Eaux [kwh]", typeof (double)); - table.Columns.Add("Eaux_xxx [kwh]", typeof (double)); - table.Columns.Add("Ebrake [kwh]", typeof (double)); - table.Columns.Add("Etransm [kwh]", typeof (double)); - table.Columns.Add("Eretarder [kwh]", typeof (double)); - table.Columns.Add("Mass [kg]", typeof (double)); - table.Columns.Add("Loading [kg]", typeof (double)); - table.Columns.Add("a [m/s2]", typeof (double)); - table.Columns.Add("a_pos [m/s2]", typeof (double)); - table.Columns.Add("a_neg [m/s2]", typeof (double)); - table.Columns.Add("Acc.Noise [m/s2]", typeof (double)); - table.Columns.Add("pAcc [%]", typeof (double)); - table.Columns.Add("pDec [%]", typeof (double)); - table.Columns.Add("pCruise [%]", typeof (double)); - table.Columns.Add("pStop [%]", typeof (double)); + table.Columns.Add("Job [-]", typeof(string)); + table.Columns.Add("Input File [-]", typeof(string)); + table.Columns.Add("Cycle [-]", typeof(string)); + table.Columns.Add("Time [s]", typeof(double)); + table.Columns.Add("distance [km]", typeof(double)); + table.Columns.Add("speed [km/h]", typeof(double)); + table.Columns.Add("∆altitude [m]", typeof(double)); + table.Columns.Add("Ppos [kw]", typeof(double)); + table.Columns.Add("Pneg [kw]", typeof(double)); + table.Columns.Add("FC [g/km]", typeof(double)); + table.Columns.Add("FC-AUXc [g/km]", typeof(double)); + table.Columns.Add("FC-WHTCc [g/km]", typeof(double)); + table.Columns.Add("Pbrake [kw]", typeof(double)); + table.Columns.Add("EposICE [kwh]", typeof(double)); + table.Columns.Add("EnegICE [kwh]", typeof(double)); + table.Columns.Add("Eair [kwh]", typeof(double)); + table.Columns.Add("Eroll [kwh]", typeof(double)); + table.Columns.Add("Egrad [kwh]", typeof(double)); + table.Columns.Add("Eacc [kwh]", typeof(double)); + table.Columns.Add("Eaux [kwh]", typeof(double)); + table.Columns.Add("Eaux_xxx [kwh]", typeof(double)); + table.Columns.Add("Ebrake [kwh]", typeof(double)); + table.Columns.Add("Etransm [kwh]", typeof(double)); + table.Columns.Add("Eretarder [kwh]", typeof(double)); + table.Columns.Add("Mass [kg]", typeof(double)); + table.Columns.Add("Loading [kg]", typeof(double)); + table.Columns.Add("a [m/s2]", typeof(double)); + table.Columns.Add("a_pos [m/s2]", typeof(double)); + table.Columns.Add("a_neg [m/s2]", typeof(double)); + table.Columns.Add("Acc.Noise [m/s2]", typeof(double)); + table.Columns.Add("pAcc [%]", typeof(double)); + table.Columns.Add("pDec [%]", typeof(double)); + table.Columns.Add("pCruise [%]", typeof(double)); + table.Columns.Add("pStop [%]", typeof(double)); } @@ -288,8 +159,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl //var data = new ModalResults(); var row = table.NewRow(); - //row["Job [-]"] = Name; - //row["Input File [-]"] = FileName; + //row["Job [-]"] = jobName; + //row["Input File [-]"] = jobFileName; //row["Cycle [-]"] = Container.CycleFileName(); //row["time [s]"] = data.Compute("Max(time)", ""); //row["distance [km]"] = data.Compute("Max(distance)", ""); @@ -311,7 +182,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl //todo auxiliaries //foreach (var auxCol in data.Auxiliaries) { - // row["Eaux_" + auxCol.Name + " [kwh]"] = data.Compute("Sum(aux_" + auxCol.Name + ")", ""); + // row["Eaux_" + auxCol.jobName + " [kwh]"] = data.Compute("Sum(aux_" + auxCol.jobName + ")", ""); //} @@ -339,7 +210,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl // (double) data.Compute("Sum(time_interval)", ""); table.ImportRow(row); - //VectoCSVFile.Write(FileName, table); + //VectoCSVFile.Write(jobFileName, table); } } } diff --git a/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs b/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs index 73916c84b2246defc79e4930eb74e5193f377cd1..ac6727a76cde63ccf151d9a3cf2c320b5986c7a1 100644 --- a/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs +++ b/VectoCore/Models/SimulationComponent/Data/DrivingCycleData.cs @@ -8,6 +8,12 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Data { + //todo: automatic parsing of si units - idea of kostis + // https://webgate.ec.europa.eu/CITnet/jira/browse/VECTO-80?focusedCommentId=1345532&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-1345532 + // VECTO-80 Kostis ANAGNOSTOPOULOS: + // It would be really nice to link the actual units used by data and column-headers, and being able to parse them back, + // using a format like this: foo [m/s^2], bar [kg (m/s)^2], + public class DrivingCycleData : SimulationComponentData { public enum CycleType diff --git a/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs b/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs index f1ef8218c1b7f94cb5820c1446974730e96d65ab..2923e1e1a10a7fe17470ba1de7dff8673166562b 100644 --- a/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs +++ b/VectoCore/Models/SimulationComponent/Data/Engine/FuelConsumptionMap.cs @@ -65,9 +65,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data.Engine { // delauney map needs is initialised with rpm, therefore the engineSpeed has to be converted. return - _fuelMap.Interpolate((double) torque, (double) engineSpeed.ConvertTo().Rounds.Per.Minute) - .SI() - .Kilo.Gramm.Per.Second; + _fuelMap.Interpolate(torque.Double(), engineSpeed.ConvertTo().Rounds.Per.Minute.Double()).SI().Kilo.Gramm.Per.Second; } private static class Fields diff --git a/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 46abd5a94fb77d1a4688255b222e0a521fadd28f..5f3aa67bee418e5107f91aa9c1882ac1a6384223 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -7,63 +7,62 @@ using TUGraz.VectoCore.Utils; namespace TUGraz.VectoCore.Models.SimulationComponent.Impl { - public class Gearbox : VectoSimulationComponent, IGearbox, ITnOutPort, ITnInPort - { - public Gearbox(IVehicleContainer container) : base(container) {} + public class Gearbox : VectoSimulationComponent, IGearbox, ITnOutPort, ITnInPort + { + public Gearbox(IVehicleContainer container) : base(container) {} - #region IInShaft + #region IInShaft - public ITnInPort InShaft() - { - throw new NotImplementedException(); - } + public ITnInPort InShaft() + { + throw new NotImplementedException(); + } - #endregion + #endregion - #region IOutShaft + #region IOutShaft - public ITnOutPort OutShaft() - { - throw new NotImplementedException(); - } + public ITnOutPort OutShaft() + { + throw new NotImplementedException(); + } - #endregion + #endregion - #region IGearboxCockpit + #region IGearboxCockpit - uint IGearboxCockpit.Gear() - { - throw new NotImplementedException(); - } + uint IGearboxCockpit.Gear() + { + throw new NotImplementedException(); + } - #endregion + #endregion - - #region ITnOutPort + #region ITnOutPort - IResponse ITnOutPort.Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond engineSpeed) - { - throw new NotImplementedException(); - } + IResponse ITnOutPort.Request(TimeSpan absTime, TimeSpan dt, NewtonMeter torque, PerSecond engineSpeed) + { + throw new NotImplementedException(); + } - #endregion + #endregion - #region ITnInPort + #region ITnInPort - void ITnInPort.Connect(ITnOutPort other) - { - throw new NotImplementedException(); - } + void ITnInPort.Connect(ITnOutPort other) + { + throw new NotImplementedException(); + } - #endregion + #endregion - #region VectoSimulationComponent + #region VectoSimulationComponent - public override void CommitSimulationStep(IModalDataWriter writer) - { - throw new NotImplementedException(); - } + public override void CommitSimulationStep(IModalDataWriter writer) + { + throw new NotImplementedException(); + } - #endregion - } + #endregion + } } \ No newline at end of file diff --git a/VectoCore/VectoCore.csproj b/VectoCore/VectoCore.csproj index cb3203cd32c26369082bc382823bc75f6c154678..78fabca70f995170279cb6853bb192a5989144f2 100644 --- a/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore.csproj @@ -129,6 +129,7 @@ <Compile Include="Models\SimulationComponent\Impl\Clutch.cs" /> <Compile Include="Models\SimulationComponent\Impl\Retarder.cs" /> <Compile Include="Models\SimulationComponent\IPowerTrainComponent.cs" /> + <Compile Include="Models\Simulation\Data\VectoJobData.cs" /> <Compile Include="Utils\Formulas.cs" /> <Compile Include="Utils\IntExtensionMethods.cs" /> <Compile Include="Utils\SI.cs" />