Bladeren bron

add a function to send the sequence to euroscope

Sven Czarnian 3 jaren geleden
bovenliggende
commit
d1536804a4
1 gewijzigde bestanden met toevoegingen van 28 en 0 verwijderingen
  1. 28 0
      aman/com/Euroscope.py

+ 28 - 0
aman/com/Euroscope.py

@@ -10,6 +10,7 @@ import zmq
 import zmq.auth
 
 from aman.com import AircraftReport_pb2
+from aman.com import Communication_pb2
 from aman.config.Server import Server
 from threading import Thread, _active
 
@@ -121,3 +122,30 @@ class Euroscope:
         self.NotificationSocket = None
 
         self.Context = None
+
+    def sendSequence(self, airport : str, inbounds):
+        if None == self.NotificationSocket:
+            return
+
+        sequence = Communication_pb2.AircraftSequence()
+        sequence.airport = airport
+
+        for inbound in inbounds:
+            entry = sequence.sequence.add()
+            entry.callsign = inbound.Callsign
+            entry.arrivalRoute = inbound.PlannedStar.Name
+            entry.arrivalRunway = inbound.PlannedRunway.Name
+
+            for waypoint in inbound.PlannedArrivalRoute:
+                wp = entry.waypoints.add()
+                wp.name = waypoint.Waypoint.Name
+
+                pta = str(waypoint.PTA)
+                delimiter = pta.find('.')
+                if -1 == delimiter:
+                    delimiter = pta.find('+')
+
+                wp.pta = pta[0:delimiter]
+
+        message = sequence.SerializeToString()
+        self.NotificationSocket.send(message)