bug fix in Router

parent 4efc0af2
...@@ -186,15 +186,15 @@ class Router(ObjectInterruption): ...@@ -186,15 +186,15 @@ class Router(ObjectInterruption):
entitiesWithOccupiedReceivers=[] entitiesWithOccupiedReceivers=[]
for operator in [x for x in candidateOperators if x.candidateEntities]: for operator in [x for x in candidateOperators if x.candidateEntities]:
operator.sortCandidateEntities(operator.candidateEntities) operator.sortCandidateEntities(operator.candidateEntities)
noAvailableReceivers=False operator.noAvailableReceivers=False
while not noAvailableReceivers: # while not operator.noAvailableReceivers:
availableEntity=next(x for x in operator.candidateEntities if not x in entitiesWithOccupiedReceivers) availableEntity=next(x for x in operator.candidateEntities if not x in entitiesWithOccupiedReceivers)
if availableEntity: if availableEntity:
operator.candidateEntity=availableEntity operator.candidateEntity=availableEntity
#======================================================= #=======================================================
# # TESTING # # TESTING
# print ' the candidate receivers for', operator.candidateEntity.id, 'are',\ # print ' the candidate receivers for', operator.candidateEntity.id, 'are',\
# [str(x.id) for x in operator.candidateEntity.candidateReceivers] # [str(x.id) for x in operator.candidateEntity.candidateReceivers],
#======================================================= #=======================================================
availableReceivers=[x for x in operator.candidateEntity.candidateReceivers\ availableReceivers=[x for x in operator.candidateEntity.candidateReceivers\
...@@ -207,25 +207,24 @@ class Router(ObjectInterruption): ...@@ -207,25 +207,24 @@ class Router(ObjectInterruption):
if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0): if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):
maxTimeWaiting=timeWaiting maxTimeWaiting=timeWaiting
availableReceiver=object availableReceiver=object
# availableReceiver=availableReceivers[0]
# print ' after',
# print availableReceiver.id
operator.candidateEntity.candidateReceiver=availableReceiver operator.candidateEntity.candidateReceiver=availableReceiver
occupiedReceivers.append(availableReceiver) occupiedReceivers.append(availableReceiver)
noAvailableReceivers=True operator.noAvailableReceivers=True
else: else:
entitiesWithOccupiedReceivers.append(availableEntity) entitiesWithOccupiedReceivers.append(availableEntity)
operator.candidateEntity.candidateReceiver=None
#=================================================================== #===================================================================
# # TESTING # # TESTING
# print ' +{}+ candidate operators :',[str(x.id) for x in candidateOperators if x.candidateEntity] # print ' +{}+ candidate operators :',[str(x.id) for x in candidateOperators if x.candidateEntity]
# print ' +{}+ have entities :',[str(x.candidateEntity.id) for x in candidateOperators if x.candidateEntity] # print ' +{}+ have entities :',[str(x.candidateEntity.id) for x in candidateOperators if x.candidateEntity]
# print ' +{}+ with receivers :',[str(x.candidateEntity.candidateReceiver.id) for x in candidateOperators if x.candidateEntity] # print ' +{}+ with receivers :',[str(x.candidateEntity.candidateReceiver.id) for x in candidateOperators if x.candidateEntity and not x.candidateEntity in entitiesWithOccupiedReceivers]
#=================================================================== #===================================================================
pendingObjectsMustBeSorted=False pendingObjectsMustBeSorted=False
for operator in [x for x in candidateOperators if x.candidateEntity]: for operator in [x for x in candidateOperators if x.candidateEntity]:
operator.called = (operator in self.calledOperators) operator.called = (operator in self.calledOperators)
# print operator.id, 'is called?', operator.called
if not operator.called: if not operator.called:
operator.candidateEntity.currentStation.sortEntitiesForOperator(operator) operator.candidateEntity.currentStation.sortEntitiesForOperator(operator)
pendingObjectsMustBeSorted=True pendingObjectsMustBeSorted=True
...@@ -310,7 +309,6 @@ class Router(ObjectInterruption): ...@@ -310,7 +309,6 @@ class Router(ObjectInterruption):
priorityObject.inPositionToGet=False priorityObject.inPositionToGet=False
elif not candidateEntityHasActiveReceiver: elif not candidateEntityHasActiveReceiver:
operator.activeCallersList=[] operator.activeCallersList=[]
# print ' activerCallersList of', operator.id, 'cleared'
# if an object cannot proceed with getEntity, unAssign the exit of its giver # if an object cannot proceed with getEntity, unAssign the exit of its giver
for object in self.pendingObjects: for object in self.pendingObjects:
if not object.canProceedWithGetEntity: if not object.canProceedWithGetEntity:
......
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