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

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

null check and correct order of updating the CurrentState

parent 5cc89b9e
No related branches found
No related tags found
No related merge requests found
......@@ -321,7 +321,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected override void DoCommitSimulationStep()
{
if (Gear != 0) {
if (CurrentState.TorqueLossResult.Extrapolated) {
if (CurrentState.TorqueLossResult != null && CurrentState.TorqueLossResult.Extrapolated) {
Log.Warn(
"Gear {0} LossMap data was extrapolated: range for loss map is not sufficient: n:{1}, torque:{2}",
Gear, CurrentState.OutAngularVelocity.ConvertTo().Rounds.Per.Minute, CurrentState.OutTorque);
......
......@@ -347,7 +347,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
var avgOutAngularVelocity = (PreviousState.OutAngularVelocity + outAngularVelocity) / 2.0;
var inTorqueLossResult = ModelData.Gears[Gear].LossMap.GetTorqueLoss(avgOutAngularVelocity, outTorque);
CurrentState.TorqueLossResult = inTorqueLossResult;
var inTorque = outTorque / ModelData.Gears[Gear].Ratio + inTorqueLossResult.Value;
var inAngularVelocity = outAngularVelocity * ModelData.Gears[Gear].Ratio;
......@@ -395,6 +395,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
} else {
CurrentState.InertiaTorqueLossOut = 0.SI<NewtonMeter>();
}
CurrentState.TorqueLossResult = inTorqueLossResult;
CurrentState.SetState(inTorque, inAngularVelocity, outTorque, outAngularVelocity);
CurrentState.Gear = Gear;
// end critical section
......
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