瀏覽代碼

extend the configuration for the UI communication

Sven Czarnian 3 年之前
父節點
當前提交
014ea5fa0a
共有 2 個文件被更改,包括 48 次插入0 次删除
  1. 30 0
      aman/com/WebUI.py
  2. 18 0
      aman/config/Server.py

+ 30 - 0
aman/com/WebUI.py

@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+import json
+
+from aman.config.Server import Server
+from aman.types.Inbound import Inbound
+
+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 sendSequence(self, airport, inbounds):
+        sequence = []
+
+        for inbound in inbounds:
+            sequence.append(str(inbound.toJSON()))
+
+        # TODO send to the server
+        #print(json.dumps({ 'airport': airport, 'sequence': sequence }, ensure_ascii=True))

+ 18 - 0
aman/config/Server.py

@@ -8,6 +8,9 @@ class Server():
         self.Address = None
         self.PortReceiver = None
         self.PortNotification = None
+        self.WebUiUrl = None
+        self.WebUiSequenceNotification = None
+        self.WebUiConfigurationReceiver = None
 
         # search the required sections
         for key in config:
@@ -17,6 +20,12 @@ class Server():
                 self.PortReceiver = int(config['portreceiver'])
             elif 'portnotification' == key:
                 self.PortNotification = int(config['portnotification'])
+            elif 'webuiurl' == key:
+                self.WebUiUrl = config['webuiurl']
+            elif 'sequencenotification' == key:
+                self.WebUiSequenceNotification = config['sequencenotification']
+            elif 'configurationreceiver' == key:
+                self.WebUiConfigurationReceiver = config['configurationreceiver']
 
         if self.Address is None:
             sys.stderr.write('No server-address configuration found!')
@@ -27,3 +36,12 @@ class Server():
         if self.PortNotification is None:
             sys.stderr.write('No server-port-notification configuration found!')
             sys.exit(-1)
+        if self.WebUiUrl is None:
+            sys.stderr.write('No Web-UI URL configuration found!')
+            sys.exit(-1)
+        if self.WebUiSequenceNotification is None:
+            sys.stderr.write('No Web-UI sequence notification configuration found!')
+            sys.exit(-1)
+        if self.WebUiConfigurationReceiver is None:
+            sys.stderr.write('No Web-UI configuration receiver configuration found!')
+            sys.exit(-1)