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

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

PTOCycleController

parent 773f8610
No related branches found
No related tags found
No related merge requests found
Showing
with 93 additions and 9 deletions
......@@ -106,6 +106,8 @@ namespace TUGraz.VectoCommon.InputData
/// The PTO Loss map for idling losses of the "consumer" part.
/// </summary>
DataTable PTOLossMap { get; }
DataTable PTOCycle { get; }
}
public interface IAxleEngineeringInputData : IAxleDeclarationInputData
......
......@@ -34,7 +34,6 @@ using System.Collections.Generic;
using System.Data;
using System.Linq;
using Newtonsoft.Json.Linq;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -238,6 +237,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
}
}
public DataTable PTOCycle
{
get { return ReadTableData(Body.GetEx(JsonKeys.Vehicle_PTO).GetEx<string>(JsonKeys.Vehicle_PTO_Cycle), "Cycle"); }
}
#endregion
public string Vendor
......
......@@ -307,7 +307,8 @@ namespace TUGraz.VectoCore.InputData.Reader.DataObjectAdapter
if (pto.PTOTransmissionType != "None") {
return new PTOTransmissionData {
TransmissionType = pto.PTOTransmissionType,
LossMap = PTOIdleLossMapReader.Create(pto.PTOLossMap)
LossMap = PTOIdleLossMapReader.Create(pto.PTOLossMap),
PTOCycle = DrivingCycleDataReader.ReadFromDataTable(pto.PTOCycle, CycleType.PTO, "PTO", false)
};
}
......
......@@ -55,6 +55,10 @@ namespace TUGraz.VectoCore.InputData.Reader
{
var cols = cycleData.Columns.Cast<DataColumn>().Select(c => c.ColumnName).ToArray();
if (PTOCycleDataParser.ValidateHeader(cols, false)) {
return CycleType.PTO;
}
if (PWheelCycleDataParser.ValidateHeader(cols, false)) {
return CycleType.PWheel;
}
......@@ -86,6 +90,8 @@ namespace TUGraz.VectoCore.InputData.Reader
return new MeasuredSpeedGearDataParser();
case CycleType.MeasuredSpeed:
return new MeasuredSpeedDataParser();
case CycleType.PTO:
return new PTOCycleDataParser();
default:
throw new ArgumentOutOfRangeException("type");
}
......@@ -294,6 +300,8 @@ namespace TUGraz.VectoCore.InputData.Reader
private static class Fields
{
public const string PTOTorque = "PTO Torque";
public const string EngineSpeedFull = "Engine Speed";
public const string PWheel = "Pwheel";
public const string Distance = "s";
public const string Time = "t";
......@@ -639,6 +647,44 @@ namespace TUGraz.VectoCore.InputData.Reader
CheckComboColumns(header, new[] { Fields.AirSpeedRelativeToVehicle, Fields.WindYawAngle }, throwExceptions);
}
}
/// <summary>
/// Parser for PTO Cycles.
/// </summary>
// <t> [s], <Engine Speed> [rpm], <PTO Torque> [Nm]
private class PTOCycleDataParser : AbstractCycleDataParser
{
public override IEnumerable<DrivingCycleData.DrivingCycleEntry> Parse(DataTable table, bool crossWindRequired)
{
ValidateHeader(table.Columns.Cast<DataColumn>().Select(col => col.ColumnName).ToArray());
var entries = table.Rows.Cast<DataRow>().Select(row => new DrivingCycleData.DrivingCycleEntry {
Time = row.ParseDouble(Fields.Time).SI<Second>(),
AngularVelocity = row.ParseDouble(Fields.EngineSpeedFull).RPMtoRad(),
Torque = row.ParseDouble(Fields.PTOTorque).SI<NewtonMeter>()
}).ToArray();
return entries;
}
public static bool ValidateHeader(string[] header, bool throwExceptions = true)
{
var requiredCols = new[] {
Fields.Time,
Fields.EngineSpeedFull,
Fields.PTOTorque
};
var allowedCols = new[] {
Fields.Time,
Fields.EngineSpeedFull,
Fields.PTOTorque
};
var allowAux = false;
return CheckColumns(header, allowedCols, requiredCols, throwExceptions, allowAux);
}
}
}
#endregion
......
......@@ -735,6 +735,15 @@ namespace TUGraz.VectoCore {
}
}
/// <summary>
/// Looks up a localized string similar to Cycle.
/// </summary>
internal static string Vehicle_PTO_Cycle {
get {
return ResourceManager.GetString("Vehicle_PTO_Cycle", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to LossMap.
/// </summary>
......
......@@ -178,6 +178,9 @@
</data>
<data name="Vehicle_PTO_LossMapFile" xml:space="preserve">
<value>LossMap</value>
</data>
<data name="Vehicle_PTO_Cycle" xml:space="preserve">
<value>Cycle</value>
</data>
<data name="Vehicle_PTO_Type" xml:space="preserve">
<value>Type</value>
......
......@@ -79,7 +79,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
if (data.Cycle.CycleType != CycleType.EngineOnly) {
throw new VectoException("CycleType must be EngineOnly.");
}
var container = new VehicleContainer(ExecutionMode.Engineering, _modData, _sumWriter) { RunData = data };
var cycle = new PowertrainDrivingCycle(container, data.Cycle);
......@@ -104,7 +104,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
// PWheelCycle --> AxleGear --> CycleClutch --> Engine <-- Aux
new PWheelCycle(container, data.Cycle, data.AxleGearData.AxleGear.Ratio,
gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio))
gearbox.ModelData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio))
.AddComponent(new AxleGear(container, data.AxleGearData))
.AddComponent(data.AngularGearData != null ? new AngularGear(container, data.AngularGearData) : null)
.AddComponent(gearbox, data.Retarder, data.PTOTransmission, container)
......@@ -187,8 +187,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
if (data.GearboxData.Type.ManualTransmission()) {
powertrain = powertrain.AddComponent(new Clutch(container, data.EngineData));
}
powertrain.AddComponent(new CombustionEngine(container, data.EngineData))
.AddAuxiliaries(container, data);
powertrain.AddComponent(new CombustionEngine(container, data.EngineData)).AddAuxiliaries(container, data);
_modData.HasTorqueConverter = data.GearboxData.Type.AutomaticTransmission();
......
......@@ -42,7 +42,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
DistanceBased,
PWheel,
MeasuredSpeed,
MeasuredSpeedGear
MeasuredSpeedGear,
PTO
}
public class DrivingCycleData : SimulationComponentData
......
......@@ -4,5 +4,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
{
public string TransmissionType;
public ILossMap LossMap;
public DrivingCycleData PTOCycle;
}
}
\ No newline at end of file
......@@ -30,11 +30,15 @@
*/
using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
namespace TUGraz.VectoCore.Models.SimulationComponent
{
/// <summary>
/// Defines interfaces for a gearbox.
/// </summary>
public interface IGearbox : IPowerTrainComponent, IAuxOutProvider, IGearboxInfo {}
public interface IGearbox : IPowerTrainComponent, IAuxOutProvider, IGearboxInfo
{
PTOEngineCycleController PTOController { get; set; }
}
}
\ No newline at end of file
......@@ -11,7 +11,8 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public abstract class AbstractGearbox<TStateType> :
StatefulProviderComponent<TStateType, ITnOutPort, ITnInPort, ITnOutPort>, ITnOutPort, ITnInPort, IGearbox, IClutchInfo
StatefulProviderComponent<TStateType, ITnOutPort, ITnInPort, ITnOutPort>, ITnOutPort, ITnInPort, IGearbox,
IClutchInfo
where TStateType : GearboxState, new()
{
/// <summary>
......@@ -87,6 +88,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
#endregion
public abstract bool ClutchClosed(Second absTime);
public PTOEngineCycleController PTOController { get; set; }
}
public class GearboxState : SimpleComponentState
......
......@@ -116,6 +116,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
}
}
CurrentState.Response = DriveTimeInterval(absTime, dt);
return CurrentState.Response;
}
......
......@@ -77,6 +77,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
AbsTime = 0.SI<Second>();
}
protected PowertrainDrivingCycle(IVehicleContainer container) : base(container)
{
AbsTime = 0.SI<Second>();
}
#region ISimulationOutPort
public IResponse Request(Second absTime, Meter ds)
......
......@@ -32,6 +32,7 @@
using System;
using System.Collections.Generic;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCore.InputData.Reader;
using TUGraz.VectoCore.Models.Connector.Ports;
using TUGraz.VectoCore.Models.Declaration;
using TUGraz.VectoCore.Models.Simulation;
......@@ -104,6 +105,7 @@ namespace TUGraz.VectoCore.Utils
if (atGbx != null) {
atGbx.IdleController = next.IdleController;
}
return next;
}
......@@ -114,6 +116,7 @@ namespace TUGraz.VectoCore.Utils
var aux = new GearboxAuxiliary(container);
aux.AddConstant("PTO_TRANSM", DeclarationData.PTOTransmission.Lookup(pto.TransmissionType));
aux.Add("PTO_IDLE", n => pto.LossMap.GetTorqueLoss(n) * n);
gearbox.PTOController = new PTOEngineCycleController(container, pto.PTOCycle);
}
switch (data.Type) {
......
......@@ -37,6 +37,7 @@ using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
using TUGraz.VectoCore.OutputData;
namespace TUGraz.VectoCore.Tests.Utils
......@@ -121,5 +122,7 @@ namespace TUGraz.VectoCore.Tests.Utils
{
throw new NotImplementedException();
}
public PTOEngineCycleController PTOController { get; set; }
}
}
\ No newline at end of file
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