sortCandidateEntities simplified

parent 2eca07ac
...@@ -64,7 +64,7 @@ class Operator(Repairman): # XXX isn't it the other way around ? ...@@ -64,7 +64,7 @@ class Operator(Repairman): # XXX isn't it the other way around ?
# TODO: clean the comments # TODO: clean the comments
# TODO: maybe the argument is not needed. the candidate entities is a variable of the object # TODO: maybe the argument is not needed. the candidate entities is a variable of the object
# ======================================================================= # =======================================================================
def sortCandidateEntities(self, candidateEntities=[]): def sortCandidateEntities(self):
pass pass
# # TODO: have to consider what happens in case of a critical order # # TODO: have to consider what happens in case of a critical order
# # FIFO sorting has no meaning when sorting candidateEntities # # FIFO sorting has no meaning when sorting candidateEntities
......
...@@ -71,22 +71,22 @@ class OperatorManagedJob(Operator): ...@@ -71,22 +71,22 @@ class OperatorManagedJob(Operator):
# sorts the candidateEntities of the Operator according to the scheduling rule # sorts the candidateEntities of the Operator according to the scheduling rule
# TODO: maybe the argument is not needed. the candidate entities is a variable of the object # TODO: maybe the argument is not needed. the candidate entities is a variable of the object
# ======================================================================= # =======================================================================
def sortCandidateEntities(self, candidateEntities=[]): def sortCandidateEntities(self):
# TODO: have to consider what happens in case of a critical order # TODO: have to consider what happens in case of a critical order
#if we have sorting according to multiple criteria we have to call the sorter many times #if we have sorting according to multiple criteria we have to call the sorter many times
if self.schedulingRule=="MC": if self.schedulingRule=="MC":
for criterion in reversed(self.multipleCriterionList): for criterion in reversed(self.multipleCriterionList):
self.activeCandidateQSorter(criterion=criterion, candidateEntities=candidateEntities) self.activeCandidateQSorter(criterion=criterion)
#else we just use the default scheduling rule #else we just use the default scheduling rule
else: else:
self.activeCandidateQSorter(self.schedulingRule, candidateEntities=candidateEntities) self.activeCandidateQSorter(self.schedulingRule)
# ======================================================================= # =======================================================================
# sorts the Entities of the Queue according to the scheduling rule # sorts the Entities of the Queue according to the scheduling rule
# ======================================================================= # =======================================================================
# TODO: entityToGet is not updated for all stations, consider using it for all stations or withdraw the idea # TODO: entityToGet is not updated for all stations, consider using it for all stations or withdraw the idea
def activeCandidateQSorter(self, criterion=None, candidateEntities=[]): def activeCandidateQSorter(self, criterion=None):
activeObjectQ=candidateEntities activeObjectQ=self.candidateEntities
if not activeObjectQ: if not activeObjectQ:
assert False, "empty candidate list" assert False, "empty candidate list"
if criterion==None: if criterion==None:
...@@ -94,7 +94,7 @@ class OperatorManagedJob(Operator): ...@@ -94,7 +94,7 @@ class OperatorManagedJob(Operator):
#if the schedulingRule is first in first out #if the schedulingRule is first in first out
if criterion=="FIFO": if criterion=="FIFO":
# FIFO sorting has no meaning when sorting candidateEntities # FIFO sorting has no meaning when sorting candidateEntities
self.activeCandidateQSorter('WT', candidateEntities=candidateEntities) self.activeCandidateQSorter('WT')
# added for testing # added for testing
# print 'there is no point of using FIFO scheduling rule for operators candidateEntities,\ # print 'there is no point of using FIFO scheduling rule for operators candidateEntities,\
# WT scheduling rule used instead' # WT scheduling rule used instead'
......
...@@ -146,7 +146,7 @@ class Router(ObjectInterruption): ...@@ -146,7 +146,7 @@ class Router(ObjectInterruption):
# check if the candidateReceivers are inPositionToGet and if they are already called # check if the candidateReceivers are inPositionToGet and if they are already called
try: try:
receiverIsActive=(operator.candidateEntity.candidateReceiver in operator.activeCallersList\ receiverIsActive=(operator.candidateEntity.candidateReceiver in operator.activeCallersList\
and operator.candidateEntity.candidateReceiver in self.pendingObjects ) and operator.candidateEntity.candidateReceiver in self.pendingObjects )
except: except:
receiverIsActive=True receiverIsActive=True
...@@ -277,6 +277,7 @@ class Router(ObjectInterruption): ...@@ -277,6 +277,7 @@ class Router(ObjectInterruption):
del self.calledOperators[:] del self.calledOperators[:]
del self.pendingObjects[:] del self.pendingObjects[:]
del self.multipleCriterionList[:] del self.multipleCriterionList[:]
# reset the call flag of the Router
self.call=False self.call=False
#======================================================================= #=======================================================================
...@@ -381,7 +382,7 @@ class Router(ObjectInterruption): ...@@ -381,7 +382,7 @@ class Router(ObjectInterruption):
# sort the candidateEntities list of each operator according to its schedulingRule # sort the candidateEntities list of each operator according to its schedulingRule
for operator in [x for x in self.candidateOperators if x.candidateEntities]: for operator in [x for x in self.candidateOperators if x.candidateEntities]:
operator.sortCandidateEntities(operator.candidateEntities) operator.sortCandidateEntities()
# if there operators that have only one option then sort the candidateOperators according to the first one of these # if there operators that have only one option then sort the candidateOperators according to the first one of these
# TODO: find out what happens if there are many operators with one option # TODO: find out what happens if there are many operators with one option
......
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