Skip to content

Commit

Permalink
prepare for release
Browse files Browse the repository at this point in the history
  • Loading branch information
Sequal32 committed Sep 15, 2020
1 parent 182e73a commit e592c62
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
<details>
<summary>Videos</Summary>

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)

</details>

## 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!
}
```
16 changes: 14 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand All @@ -84,12 +91,16 @@ fn main() {
let mut injected_tracker: HashMap<String, TrackedData> = 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(),
Expand All @@ -107,6 +118,7 @@ fn main() {

if should_update_position {
timer = Instant::now();
println!("Updating aircraft: {} shown.", aircraft_count);
}

// Remove untracked
Expand Down

0 comments on commit e592c62

Please sign in to comment.