From fc59cfb513b215ac8b70054f06ae2a8ca657bd09 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 20 Jan 2024 09:29:26 -0700 Subject: [PATCH] fix doc tests --- src/lib.rs | 20 +++++++------------- src/state_machine/state.rs | 26 ++++++++++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 78b0a63..f19a720 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,22 +9,16 @@ //! ``` //! use sdre_rust_adsb_parser::DecodeMessage; //! -//! let json_message = r#"{ -//! "messageType": "Aircraft", -//! "icao": "ABC123", -//! "altitude": 35000, -//! "latitude": 37.7749, -//! "longitude": -122.4194 -//! }"#; +//! let message = "8EADC035002D7000000000B02845"; //! -//! let decoded_message = json_message.decode_message().unwrap(); +//! let decoded_message = message.decode_message().unwrap(); //! //! match decoded_message { -//! sdre_rust_adsb_parser::ADSBMessage::AircraftJSON(aircraft) => { -//! println!("ICAO: {}", aircraft.icao); -//! println!("Altitude: {} feet", aircraft.altitude); -//! println!("Latitude: {}", aircraft.latitude); -//! println!("Longitude: {}", aircraft.longitude); +//! sdre_rust_adsb_parser::ADSBMessage::JSONMessage(aircraft) => { +//! println!("ICAO: {}", aircraft.transponder_hex); +//! println!("Altitude: {:?} feet", aircraft.barometric_altitude); +//! println!("Latitude: {:?}", aircraft.latitude); +//! println!("Longitude: {:?}", aircraft.longitude); //! } //! _ => { //! println!("Invalid message type"); diff --git a/src/state_machine/state.rs b/src/state_machine/state.rs index 19576c3..5afc4bc 100644 --- a/src/state_machine/state.rs +++ b/src/state_machine/state.rs @@ -8,21 +8,27 @@ /// /// ``` /// use sdre_rust_adsb_parser::state_machine::state::StateMachine; +/// use sdre_rust_adsb_parser::state_machine::state::ProcessMessageType; /// -/// // Create a new state machine with a timeout of 10 seconds for ADS-B messages -/// let state_machine = StateMachine::new(10, 0, 37.7749, -122.4194); +/// async fn process_message() { +/// // Create a raw ADS-B message. Generally input will be from a receiver. +/// let raw_message = "8D4840D6202CC371C32CE0576098".to_string(); +/// // Create a new state machine with a timeout of 10 seconds for ADS-B messages +/// let mut state_machine = StateMachine::new(10, 0, 37.7749, -122.4194); /// -/// // Get the sender channel to send messages to the state machine -/// let sender_channel = state_machine.get_sender_channel(); /// -/// // Send a raw ADS-B message to the state machine -/// sender_channel.send(ProcessMessageType::Raw(raw_message)).await; +/// // Get the sender channel to send messages to the state machine +/// let sender_channel = state_machine.get_sender_channel(); /// -/// // Process the incoming messages in the state machine -/// state_machine.process_adsb_message().await; +/// // Send a raw ADS-B message to the state machine +/// sender_channel.send(ProcessMessageType::AsString(raw_message)).await; /// -/// // Print the airplanes in the state machine -/// state_machine.print_airplanes().await; +/// // Process the incoming messages in the state machine +/// state_machine.process_adsb_message().await; +/// +/// // Print the airplanes in the state machine +/// state_machine.print_airplanes().await; +/// } /// ``` /// /// The state machine processes different types of messages, such as raw ADS-B data, JSON messages,