public PressureTank() { InitializeComponent(); // Initialize visualization resources _pumpingStoryboard = (Storyboard)Resources["RotatePump"]; _pumpingStoryboard.Begin(); _pressureLevelStoryboard = (Storyboard)Resources["PressureLevel"]; _pressureLevelStoryboard.Begin(); _pressureLevelStoryboard.Pause(); _timerAlertStoryboard = (Storyboard)Resources["TimerEvent"]; _sensorAlertStoryboard = (Storyboard)Resources["SensorEvent"]; // Initialize the simulation environment _simulator = new RealTimeSimulator(_model, stepDelay: 1000); _simulator.SimulationStateChanged += (o, e) => UpdateSimulationButtonVisibilities(); _simulator.ModelStateChanged += (o, e) => UpdateModelState(); // Initialize the visualization state UpdateSimulationButtonVisibilities(); UpdateModelState(); TimerAlert.Opacity = 0; SensorAlert.Opacity = 0; ChangeSpeed(8); }
private void SetSimulator(Simulator simulator) { if (Simulator != null) { Simulator.ModelStateChanged -= OnModelStateChanged; Simulator.Pause(); } Simulator = new RealTimeSimulator(simulator, (int)Math.Round(1000 / _speed)); Simulator.ModelStateChanged += OnModelStateChanged; UpdateSimulationButtonVisibilities(); OnReset(null, null); }