melvin_ob/scheduling/task/
switch_state_task.rs

1use crate::flight_control::FlightState;
2
3/// Represents a task to switch to a target flight state.
4///
5/// This task specifies the desired state the flight system should transition to.
6/// The target state must be a valid operational mode.
7#[derive(Debug, Copy, Clone)]
8pub struct SwitchStateTask {
9    /// The target state to switch to.
10    target_state: FlightState,
11}
12
13impl SwitchStateTask {
14    /// Creates a new [`SwitchStateTask`] for a given target state.
15    ///
16    /// # Arguments
17    /// - `target_state`: The desired flight state to switch to.
18    ///
19    /// # Returns
20    /// - `Some(SwitchStateTask)`: If the target state is a valid state for switching.
21    /// - `None`: If the target state is not valid for switching.
22    ///
23    /// # Valid States
24    /// - [`FlightState::Charge`]: The state where the system is charging its batteries.
25    /// - [`FlightState::Comms`]: The state where the system is communicating via high-gain antenna.
26    /// - [`FlightState::Acquisition`]: The state where the system is actively acquiring images.
27    pub fn new(target_state: FlightState) -> Option<Self> {
28        match target_state {
29            FlightState::Charge | FlightState::Comms | FlightState::Acquisition => {
30                Some(Self { target_state })
31            }
32            _ => None,
33        }
34    }
35
36    /// Returns the target state of the `SwitchStateTask`.
37    ///
38    /// # Returns
39    /// - The `FlightState` this task is targeting.
40    pub fn target_state(self) -> FlightState { self.target_state }
41}