signalRouter and sortEntitiesForReceiver methods added

parent 06b7c16e
...@@ -348,24 +348,11 @@ class CoreObject(Process): ...@@ -348,24 +348,11 @@ class CoreObject(Process):
return False return False
receiver=activeObject.selectReceiver(possibleReceivers) receiver=activeObject.selectReceiver(possibleReceivers)
receiversGiver=activeObject receiversGiver=activeObject
# sorting the entities of the object for the receiver
#------------------------------------------------------------------------------ activeObject.sortEntitiesForReceiver(receiver)
# if an operator is not assigned to the receiver then do not signal the receiver but the Router # signalling the Router if the receiver is operated and not assigned an operator
try: if activeObject.signalRouter(receiver):
if not receiver.assignedOperator: return False
if any(type=='Load' or type=='Setup' for type in receiver.multOperationTypeList):
from Globals import G
if not G.Router.invoked:
#===================================================================
# # TESTING
# print now(), self.id,' '*50, 'signalling router'
#===================================================================
G.Router.invoked=True
G.Router.isCalled.signal(now())
return False
except:
pass
#------------------------------------------------------------------------------
activeObject.receiver=receiver activeObject.receiver=receiver
activeObject.receiver.giver=activeObject activeObject.receiver.giver=activeObject
...@@ -395,6 +382,34 @@ class CoreObject(Process): ...@@ -395,6 +382,34 @@ class CoreObject(Process):
receiver=object # set the receiver as the longest waiting possible receiver receiver=object # set the receiver as the longest waiting possible receiver
return receiver return receiver
#===========================================================================
# signalRouter method
#===========================================================================
def signalRouter(self, receiver=None):
# if an operator is not assigned to the receiver then do not signal the receiver but the Router
try:
if not receiver.assignedOperator:
if receiver.isLoadRequested():
from Globals import G
if not G.Router.invoked:
#===================================================================
# # TESTING
# print now(), self.id,' '*50, 'signalling router'
#===================================================================
G.Router.invoked=True
G.Router.isCalled.signal(now())
return True
else:
return False
except:
return False
#===========================================================================
# sort the entities of the queue for the receiver
#===========================================================================
def sortEntitiesForReceiver(self, receiver=None):
pass
#=========================================================================== #===========================================================================
# find possible givers # find possible givers
#=========================================================================== #===========================================================================
......
...@@ -689,6 +689,13 @@ class Machine(CoreObject): ...@@ -689,6 +689,13 @@ class Machine(CoreObject):
return False return False
return True return True
#===========================================================================
# return whether Load or setup Requested
#===========================================================================
def isLoadRequested(self):
activeObject=self.getActiveObject()
return any(type=='Load' or type=='Setup' for type in activeObject.multOperationTypeList)
# ======================================================================= # =======================================================================
# to be called by canAcceptAndIsRequested and check for the operator # to be called by canAcceptAndIsRequested and check for the operator
# ======================================================================= # =======================================================================
......
...@@ -100,68 +100,31 @@ class QueueManagedJob(QueueJobShop): ...@@ -100,68 +100,31 @@ class QueueManagedJob(QueueJobShop):
# return len(activeObjectQueue)>0\ # return len(activeObjectQueue)>0\
# and (thecaller in activeObject.next)\ # and (thecaller in activeObject.next)\
# and thecaller.isInRoute(activeObject) # and thecaller.isInRoute(activeObject)
#=========================================================================== #===========================================================================
# signalReceiver Method # signalRouter method
#=========================================================================== #===========================================================================
def signalReceiver(self): def signalRouter(self, receiver=None):
# print now(), self.id, 'trying to signal receiver' # if an operator is not assigned to the receiver then do not signal the receiver but the Router
activeObject=self.getActiveObject() # TODO: identifyEntityToGet needs giver defined but here is not yet defined for Machines and machineJobShops
possibleReceivers=[] try:
for object in [x for x in self.next if x.canAccept(activeObject)]: if receiver.identifyEntityToGet().manager:
possibleReceivers.append(object) if receiver.isLoadRequested():
if possibleReceivers: if receiver.identifyEntityToGet().manager.isAssignedTo()!=receiver:
receiver=activeObject.selectReceiver(possibleReceivers) from Globals import G
receiversGiver=activeObject if not G.Router.invoked:
# perform the checks that canAcceptAndIsRequested used to perform and update assignExit and operatorPool #===================================================================
while not receiver.canAcceptAndIsRequested(receiversGiver): # # TESTING
# print 'removing receiver from possibleReceivrs', receiver.id # print now(), self.id,' '*50, 'signalling router'
possibleReceivers.remove(receiver) #===================================================================
if not possibleReceivers: G.Router.invoked=True
receiversGiver=None G.Router.isCalled.signal(now())
receiver=None return True
return False else:
receiver=activeObject.selectReceiver(possibleReceivers) return False
receiversGiver=activeObject except:
#------------------------------------------------------------------------------ return False
# TODO: if the receiver is already assigned an operator then the giver should sort for that manager
from Globals import G
for operator in G.OperatorsList:
if operator.isAssignedTo()==receiver:
activeObject.sortEntitiesForOperator(operator)
break
#------------------------------------------------------------------------------
# if an operator is not assigned to the receiver then do not signal the receiver but the Router
# TODO: identifyEntityToGet needs giver defined but here is not yet defined for Machines and machineJobShops
try:
if receiver.identifyEntityToGet().manager:
if any(type=='Load' or type=='Setup' for type in receiver.multOperationTypeList):
if receiver.identifyEntityToGet().manager.isAssignedTo()!=receiver:
from Globals import G
if not G.Router.invoked:
#===================================================================
# # TESTING
# print now(), self.id,' '*50, 'signalling router'
#===================================================================
G.Router.invoked=True
G.Router.isCalled.signal(now())
return False
except:
pass
activeObject.receiver=receiver
activeObject.receiver.giver=activeObject
#===================================================================
# # # TESTING
# print now(), self.id,' '*50, 'signalling receiver', self.receiver.id
#===================================================================
# assign the entry of the receiver
activeObject.receiver.assignEntryTo()
activeObject.receiver.isRequested.signal(activeObject)
return True
return False
# ======================================================================= # =======================================================================
# override the default method so that Entities # override the default method so that Entities
# that have the manager available go in front # that have the manager available go in front
...@@ -195,4 +158,16 @@ class QueueManagedJob(QueueJobShop): ...@@ -195,4 +158,16 @@ class QueueManagedJob(QueueJobShop):
activeObjectQueue.sort(key=lambda x: x.manager==operator and x.managerAvailable, reverse=True) activeObjectQueue.sort(key=lambda x: x.manager==operator and x.managerAvailable, reverse=True)
else: else:
# added for testing # added for testing
print 'there must be a caller defined for this kind of Queue sorting' print 'there must be a caller defined for this kind of Queue sorting'
\ No newline at end of file
#===========================================================================
# 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
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