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

sortEntitiesForReceiver introduced to CoreObject s getEntity....

sortEntitiesForReceiver introduced to CoreObject s getEntity. sortEntitiesForReceived moved to QueueJobShop.
parent 0ab4bd42
......@@ -145,5 +145,32 @@ class QueueJobShop(Queue):
if removeReceiver:
self.next.remove(receiverObject)
return activeEntity
# =======================================================================
# sorting will take into account the manager calling the method
# the entities which have the same manager with the operator
# will be in front of the queue
# if the entity in front of the queue has no manager available
# then the sorting is unsuccessful
# =======================================================================
def sortEntitiesForOperator(self, operator=None):
activeObjectQueue=self.getActiveObjectQueue()
if operator:
activeObjectQueue.sort(key=lambda x: x==operator.candidateEntity, reverse=True)
else:
# added for testing
print 'there must be a caller defined for this kind of Queue sorting'
#===========================================================================
# sort the entities of the queue for the receiver
#===========================================================================
def sortEntitiesForReceiver(self, receiver=None):
# TODO: if the receiver is already assigned an operator then the giver should sort for that manager
activeObject=self.getActiveObject()
from Globals import G
for operator in G.OperatorsList:
if operator.isAssignedTo()==receiver:
activeObject.sortEntitiesForOperator(operator)
break
\ No newline at end of file
......@@ -160,20 +160,7 @@ class QueueManagedJob(QueueJobShop):
def sortEntitiesForOperator(self, operator=None):
activeObjectQueue=self.getActiveObjectQueue()
if operator:
# self.sortEntities()
activeObjectQueue.sort(key=lambda x: x.manager==operator and x.managerAvailable, reverse=True)
else:
# added for testing
print 'there must be a caller defined for this kind of Queue sorting'
#===========================================================================
# sort the entities of the queue for the receiver
#===========================================================================
def sortEntitiesForReceiver(self, receiver=None):
# TODO: if the receiver is already assigned an operator then the giver should sort for that manager
activeObject=self.getActiveObject()
from Globals import G
for operator in G.OperatorsList:
if operator.isAssignedTo()==receiver:
activeObject.sortEntitiesForOperator(operator)
break
\ No newline at end of file
print 'there must be a caller defined for this kind of Queue sorting'
\ No newline at end of file
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