Commit a75ddd26 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

ExitJobShop also updated in the new style

parent dfdd5cf8
......@@ -33,21 +33,41 @@ from Exit import Exit
#the ExitJobShop object
class ExitJobShop(Exit):
#checks if the Exit can accept an entity and there is an entity waiting for it
def canAcceptAndIsRequested(self):
if self.getGiverObject():
return self.getGiverObject().haveToDispose(self)
else:
return False
#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
def canAcceptAndIsRequested(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
from Globals import G
# 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
for object in G.ObjList:
if(object.haveToDispose(activeObject) and object.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
return isRequested
#get the giver object in a getEntity transaction.
def getGiverObject(self):
from Globals import G
#loop through the objects to see if there is one that holds an Entity requesting for current object
for obj in G.ObjList:
if len(obj.getActiveObjectQueue())>0 and (obj!=self) and now()!=0:
activeEntity=obj.getActiveObjectQueue()[0]
if activeEntity.remainingRoute[0][0]==self.id:
return obj
return None
#if there are predecessors use default method
if len(self.previous)>0:
return Machine.getGiverObject(self)
#else if there is a giver return it
elif self.giver:
return self.giver
return None
\ 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