Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

Merge pull request #173 in VECTO/vecto-sim from...

Merge pull request #173 in VECTO/vecto-sim from ~EMQUARIMA/vecto-sim:feature/VECTO-260-aaux-lookup-cycle to develop

* commit 'b3d54015':
  disabled drawing graph of delaunay map
  added all cycles to generic coach
  make sure, commits are called in a particular order (for important components)
  [Driver] set operating point property in response
  adding new test-files
  gearbox: when halted: engage gear
  added new test with a different gearbox (12t truck)
  use actionRoll in abort criterion; use vehicleStopped property
  renamed method parameter to be more accurate
  only compensate torque in brakes when stopping if clutch is engaged (otherwise no operating point might be found)
  omit vehicleContainer and VectoRunData in error message on validation
parents e4232b51 b3d54015
No related branches found
No related tags found
No related merge requests found
{
"Header": {
"CreatedBy": " ()",
"Date": "06.04.2016 15:08:33",
"Date": "03.05.2016 08:08:42",
"AppVersion": "2.2",
"FileVersion": 2
},
......@@ -11,6 +11,10 @@
"EngineFile": "24t Coach.veng",
"GearboxFile": "24t Coach.vgbx",
"Cycles": [
"Interurban_Bus.vdri",
"Citybus_Heavy_Urban.vdri",
"Citybus_Suburban.vdri",
"Citybus_Urban.vdri",
"Coach.vdri"
],
"AuxiliaryAssembly": "BusAuxiliaries",
......
......@@ -29,9 +29,11 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -47,7 +49,9 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
{
public class VehicleContainer : LoggingObject, IVehicleContainer
{
internal readonly IList<VectoSimulationComponent> Components = new List<VectoSimulationComponent>();
internal readonly IList<Tuple<VectoSimulationComponent, int>> Components =
new List<Tuple<VectoSimulationComponent, int>>();
internal IEngineInfo Engine;
internal IGearboxInfo Gearbox;
internal IVehicleInfo Vehicle;
......@@ -192,19 +196,33 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
public virtual void AddComponent(VectoSimulationComponent component)
{
Components.Add(component);
var commitPriority = 0;
component.Switch()
.If<IEngineInfo>(c => Engine = c)
.If<IEngineInfo>(c => {
Engine = c;
commitPriority = 2;
})
.If<IDriverInfo>(c => Driver = c)
.If<IGearboxInfo>(c => Gearbox = c)
.If<IVehicleInfo>(c => Vehicle = c)
.If<IGearboxInfo>(c => {
Gearbox = c;
commitPriority = 4;
})
.If<IVehicleInfo>(c => {
Vehicle = c;
commitPriority = 5;
})
.If<ISimulationOutPort>(c => Cycle = c)
.If<IMileageCounter>(c => MilageCounter = c)
.If<IBrakes>(c => Brakes = c)
.If<IRoadLookAhead>(c => Road = c)
.If<IClutchInfo>(c => Clutch = c)
.If<IDrivingCycleInfo>(c => DrivingCycle = c);
.If<IDrivingCycleInfo>(c => {
DrivingCycle = c;
commitPriority = 3;
});
Components.Add(Tuple.Create(component, commitPriority));
}
......@@ -212,7 +230,8 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
{
Log.Info("VehicleContainer committing simulation. time: {0}, dist: {1}, speed: {2}", time,
ExecutionMode == ExecutionMode.EngineOnly ? null : Distance, VehicleSpeed);
foreach (var component in Components) {
foreach (var component in Components.OrderBy(x => x.Item2).Reverse().Select(x => x.Item1)) {
component.CommitSimulationStep(ModData);
}
......@@ -237,7 +256,7 @@ namespace TUGraz.VectoCore.Models.Simulation.Impl
public IReadOnlyCollection<VectoSimulationComponent> SimulationComponents()
{
return new ReadOnlyCollection<VectoSimulationComponent>(Components);
return new ReadOnlyCollection<VectoSimulationComponent>(Components.Select(x => x.Item1).ToList());
}
public Meter Distance
......
......@@ -77,7 +77,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
// but this could lead to extrapolation of loss maps (in axlegear and gear).
// solution: we check here if the angularVelocity is 0 the first time and brake away all the torque if it is.
// afterwards the vehicle is standing and other mechanisms take over (Driver.DriveTimeInterval)
if (DataBus.DriverBehavior == DrivingBehavior.Braking && !PreviousState.OutAngularVelocity.IsEqual(0) &&
if (DataBus.ClutchClosed(absTime) && DataBus.DriverBehavior == DrivingBehavior.Braking && !PreviousState.OutAngularVelocity.IsEqual(0) &&
angularVelocity.IsEqual(0)) {
brakeTorque = -torque;
if (!dryRun) {
......
......@@ -220,6 +220,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
retVal.Acceleration = operatingPoint.Acceleration;
retVal.SimulationInterval = operatingPoint.SimulationInterval;
retVal.OperatingPoint = operatingPoint;
return retVal;
}
......@@ -287,11 +288,11 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
OperatingPoint searchedOperatingPoint;
try {
searchedOperatingPoint = SearchOperatingPoint(absTime, requestedOperatingPoint.SimulationDistance, gradient,
requestedOperatingPoint.Acceleration, initialResponse, coasting: true);
requestedOperatingPoint.Acceleration, initialResponse, coastingOrRoll: true);
} catch (VectoEngineSpeedTooLowException) {
// in case of an exception during search the engine-speed got too low - gear disengaged --> try again with disengaged gear.
searchedOperatingPoint = SearchOperatingPoint(absTime, requestedOperatingPoint.SimulationDistance, gradient,
requestedOperatingPoint.Acceleration, initialResponse, coasting: true);
requestedOperatingPoint.Acceleration, initialResponse, coastingOrRoll: true);
}
if (!ds.IsEqual(searchedOperatingPoint.SimulationDistance)) {
......@@ -302,7 +303,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Source = this,
MaxDistance = searchedOperatingPoint.SimulationDistance,
Acceleration = searchedOperatingPoint.Acceleration,
SimulationInterval = searchedOperatingPoint.SimulationInterval
SimulationInterval = searchedOperatingPoint.SimulationInterval,
OperatingPoint = searchedOperatingPoint
};
return CurrentState.Response;
}
......@@ -325,6 +327,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
response.SimulationInterval = limitedOperatingPoint.SimulationInterval;
response.Acceleration = limitedOperatingPoint.Acceleration;
response.OperatingPoint = limitedOperatingPoint;
response.Switch().
Case<ResponseSuccess>().
......@@ -413,6 +416,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
CurrentState.Response = retVal;
retVal.Acceleration = operatingPoint.Acceleration;
retVal.SimulationInterval = operatingPoint.SimulationInterval;
retVal.OperatingPoint = operatingPoint;
return retVal;
}
......@@ -455,6 +459,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
CurrentState.Response = retVal;
retVal.Acceleration = operatingPoint.Acceleration;
retVal.SimulationInterval = operatingPoint.SimulationInterval;
retVal.OperatingPoint = operatingPoint;
return retVal;
}
......@@ -548,7 +553,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
protected OperatingPoint SearchOperatingPoint(Second absTime, Meter ds, Radian gradient,
MeterPerSquareSecond acceleration, IResponse initialResponse, bool coasting = false)
MeterPerSquareSecond acceleration, IResponse initialResponse, bool coastingOrRoll = false)
{
IterationStatistics.Increment(this, "SearchOperatingPoint", 0);
......@@ -565,7 +570,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} else {
initialResponse.Switch().
Case<ResponseOverload>(r => origDelta = r.Delta). // search operating point in drive action after overload
Case<ResponseDryRun>(r => origDelta = coasting ? r.DeltaDragLoad : r.DeltaFullLoad).
Case<ResponseDryRun>(r => origDelta = coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad).
Default(r => { throw new UnexpectedResponseException("Unknown response type.", r); });
}
var delta = origDelta;
......@@ -574,7 +579,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
Constants.SimulationSettings.OperatingPointInitialSearchIntervalAccelerating,
getYValue: response => {
var r = (ResponseDryRun)response;
return actionRoll ? r.GearboxPowerRequest : (coasting ? r.DeltaDragLoad : r.DeltaFullLoad);
return actionRoll ? r.GearboxPowerRequest : (coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad);
},
evaluateFunction:
acc => {
......@@ -600,7 +605,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
var r = (ResponseDryRun)response;
delta = actionRoll ? r.GearboxPowerRequest : (coasting ? r.DeltaDragLoad : r.DeltaFullLoad);
delta = actionRoll ? r.GearboxPowerRequest : (coastingOrRoll ? r.DeltaDragLoad : r.DeltaFullLoad);
return delta.Value();
},
abortCriterion:
......@@ -610,7 +615,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
return false;
}
return coasting && !ds.IsEqual(r.OperatingPoint.SimulationDistance);
return !actionRoll && !ds.IsEqual(r.OperatingPoint.SimulationDistance);
});
} catch (VectoSearchAbortedException) {
// search aborted, try to go ahead with the last acceleration
......@@ -761,7 +766,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <returns></returns>
public IResponse DrivingActionHalt(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient)
{
if (!targetVelocity.IsEqual(0) || !DataBus.VehicleSpeed.IsEqual(0, 1e-3)) {
if (!targetVelocity.IsEqual(0) || !DataBus.VehicleStopped) {
Log.Error("TargetVelocity ({0}) and VehicleVelocity ({1}) must be zero when vehicle is halting!", targetVelocity,
DataBus.VehicleSpeed);
throw new VectoSimulationException(
......
......@@ -138,7 +138,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var dt = Constants.SimulationSettings.TargetTimeInterval;
// MK 2016-02-10: SI doesn't allow inifinity anymore -- therefore simply a very negative value is used.
_engageTime = -1e10.SI<Second>(); //double.NegativeInfinity.SI<Second>();
_engageTime = -double.MaxValue.SI<Second>(); //double.NegativeInfinity.SI<Second>();
if (Disengaged) {
Gear = _strategy.InitGear(absTime, dt, outTorque, outAngularVelocity);
......@@ -329,7 +329,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (dryRun) {
if ((DataBus.DriverBehavior == DrivingBehavior.Braking || DataBus.DriverBehavior == DrivingBehavior.Coasting) &&
inAngularVelocity < DataBus.EngineIdleSpeed && DataBus.VehicleSpeed < Constants.SimulationSettings.VehicleStopClutchDisengageSpeed) {
inAngularVelocity < DataBus.EngineIdleSpeed &&
DataBus.VehicleSpeed < Constants.SimulationSettings.VehicleStopClutchDisengageSpeed) {
Disengaged = true;
_engageTime = absTime + dt;
_strategy.Disengage(absTime, dt, outTorque, outAngularVelocity);
......@@ -350,7 +351,8 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
if (shiftRequired) {
_engageTime = absTime + ModelData.TractionInterruption;
Log.Debug("Gearbox is shifting. absTime: {0}, dt: {1}, interuptionTime: {2}, out: ({3}, {4}), in: ({5}, {6})", absTime,
Log.Debug("Gearbox is shifting. absTime: {0}, dt: {1}, interuptionTime: {2}, out: ({3}, {4}), in: ({5}, {6})",
absTime,
dt, _engageTime, outTorque, outAngularVelocity, inTorque, inAngularVelocity);
Disengaged = true;
......@@ -430,7 +432,10 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
}
}
}
if (DataBus.VehicleStopped) {
Disengaged = false;
_engageTime = -double.MaxValue.SI<Second>();
}
AdvanceState();
}
......
......@@ -133,7 +133,7 @@ namespace TUGraz.VectoCore.Utils
}
}
DrawGraph(pointCount, triangles, superTriangle, xmin, xmax, ymin, ymax);
//DrawGraph(pointCount, triangles, superTriangle, xmin, xmax, ymin, ymax);
_convexHull = triangles.FindAll(t => t.SharesVertexWith(superTriangle)).
SelectMany(t => t.GetEdges()).
......
......@@ -57,8 +57,9 @@ namespace TUGraz.VectoCore.Utils
var results = new List<ValidationResult>();
Validator.TryValidateObject(entity, new ValidationContext(entity), results, true);
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.FlattenHierarchy;
const BindingFlags flags =
BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.FlattenHierarchy;
var properties = entity.GetType().GetProperties(flags);
foreach (var p in properties) {
......@@ -95,16 +96,22 @@ namespace TUGraz.VectoCore.Utils
private static IEnumerable<T> GetAttributes<T>(this MemberInfo m, Type obj) where T : Attribute
{
var attributes = Enumerable.Empty<T>();
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy;
const BindingFlags flags =
BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.FlattenHierarchy;
var prop = obj.GetProperty(m.Name, flags);
if (prop != null) {
attributes = prop.GetCustomAttributes(typeof(T)).Cast<T>().Concat(obj.GetInterfaces().SelectMany(m.GetAttributes<T>));
attributes = prop.GetCustomAttributes(typeof(T))
.Cast<T>()
.Concat(obj.GetInterfaces().SelectMany(m.GetAttributes<T>));
}
var field = obj.GetField(m.Name, flags);
if (field != null) {
attributes = attributes.Concat(field.GetCustomAttributes(typeof(T)).Cast<T>().Concat(obj.GetInterfaces().SelectMany(m.GetAttributes<T>)));
attributes =
attributes.Concat(
field.GetCustomAttributes(typeof(T)).Cast<T>().Concat(obj.GetInterfaces().SelectMany(m.GetAttributes<T>)));
}
return attributes;
......@@ -155,10 +162,14 @@ namespace TUGraz.VectoCore.Utils
}
} else {
var results = value.Validate();
if (results.Any()) {
return new ValidationResult(
string.Format("{{{0}}} invalid: {1}", validationContext.DisplayName, string.Join("\n", results)));
if (!results.Any()) {
return ValidationResult.Success;
}
if (validationContext.MemberName == "Container" || validationContext.MemberName == "RunData") {
return new ValidationResult(string.Join("\n", results));
}
return new ValidationResult(
string.Format("{{{0}}} invalid: {1}", validationContext.DisplayName, string.Join("\n", results)));
}
return ValidationResult.Success;
......
......@@ -50,6 +50,9 @@ namespace TUGraz.VectoCore.Tests.Integration
public const string DeliveryTruckDeclarationJob =
@"TestData\Integration\DeclarationMode\12t Truck\12t Delivery Truck.vecto";
public const string DeliveryTruck8GearDeclarationJob =
@"TestData\Integration\DeclarationMode\12t Truck\12t Delivery Truck_8gear.vecto";
[TestMethod]
public void Truck40t_LongHaulCycle_RefLoad()
{
......@@ -186,5 +189,27 @@ namespace TUGraz.VectoCore.Tests.Integration
Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException)));
}
[TestMethod, TestCategory("LongRunning")]
public void Truck12t8Gear_DeclarationTest()
{
var inputData = JSONInputDataFactory.ReadJsonJob(DeliveryTruck8GearDeclarationJob);
var fileWriter = new FileOutputWriter(DeliveryTruck8GearDeclarationJob);
var factory = new SimulatorFactory(ExecutionMode.Declaration, inputData, fileWriter) {
WriteModalResults = true
};
var sumData = new SummaryDataContainer(fileWriter);
var jobContainer = new JobContainer(sumData);
jobContainer.AddRuns(factory);
var runs = jobContainer.Runs;
//runs[8].Run.Run();
jobContainer.Execute();
jobContainer.WaitFinished();
Assert.IsTrue(jobContainer.Runs.All(r => r.Success), string.Concat(jobContainer.Runs.Select(r => r.ExecException)));
}
}
}
\ No newline at end of file
......@@ -484,6 +484,9 @@
<None Include="TestData\Integration\DeclarationMode\12t Truck\12t Delivery Truck.vveh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Integration\DeclarationMode\12t Truck\12t Delivery Truck_8gear.vecto">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Integration\DeclarationMode\12t Truck\12t Delivery Truck_LongHaulEmptyLoading.vmod">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......@@ -514,6 +517,9 @@
<None Include="TestData\Integration\DeclarationMode\12t Truck\Axle.vtlm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Integration\DeclarationMode\12t Truck\Decl_8spd.vgbx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestData\Integration\DeclarationMode\12t Truck\Direct Gear.vtlm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
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