private void Instance_RobotStatusChanged(object sender, RobotStatusChangedEventArgs e) { switch (e.CurrentRobotState) { case RobotState.Auton: notifyRobotState(Constants.AUTON); break; case RobotState.Teleop: notifyRobotState(Constants.TELEOP); break; default: notifyRobotState(Constants.DISABLED); break; } }
private void Instance_RobotStatusChanged(object sender, RobotStatusChangedEventArgs e) { if (e.CurrentRobotState == RobotState.Auton || e.CurrentRobotState == RobotState.Teleop) { finished = false; cancel = false; thread = new Thread(backgroundLoop); thread.Start(); Started?.Invoke(this, new EventArgs()); } else { if (thread != null && thread.IsAlive) { Abort(RobotStatus.Instance); } } }
/// <summary> /// Disposes of the instance if the robot state changes /// </summary> /// <param name="sender">The object invoking the method</param> /// <param name="e">RobotStatusChanged Arguments passed</param> private void Instance_RobotStatusChanged(object sender, RobotStatusChangedEventArgs e) { Report.Warning("WatchDog disposed due to robot state change."); Dispose(); }