diff --git a/VectoCore/Models/Simulation/DataBus/IDataBus.cs b/VectoCore/Models/Simulation/DataBus/IDataBus.cs index 60850eb1eaf16d2a8eb8a7ff13ea205e200386aa..35cb479e3369cd50f4e972648d047486d03cd3c5 100644 --- a/VectoCore/Models/Simulation/DataBus/IDataBus.cs +++ b/VectoCore/Models/Simulation/DataBus/IDataBus.cs @@ -23,7 +23,7 @@ namespace TUGraz.VectoCore.Models.Simulation.DataBus /// Defines interfaces for all different cockpits to access shared data of the powertrain. /// </summary> public interface IDataBus : IGearboxInfo, IEngineInfo, IVehicleInfo, IMileageCounter, IClutchInfo, IBrakes, - IRoadLookAhead, IDriverInfo + IRoadLookAhead, IDriverInfo, IDrivingCycleInfo { ExecutionMode ExecutionMode { get; set; } } diff --git a/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs b/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs index abbf86fb3502ad074bf1f91e66b91439631c050e..009952a63431a401d95cfd98c177780870f55981 100644 --- a/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs +++ b/VectoCore/Models/Simulation/Impl/PowertrainBuilder.cs @@ -58,7 +58,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl var cycle = new PowertrainDrivingCycle(_container, data.Cycle); var directAux = new Auxiliary(_container); - directAux.AddDirect(cycle); + directAux.AddDirect(); cycle.InPort().Connect(directAux.OutPort()); @@ -70,31 +70,35 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl private VehicleContainer BuildPWheel(VectoRunData data) { - var cycle = new PWheelCycle(_container, data.Cycle, data.AxleGearData.Ratio, - data.GearboxData.Gears.ToDictionary(g => g.Key, g => g.Value.Ratio)); + data.GearboxData.Type = GearboxType.PWheel; + var gearbox = GetGearbox(_container, data.GearboxData); + + var cycle = new PWheelCycle(_container, data.Cycle, data.AxleGearData.Ratio, (Gearbox)gearbox); var tmp = AddComponent(cycle, new AxleGear(_container, data.AxleGearData)); + switch (data.Retarder.Type) { case RetarderData.RetarderType.Primary: tmp = AddComponent(tmp, new Retarder(_container, data.Retarder.LossMap)); - tmp = AddComponent(tmp, GetGearbox(_container, data.GearboxData)); + tmp = AddComponent(tmp, gearbox); break; case RetarderData.RetarderType.Secondary: - tmp = AddComponent(tmp, GetGearbox(_container, data.GearboxData)); + tmp = AddComponent(tmp, gearbox); tmp = AddComponent(tmp, new Retarder(_container, data.Retarder.LossMap)); break; case RetarderData.RetarderType.None: - tmp = AddComponent(tmp, GetGearbox(_container, data.GearboxData)); + tmp = AddComponent(tmp, gearbox); break; case RetarderData.RetarderType.LossesIncludedInTransmission: - tmp = AddComponent(tmp, GetGearbox(_container, data.GearboxData)); + tmp = AddComponent(tmp, gearbox); break; default: throw new ArgumentOutOfRangeException(); } - var engine = new CombustionEngine(_container, data.EngineData); + // pWheel: pt1 disabled!! + var engine = new CombustionEngine(_container, data.EngineData, pt1Disabled: true); var clutch = new Clutch(_container, data.EngineData, engine.IdleController); // gearbox --> clutch @@ -109,10 +113,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl aux.AddConstant(auxData.ID, auxData.PowerDemand); break; case AuxiliaryDemandType.Direct: - aux.AddDirect(cycle); + aux.AddDirect(); break; case AuxiliaryDemandType.Mapping: - aux.AddMapping(auxData.ID, cycle, auxData.Data); + aux.AddMapping(auxData.ID, auxData.Data); break; } _modData.AddAuxiliary(auxData.ID); @@ -184,10 +188,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl aux.AddConstant(auxData.ID, auxData.PowerDemand); break; case AuxiliaryDemandType.Direct: - aux.AddDirect(cycle); + aux.AddDirect(); break; case AuxiliaryDemandType.Mapping: - aux.AddMapping(auxData.ID, cycle, auxData.Data); + aux.AddMapping(auxData.ID, auxData.Data); break; } _modData.AddAuxiliary(auxData.ID); @@ -218,6 +222,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl case GearboxType.Custom: strategy = new CustomShiftStrategy(data, container); break; + case GearboxType.PWheel: + strategy = new PWheelShiftStrategy(data, container); + break; default: throw new VectoSimulationException("Unknown Gearbox Type: {0}", data.Type); } diff --git a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs index 269795aa208f5019f15928ec376b99ef8d93ec10..8a275ce9c0123350af0984bde8b41be1b975e93c 100644 --- a/VectoCore/Models/Simulation/Impl/VehicleContainer.cs +++ b/VectoCore/Models/Simulation/Impl/VehicleContainer.cs @@ -41,6 +41,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl internal IClutchInfo Clutch; + internal IDrivingCycleInfo DrivingCycle; + internal IRoadLookAhead Road; internal ISimulationOutPort Cycle; @@ -150,7 +152,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl ExecutionMode executionMode = ExecutionMode.Declaration) { ModData = modData; - WriteSumData = writeSumData ?? delegate {}; + WriteSumData = writeSumData ?? delegate { }; ExecutionMode = executionMode; } @@ -179,9 +181,11 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl .If<IMileageCounter>(c => MilageCounter = c) .If<IBrakes>(c => Brakes = c) .If<IRoadLookAhead>(c => Road = c) - .If<IClutchInfo>(c => Clutch = c); + .If<IClutchInfo>(c => Clutch = c) + .If<IDrivingCycleInfo>(c => DrivingCycle = c); } + public void CommitSimulationStep(Second time, Second simulationInterval) { Log.Info("VehicleContainer committing simulation. time: {0}, dist: {1}, speed: {2}", time, Distance, VehicleSpeed); @@ -267,5 +271,10 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl public VectoRunData RunData { get; set; } public ExecutionMode ExecutionMode { get; set; } + + public CycleData CycleData + { + get { return DrivingCycle.CycleData; } + } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs index ba26f053bea9b5422357008b591d9ea879edfc0d..5295acdb7b386d4c25f468a295c042ee2ba0394c 100644 --- a/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs +++ b/VectoCore/Models/SimulationComponent/Data/CombustionEngineData.cs @@ -14,7 +14,6 @@ * limitations under the Licence. */ -using System; using System.ComponentModel.DataAnnotations; using TUGraz.VectoCore.Configuration; using TUGraz.VectoCore.Models.SimulationComponent.Data.Engine; diff --git a/VectoCore/Models/SimulationComponent/Data/GearboxType.cs b/VectoCore/Models/SimulationComponent/Data/GearboxType.cs index 959e4ad96db9647e52307512032dc15d9087977b..76617085a26737315bd8d821bf44590bf3459490 100644 --- a/VectoCore/Models/SimulationComponent/Data/GearboxType.cs +++ b/VectoCore/Models/SimulationComponent/Data/GearboxType.cs @@ -25,7 +25,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Data MT, // Manual Transmission AMT, // Automated Manual Transmission AT, // Automatic Transmission - Custom + Custom, + PWheel // for PWheel Mode where the gear is given by the cycle } public static class GearBoxTypeExtension diff --git a/VectoCore/Models/SimulationComponent/IDrivingCycleInfo.cs b/VectoCore/Models/SimulationComponent/IDrivingCycleInfo.cs index 2000576767efbed7b3a8450d458c8c2745ce7020..ee5ee7c216a6d503b779ee1b2b1140ae2a35f03c 100644 --- a/VectoCore/Models/SimulationComponent/IDrivingCycleInfo.cs +++ b/VectoCore/Models/SimulationComponent/IDrivingCycleInfo.cs @@ -27,6 +27,6 @@ namespace TUGraz.VectoCore.Models.SimulationComponent /// <summary> /// Returns the data samples for the current position in the cycle. /// </summary> - CycleData CycleData(); + CycleData CycleData { get; } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/IGearbox.cs b/VectoCore/Models/SimulationComponent/IGearbox.cs index 1bb5e8a55bb1349f2816eea12cccd584a828bd7b..928904091e8de14f7155791fadb44798d1e3e32d 100644 --- a/VectoCore/Models/SimulationComponent/IGearbox.cs +++ b/VectoCore/Models/SimulationComponent/IGearbox.cs @@ -14,7 +14,6 @@ * limitations under the Licence. */ -using TUGraz.VectoCore.Models.Connector.Ports; using TUGraz.VectoCore.Models.Simulation.DataBus; namespace TUGraz.VectoCore.Models.SimulationComponent diff --git a/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs b/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs index 8e9120850e61d8b8d735b9900d3ba2a34beb46dc..7939c6e6f9626ba059e1b43efc5040204510a295 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Auxiliary.cs @@ -122,21 +122,21 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl _auxDict[auxId] = speed => powerDemand; } - public void AddDirect(IDrivingCycleInfo cycle) + public void AddDirect() { - _auxDict[DirectAuxiliaryId] = speed => cycle.CycleData().LeftSample.AdditionalAuxPowerDemand; + _auxDict[DirectAuxiliaryId] = speed => DataBus.CycleData.LeftSample.AdditionalAuxPowerDemand; } - public void AddMapping(string auxId, IDrivingCycleInfo cycle, AuxiliaryData data) + public void AddMapping(string auxId, AuxiliaryData data) { - if (!cycle.CycleData().LeftSample.AuxiliarySupplyPower.ContainsKey("Aux_" + auxId)) { + if (!DataBus.CycleData.LeftSample.AuxiliarySupplyPower.ContainsKey("Aux_" + auxId)) { var error = string.Format("driving cycle does not contain column for auxiliary: {0}", auxId); Log.Error(error); throw new VectoException(error); } _auxDict[auxId] = speed => { - var powerSupply = cycle.CycleData().LeftSample.AuxiliarySupplyPower["Aux_" + auxId]; + var powerSupply = DataBus.CycleData.LeftSample.AuxiliarySupplyPower["Aux_" + auxId]; var nAuxiliary = speed * data.TransmissionRatio; var powerAuxOut = powerSupply / data.EfficiencyToSupply; var powerAuxIn = data.GetPowerDemand(nAuxiliary, powerAuxOut); diff --git a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs index 27b26b43b8a78fc2322d0f596c6ab49d688527d6..239e16dea1668b72a8d8e8e5724578fd384d9346 100644 --- a/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs +++ b/VectoCore/Models/SimulationComponent/Impl/CombustionEngine.cs @@ -36,6 +36,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> public class CombustionEngine : VectoSimulationComponent, ICombustionEngine, ITnOutPort { + public bool PT1Disabled { get; set; } + public enum EngineOperationMode { Idle, @@ -63,9 +65,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl protected internal readonly CombustionEngineData Data; - public CombustionEngine(IVehicleContainer cockpit, CombustionEngineData data) + public CombustionEngine(IVehicleContainer cockpit, CombustionEngineData data, bool pt1Disabled = false) : base(cockpit) { + PT1Disabled = pt1Disabled; Data = data; PreviousState.OperationMode = EngineOperationMode.Idle; @@ -148,6 +151,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } CurrentState.EnginePower = LimitEnginePower(requestedEnginePower); + + // = requestedEnginePower; //todo + _currentState.EnginePowerLoss; + CurrentState.EngineTorque = CurrentState.EnginePower / CurrentState.EngineSpeed; + var delta = requestedEnginePower - CurrentState.EnginePower; if (delta.IsGreater(0.SI<Watt>(), Constants.SimulationSettings.EnginePowerSearchTolerance)) { @@ -160,15 +167,19 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } + if (delta.IsSmaller(0.SI<Watt>(), Constants.SimulationSettings.EnginePowerSearchTolerance)) { Log.Debug("requested engine power is below drag power: delta: {0}", delta); - return new ResponseUnderload { Delta = delta, EnginePowerRequest = requestedEnginePower, Source = this }; + return new ResponseUnderload { + AbsTime = absTime, + Delta = delta, + EnginePowerRequest = requestedEnginePower, + Source = this + }; } - UpdateEngineState(CurrentState.EnginePower); - // = requestedEnginePower; //todo + _currentState.EnginePowerLoss; - CurrentState.EngineTorque = CurrentState.EnginePower / CurrentState.EngineSpeed; + UpdateEngineState(CurrentState.EnginePower); return new ResponseSuccess { EnginePowerRequest = requestedEnginePower }; } @@ -315,11 +326,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl var stationaryFullLoadTorque = Data.FullLoadCurve.FullLoadStationaryTorque(angularVelocity); var stationaryFullLoadPower = stationaryFullLoadTorque * angularVelocity; - var pt1 = Data.FullLoadCurve.PT1(angularVelocity).Value(); - var powerRatio = PreviousState.EnginePower / stationaryFullLoadPower; - var tStarPrev = pt1 * Math.Log(1 / (1 - powerRatio.Value())).SI<Second>(); - var tStar = tStarPrev + PreviousState.dt; - var dynFullPower = stationaryFullLoadPower * (1 - Math.Exp((-tStar / pt1).Value())); + + Watt dynFullPower; + if (PT1Disabled) { + dynFullPower = stationaryFullLoadPower; + } else { + var pt1 = Data.FullLoadCurve.PT1(angularVelocity).Value(); + var powerRatio = PreviousState.EnginePower / stationaryFullLoadPower; + var tStarPrev = pt1 * Math.Log(1 / (1 - powerRatio.Value())).SI<Second>(); + var tStar = tStarPrev + PreviousState.dt; + dynFullPower = stationaryFullLoadPower * (1 - Math.Exp((-tStar / pt1).Value())); + } CurrentState.StationaryFullLoadPower = stationaryFullLoadPower; CurrentState.StationaryFullLoadTorque = stationaryFullLoadTorque; @@ -330,6 +347,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl Log.Debug("FullLoad: torque: {0}, power: {1}", CurrentState.DynamicFullLoadTorque, CurrentState.DynamicFullLoadPower); } + protected bool IsFullLoad(Watt requestedPower, Watt maxPower) { var testValue = (requestedPower / maxPower).Cast<Scalar>() - 1.0; diff --git a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs index be0ae3dc568118efbfe5fbd4ffa833eabb3a79c3..88fec3b22c0c30f7f239f626cff86d432cbb2865 100644 --- a/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/DistanceBasedDrivingCycle.cs @@ -326,14 +326,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl return LookAhead((LookaheadTimeSafetyMargin * DataBus.VehicleSpeed * time).Cast<Meter>()); } - public CycleData CycleData() + public CycleData CycleData { - return new CycleData { - AbsTime = CurrentState.AbsTime, - AbsDistance = CurrentState.Distance, - LeftSample = CycleIntervalIterator.LeftSample, - RightSample = CycleIntervalIterator.RightSample - }; + get + { + return new CycleData { + AbsTime = CurrentState.AbsTime, + AbsDistance = CurrentState.Distance, + LeftSample = CycleIntervalIterator.LeftSample, + RightSample = CycleIntervalIterator.RightSample + }; + } } public class DrivingCycleEnumerator : IEnumerator<DrivingCycleData.DrivingCycleEntry> diff --git a/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs index 13d26cbb2fd5c165ad2d561c1a46ed82b32f8dc0..dc7db18669265dfb16933ea5a802931c67e25920 100644 --- a/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs +++ b/VectoCore/Models/SimulationComponent/Impl/Gearbox.cs @@ -54,7 +54,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// <summary> /// True if gearbox is disengaged (no gear is set). /// </summary> - protected bool Disengaged = true; + protected internal bool Disengaged = true; /// <summary> /// The power loss for the mod data. @@ -219,7 +219,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl ShiftTime = absTime; } IResponse retVal; - if (ClutchClosed(absTime)) { + if (DataBus.ClutchClosed(absTime)) { retVal = RequestGearEngaged(absTime, dt, torque, angularVelocity, dryRun); } else { retVal = RequestGearDisengaged(absTime, dt, torque, angularVelocity, dryRun); diff --git a/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs index c0a53d5f3a4753addf408a8439a43757b591553f..da764ef3c9fca65c7f656a88c3b616d1228d9ac3 100644 --- a/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/PowertrainDrivingCycle.cs @@ -98,16 +98,25 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl }; } - var request = NextComponent.Request(absTime, dt, LeftSample.Current.Torque, LeftSample.Current.AngularVelocity); - request.Switch() - .Case<ResponseSuccess>(() => { - // if response successfull update internal AbsTime for DoCommit - AbsTime = absTime + dt; + var response = NextComponent.Request(absTime, dt, LeftSample.Current.Torque, + DataBus.ClutchClosed(absTime) ? LeftSample.Current.AngularVelocity : 0.SI<PerSecond>()); + + AbsTime = absTime + dt; + + response.Switch() + .Case<ResponseUnderload>(r => { + Log.Warn("PowertrainDrivingCycle got an underload response. Using PDrag."); + response = new ResponseSuccess(); }) + .Case<ResponseOverload>(r => { + Log.Warn("PowertrainDrivingCycle got an underload response. Using PFullLoad."); + response = new ResponseSuccess(); + }) + .Case<ResponseSuccess>(() => { }) .Default( r => { throw new UnexpectedResponseException("PowertrainDrivingCycle received an unexpected response.", r); }); - return request; + return response; } public IResponse Initialize() @@ -155,42 +164,58 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #endregion - public CycleData CycleData() + public CycleData CycleData { - return new CycleData { - AbsTime = LeftSample.Current.Time, - AbsDistance = null, - LeftSample = LeftSample.Current, - RightSample = RightSample.Current, - }; + get + { + return new CycleData { + AbsTime = LeftSample.Current.Time, + AbsDistance = null, + LeftSample = LeftSample.Current, + RightSample = RightSample.Current, + }; + } } } /// <summary> /// Driving Cycle for the PWheel driving cycle. /// </summary> - public class PWheelCycle : PowertrainDrivingCycle, IDriverInfo + public class PWheelCycle : PowertrainDrivingCycle, IDriverInfo, IClutchInfo { + public Gearbox Gearbox { get; set; } + /// <summary> /// Initializes a new instance of the <see cref="PWheelCycle"/> class. /// </summary> /// <param name="container">The container.</param> /// <param name="cycle">The cycle.</param> /// <param name="axleRatio">The axle ratio.</param> - /// <param name="gears">The gears.</param> - public PWheelCycle(IVehicleContainer container, DrivingCycleData cycle, double axleRatio, - IDictionary<uint, double> gears) : base(container, cycle) + /// <param name="gearbox"></param> + public PWheelCycle(IVehicleContainer container, DrivingCycleData cycle, double axleRatio, Gearbox gearbox) + : base(container, cycle) { - if (!gears.ContainsKey(0)) { - gears[0] = 1; - } + Gearbox = gearbox; foreach (var entry in Data.Entries) { - entry.AngularVelocity = entry.AngularVelocity / (axleRatio * gears[entry.Gear]); + entry.AngularVelocity = entry.AngularVelocity / + (axleRatio * (entry.Gear == 0 ? 1 : Gearbox.Data.Gears[entry.Gear].Ratio)); entry.Torque = entry.PWheel / entry.AngularVelocity; } } + public override IResponse Request(Second absTime, Second dt) + { + if (RightSample.Current == null) { + return new ResponseCycleFinished { Source = this }; + } + + Gearbox.Gear = LeftSample.Current.Gear; + Gearbox.Disengaged = LeftSample.Current.Gear == 0; + return base.Request(absTime, dt); + } + + protected override void DoWriteModalResults(IModalDataContainer container) { container[ModalResultField.Pwheel] = LeftSample.Current.PWheel; @@ -204,15 +229,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl /// </summary> public bool VehicleStopped { - get { return LeftSample.Current.AngularVelocity.IsEqual(0); } - } - - public override IResponse Request(Second absTime, Second dt) - { - if (RightSample.Current == null) { - return new ResponseCycleFinished { Source = this }; - } - return base.Request(absTime, dt); + get { return LeftSample.Current.PWheel.Abs().IsEqual(0); } } /// <summary> @@ -224,5 +241,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } #endregion + + public bool ClutchClosed(Second absTime) + { + return LeftSample.Current.Gear != 0; + } } } \ No newline at end of file diff --git a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs index f3d903da647bbd938ffafb76f6e1a636e9a1093d..c848101f63292e3db5525ba439f005fa035ab270 100644 --- a/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs +++ b/VectoCore/Models/SimulationComponent/Impl/ShiftStrategy.cs @@ -351,6 +351,34 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl } } + /// <summary> + /// Shift Strategy for PWheel Mode. The Cycle should set the gear, therefore the shift strategy has nothing to do. + /// </summary> + public class PWheelShiftStrategy : ShiftStrategy + { + public PWheelShiftStrategy(GearboxData data, IDataBus bus) : base(data, bus) {} + + public override uint Engage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) + { + return DataBus.CycleData.LeftSample.Gear; + } + + public override void Disengage(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) {} + + public override bool ShiftRequired(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outAngularVelocity, + NewtonMeter inTorque, + PerSecond inAngularSpeed, uint gear, Second lastShiftTime) + { + return false; + } + + public override uint InitGear(Second absTime, Second dt, NewtonMeter outTorque, PerSecond outEngineSpeed) + { + return DataBus.CycleData.LeftSample.Gear; + } + } + + // TODO Implement ATShiftStrategy public class ATShiftStrategy : ShiftStrategy { diff --git a/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs b/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs index 023c813d825fce478de3053a85407c7a944bfacd..ed9528a465ae40f35e9bd036702397277b0a8aae 100644 --- a/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs +++ b/VectoCore/Models/SimulationComponent/Impl/TimeBasedDrivingCycle.cs @@ -123,15 +123,17 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl #endregion - public CycleData CycleData() + public CycleData CycleData { - //todo: leftsample, rightsample - return new CycleData { - AbsTime = 0.SI<Second>(), - AbsDistance = 0.SI<Meter>(), - LeftSample = null, - RightSample = null - }; + get + { + return new CycleData { + AbsTime = 0.SI<Second>(), + AbsDistance = 0.SI<Meter>(), + LeftSample = null, + RightSample = null + }; + } } } } \ No newline at end of file diff --git a/VectoCore/Properties/Version.cs b/VectoCore/Properties/Version.cs index c7c3ff8d8cc369083f3c3838f01cff395b3f68fc..9f3230e428f7ea6ea249efecdd6d9491066944fe 100644 --- a/VectoCore/Properties/Version.cs +++ b/VectoCore/Properties/Version.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright 2015 European Union * * Licensed under the EUPL (the "Licence"); @@ -13,7 +13,6 @@ * See the Licence for the specific language governing permissions and * limitations under the Licence. */ - using System.Reflection; -[assembly: AssemblyVersion("3.0.1.334")] -[assembly: AssemblyFileVersion("3.0.1.334")] \ No newline at end of file +[assembly: AssemblyVersion("3.0.1.397")] +[assembly: AssemblyFileVersion("3.0.1.397")] diff --git a/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs b/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs index 777e3885b100d88223efa249ad09cc74a48d4246..256cd6cf9ac9b7ee1a6d5643db03a400133c8712 100644 --- a/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs +++ b/VectoCoreTest/Integration/EngineOnlyCycle/EngineOnlyCycleTest.cs @@ -49,7 +49,7 @@ namespace TUGraz.VectoCore.Tests.Integration.EngineOnlyCycle MockSimulationDataFactory.CreateEngineDataFromFile(TestContext.DataRow["EngineFile"].ToString()); var aux = new Auxiliary(vehicle); - aux.AddDirect(cycle); + aux.AddDirect(); var engine = new EngineOnlyCombustionEngine(vehicle, engineData); diff --git a/VectoCoreTest/Models/Simulation/AuxTests.cs b/VectoCoreTest/Models/Simulation/AuxTests.cs index 7b3f002e1e69b8077d9f3ae89187fc9de08a355a..480ba8b969a4096d82c26431aed6c61d462691ad 100644 --- a/VectoCoreTest/Models/Simulation/AuxTests.cs +++ b/VectoCoreTest/Models/Simulation/AuxTests.cs @@ -137,7 +137,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var aux = new Auxiliary(container); aux.InPort().Connect(port); - aux.AddDirect(cycle); + aux.AddDirect(); var speed = 2358.RPMtoRad(); var torque = 500.SI<NewtonMeter>(); @@ -179,8 +179,8 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation // efficiency_engine = 0.96 // efficiency_supply = 0.98 - aux.AddMapping("ALT1", cycle, auxData); - aux.AddDirect(cycle); + aux.AddMapping("ALT1", auxData); + aux.AddDirect(); var constPower = 1200.SI<Watt>(); aux.AddConstant("CONSTANT", constPower); @@ -238,7 +238,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation // efficiency_engine = 0.96 // efficiency_supply = 0.98 - aux.AddMapping(auxId, cycle, auxData); + aux.AddMapping(auxId, auxData); var speed = 578.22461991.RPMtoRad(); // = 2358 (nAuxiliary) * ratio var torque = 500.SI<NewtonMeter>(); @@ -276,7 +276,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation var cycle = new MockDrivingCycle(container, data); var aux = new Auxiliary(container); - AssertHelper.Exception<VectoException>(() => aux.AddMapping("NONEXISTING_AUX", cycle, null), + AssertHelper.Exception<VectoException>(() => aux.AddMapping("NONEXISTING_AUX", null), "driving cycle does not contain column for auxiliary: NONEXISTING_AUX"); } diff --git a/VectoCoreTest/Models/Simulation/PwheelModeTests.cs b/VectoCoreTest/Models/Simulation/PwheelModeTests.cs index d36859bfb71c54c9c0561e296af470db3784d8e2..688636ea4c0b8ff40330117d1bb5eabd2f2387e3 100644 --- a/VectoCoreTest/Models/Simulation/PwheelModeTests.cs +++ b/VectoCoreTest/Models/Simulation/PwheelModeTests.cs @@ -35,25 +35,31 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation Stream cycleFile = new MemoryStream(Encoding.UTF8.GetBytes(inputData)); var drivingCycle = DrivingCycleDataReader.ReadFromStream(cycleFile, CycleType.PWheel); - var cycle = new PWheelCycle(container, drivingCycle, 2.3, new Dictionary<uint, double> { { 2, 3.5 } }); - Assert.AreEqual(cycle.CycleData().LeftSample.Time, 1.SI<Second>()); - Assert.AreEqual(cycle.CycleData().RightSample.Time, 2.SI<Second>()); + var gearbox = new Gearbox(container, + new GearboxData { + Gears = new Dictionary<uint, GearData> { { 1, new GearData { Ratio = 2.0 } }, { 2, new GearData { Ratio = 3.5 } } } + }, new PWheelShiftStrategy(null, container)); - Assert.AreEqual(1748.RPMtoRad() / (2.3 * 3.5), cycle.CycleData().LeftSample.AngularVelocity); - Assert.AreEqual(1400.RPMtoRad() / (2.3 * 3.5), cycle.CycleData().RightSample.AngularVelocity); + var cycle = new PWheelCycle(container, drivingCycle, 2.3, gearbox); - Assert.AreEqual(89.SI().Kilo.Watt, cycle.CycleData().LeftSample.PWheel); - Assert.AreEqual(120.SI().Kilo.Watt, cycle.CycleData().RightSample.PWheel); + Assert.AreEqual(container.CycleData.LeftSample.Time, 1.SI<Second>()); + Assert.AreEqual(container.CycleData.RightSample.Time, 2.SI<Second>()); - Assert.AreEqual(2u, cycle.CycleData().LeftSample.Gear); - Assert.AreEqual(2u, cycle.CycleData().RightSample.Gear); + Assert.AreEqual(1748.RPMtoRad() / (2.3 * 3.5), container.CycleData.LeftSample.AngularVelocity); + Assert.AreEqual(1400.RPMtoRad() / (2.3 * 3.5), container.CycleData.RightSample.AngularVelocity); - Assert.AreEqual(1300.SI<Watt>(), cycle.CycleData().LeftSample.AdditionalAuxPowerDemand); - Assert.AreEqual(400.SI<Watt>(), cycle.CycleData().RightSample.AdditionalAuxPowerDemand); + Assert.AreEqual(89.SI().Kilo.Watt, container.CycleData.LeftSample.PWheel); + Assert.AreEqual(120.SI().Kilo.Watt, container.CycleData.RightSample.PWheel); - Assert.AreEqual(89.SI().Kilo.Watt / (1748.RPMtoRad() / (2.3 * 3.5)), cycle.CycleData().LeftSample.Torque); - Assert.AreEqual(120.SI().Kilo.Watt / (1400.RPMtoRad() / (2.3 * 3.5)), cycle.CycleData().RightSample.Torque); + Assert.AreEqual(2u, container.CycleData.LeftSample.Gear); + Assert.AreEqual(2u, container.CycleData.RightSample.Gear); + + Assert.AreEqual(1300.SI<Watt>(), container.CycleData.LeftSample.AdditionalAuxPowerDemand); + Assert.AreEqual(400.SI<Watt>(), container.CycleData.RightSample.AdditionalAuxPowerDemand); + + Assert.AreEqual(89.SI().Kilo.Watt / (1748.RPMtoRad() / (2.3 * 3.5)), container.CycleData.LeftSample.Torque); + Assert.AreEqual(120.SI().Kilo.Watt / (1400.RPMtoRad() / (2.3 * 3.5)), container.CycleData.RightSample.Torque); } /// <summary> @@ -119,7 +125,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.WaitFinished(); - Assert.IsTrue(jobContainer.Runs.All(r => r.Success)); + Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Join("", jobContainer.Runs.Select(r => r.ExecException))); ResultFileHelper.TestSumFile(@"TestData\Results\Pwheel\Atego_ges.v2.vsum", @"TestData\Jobs\Pwheel.vsum"); @@ -147,8 +153,7 @@ namespace TUGraz.VectoCore.Tests.Models.Simulation jobContainer.WaitFinished(); - Assert.IsTrue(jobContainer.Runs.All(r => r.Success), - string.Join("", jobContainer.Runs.Select(r => r.ExecException.ToString()))); + Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Join("", jobContainer.Runs.Select(r => r.ExecException))); ResultFileHelper.TestModFile(@"TestData\Results\Pwheel\Atego_HDVCO2_RD_#1_AuxStd.vmod", @"TestData\Jobs\Pwheel_ultimate_RD_#1_Pwheel_AuxStd.vmod"); diff --git a/VectoCoreTest/Utils/MockAuxiliaryDemand.cs b/VectoCoreTest/Utils/MockAuxiliaryDemand.cs index 95bc6de3c8ef51686249cc34d645afaa875f5117..b62d773dd2d5e7f0244b31b90da338243720bc97 100644 --- a/VectoCoreTest/Utils/MockAuxiliaryDemand.cs +++ b/VectoCoreTest/Utils/MockAuxiliaryDemand.cs @@ -47,14 +47,17 @@ namespace TUGraz.VectoCore.Tests.Utils } - public CycleData CycleData() + public CycleData CycleData { - return new CycleData { - AbsTime = 0.SI<Second>(), - AbsDistance = 0.SI<Meter>(), - LeftSample = _left.Current, - RightSample = _right.Current - }; + get + { + return new CycleData { + AbsTime = 0.SI<Second>(), + AbsDistance = 0.SI<Meter>(), + LeftSample = _left.Current, + RightSample = _right.Current + }; + } } protected override void DoWriteModalResults(IModalDataContainer container)