Beispiel #1
0
        /// <summary>
        /// Update the UI with the Current Connection State
        /// </summary>
        /// <param name="currentState"></param>
        private void updateSimulationStatusUi(Simulation_State currentState)
        {
            currentSimulationState = currentState;

            switch (currentState)
            {
            case Simulation_State.Pause:
                disableUserInput();
                statusBarSimulationState.Text       = " Pausiert ";
                statusBarSimulationState.Background = System.Windows.Media.Brushes.Yellow;
                break;

            case Simulation_State.Run:
                disableUserInput();
                statusBarSimulationState.Text       = " Läuft ";
                statusBarSimulationState.Background = System.Windows.Media.Brushes.Green;
                break;

            case Simulation_State.Stop:
                enableUserInput();
                statusBarSimulationState.Text       = " Gestoppt ";
                statusBarSimulationState.Background = System.Windows.Media.Brushes.Red;
                // Set the last Row Background back to White
                if (lastAktiveRow != null)
                {
                    lastAktiveRow.Background = System.Windows.Media.Brushes.White;
                }
                break;
            }
        }
        /// <summary>
        /// Trigger function to start the Simulation State Chnge Event
        /// </summary>
        /// <param name="currentState"></param>
        private void triggerSimulationStateChangedEvent(Simulation_State currentState)
        {
            state = currentState;
            SimulationStateUpdateEventArgs myArgument = new SimulationStateUpdateEventArgs();

            myArgument.simulationState = currentState;
            simulationStateChanged(myArgument);
        }
        /// <summary>
        /// Control of the Simulation Working State
        /// </summary>
        /// <param name="requestedState">Set the State of the Simulation State Stop = Stopping end ending the Thread // Pause = Stop the Simulation but dont end it // Run = Start the Simulation </param>
        public void RequestStateChange(Simulation_State requestedState)
        {
            switch (requestedState)
            {
            // Stop the Simulation Thread
            case Simulation_State.Stop:

                // If the Thread is Paused we wake him up to kill him!
                if (state == Simulation_State.Pause)
                {
                    lastMsg = null;     // Discard the recived Msg's if we got some during the Pause state
                    simulationWorkingThread.Interrupt();
                    pauseThread = false;
                }

                stopThread = true;

                break;

            // Pause the Simulation Thread
            case Simulation_State.Pause:

                pauseThread = true;

                break;

            // Start the Simulation Thread
            case Simulation_State.Run:

                if (state == Simulation_State.Pause)
                {
                    lastMsg = null;     // Discard the recived Msg's if we got some during the Pause state
                    simulationWorkingThread.Interrupt();
                    pauseThread = false;
                }
                else
                {
                    simulationWorkingThread = new Thread(new ThreadStart(WorkingThread));
                    simulationWorkingThread.Start();
                    lastMsg = null;     // Discard the recived Msg's if we got some during the Pause state
                }

                break;

            default:
                // Console.WriteLine("No valit Simulation State Request enterd");
                break;
            }
        }
 /// <summary>
 /// Start with new Sim Data
 /// </summary>
 /// <param name="requestedState"></param>
 /// <param name="jobs"></param>
 public void RequestStateChange(Simulation_State requestedState, ObservableCollection <Simulation_Job> jobs)
 {
     sequenceJobs = jobs;
     RequestStateChange(requestedState);
 }