/// <summary> /// This private method goes from Train tail to Train head and records the ceiling speed for the Train /// </summary> /// <returns> false in case of error - e.g. chaining braking under the Train - true otherwise </returns> private bool RefreshCeilingSpeed() { CeilingSpeed = 0; Block CurrentBlock = BlockTail; bool ScrutationFinished = false; while (!ScrutationFinished) { if (CurrentBlock.ListPSR.Count == 0) { return(false); } foreach (PSR psr in CurrentBlock.ListPSR) { if ((CurrentBlock == BlockTail) && (psr.KP <= LocTail)) { CeilingSpeed = (CeilingSpeed > psr.Speed) ? CeilingSpeed : psr.Speed; } else if (CurrentBlock == BlockHead) { if (psr.KP <= LocHead) { CeilingSpeed = (CeilingSpeed > psr.Speed) ? psr.Speed : CeilingSpeed; } } else { CeilingSpeed = (CeilingSpeed > psr.Speed) ? psr.Speed : CeilingSpeed; } } if (CurrentBlock == BlockHead) { ScrutationFinished = true; } else { CurrentBlock = CurrentBlock.GetNextBlock(DoT); if (CurrentBlock == null) { return(false); } } } return(true); }
/// <summary> /// This method computes the current effect of the slope under the Train /// </summary> /// <returns> false if there is an issue during computation, e.g. chainage breaking, true otherwise </returns> private bool RefreshSlope() { Block CurrentBlock = BlockTail; bool ScrutationFinished = false; double KP1, KP2, SlopeSegmentValue; TrainGradient = KP1 = KP2 = SlopeSegmentValue = 0; while (!ScrutationFinished) { if (CurrentBlock.ListGradient.Count == 0) { return(false); } foreach (Gradient gradient in CurrentBlock.ListGradient) { if (CurrentBlock == BlockTail && gradient.KP <= LocTail) { KP2 = LocTail; SlopeSegmentValue = gradient.Slope; } else if (CurrentBlock != BlockHead) { KP1 = KP2; KP2 = gradient.KP; TrainGradient += (KP2 - KP1) / Length * SlopeSegmentValue; SlopeSegmentValue = gradient.Slope; } else if (CurrentBlock == BlockHead && gradient.KP < LocHead) { KP1 = KP2; KP2 = gradient.KP; TrainGradient += (KP2 - KP1) / Length * SlopeSegmentValue; SlopeSegmentValue = gradient.Slope; } else if (CurrentBlock == BlockHead && gradient.KP >= LocHead) { KP1 = KP2; KP2 = LocHead; TrainGradient += (KP2 - KP1) / Length * SlopeSegmentValue; SlopeSegmentValue = gradient.Slope; ScrutationFinished = true; } } if (CurrentBlock == BlockHead) { KP1 = KP2; KP2 = LocHead; TrainGradient += (KP2 - KP1) / Length * SlopeSegmentValue; ScrutationFinished = true; } else { KP1 = KP2; TrainGradient += (CurrentBlock.Length - KP1) / Length * SlopeSegmentValue; KP1 = KP2 = 0; } CurrentBlock = CurrentBlock.GetNextBlock(DoT); } return(true); }