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

more cleanup in job-shop objects

parent ec709e5d
......@@ -102,7 +102,7 @@ class Exit(CoreObject):
# check if any of the possible givers has something to deliver
# if yes, then return true and update the giver
for object in self.previous:
if(object.haveToDispose(activeObject)):
if(object.haveToDispose(activeObject) and object.receiver==self):
isRequested=True
self.giver=object
return isRequested
......
......@@ -33,41 +33,9 @@ from Exit import Exit
#the ExitJobShop object
class ExitJobShop(Exit):
#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
#set all the objects in previous
def initialize(self):
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):
#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
self.previous=G.ObjList
Exit.initialize(self) #run default behaviour
\ No newline at end of file
......@@ -33,11 +33,12 @@ from Machine import Machine
#the MachineJobShop object
class MachineJobShop(Machine):
#set all the objects in previous and next
def initialize(self):
from Globals import G
self.previous=G.ObjList
self.next=G.ObjList
Machine.initialize(self)
Machine.initialize(self) #run default behaviour
#gets an entity from the predecessor that the predecessor index points to
......
......@@ -34,11 +34,12 @@ from Queue import Queue
#the MachineJobShop object
class QueueJobShop(Queue):
#set all the objects in previous and next
def initialize(self):
from Globals import G
self.previous=G.ObjList
self.next=G.ObjList
Queue.initialize(self)
Queue.initialize(self) #run default behaviour
#checks if the Queue can accept an entity
#it checks also the next station of the Entity and returns true only if the active object is the next station
......
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