Commit fc9b82db authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

router minor-cleanup

parent e06031a0
...@@ -1097,17 +1097,17 @@ class Machine(CoreObject): ...@@ -1097,17 +1097,17 @@ class Machine(CoreObject):
return self.loadRng.generateNumber() return self.loadRng.generateNumber()
#=========================================================================== # #===========================================================================
# find candidate operators within the free operators # # find candidate operators within the free operators
#=========================================================================== # #===========================================================================
def findCandidateOperator(self): # def findCandidateOperator(self):
# TODO: this way no sorting is performed # # TODO: this way no sorting is performed
# find an available operator # # find an available operator
candidateOperator=self.operatorPool.findAvailableOperator() # candidateOperator=self.operatorPool.findAvailableOperator()
# append the station into its candidateStations # # append the station into its candidateStations
if candidateOperator: # if there was an operator found append the Machine on his candidateStations # if candidateOperator: # if there was an operator found append the Machine on his candidateStations
candidateOperator.candidateStations.append(self) # candidateOperator.candidateStations.append(self)
return candidateOperator # return candidateOperator
#=========================================================================== #===========================================================================
# checks whether the entity can proceed to a successor object # checks whether the entity can proceed to a successor object
......
...@@ -200,12 +200,16 @@ class Operator(ObjectResource): ...@@ -200,12 +200,16 @@ class Operator(ObjectResource):
machine.timeWaiting=self.env.now-machine.broker.timeWaitForOperatorStarted machine.timeWaiting=self.env.now-machine.broker.timeWaitForOperatorStarted
else: else:
machine.timeWaiting=self.env.now-machine.timeLastEntityLeft 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: if self in router.preemptiveOperators:
for entity in station.getActiveObjectQueue(): for entity in machine.getActiveObjectQueue():
if entity.isCritical: if entity in router.pending and entity.isCritical:
machine.critical=True machine.critical=True
break 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 # sort the stations according their timeWaiting
self.candidateStations.sort(key= lambda x: x.timeWaiting, reverse=True) self.candidateStations.sort(key= lambda x: x.timeWaiting, reverse=True)
# sort the stations if they hold critical entities # sort the stations if they hold critical entities
......
This diff is collapsed.
...@@ -52,6 +52,7 @@ class RouterManaged(Router): ...@@ -52,6 +52,7 @@ class RouterManaged(Router):
self.schedulingRule='WT' self.schedulingRule='WT'
# boolean flag to check whether the Router should perform sorting on operators and on pendingEntities # boolean flag to check whether the Router should perform sorting on operators and on pendingEntities
self.sorting=sorting self.sorting=sorting
self.entitiesWithOccupiedReceivers=[] # list of entities that have no available receivers
#=========================================================================== #===========================================================================
# the initialize method # the initialize method
...@@ -67,6 +68,7 @@ class RouterManaged(Router): ...@@ -67,6 +68,7 @@ class RouterManaged(Router):
self.multipleCriterionList=[] self.multipleCriterionList=[]
# TODO: find out which must be the default for the scheduling Rule # TODO: find out which must be the default for the scheduling Rule
self.schedulingRule='WT' self.schedulingRule='WT'
self.entitiesWithOccupiedReceivers=[]
# ======================================================================= # =======================================================================
# the run method # the run method
...@@ -248,6 +250,7 @@ class RouterManaged(Router): ...@@ -248,6 +250,7 @@ class RouterManaged(Router):
def findPendingEntities(self): def findPendingEntities(self):
from Globals import G from Globals import G
self.pending=[] # list of entities that are pending self.pending=[] # list of entities that are pending
self.criticalPending=[]
for machine in self.pendingMachines: for machine in self.pendingMachines:
self.pending.append(machine.currentEntity) self.pending.append(machine.currentEntity)
for entity in G.pendingEntities: 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