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:
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 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
# ======================================================================= # =======================================================================
......
...@@ -101,67 +101,30 @@ class QueueManagedJob(QueueJobShop): ...@@ -101,67 +101,30 @@ class QueueManagedJob(QueueJobShop):
# 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'
activeObject=self.getActiveObject()
possibleReceivers=[]
for object in [x for x in self.next if x.canAccept(activeObject)]:
possibleReceivers.append(object)
if possibleReceivers:
receiver=activeObject.selectReceiver(possibleReceivers)
receiversGiver=activeObject
# perform the checks that canAcceptAndIsRequested used to perform and update assignExit and operatorPool
while not receiver.canAcceptAndIsRequested(receiversGiver):
# print 'removing receiver from possibleReceivrs', receiver.id
possibleReceivers.remove(receiver)
if not possibleReceivers:
receiversGiver=None
receiver=None
return False
receiver=activeObject.selectReceiver(possibleReceivers)
receiversGiver=activeObject
#------------------------------------------------------------------------------
# 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 # 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 # TODO: identifyEntityToGet needs giver defined but here is not yet defined for Machines and machineJobShops
try: try:
if receiver.identifyEntityToGet().manager: if receiver.identifyEntityToGet().manager:
if any(type=='Load' or type=='Setup' for type in receiver.multOperationTypeList): if receiver.isLoadRequested():
if receiver.identifyEntityToGet().manager.isAssignedTo()!=receiver: if receiver.identifyEntityToGet().manager.isAssignedTo()!=receiver:
from Globals import G from Globals import G
if not G.Router.invoked: if not G.Router.invoked:
#=================================================================== #===================================================================
# # TESTING # # TESTING
# print now(), self.id,' '*50, 'signalling router' # print now(), self.id,' '*50, 'signalling router'
#=================================================================== #===================================================================
G.Router.invoked=True G.Router.invoked=True
G.Router.isCalled.signal(now()) G.Router.isCalled.signal(now())
return True
else:
return False return False
except: 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 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
...@@ -196,3 +159,15 @@ class QueueManagedJob(QueueJobShop): ...@@ -196,3 +159,15 @@ class QueueManagedJob(QueueJobShop):
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'
#===========================================================================
# 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