1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #!/usr/bin/env python
- from threading import Thread, Lock
- import time
- from aman.config.Airport import Airport
- class Worker(Thread):
- def __init__(self):
- Thread.__init__(self)
- self.stopThread = None
- self.icao = None
- self.configuration = None
- self.arrivalRoutes = None
- self.updateLock = None
- self.reportQueue = {}
- def __del__(self):
- self.release()
- def acquire(self, icao : str, configuration : Airport):
- self.stopThread = None
- self.icao = icao
- self.configuration = configuration
- self.arrivalRoutes = configuration.gngData.arrivalRoutes
- self.updateLock = Lock()
- self.reportQueue = {}
- self.start()
- def acquireLock(self):
- if None != self.updateLock:
- self.updateLock.acquire()
- def release(self):
- self.stopThread = True
- self.join()
- def releaseLock(self):
- if None != self.updateLock:
- self.updateLock.release()
- def run(self):
- counter = 0
- while None == self.stopThread:
- time.sleep(1)
- counter += 1
- if 0 != (counter % 60):
- continue
- # TODO handle the report queue and update internal information
- # TODO execute planning, etc.
- continue
|