Skip to content

Commit

Permalink
add topsky cpdlc workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoKle committed Dec 19, 2023
1 parent df5c8b3 commit 849ad86
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 74 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tasks.consolidateData import consolidateJsons
from tasks.tsBotWorkflow import createTeamspeakStationBotJson
from tasks.scheduleWorkflow import createScheduleJson
from tasks.topskyCpdlc import createTopskyCpdlcTxt

try:
OUTPUT_PATH = "data.json"
Expand All @@ -28,6 +29,9 @@
# create legacy jsons
createTeamspeakStationBotJson(OUTPUT_PATH, "legacy/atc_station_mappings.json")

# create TopSkyCPDLC.txt
createTopskyCpdlcTxt(OUTPUT_PATH, "topsky/TopSkyCPDLC.txt")

except Exception as error:
print(error)
sys.exit(1)
57 changes: 57 additions & 0 deletions .github/workflows/tasks/topskyCpdlc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import json


def createTopskyCpdlcTxt(input_file, output_file):
try:
# Load cpdlc_callsign_map from the file
with open("topsky/cpdlcMap.json", "r") as callsign_map_file:
cpdlc_callsign_map = json.load(callsign_map_file)

# Load data from the inputFile
with open(input_file, "r") as json_file:
data = json.load(json_file)

cpdlc_station_data = []

for item in data:
cpdlc_login = item.get("cpdlc_login")
callsign = cpdlc_callsign_map.get(item.get("logon").split("_")[0])
abbreviation = item.get("abbreviation")

if cpdlc_login and callsign and abbreviation:
cpdlc_station_data.append(
{
"login": cpdlc_login,
"callsign": callsign,
"abbreviation": abbreviation,
}
)

# Sort cpdlc_station_data first by callsign and then by login alphabetically
sorted_cpdlc_station_data = sorted(
cpdlc_station_data,
key=lambda station: (station["callsign"], station["login"]),
)

output_lines = []

# store the last callsign to add line breaks between callsign changes
last_callsign = None

for station in sorted_cpdlc_station_data:
if station["callsign"] != last_callsign:
# Add an empty line after every change of callsign (excluding the first)
if last_callsign is not None:
output_lines.append("\n")

output_lines.append(
f"LOGIN:{station['login']}:{station['callsign']}:{station['abbreviation']}\n"
)

last_callsign = station["callsign"]

with open(output_file, "w") as output_text:
output_text.writelines(output_lines)

except Exception as error:
print("Error while creating cpdlc txt", error)
2 changes: 1 addition & 1 deletion edmm/ctr.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"EDDC",
"EDDE"
],
"cpdlc_login": "EDMH"
"cpdlc_login": "EDMO"
},
{
"logon": "EDMM_RDG_CTR",
Expand Down
29 changes: 7 additions & 22 deletions topsky/CPDLCmap.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
[
{
"login": "EDG",
"callsign": "LANGEN CTR"
},
{
"login": "EDM",
"callsign": "MUENCHEN CTR"
},
{
"login": "EDW",
"callsign": "BREMEN CTR"
},
{
"login": "EDY",
"callsign": "MAASTRICHT CTR"
},
{
"login": "EDU",
"callsign": "RHEIN CTR"
}
]
{
"EDGG": "LANGEN CTR",
"EDMM": "MUENCHEN CTR",
"EDWW": "BREMEN CTR",
"EDYY": "MAASTRICHT CTR",
"EDUU": "RHEIN CTR"
}
99 changes: 48 additions & 51 deletions topsky/TopSkyCPDLC.txt
Original file line number Diff line number Diff line change
@@ -1,55 +1,52 @@
// Bremen
LOGIN:EDWW:BREMEN CTR:
LOGIN:EDWA:BREMEN CTR:
LOGIN:EDWB:BREMEN CTR:
LOGIN:EDWD:BREMEN CTR:
LOGIN:EDWE:BREMEN CTR:
LOGIN:EDWM:BREMEN CTR:
LOGIN:EDWA:BREMEN CTR:ALR
LOGIN:EDWB:BREMEN CTR:BOR
LOGIN:EDWD:BREMEN CTR:DST
LOGIN:EDWE:BREMEN CTR:EIDE
LOGIN:EDWM:BREMEN CTR:MRZ
LOGIN:EDWW:BREMEN CTR:WC

// Langen
LOGIN:EDGB:LANGEN CTR:
LOGIN:EDGD:LANGEN CTR:
LOGIN:EDGG:LANGEN CTR:
LOGIN:EDGK:LANGEN CTR:
LOGIN:EDGP:LANGEN CTR:
LOGIN:EDGR:LANGEN CTR:
LOGIN:EDGB:LANGEN CTR:BAD
LOGIN:EDGD:LANGEN CTR:DKB
LOGIN:EDGG:LANGEN CTR:GIN
LOGIN:EDGK:LANGEN CTR:KTG
LOGIN:EDGP:LANGEN CTR:PADH
LOGIN:EDGR:LANGEN CTR:RUD

// Muenchen
LOGIN:EDMM:MUENCHEN CTR:
LOGIN:EDML:MUENCHEN CTR:
LOGIN:EDMB:MUENCHEN CTR:
LOGIN:EDME:MUENCHEN CTR:
LOGIN:EDMG:MUENCHEN CTR:
LOGIN:EDMH:MUENCHEN CTR:
LOGIN:EDMN:MUENCHEN CTR:
LOGIN:EDMS:MUENCHEN CTR:
LOGIN:EDMO:MUENCHEN CTR:
LOGIN:EDMR:MUENCHEN CTR:
LOGIN:EDMU:MUENCHEN CTR:
LOGIN:EDMZ:MUENCHEN CTR:
LOGIN:EDCH:MAASTRICHT CTR:CELH
LOGIN:EDJH:MAASTRICHT CTR:JEVH
LOGIN:EDSH:MAASTRICHT CTR:SOLH
LOGIN:EDYC:MAASTRICHT CTR:CEL
LOGIN:EDYH:MAASTRICHT CTR:HOL
LOGIN:EDYJ:MAASTRICHT CTR:JEV
LOGIN:EDYM:MAASTRICHT CTR:MNS
LOGIN:EDYR:MAASTRICHT CTR:RHR
LOGIN:EDYS:MAASTRICHT CTR:SOL

// Maastricht
LOGIN:EDYC:MAASTRICHT CTR:
LOGIN:EDYD:MAASTRICHT CTR:
LOGIN:EDYH:MAASTRICHT CTR:
LOGIN:EDYJ:MAASTRICHT CTR:
LOGIN:EDYM:MAASTRICHT CTR:
LOGIN:EDYR:MAASTRICHT CTR:
LOGIN:EDYS:MAASTRICHT CTR:
LOGIN:EDMB:MUENCHEN CTR:BBG
LOGIN:EDME:MUENCHEN CTR:EGG
LOGIN:EDMG:MUENCHEN CTR:GER
LOGIN:EDMH:MUENCHEN CTR:HAL
LOGIN:EDML:MUENCHEN CTR:ALB
LOGIN:EDMM:MUENCHEN CTR:MMC
LOGIN:EDMN:MUENCHEN CTR:NDG
LOGIN:EDMO:MUENCHEN CTR:HOF
LOGIN:EDMR:MUENCHEN CTR:RDG
LOGIN:EDMS:MUENCHEN CTR:MEI
LOGIN:EDMU:MUENCHEN CTR:TRU
LOGIN:EDMZ:MUENCHEN CTR:ZUG

// Rhein
LOGIN:EDUA:RHEIN RADAR CTR:
LOGIN:EDUC:RHEIN RADAR CTR:
LOGIN:EDUD:RHEIN RADAR CTR:
LOGIN:EDUF:RHEIN RADAR CTR:
LOGIN:EDUH:RHEIN RADAR CTR:
LOGIN:EDUI:RHEIN RADAR CTR:
LOGIN:EDUL:RHEIN RADAR CTR:
LOGIN:EDUN:RHEIN RADAR CTR:
LOGIN:EDUO:RHEIN RADAR CTR:
LOGIN:EDUP:RHEIN RADAR CTR:
LOGIN:EDUR:RHEIN RADAR CTR:
LOGIN:EDUS:RHEIN RADAR CTR:
LOGIN:EDUT:RHEIN RADAR CTR:
LOGIN:EDUU:RHEIN RADAR CTR:
LOGIN:EDUW:RHEIN RADAR CTR:
LOGIN:EDUA:RHEIN CTR:SAL
LOGIN:EDUC:RHEIN CTR:CHI
LOGIN:EDUD:RHEIN CTR:DON
LOGIN:EDUF:RHEIN CTR:FFM
LOGIN:EDUH:RHEIN CTR:HVL
LOGIN:EDUI:RHEIN CTR:ISA
LOGIN:EDUL:RHEIN CTR:ALP
LOGIN:EDUN:RHEIN CTR:NTM
LOGIN:EDUO:RHEIN CTR:OSE
LOGIN:EDUP:RHEIN CTR:SPE
LOGIN:EDUR:RHEIN CTR:ERL
LOGIN:EDUS:RHEIN CTR:SLN
LOGIN:EDUT:RHEIN CTR:TGO
LOGIN:EDUU:RHEIN CTR:FUL
LOGIN:EDUW:RHEIN CTR:WUR

0 comments on commit 849ad86

Please sign in to comment.