|
@@ -0,0 +1,59 @@
|
|
|
+#!/usr/bin/env python
|
|
|
+
|
|
|
+import glob
|
|
|
+import os
|
|
|
+import sys
|
|
|
+
|
|
|
+from aman.com.Euroscope import Euroscope
|
|
|
+from aman.config.AircraftPerformance import AircraftPerformance
|
|
|
+from aman.config.Airport import Airport
|
|
|
+import aman.config.System
|
|
|
+
|
|
|
+class System:
|
|
|
+ def findConfigPath():
|
|
|
+ envvar = os.environ.get('AMAN_CONFIG_PATH')
|
|
|
+ if None == envvar:
|
|
|
+ print('No AMAN_CONFIG_PATH in environment variables found. Using execution directory.')
|
|
|
+ path = os.getcwd()
|
|
|
+ else:
|
|
|
+ print('AMAN_CONFIG_PATH found.')
|
|
|
+ path = envvar
|
|
|
+
|
|
|
+ print('Config-path: ' + path)
|
|
|
+ return path
|
|
|
+
|
|
|
+ def __init__(self):
|
|
|
+ # default initialization of members
|
|
|
+ self.systemConfig = None
|
|
|
+ self.aircraftPerformance = None
|
|
|
+ self.receiver = None
|
|
|
+
|
|
|
+ configPath = System.findConfigPath()
|
|
|
+
|
|
|
+ # read all system relevant configuration files
|
|
|
+ self.systemConfig = aman.config.System.System(os.path.join(configPath, 'System.ini'))
|
|
|
+ print('Parsed System.ini')
|
|
|
+
|
|
|
+ # read the aircraft performance data
|
|
|
+ self.aircraftPerformance = AircraftPerformance(os.path.join(configPath, 'PerformanceData.ini'))
|
|
|
+ if None == self.aircraftPerformance:
|
|
|
+ sys.stderr.write('No aircraft performance data found!')
|
|
|
+ sys.exit(-1)
|
|
|
+ else:
|
|
|
+ print('Parsed PerformanceData.ini. Extracted ' + str(len(self.aircraftPerformance.aircrafts)) + ' aircrafts')
|
|
|
+
|
|
|
+ # find the airport configurations and create the workers
|
|
|
+ airportsPath = os.path.join(os.path.join(configPath, 'airports'), '*.ini')
|
|
|
+ for file in glob.glob(airportsPath):
|
|
|
+ icao = os.path.splitext(os.path.basename(file))[0]
|
|
|
+
|
|
|
+ print('Parsing planner configuration for ' + icao)
|
|
|
+ airportConfig = Airport(file, icao)
|
|
|
+
|
|
|
+ # create the EuroScope receiver
|
|
|
+ self.receiver = Euroscope(configPath, self.systemConfig.Server)
|
|
|
+
|
|
|
+ def __del__(self):
|
|
|
+ if None != self.receiver:
|
|
|
+ del self.receiver
|
|
|
+ self.receiver = None
|