Commit 5beb1e5c authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

router minor-cleanup

parent 3ccefa64
......@@ -1111,17 +1111,17 @@ class Machine(CoreObject):
return self.loadRng.generateNumber()
#===========================================================================
# find candidate operators within the free operators
#===========================================================================
def findCandidateOperator(self):
# TODO: this way no sorting is performed
# find an available operator
candidateOperator=self.operatorPool.findAvailableOperator()
# append the station into its candidateStations
if candidateOperator: # if there was an operator found append the Machine on his candidateStations
candidateOperator.candidateStations.append(self)
return candidateOperator
# #===========================================================================
# # find candidate operators within the free operators
# #===========================================================================
# def findCandidateOperator(self):
# # TODO: this way no sorting is performed
# # find an available operator
# candidateOperator=self.operatorPool.findAvailableOperator()
# # append the station into its candidateStations
# if candidateOperator: # if there was an operator found append the Machine on his candidateStations
# candidateOperator.candidateStations.append(self)
# return candidateOperator
#===========================================================================
# checks whether the entity can proceed to a successor object
......
......@@ -202,12 +202,16 @@ class Operator(ObjectResource):
machine.timeWaiting=self.env.now-machine.broker.timeWaitForOperatorStarted
else:
machine.timeWaiting=self.env.now-machine.timeLastEntityLeft
# find the stations that hold critical entities
# find the stations that hold or are about to be delivered critical entities
if self in router.preemptiveOperators:
for entity in station.getActiveObjectQueue():
if entity.isCritical:
for entity in machine.getActiveObjectQueue():
if entity in router.pending and entity.isCritical:
machine.critical=True
break
for previous in machine.previous:
for entity in previous.getActiveObjectQueue():
if entity in router.pending and entity.isCritical:
machine.critical=True
# sort the stations according their timeWaiting
self.candidateStations.sort(key= lambda x: x.timeWaiting, reverse=True)
# sort the stations if they hold critical entities
......
This diff is collapsed.
......@@ -52,6 +52,7 @@ class RouterManaged(Router):
self.schedulingRule='WT'
# boolean flag to check whether the Router should perform sorting on operators and on pendingEntities
self.sorting=sorting
self.entitiesWithOccupiedReceivers=[] # list of entities that have no available receivers
#===========================================================================
# the initialize method
......@@ -67,6 +68,7 @@ class RouterManaged(Router):
self.multipleCriterionList=[]
# TODO: find out which must be the default for the scheduling Rule
self.schedulingRule='WT'
self.entitiesWithOccupiedReceivers=[]
# =======================================================================
# the run method
......@@ -248,6 +250,7 @@ class RouterManaged(Router):
def findPendingEntities(self):
from Globals import G
self.pending=[] # list of entities that are pending
self.criticalPending=[]
for machine in self.pendingMachines:
self.pending.append(machine.currentEntity)
for entity in G.pendingEntities:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment