Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

adding vehicle container (and thus run-data) as argument to constructor for...

adding vehicle container (and thus run-data) as argument to constructor for driver strategy, new PTO-related input parameters on vehicle level, new aux type for roadsweeper aux, testdata, testcase, adding simulation interval and dryrun as parameter to aux calculation, change ptoactive in driving cycle from bool to enum, new aux ids for pto operation, adapt driver strategy to pto operation
parent 464ef01f
Branches
Tags
No related merge requests found
Showing
with 209 additions and 47 deletions
...@@ -74,6 +74,9 @@ Public Class Vehicle ...@@ -74,6 +74,9 @@ Public Class Vehicle
public VehicleTankSystem as TankSystem? public VehicleTankSystem as TankSystem?
public GearDuringPTODrive As UInteger?
Public EngineSpeedDuringPTODrive As PerSecond
Public Sub New() Public Sub New()
_path = "" _path = ""
_filePath = "" _filePath = ""
...@@ -710,6 +713,18 @@ Public Class Vehicle ...@@ -710,6 +713,18 @@ Public Class Vehicle
End Get End Get
End Property End Property
Public ReadOnly Property PTO_DriveGear As UInteger? Implements IVehicleEngineeringInputData.PTO_DriveGear
get
return gearDuringPTODrive
End Get
End Property
Public ReadOnly Property PTO_DriveEngineSpeed As PerSecond Implements IVehicleEngineeringInputData.PTO_DriveEngineSpeed
get
Return EngineSpeedDuringPTODrive
End Get
End Property
Public ReadOnly Property ZeroEmissionVehicle As Boolean Implements IVehicleDeclarationInputData.ZeroEmissionVehicle Public ReadOnly Property ZeroEmissionVehicle As Boolean Implements IVehicleDeclarationInputData.ZeroEmissionVehicle
get get
Return DeclarationData.Vehicle.ZeroEmissionVehicleDefault Return DeclarationData.Vehicle.ZeroEmissionVehicleDefault
......
...@@ -79,6 +79,12 @@ namespace TUGraz.VectoCommon.InputData ...@@ -79,6 +79,12 @@ namespace TUGraz.VectoCommon.InputData
new IVehicleComponentsEngineering Components { get; } new IVehicleComponentsEngineering Components { get; }
new IAdvancedDriverAssistantSystemsEngineering ADAS { get; } new IAdvancedDriverAssistantSystemsEngineering ADAS { get; }
// input parameters for road sweeper use case
uint? PTO_DriveGear { get; }
PerSecond PTO_DriveEngineSpeed { get; }
} }
public interface IAdvancedDriverAssistantSystemsEngineering public interface IAdvancedDriverAssistantSystemsEngineering
......
...@@ -51,7 +51,8 @@ namespace TUGraz.VectoCore.Configuration ...@@ -51,7 +51,8 @@ namespace TUGraz.VectoCore.Configuration
public static class IDs public static class IDs
{ {
public static string PTOTransmission = "PTO_TRANSM"; public const string PTOTransmission = "PTO_TRANSM";
public const string PTOWhileDrive = "PTO_RoadSweeping";
public const string Fan = "FAN"; public const string Fan = "FAN";
public const string SteeringPump = "STP"; public const string SteeringPump = "STP";
public const string ElectricSystem = "ES"; public const string ElectricSystem = "ES";
......
...@@ -226,6 +226,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON ...@@ -226,6 +226,16 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
get { return this; } get { return this; }
} }
public uint? PTO_DriveGear
{
get { return VehicleData.PTO_DriveGear; }
}
public PerSecond PTO_DriveEngineSpeed
{
get { return VehicleData.PTO_DriveEngineSpeed; }
}
public IAirdragEngineeringInputData AirdragInputData public IAirdragEngineeringInputData AirdragInputData
{ {
get { return AirdragData; } get { return AirdragData; }
......
...@@ -171,6 +171,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON ...@@ -171,6 +171,14 @@ namespace TUGraz.VectoCore.InputData.FileIO.JSON
get { return null; } get { return null; }
} }
public uint? PTO_DriveGear { get {
return Body["GearDuringPTODrive"] != null ? Body["GearDuringPTODrive"].Value<uint>() : (uint?)null;
} }
public PerSecond PTO_DriveEngineSpeed { get {
return Body["EngineSpeedDuringPTODrive"] != null ? Body.GetEx<double>("EngineSpeedDuringPTODrive").RPMtoRad() : null;
} }
public virtual AxleConfiguration AxleConfiguration public virtual AxleConfiguration AxleConfiguration
{ {
get { get {
......
...@@ -172,6 +172,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider ...@@ -172,6 +172,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Engineering.DataProvider
get { return null; } get { return null; }
} }
public virtual uint? PTO_DriveGear { get { return null; } }
public virtual PerSecond PTO_DriveEngineSpeed { get { return null; } }
public IAdvancedDriverAssistantSystemsEngineering ADAS public IAdvancedDriverAssistantSystemsEngineering ADAS
{ {
......
...@@ -240,7 +240,7 @@ namespace TUGraz.VectoCore.InputData.Reader ...@@ -240,7 +240,7 @@ namespace TUGraz.VectoCore.InputData.Reader
// vehicle stops. duplicate current distance entry with 0 waiting time // vehicle stops. duplicate current distance entry with 0 waiting time
var tmp = new DrivingCycleData.DrivingCycleEntry(entry) { var tmp = new DrivingCycleData.DrivingCycleEntry(entry) {
StoppingTime = 0.SI<Second>(), StoppingTime = 0.SI<Second>(),
PTOActive = false, PTOActive = PTOActivity.Inactive,
RoadGradient = entry.RoadGradient, RoadGradient = entry.RoadGradient,
VehicleTargetSpeed = i < entries.Count - 1 ? entries[i + 1].VehicleTargetSpeed : 0.SI<MeterPerSecond>() VehicleTargetSpeed = i < entries.Count - 1 ? entries[i + 1].VehicleTargetSpeed : 0.SI<MeterPerSecond>()
}; };
...@@ -306,11 +306,20 @@ namespace TUGraz.VectoCore.InputData.Reader ...@@ -306,11 +306,20 @@ namespace TUGraz.VectoCore.InputData.Reader
return false; return false;
} }
if (first.PTOActive != second.PTOActive) {
return false;
}
if (first.PTOPowerDemandDuringDrive != null && !first.PTOPowerDemandDuringDrive.IsEqual(second.PTOPowerDemandDuringDrive)) {
return false;
}
return true; return true;
} }
public static class Fields public static class Fields
{ {
public const string PTOPowerDemand = "P_PTO";
public const string PTOTorque = "PTO Torque"; public const string PTOTorque = "PTO Torque";
public const string EngineSpeedFull = "Engine speed"; public const string EngineSpeedFull = "Engine speed";
public const string PWheel = "Pwheel"; public const string PWheel = "Pwheel";
...@@ -424,7 +433,8 @@ namespace TUGraz.VectoCore.InputData.Reader ...@@ -424,7 +433,8 @@ namespace TUGraz.VectoCore.InputData.Reader
crossWindRequired ? row.ParseDouble(Fields.AirSpeedRelativeToVehicle).KMPHtoMeterPerSecond() : null, crossWindRequired ? row.ParseDouble(Fields.AirSpeedRelativeToVehicle).KMPHtoMeterPerSecond() : null,
WindYawAngle = crossWindRequired ? row.ParseDoubleOrGetDefault(Fields.WindYawAngle) : 0, WindYawAngle = crossWindRequired ? row.ParseDoubleOrGetDefault(Fields.WindYawAngle) : 0,
AuxiliarySupplyPower = row.GetAuxiliaries(), AuxiliarySupplyPower = row.GetAuxiliaries(),
PTOActive = table.Columns.Contains(Fields.PTOActive) && row.Field<string>(Fields.PTOActive) == "1" PTOActive = table.Columns.Contains(Fields.PTOActive) ? (PTOActivity)row.Field<string>(Fields.PTOActive).ToInt() : PTOActivity.Inactive,
PTOPowerDemandDuringDrive = table.Columns.Contains(Fields.PTOPowerDemand) ? row.ParseDouble(Fields.PTOPowerDemand).SI(Unit.SI.Kilo.Watt).Cast<Watt>() : null
}); });
} }
...@@ -444,7 +454,8 @@ namespace TUGraz.VectoCore.InputData.Reader ...@@ -444,7 +454,8 @@ namespace TUGraz.VectoCore.InputData.Reader
Fields.RoadGradient, Fields.RoadGradient,
Fields.AirSpeedRelativeToVehicle, Fields.AirSpeedRelativeToVehicle,
Fields.WindYawAngle, Fields.WindYawAngle,
Fields.PTOActive Fields.PTOActive,
Fields.PTOPowerDemand,
}; };
const bool allowAux = true; const bool allowAux = true;
......
...@@ -76,6 +76,16 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl ...@@ -76,6 +76,16 @@ namespace TUGraz.VectoCore.InputData.Reader.Impl
var angledriveData = dao.CreateAngledriveData(vehicle.Components.AngledriveInputData); var angledriveData = dao.CreateAngledriveData(vehicle.Components.AngledriveInputData);
var ptoTransmissionData = dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData); var ptoTransmissionData = dao.CreatePTOTransmissionData(vehicle.Components.PTOTransmissionInputData);
if (InputDataProvider.JobInputData.Vehicle.PTO_DriveGear.HasValue &&
InputDataProvider.JobInputData.Vehicle.PTO_DriveEngineSpeed != null) {
driver.PTODriveMinSpeed = InputDataProvider.JobInputData.Vehicle.PTO_DriveEngineSpeed /
axlegearData.AxleGear.Ratio /
gearboxData.Gears[InputDataProvider.JobInputData.Vehicle.PTO_DriveGear.Value].Ratio /
(angledriveData?.Angledrive.Ratio ?? 1.0) * vehicle.DynamicTyreRadius;
driver.PTODriveRoadsweepingGear = InputDataProvider.JobInputData.Vehicle.PTO_DriveGear.Value;
}
return InputDataProvider.JobInputData.Cycles.Select(cycle => { return InputDataProvider.JobInputData.Cycles.Select(cycle => {
var drivingCycle = CyclesCache.ContainsKey(cycle.CycleData.Source) var drivingCycle = CyclesCache.ContainsKey(cycle.CycleData.Source)
? CyclesCache[cycle.CycleData.Source] ? CyclesCache[cycle.CycleData.Source]
......
...@@ -145,12 +145,22 @@ namespace TUGraz.VectoCore.Models.Simulation.Data ...@@ -145,12 +145,22 @@ namespace TUGraz.VectoCore.Models.Simulation.Data
} }
} }
if (runData.Cycle != null && runData.Cycle.Entries.Any(e => e.PTOActive)) { if (runData.Cycle != null && runData.Cycle.Entries.Any(e => e.PTOActive == PTOActivity.PTOActivityDuringStop)) {
if (runData.PTO == null || runData.PTO.PTOCycle == null) { if (runData.PTO == null || runData.PTO.PTOCycle == null) {
return new ValidationResult("PTOCycle is used in DrivingCycle, but is not defined in Vehicle-Data."); return new ValidationResult("PTOCycle is used in DrivingCycle, but is not defined in Vehicle-Data.");
} }
} }
if (runData.EngineData.PTORoadSweepEngineSpeed != null) {
if (runData.EngineData.IdleSpeed.IsGreater(runData.EngineData.PTORoadSweepEngineSpeed)) {
return new ValidationResult("PTO Operating enginespeed is below engine idling speed");
}
if (runData.EngineData.FullLoadCurves[0].N95hSpeed.IsSmaller(runData.EngineData.PTORoadSweepEngineSpeed)) {
return new ValidationResult("PTO operating enginespeed is above n_95h");
}
}
return ValidationResult.Success; return ValidationResult.Success;
} }
......
...@@ -236,7 +236,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -236,7 +236,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
// DistanceBasedDrivingCycle --> driver --> vehicle --> wheels // DistanceBasedDrivingCycle --> driver --> vehicle --> wheels
// --> axleGear --> (retarder) --> gearBox --> (retarder) --> clutch --> engine <-- Aux // --> axleGear --> (retarder) --> gearBox --> (retarder) --> clutch --> engine <-- Aux
var cycle = new DistanceBasedDrivingCycle(container, data.Cycle); var cycle = new DistanceBasedDrivingCycle(container, data.Cycle);
var powertrain = cycle.AddComponent(new Driver(container, data.DriverData, new DefaultDriverStrategy())) var powertrain = cycle.AddComponent(new Driver(container, data.DriverData, new DefaultDriverStrategy(container)))
.AddComponent(new Vehicle(container, data.VehicleData, data.AirdragData)) .AddComponent(new Vehicle(container, data.VehicleData, data.AirdragData))
.AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia)) .AddComponent(new Wheels(container, data.VehicleData.DynamicTyreRadius, data.VehicleData.WheelsInertia))
.AddComponent(new Brakes(container)) .AddComponent(new Brakes(container))
...@@ -309,10 +309,17 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ...@@ -309,10 +309,17 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOTransmission); Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOTransmission);
aux.Add(Constants.Auxiliaries.IDs.PTOConsumer, aux.Add(Constants.Auxiliaries.IDs.PTOConsumer,
n => container.PTOActive ? null : data.PTO.LossMap.GetTorqueLoss(n) * n); (n, dt, dryRun) => container.PTOActive ? null : data.PTO.LossMap.GetTorqueLoss(n) * n);
container.ModalData.AddAuxiliary(Constants.Auxiliaries.IDs.PTOConsumer, container.ModalData.AddAuxiliary(Constants.Auxiliaries.IDs.PTOConsumer,
Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOConsumer); Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOConsumer);
} }
if (data.ExecutionMode == ExecutionMode.Engineering && data.Cycle.Entries.Any(x => x.PTOActive == PTOActivity.PTOActivityRoadSweeping)) {
var rdSwpAux = new RoadSweeperAuxiliary(container);
aux.Add(Constants.Auxiliaries.IDs.PTOWhileDrive, (nEng, dt, dryRun) => rdSwpAux.PowerDemand(nEng, dt, dryRun));
container.ModalData.AddAuxiliary(Constants.Auxiliaries.IDs.PTOWhileDrive, Constants.Auxiliaries.PowerPrefix + Constants.Auxiliaries.IDs.PTOWhileDrive);
}
return aux; return aux;
} }
......
...@@ -42,6 +42,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -42,6 +42,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
[CustomValidation(typeof(CombustionEngineData), "ValidateData")] [CustomValidation(typeof(CombustionEngineData), "ValidateData")]
public class CombustionEngineData : SimulationComponentData public class CombustionEngineData : SimulationComponentData
{ {
[Required, SIRange(1000 * 1E-6, 20000 * 1E-6)] [Required, SIRange(1000 * 1E-6, 20000 * 1E-6)]
public CubicMeter Displacement { get; internal set; } public CubicMeter Displacement { get; internal set; }
...@@ -84,6 +85,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -84,6 +85,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public FuelData.Entry FuelData { get; internal set; } public FuelData.Entry FuelData { get; internal set; }
public PerSecond PTORoadSweepEngineSpeed;
public CombustionEngineData() public CombustionEngineData()
{ {
WHTCUrban = 1; WHTCUrban = 1;
...@@ -117,6 +120,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -117,6 +120,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
ADASCorrectionFactor = ADASCorrectionFactor, ADASCorrectionFactor = ADASCorrectionFactor,
CertificationNumber = CertificationNumber, CertificationNumber = CertificationNumber,
CertificationMethod = CertificationMethod, CertificationMethod = CertificationMethod,
PTORoadSweepEngineSpeed = PTORoadSweepEngineSpeed,
}; };
} }
......
...@@ -45,6 +45,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -45,6 +45,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
[Required, ValidateObject] public AccelerationCurveData AccelerationCurve; [Required, ValidateObject] public AccelerationCurveData AccelerationCurve;
public MeterPerSecond PTODriveMinSpeed { get; set; }
public uint PTODriveRoadsweepingGear { get; set; }
public static DriverMode ParseDriverMode(string mode) public static DriverMode ParseDriverMode(string mode)
{ {
return mode.Replace("-", "").ParseEnum<DriverMode>(); return mode.Replace("-", "").ParseEnum<DriverMode>();
......
...@@ -141,6 +141,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -141,6 +141,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
AuxiliarySupplyPower = new Dictionary<string, Watt>(entry.AuxiliarySupplyPower); AuxiliarySupplyPower = new Dictionary<string, Watt>(entry.AuxiliarySupplyPower);
EngineSpeed = entry.EngineSpeed; EngineSpeed = entry.EngineSpeed;
FanSpeed = entry.FanSpeed; FanSpeed = entry.FanSpeed;
PTOPowerDemandDuringDrive = entry.PTOPowerDemandDuringDrive;
} }
/// <summary> /// <summary>
...@@ -236,7 +237,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -236,7 +237,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
/// <summary> /// <summary>
/// Flag if PTO Cycle is active or not. /// Flag if PTO Cycle is active or not.
/// </summary> /// </summary>
public bool PTOActive; public PTOActivity PTOActive;
public PerSecond EngineSpeed; public PerSecond EngineSpeed;
...@@ -251,6 +252,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data ...@@ -251,6 +252,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data
public PerSecond WheelSpeedRight; public PerSecond WheelSpeedRight;
// road sweeper application
public Watt PTOPowerDemandDuringDrive;
} }
} }
public enum PTOActivity
{
Inactive = 0,
PTOActivityDuringStop = 1,
PTOActivityRoadSweeping = 2,
PTOActivityWhileDrive = 3,
}
} }
\ No newline at end of file
...@@ -35,6 +35,7 @@ using TUGraz.VectoCore.Configuration; ...@@ -35,6 +35,7 @@ using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
...@@ -45,6 +46,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -45,6 +46,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{ {
protected readonly uint MaxStartGear; protected readonly uint MaxStartGear;
protected uint _nextGear; protected uint _nextGear;
private uint DesiredGearRoadsweeping;
public AMTShiftStrategy(VectoRunData runData, IDataBus dataBus) : base(runData.GearboxData, dataBus) public AMTShiftStrategy(VectoRunData runData, IDataBus dataBus) : base(runData.GearboxData, dataBus)
{ {
...@@ -56,6 +58,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -56,6 +58,9 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
runData.VehicleData.DynamicTyreRadius; runData.VehicleData.DynamicTyreRadius;
var minEngineSpeed = (runData.EngineData.FullLoadCurves[0].RatedSpeed - runData.EngineData.IdleSpeed) * var minEngineSpeed = (runData.EngineData.FullLoadCurves[0].RatedSpeed - runData.EngineData.IdleSpeed) *
Constants.SimulationSettings.ClutchClosingSpeedNorm + runData.EngineData.IdleSpeed; Constants.SimulationSettings.ClutchClosingSpeedNorm + runData.EngineData.IdleSpeed;
DesiredGearRoadsweeping = runData.DriverData.PTODriveRoadsweepingGear;
foreach (var gearData in ModelData.Gears.Reverse()) { foreach (var gearData in ModelData.Gears.Reverse()) {
if (ModelData.StartSpeed * transmissionRatio * gearData.Value.Ratio > minEngineSpeed) { if (ModelData.StartSpeed * transmissionRatio * gearData.Value.Ratio > minEngineSpeed) {
MaxStartGear = gearData.Key; MaxStartGear = gearData.Key;
...@@ -179,6 +184,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -179,6 +184,20 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return true; return true;
} }
// PTO Active while drive (roadsweeping) shift rules
if (DataBus.CycleData.LeftSample.PTOActive == PTOActivity.PTOActivityRoadSweeping) {
if (gear == DesiredGearRoadsweeping) {
return false;
}
if (gear > DesiredGearRoadsweeping) {
if (IsAboveDownShiftCurve(DesiredGearRoadsweeping, inTorque, inAngularVelocity)) {
_nextGear = DesiredGearRoadsweeping;
return true;
}
}
}
// normal shift when all requirements are fullfilled ------------------ // normal shift when all requirements are fullfilled ------------------
var minimumShiftTimePassed = (lastShiftTime + ModelData.ShiftTime).IsSmallerOrEqual(absTime); var minimumShiftTimePassed = (lastShiftTime + ModelData.ShiftTime).IsSmallerOrEqual(absTime);
if (!minimumShiftTimePassed) { if (!minimumShiftTimePassed) {
......
...@@ -38,6 +38,7 @@ using TUGraz.VectoCommon.Models; ...@@ -38,6 +38,7 @@ using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils; using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Configuration;
using TUGraz.VectoCore.Models.Connector.Ports.Impl; using TUGraz.VectoCore.Models.Connector.Ports.Impl;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.DataBus; using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Utils;
...@@ -60,8 +61,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -60,8 +61,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected readonly Dictionary<DrivingMode, IDriverMode> DrivingModes = new Dictionary<DrivingMode, IDriverMode>(); protected readonly Dictionary<DrivingMode, IDriverMode> DrivingModes = new Dictionary<DrivingMode, IDriverMode>();
public DefaultDriverStrategy() public readonly MeterPerSecond PTODriveMinSpeed;
public DefaultDriverStrategy(IVehicleContainer dataBus)
{ {
PTODriveMinSpeed = dataBus.RunData.DriverData.PTODriveMinSpeed;
DrivingModes.Add(DrivingMode.DrivingModeDrive, new DriverModeDrive() { DriverStrategy = this }); DrivingModes.Add(DrivingMode.DrivingModeDrive, new DriverModeDrive() { DriverStrategy = this });
DrivingModes.Add(DrivingMode.DrivingModeBrake, new DriverModeBrake() { DriverStrategy = this }); DrivingModes.Add(DrivingMode.DrivingModeBrake, new DriverModeBrake() { DriverStrategy = this });
CurrentDrivingMode = DrivingMode.DrivingModeDrive; CurrentDrivingMode = DrivingMode.DrivingModeDrive;
...@@ -422,6 +426,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -422,6 +426,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (DriverStrategy.OverspeedAllowed(targetVelocity, prohibitOverspeed)) { if (DriverStrategy.OverspeedAllowed(targetVelocity, prohibitOverspeed)) {
velocity += DriverData.OverSpeedEcoRoll.OverSpeed; velocity += DriverData.OverSpeedEcoRoll.OverSpeed;
} }
if (DataBus.CycleData.LeftSample.PTOActive == PTOActivity.PTOActivityRoadSweeping) {
velocity = DriverStrategy.PTODriveMinSpeed;
targetVelocity = velocity;
}
if (DataBus.GearboxType.AutomaticTransmission() || DataBus.ClutchClosed(absTime)) { if (DataBus.GearboxType.AutomaticTransmission() || DataBus.ClutchClosed(absTime)) {
for (var i = 0; i < 3; i++) { for (var i = 0; i < 3; i++) {
var retVal = HandleRequestEngaged(absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocity, debug); var retVal = HandleRequestEngaged(absTime, ds, targetVelocity, gradient, prohibitOverspeed, velocity, debug);
......
...@@ -152,7 +152,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -152,7 +152,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
private IResponse DoFirstSimulationInterval(Second absTime) private IResponse DoFirstSimulationInterval(Second absTime)
{ {
// we are exactly on an entry in the cycle. // we are exactly on an entry in the cycle.
var stopTime = Left.PTOActive && IdleController != null var stopTime = Left.PTOActive == PTOActivity.PTOActivityDuringStop && IdleController != null
? Left.StoppingTime + IdleController.Duration ? Left.StoppingTime + IdleController.Duration
: Left.StoppingTime; : Left.StoppingTime;
...@@ -178,7 +178,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -178,7 +178,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
private Second GetStopTimeInterval() private Second GetStopTimeInterval()
{ {
if (!Left.PTOActive || IdleController == null) { if (Left.PTOActive != PTOActivity.PTOActivityDuringStop || IdleController == null) {
if ((Left.StoppingTime - PreviousState.WaitTime).IsGreater(2 * Constants.SimulationSettings.TargetTimeInterval, if ((Left.StoppingTime - PreviousState.WaitTime).IsGreater(2 * Constants.SimulationSettings.TargetTimeInterval,
0.1 * Constants.SimulationSettings.TargetTimeInterval)) { 0.1 * Constants.SimulationSettings.TargetTimeInterval)) {
return 2 * Constants.SimulationSettings.TargetTimeInterval; return 2 * Constants.SimulationSettings.TargetTimeInterval;
...@@ -307,7 +307,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -307,7 +307,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
_intervalProlonged = false; _intervalProlonged = false;
var stopTime = Left.PTOActive && IdleController != null var stopTime = Left.PTOActive == PTOActivity.PTOActivityDuringStop && IdleController != null
? Left.StoppingTime + IdleController.Duration ? Left.StoppingTime + IdleController.Duration
: Left.StoppingTime; : Left.StoppingTime;
...@@ -318,7 +318,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -318,7 +318,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
// we have reached the end of the current interval in the cycle, move on... // we have reached the end of the current interval in the cycle, move on...
CycleIntervalIterator.MoveNext(); CycleIntervalIterator.MoveNext();
stopTime = Left.PTOActive && IdleController != null stopTime = Left.PTOActive == PTOActivity.PTOActivityDuringStop && IdleController != null
? Left.StoppingTime + IdleController.Duration ? Left.StoppingTime + IdleController.Duration
: Left.StoppingTime; : Left.StoppingTime;
} }
......
...@@ -47,8 +47,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -47,8 +47,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public class EngineAuxiliary : StatefulVectoSimulationComponent<EngineAuxiliary.State>, IAuxInProvider, public class EngineAuxiliary : StatefulVectoSimulationComponent<EngineAuxiliary.State>, IAuxInProvider,
IAuxPort IAuxPort
{ {
protected readonly Dictionary<string, Func<PerSecond, Watt>> Auxiliaries = protected readonly Dictionary<string, Func<PerSecond, Second, bool, Watt>> Auxiliaries =
new Dictionary<string, Func<PerSecond, Watt>>(); new Dictionary<string, Func<PerSecond, Second, bool, Watt>>();
public EngineAuxiliary(IVehicleContainer container) : base(container) {} public EngineAuxiliary(IVehicleContainer container) : base(container) {}
...@@ -64,7 +64,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -64,7 +64,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <param name="powerDemand"></param> /// <param name="powerDemand"></param>
public void AddConstant(string auxId, Watt powerDemand) public void AddConstant(string auxId, Watt powerDemand)
{ {
Add(auxId, _ => powerDemand); Add(auxId, (nEng, dt, dryRun) => powerDemand);
} }
/// <summary> /// <summary>
...@@ -73,12 +73,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -73,12 +73,12 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <param name="auxId"></param> /// <param name="auxId"></param>
public void AddCycle(string auxId) public void AddCycle(string auxId)
{ {
Add(auxId, _ => DataBus.CycleData.LeftSample.AdditionalAuxPowerDemand); Add(auxId, (nEng, dt, dryRun) => DataBus.CycleData.LeftSample.AdditionalAuxPowerDemand);
} }
public void AddCycle(string auxId, Func<DrivingCycleData.DrivingCycleEntry, Watt> powerLossFunc) public void AddCycle(string auxId, Func<DrivingCycleData.DrivingCycleEntry, Watt> powerLossFunc)
{ {
Add(auxId, _ => powerLossFunc(DataBus.CycleData.LeftSample)); Add(auxId, (nEng, dt, dryRun) => powerLossFunc(DataBus.CycleData.LeftSample));
} }
/// <summary> /// <summary>
...@@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -95,7 +95,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
throw new VectoException(error); throw new VectoException(error);
} }
Add(auxId, speed => { Add(auxId, (speed, dt, dryRun) => {
var powerSupply = DataBus.CycleData.LeftSample.AuxiliarySupplyPower[auxId]; var powerSupply = DataBus.CycleData.LeftSample.AuxiliarySupplyPower[auxId];
var nAuxiliary = speed * data.TransmissionRatio; var nAuxiliary = speed * data.TransmissionRatio;
var powerAuxOut = powerSupply / data.EfficiencyToSupply; var powerAuxOut = powerSupply / data.EfficiencyToSupply;
...@@ -109,7 +109,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -109,7 +109,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// </summary> /// </summary>
/// <param name="auxId"></param> /// <param name="auxId"></param>
/// <param name="powerLossFunction"></param> /// <param name="powerLossFunction"></param>
public void Add(string auxId, Func<PerSecond, Watt> powerLossFunction) public void Add(string auxId, Func<PerSecond, Second, bool, Watt> powerLossFunction)
{ {
Auxiliaries[auxId] = powerLossFunction; Auxiliaries[auxId] = powerLossFunction;
} }
...@@ -121,7 +121,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -121,7 +121,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return 0.SI<NewtonMeter>(); return 0.SI<NewtonMeter>();
} }
return ComputePowerDemand(angularSpeed, false) / angularSpeed; return ComputePowerDemand(angularSpeed, Constants.SimulationSettings.TargetTimeInterval, false) / angularSpeed;
} }
/// <summary> /// <summary>
...@@ -144,16 +144,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ...@@ -144,16 +144,16 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
CurrentState.AngularSpeed = angularSpeed; CurrentState.AngularSpeed = angularSpeed;
} }
if (avgAngularSpeed.IsGreater(0)) { if (avgAngularSpeed.IsGreater(0)) {
return ComputePowerDemand(avgAngularSpeed, dryRun) / avgAngularSpeed; return ComputePowerDemand(avgAngularSpeed, dt, dryRun) / avgAngularSpeed;
} }
return 0.SI<NewtonMeter>(); return 0.SI<NewtonMeter>();
} }
protected Watt ComputePowerDemand(PerSecond engineSpeed, bool dryRun) protected Watt ComputePowerDemand(PerSecond engineSpeed, Second dt, bool dryRun)
{ {
var powerDemands = new Dictionary<string, Watt>(Auxiliaries.Count); var powerDemands = new Dictionary<string, Watt>(Auxiliaries.Count);
foreach (var item in Auxiliaries) { foreach (var item in Auxiliaries) {
var value = item.Value(engineSpeed); var value = item.Value(engineSpeed, dt, dryRun);
if (value != null) { if (value != null) {
powerDemands[item.Key] = value; powerDemands[item.Key] = value;
} }
......
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.Simulation.DataBus;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
public class RoadSweeperAuxiliary
{
private IDataBus DataBus;
public RoadSweeperAuxiliary(IVehicleContainer container)
{
DataBus = container;
}
public Watt PowerDemand(PerSecond engineSpeed, Second dt, bool dryRun)
{
var left = DataBus.CycleData.LeftSample;
//var acc = DataBus.DriverAcceleration;
//var vehicleSpeed = DataBus.VehicleSpeed;
var powerDemand = 0.SI<Watt>();
if (left.PTOActive == PTOActivity.PTOActivityRoadSweeping) {
// todo: iterate over cycle from left to right and compute pto energy and then average power demand
powerDemand = left.PTOPowerDemandDuringDrive;
}
return powerDemand;
}
}
}
...@@ -253,6 +253,7 @@ ...@@ -253,6 +253,7 @@
<Compile Include="InputData\FileIO\XML\Declaration\IXMLDeclarationInputDataReader.cs" /> <Compile Include="InputData\FileIO\XML\Declaration\IXMLDeclarationInputDataReader.cs" />
<Compile Include="InputData\FileIO\XML\IXMLInputDataReader.cs" /> <Compile Include="InputData\FileIO\XML\IXMLInputDataReader.cs" />
<Compile Include="InputData\FileIO\XML\XMLInputDataNinjectModule.cs" /> <Compile Include="InputData\FileIO\XML\XMLInputDataNinjectModule.cs" />
<Compile Include="Models\SimulationComponent\Impl\RoadSweeperAuxiliary.cs" />
<Compile Include="Models\Simulation\ISimulatorFactory.cs" /> <Compile Include="Models\Simulation\ISimulatorFactory.cs" />
<Compile Include="Models\Simulation\ISimulatorFactoryFactory.cs" /> <Compile Include="Models\Simulation\ISimulatorFactoryFactory.cs" />
<Compile Include="Models\Simulation\SimulationFactoryNinjectModule.cs" /> <Compile Include="Models\Simulation\SimulationFactoryNinjectModule.cs" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment