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