remove the web UI
This commit is contained in:
@@ -9,7 +9,6 @@ import time
|
|||||||
from aman.com import AircraftReport_pb2
|
from aman.com import AircraftReport_pb2
|
||||||
from aman.com.Euroscope import Euroscope
|
from aman.com.Euroscope import Euroscope
|
||||||
from aman.com.Weather import Weather
|
from aman.com.Weather import Weather
|
||||||
from aman.com.WebUI import WebUI
|
|
||||||
from aman.config.AircraftPerformance import AircraftPerformance
|
from aman.config.AircraftPerformance import AircraftPerformance
|
||||||
from aman.config.Airport import Airport
|
from aman.config.Airport import Airport
|
||||||
from aman.config.System import System
|
from aman.config.System import System
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import json
|
|
||||||
import requests
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from json import JSONEncoder
|
|
||||||
from requests.adapters import HTTPAdapter
|
|
||||||
from requests.packages.urllib3.util.retry import Retry
|
|
||||||
from requests.structures import CaseInsensitiveDict
|
|
||||||
|
|
||||||
from aman.config.AirportSequencing import AirportSequencing
|
|
||||||
from aman.config.RunwaySequencing import RunwaySequencing
|
|
||||||
from aman.config.Server import Server
|
|
||||||
|
|
||||||
class InboundEncoder(JSONEncoder):
|
|
||||||
def default(self, o):
|
|
||||||
pta = str(o.PlannedArrivalTime)
|
|
||||||
delimiter = pta.find('.')
|
|
||||||
if -1 == delimiter:
|
|
||||||
delimiter = pta.find('+')
|
|
||||||
return { 'callsign' : o.Callsign, 'runway' : o.PlannedRunway.Name, 'pta' : pta[0:delimiter] }
|
|
||||||
|
|
||||||
class WebUI:
|
|
||||||
def __init__(self):
|
|
||||||
self.Config = None
|
|
||||||
self.Aman = None
|
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
self.release()
|
|
||||||
|
|
||||||
def acquire(self, config : Server, aman):
|
|
||||||
self.Config = config
|
|
||||||
self.Aman = aman
|
|
||||||
|
|
||||||
def release(self):
|
|
||||||
return
|
|
||||||
|
|
||||||
def createSession():
|
|
||||||
# prepare the session
|
|
||||||
session = requests.Session()
|
|
||||||
retry = Retry(total=1, read=1, connect=1)
|
|
||||||
adapter = HTTPAdapter(max_retries=retry)
|
|
||||||
session.mount('http://', adapter)
|
|
||||||
session.mount('https://', adapter)
|
|
||||||
return session
|
|
||||||
|
|
||||||
def requestConfiguration(self, airport, navData):
|
|
||||||
if airport not in navData.Runways:
|
|
||||||
return None
|
|
||||||
|
|
||||||
# prepare the HTTP header and session
|
|
||||||
headers = CaseInsensitiveDict()
|
|
||||||
headers['Accept'] = 'application/json'
|
|
||||||
headers['Content-Type'] = 'application/json'
|
|
||||||
session = WebUI.createSession()
|
|
||||||
|
|
||||||
url = self.Config.WebUiUrl + self.Config.WebUiConfigurationReceiver
|
|
||||||
data = json.dumps({ 'airport': airport }, ensure_ascii=True)
|
|
||||||
|
|
||||||
try:
|
|
||||||
response = session.get(url, headers=headers, data=data, timeout=2)
|
|
||||||
if 200 != response.status_code:
|
|
||||||
return None
|
|
||||||
except requests.exceptions.ConnectTimeout:
|
|
||||||
return None
|
|
||||||
|
|
||||||
config = json.loads(response.json())
|
|
||||||
|
|
||||||
# WebUI sent the wrong airport
|
|
||||||
if config['airport'] != airport or 0 == len(config['activeRunways']):
|
|
||||||
return None
|
|
||||||
|
|
||||||
airportConfig = AirportSequencing(airport)
|
|
||||||
airportConfig.UseMustShallMay = config['useMustShallMay']
|
|
||||||
|
|
||||||
# build the sequencing information per runway
|
|
||||||
for activeRunway in config['activeRunways']:
|
|
||||||
gngRunway = None
|
|
||||||
for runway in navData.Runways[airport]:
|
|
||||||
if runway.Name == activeRunway['runway']:
|
|
||||||
gngRunway = runway
|
|
||||||
break
|
|
||||||
|
|
||||||
# could not find the runway
|
|
||||||
if None == gngRunway:
|
|
||||||
return None
|
|
||||||
|
|
||||||
runway = RunwaySequencing(gngRunway)
|
|
||||||
runway.Spacing = int(activeRunway['spacing'])
|
|
||||||
airportConfig.activateRunway(runway)
|
|
||||||
|
|
||||||
# resolve the dependencies
|
|
||||||
for dependency in config['dependentRunways']:
|
|
||||||
if 2 == len(dependency):
|
|
||||||
airportConfig.addDependency(dependency[0], dependency[1])
|
|
||||||
|
|
||||||
return airportConfig
|
|
||||||
|
|
||||||
def sendSequence(self, airport, inbounds):
|
|
||||||
# prepare the HTTP header and session
|
|
||||||
headers = CaseInsensitiveDict()
|
|
||||||
headers['Accept'] = 'application/json'
|
|
||||||
headers['Content-Type'] = 'application/json'
|
|
||||||
session = WebUI.createSession()
|
|
||||||
|
|
||||||
# prepare the relevant information
|
|
||||||
url = self.Config.WebUiUrl + self.Config.WebUiSequenceNotification
|
|
||||||
data = json.dumps({ 'airport': airport, 'sequence': inbounds }, ensure_ascii=True, cls=InboundEncoder)
|
|
||||||
|
|
||||||
# send to the server
|
|
||||||
try:
|
|
||||||
session.patch(url, headers=headers, data=data, timeout=2)
|
|
||||||
except requests.exceptions.ConnectTimeout:
|
|
||||||
return
|
|
||||||
@@ -6,7 +6,6 @@ import time
|
|||||||
|
|
||||||
from aman.com import Weather
|
from aman.com import Weather
|
||||||
from aman.com.Euroscope import Euroscope
|
from aman.com.Euroscope import Euroscope
|
||||||
from aman.com.WebUI import WebUI
|
|
||||||
from aman.config.Airport import Airport
|
from aman.config.Airport import Airport
|
||||||
from aman.sys.aco.Colony import Colony
|
from aman.sys.aco.Colony import Colony
|
||||||
from aman.sys.aco.Configuration import Configuration
|
from aman.sys.aco.Configuration import Configuration
|
||||||
@@ -29,7 +28,6 @@ class Worker(Thread):
|
|||||||
self.ReportQueue = {}
|
self.ReportQueue = {}
|
||||||
self.WeatherModel = WeatherModel(configuration.GaforId, weather)
|
self.WeatherModel = WeatherModel(configuration.GaforId, weather)
|
||||||
self.RecedingHorizonControl = RecedingHorizonControl(configuration.RecedingHorizonControl)
|
self.RecedingHorizonControl = RecedingHorizonControl(configuration.RecedingHorizonControl)
|
||||||
self.WebUi = webui
|
|
||||||
self.Euroscope = euroscope
|
self.Euroscope = euroscope
|
||||||
|
|
||||||
# merge the constraint information with the GNG information
|
# merge the constraint information with the GNG information
|
||||||
@@ -132,7 +130,6 @@ class Worker(Thread):
|
|||||||
|
|
||||||
# send the sequence to the GUI and Euroscope
|
# send the sequence to the GUI and Euroscope
|
||||||
sequence = self.RecedingHorizonControl.sequence()
|
sequence = self.RecedingHorizonControl.sequence()
|
||||||
self.WebUi.sendSequence(self.Icao, sequence)
|
|
||||||
self.Euroscope.sendSequence(self.Icao, sequence, self.WeatherModel)
|
self.Euroscope.sendSequence(self.Icao, sequence, self.WeatherModel)
|
||||||
|
|
||||||
self.releaseLock()
|
self.releaseLock()
|
||||||
|
|||||||
Reference in New Issue
Block a user