remove acquire() and release() functions and run the threads as deamons for easier cleanups
This commit is contained in:
		| @@ -17,27 +17,13 @@ from aman.types.Inbound import Inbound | ||||
| from aman.types.PerformanceData import PerformanceData | ||||
|  | ||||
| class Worker(Thread): | ||||
|     def __init__(self): | ||||
|     def __init__(self, icao : str, configuration : Airport, weather : Weather, | ||||
|                  performance : PerformanceData, euroscope : Euroscope): | ||||
|         Thread.__init__(self) | ||||
|         self.StopThread = None | ||||
|         self.Icao = None | ||||
|         self.Configuration = None | ||||
|         self.PerformanceData = None | ||||
|         self.UpdateLock = None | ||||
|         self.ReportQueue = {} | ||||
|         self.WeatherModel = None | ||||
|         self.RecedingHorizonControl = None | ||||
|         self.WebUi = None | ||||
|  | ||||
|     def __del__(self): | ||||
|         self.release() | ||||
|  | ||||
|     def acquire(self, icao : str, configuration : Airport, weather : Weather, | ||||
|                 performance : PerformanceData, webui : WebUI, euroscope : Euroscope): | ||||
|         self.StopThread = None | ||||
|         self.Icao = icao | ||||
|         self.Configuration = configuration | ||||
|         self.sequencingConfiguration = configuration.DefaultSequencing | ||||
|         self.SequencingConfiguration = configuration.DefaultSequencing | ||||
|         self.PerformanceData = performance | ||||
|         self.UpdateLock = Lock() | ||||
|         self.ReportQueue = {} | ||||
| @@ -68,16 +54,13 @@ class Worker(Thread): | ||||
|                                 sys.exit(-1) | ||||
|                         break | ||||
|  | ||||
|         self.setDaemon(True) | ||||
|         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() | ||||
| @@ -107,7 +90,7 @@ class Worker(Thread): | ||||
|  | ||||
|                 if 0 != report.distanceToIAF and '' != report.initialApproachFix: | ||||
|                     inbound = Inbound(report, self.PerformanceData) | ||||
|                     Node(inbound, inbound.ReportTime, self.WeatherModel, self.Configuration.GngData, self.sequencingConfiguration) | ||||
|                     Node(inbound, inbound.ReportTime, self.WeatherModel, self.Configuration.GngData, self.SequencingConfiguration) | ||||
|                     if None != inbound.InitialArrivalTime: | ||||
|                         self.RecedingHorizonControl.updateReport(inbound) | ||||
|                     else: | ||||
| @@ -123,13 +106,13 @@ class Worker(Thread): | ||||
|                 # get the last landing aircrafts per runway before the RHC stage to check for constraints | ||||
|                 # this is required to handle the overlap between windows | ||||
|                 preceedingInbounds = {} | ||||
|                 for runway in self.sequencingConfiguration.ActiveArrivalRunways: | ||||
|                 for runway in self.SequencingConfiguration.ActiveArrivalRunways: | ||||
|                     inbound = self.RecedingHorizonControl.lastFixedInboundOnRunway(runway.Runway.Name) | ||||
|                     if None != inbound: | ||||
|                         preceedingInbounds[runway.Runway.Name] = inbound | ||||
|  | ||||
|                 # configure the ACO run | ||||
|                 acoConfig = Configuration(constraints = self.sequencingConfiguration, nav = self.Configuration.GngData, | ||||
|                 acoConfig = Configuration(constraints = self.SequencingConfiguration, nav = self.Configuration.GngData, | ||||
|                                           earliest = earliestArrivalTime, weather = self.WeatherModel, | ||||
|                                           preceeding = None if 0 == len(preceedingInbounds) else preceedingInbounds, | ||||
|                                           ants = 5 * len(relevantInbounds), generations = 5 * len(relevantInbounds)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user