/// <summary> /// This ends the SensorMonitoringRoutine. This should only be executed when "Shutdown RT" is clicked. /// </summary> /// <param name="rebooting">This will tell the function if we are rebooting, or shutting down indefinitely.</param> /// <returns>If ended successfully, return true. Else, return false.</returns> public void EndSensorMonitoringRoutine(bool rebooting = false) { CurrentlyRunning = false; // The stream will only be null if the sensor monitoring thread has not been called if (Stream != null) { Stream.Close(); Stream.Dispose(); } Server.Stop(); if (Timeout.Enabled) { Timeout.Stop(); } SensorMonitoringThread.Join(); if (!rebooting) { // We want to keep using the timer if we are rebooting, not destroy it. Status = SensorNetworkStatusEnum.None; Timeout.Dispose(); if (SimulationSensorNetwork != null) { SimulationSensorNetwork.EndSimulationSensorNetwork(); } } else { Status = SensorNetworkStatusEnum.Rebooting; SensorMonitoringThread = new Thread(() => { SensorMonitoringRoutine(); }); } }
/// <summary> /// This starts the SensorMonitoringRoutine. Calling this will immediately begin initialization. /// </summary> /// <returns>If started successfully, return true. Else, return false.</returns> public void StartSensorMonitoringRoutine(bool rebooting = false) { Server.Start(); CurrentlyRunning = true; Status = SensorNetworkStatusEnum.Initializing; Timeout.Interval = InitializationClient.SensorNetworkConfig.TimeoutInitialization; Timeout.Start(); SensorMonitoringThread.Start(); if (SimulationSensorNetwork != null && !rebooting) { SimulationSensorNetwork.StartSimulationSensorNetwork(); } }