/// <summary> /// Function to set simulation speed to normal (wall speed) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _btnGlobalTimeWallSpeed_Click(object sender, EventArgs e) { _environment.StopTick(); _environment.SetInterval(_environment.GetInterval() * 10); _btnGlobalTimeWallSpeed.Enabled = false; _environment.StartTick(); }
// Calls into the PLC passing in the current Blocks, Trains, and Routes private void PlcDoWork() { // Snapshot values. A new train entering the track // will not be processed by this track controller var sb = Blocks; var st = Trains; var sr = Routes; var up = _updateBlocks.Values.ToList(); var proximityBlock = false; var proximityTrain = false; if (Next != null) { proximityBlock = Next.Blocks.Any( x => x.BlockID < Next.Blocks[0].BlockID + 3 && (x.State == StateEnum.BrokenTrackFailure) || (x.State == StateEnum.BlockClosed)); proximityTrain = Next.Trains.Any(t => t.CurrentBlock.BlockID < Next.Blocks[0].BlockID + 3); } // Disable time while the PLC performs its analysis _env.StopTick(); { _plc.IsSafe(sb, st, sr, _messages, proximityTrain, proximityBlock); _plc.ToggleSwitches(sb, st, sr, _messages); _plc.ToggleLights(sb, st, sr, _messages); _plc.UpdateBlocks(up); } _env.StartTick(); _updateBlocks.Clear(); }