print comments added to Router

parent 227a45a1
...@@ -92,16 +92,65 @@ class Router(ObjectInterruption): ...@@ -92,16 +92,65 @@ class Router(ObjectInterruption):
yield waituntil, self,self.entitiesFinishedMoving yield waituntil, self,self.entitiesFinishedMoving
# update the objects to be served list (pendingObjects) # update the objects to be served list (pendingObjects)
self.pendingObjects=[object for object in G.MachineList if object.inPositionToGet] self.pendingObjects=[object for object in G.MachineList if object.inPositionToGet]
#===================================================================
# # TESTING
# print now(), '================================================================================'
# print ' the pending objects are ', [str(object.id) for object in self.pendingObjects]
#===================================================================
# update the calledOperators list # update the calledOperators list
self.calledOperators=[operator for operator in G.OperatorsList if len(operator.activeCallersList)] self.calledOperators=[operator for operator in G.OperatorsList if len(operator.activeCallersList)]
#===================================================================
# # TESTING
# print ' (calledOperators, activeCallers, callerEntities): ', [(str(operator.id),\
# [str(x.id) for x in operator.activeCallersList],\
# [str(x.giver.getActiveObjectQueue()[0].id)for x in operator.activeCallersList])\
# for operator in self.calledOperators]
#===================================================================
# find the operators that can start working now even if they are not called # find the operators that can start working now even if they are not called
self.findCandidateOperators() self.findCandidateOperators()
#===================================================================
# # TESTING
# print ' {} the candidateOperators ',
# print [str(op.id) for op in self.candidateOperators]
# print [str(entity.id) for entity in G.pendingEntities]
#===================================================================
# sort the pendingEntities list # sort the pendingEntities list
self.sortPendingEntities() self.sortPendingEntities()
#===================================================================
# # TESTING
# print [str(entity.id) for entity in G.pendingEntities]
# if G.pendingEntities:
# print ' {} the pending entities that can proceed are: ',
# print [str(entity.id) for entity in G.pendingEntities if entity.canProceed]
#===================================================================
# find the operators candidateEntities # find the operators candidateEntities
self.findCandidateEntities() self.findCandidateEntities()
#===================================================================
# # TESTING
# print ' {} candidate entities for each candidateOperator ',
# print [(str(operator.id),[str(candidateEntity.id) for candidateEntity in operator.candidateEntities],)\
# for operator in self.candidateOperators]
#===================================================================
# find the entity that will occupy the resource, and the station that will receive it (if any available) # find the entity that will occupy the resource, and the station that will receive it (if any available)
self.findCandidateReceivers() self.findCandidateReceivers()
#===================================================================
# # TESTING
# print ' {} (candidateOperator, candidateEntity, candidateReceiver) ',
# print [(str(op.id), str(op.candidateEntity.id), str(op.candidateEntity.candidateReceiver.id))\
# for op in self.candidateOperators if op.candidateEntity.candidateReceiver]
#===================================================================
# sort the givers for the operators that will process the entities # sort the givers for the operators that will process the entities
self.sortGiverQueue() self.sortGiverQueue()
# for all the operators that are requested # for all the operators that are requested
...@@ -113,6 +162,13 @@ class Router(ObjectInterruption): ...@@ -113,6 +162,13 @@ class Router(ObjectInterruption):
and operator.candidateEntity.candidateReceiver in self.pendingObjects ) and operator.candidateEntity.candidateReceiver in self.pendingObjects )
except: except:
receiverIsActive=True receiverIsActive=True
#===============================================================
# # TESTING
# print ' calledOperator', operator.id,
# print 'will receive?',operator.checkIfResourceIsAvailable() and receiverIsActive
#===============================================================
# check if the candidateOperators are available, if the are requested and reside in the pendingObjects list # check if the candidateOperators are available, if the are requested and reside in the pendingObjects list
if operator.checkIfResourceIsAvailable() and \ if operator.checkIfResourceIsAvailable() and \
receiverIsActive: receiverIsActive:
...@@ -120,10 +176,23 @@ class Router(ObjectInterruption): ...@@ -120,10 +176,23 @@ class Router(ObjectInterruption):
operator.sortActiveCallers() operator.sortActiveCallers()
# find the activeCaller that has priority # find the activeCaller that has priority
priorityObject=next(x for x in operator.activeCallersList if x in self.pendingObjects) priorityObject=next(x for x in operator.activeCallersList if x in self.pendingObjects)
#===========================================================
# # TESTING
# print [str(caller.id) for caller in operator.activeCallersList]
# print ' the PRIORITY object is', priorityObject.id
#===========================================================
# and if the priorityObject is indeed pending # and if the priorityObject is indeed pending
if priorityObject in self.pendingObjects: if priorityObject in self.pendingObjects:
# assign an operator to the priorityObject # assign an operator to the priorityObject
operator.operatorAssignedTo=priorityObject operator.operatorAssignedTo=priorityObject
#=======================================================
# # TESTING
# print operator.id, 'got assigned to', priorityObject.id
#=======================================================
# and let it proceed withGetEntity # and let it proceed withGetEntity
priorityObject.canProceedWithGetEntity=True priorityObject.canProceedWithGetEntity=True
priorityObject.inPositionToGet=False priorityObject.inPositionToGet=False
...@@ -134,6 +203,13 @@ class Router(ObjectInterruption): ...@@ -134,6 +203,13 @@ class Router(ObjectInterruption):
for object in self.pendingObjects: for object in self.pendingObjects:
if not object.canProceedWithGetEntity: if not object.canProceedWithGetEntity:
object.giver.unAssignExit() object.giver.unAssignExit()
#===================================================================
# # TESTING
# print ' these objects will proceed with getting entities',
# print [str(object.id) for object in self.pendingObjects if object.canProceedWithGetEntity]
#===================================================================
self.exit() self.exit()
#=========================================================================== #===========================================================================
......
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