diff --git a/Cargo.toml b/Cargo.toml index 29b37cb..b2f6660 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,5 @@ edition = "2018" crossbeam-channel = "0.4" regex = "1" reqwest = {version = "0.10.8", features=["blocking"]} -scraper = "0.12" serde_json = "1.0" serde = {version = "1.0", features=["derive"]} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7e4292b --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# Live Traffic for VATSIM Clients +This program brings the real world into VRC and any other server-configurable clients for VATSIM. It offers data pulled from flightradar24, and flightplans from flightaware. + +## Preview +
+Videos + +Boston Clearance/Ground/Tower +[![](https://img.youtube.com/vi/hU109JQMo9Y/0.jpg)](https://www.youtube.com/watch?v=hU109JQMo9Y) + +Boston Center +[![](https://img.youtube.com/vi/khF5jed41oI/0.jpg)](https://www.youtube.com/watch?v=khF5jed41oI) + +
+ +## Installing +1. Grab the latest [release](https://github.com/Sequal32/vrcliveatc/releases/latest) and unzip to a directory of your choice. +2. Install [Microsoft Visual C++ Redistributable](https://www.microsoft.com/en-us/download/details.aspx?id=52685). +3. Configure values to your liking as described below. +4. For VRC: + Open or create `myservers.txt` in Documents/VRC. Add the following entry: + ``` + 127.0.0.1 LIVE TRAFFIC + ``` +5. Start `liveatc.exe` +6. Connect using the new server. +7. Optional: Listen to [LiveATC](https://www.liveatc.net/) + +## Configuration +`config.json` is read by the program and can be configured as follows: +``` +{ + "upper_lat": 42.48, - The latitude of the upper left map bound + "upper_lon": -71.28, - The longitude of the upper left map bound + "bottom_lat": 42.26, - The latitude of the lower right map bound + "bottom_lon": -70.74, - The longitude of the lower right map bound + + "floor": 0, - Aircraft below this altitude (in feet) will not be displayed + "ceiling": 99999, - Aircraft above this altitude will not be displayed +"callsign": "BOS_GND" - The callsign you're connecting with. This is used for assigning squawk codes or tracking aircraft for fun! +} +``` \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 6ff6cdd..443c8f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,6 +61,7 @@ struct ConfigData { const CONFIG_FILENAME: &str = "config.json"; fn main() { + println!("Starting TCP Server"); let listener = TcpListener::bind("127.0.0.1:6809").unwrap(); let config: ConfigData; @@ -71,9 +72,15 @@ fn main() { file.read_to_end(&mut data).expect("Could not read config.json!"); config = serde_json::from_str(String::from_utf8(data).expect("Error decoding file!").as_str()).expect("Config.json is invalid."); } + println!("Read config.json"); loop { - let (mut stream, _) = listener.accept().unwrap(); + println!("Waiting for connection..."); + + let (mut stream, addr) = listener.accept().unwrap(); + + println!("Connection established! {}", addr.to_string()); + stream.write("$DISERVER:CLIENT:LIVE ATC:\r\n".as_bytes()).ok(); stream.write(format!("$CRSERVER:{0:}:ATC:Y:{0:}\r\n", config.callsign).as_bytes()).ok(); @@ -84,12 +91,16 @@ fn main() { let mut injected_tracker: HashMap = HashMap::new(); let mut timer = Instant::now(); + println!("Displaying aircraft..."); + 'main: loop { tracker.step(); let should_update_position = timer.elapsed().as_secs_f32() >= 3.0; - for aircraft in tracker.get_aircraft_data() { + let ac_data = tracker.get_aircraft_data(); + let aircraft_count = ac_data.len(); + for aircraft in ac_data { // Insert aircraft as "injected" if not already in let tracked: &mut TrackedData = match injected_tracker.entry(aircraft.id.clone()) { Entry::Occupied(o) => o.into_mut(), @@ -107,6 +118,7 @@ fn main() { if should_update_position { timer = Instant::now(); + println!("Updating aircraft: {} shown.", aircraft_count); } // Remove untracked