self.giver=None#the CoreObject that the activeObject will take an Entity from
self.receiver=None#the CoreObject that the activeObject will give an Entity to
#gets an entity from the predecessor that the predecessor index points to
defgetEntity(self):
...
...
@@ -61,35 +63,7 @@ class MachineJobShop(Machine):
ifactiveEntity.remainingRoute[0][0]==self.id:
returnlen(self.getActiveObjectQueue())<self.capacity#return according to the state of the Queue
returnFalse
#checks if the Queue can accept an entity and there is an entity in some predecessor waiting for it
#also updates the predecessorIndex to the one that is to be taken
defcanAcceptAndIsRequested(self):
# get active object and its queue
activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
# dummy variables that help prioritize the objects requesting to give objects to the Machine (activeObject)
isRequested=False# is requested is dummyVariable checking if it is requested to accept an item
maxTimeWaiting=0# dummy variable counting the time a predecessor is blocked
fromGlobalsimportG
# loop through the objects to see which have to dispose and which is the one blocked for longer # index used to set the predecessorIndex to the giver waiting the most
forobjectinG.ObjList:
if(object.haveToDispose(activeObject)andobject.receiver==self):#if the caller is the receiver and it has to dispose
isRequested=True# if the predecessor objects have entities to dispose of
if(object.downTimeInTryingToReleaseCurrentEntity>0):# and the object has been down while trying to give away the Entity
timeWaiting=now()-object.timeLastFailureEnded# the timeWaiting dummy variable counts the time end of the last failure of the giver object
else:
timeWaiting=now()-object.timeLastEntityEnded# in any other case, it holds the time since the end of the Entity processing
#if more than one have to dispose take the part from the one that is blocked longer
if(timeWaiting>=maxTimeWaiting):
activeObject.giver=object# the object to deliver the Entity to the activeObject is set to the ith member of the previous list
maxTimeWaiting=timeWaiting
#i+=1 # in the next loops, check the other predecessors in the previous list
returnlen(self.getActiveObjectQueue())<self.capacity#return according to the state of the Queue
returnFalse
#checks if the Queue can accept an entity and there is an entity in some predecessor waiting for it
#also updates the predecessorIndex to the one that is to be taken
defcanAcceptAndIsRequested(self):
# get active object and its queue
activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
# dummy variables that help prioritize the objects requesting to give objects to the Machine (activeObject)
isRequested=False# is requested is dummyVariable checking if it is requested to accept an item
maxTimeWaiting=0# dummy variable counting the time a predecessor is blocked
fromGlobalsimportG
# loop through the objects to see which have to dispose and which is the one blocked for longer # index used to set the predecessorIndex to the giver waiting the most
forobjectinG.ObjList:
if(object.haveToDispose(activeObject)andobject.receiver==self):#if the caller is the receiver and it has to dispose
isRequested=True# if the predecessor objects have entities to dispose of
if(object.downTimeInTryingToReleaseCurrentEntity>0):# and the predecessor has been down while trying to give away the Entity
timeWaiting=now()-object.timeLastFailureEnded# the timeWaiting dummy variable counts the time end of the last failure of the giver object
else:
timeWaiting=now()-object.timeLastEntityEnded# in any other case, it holds the time since the end of the Entity processing
#if more than one predecessor have to dispose take the part from the one that is blocked longer
if(timeWaiting>=maxTimeWaiting):
activeObject.giver=object# the object to deliver the Entity to the activeObject is set to the ith member of the previous list
maxTimeWaiting=timeWaiting
#i+=1 # in the next loops, check the other predecessors in the previous list