Commit 880c1dce authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

more cleanup in getEntity and removeEntity of coreobjects

parent 40253aa2
...@@ -185,7 +185,8 @@ class Assembly(CoreObject): ...@@ -185,7 +185,8 @@ class Assembly(CoreObject):
def removeEntity(self): def removeEntity(self):
activeEntity=CoreObject.removeEntity(self) #run the default method activeEntity=CoreObject.removeEntity(self) #run the default method
self.outputTrace(activeEntity.name, "releases "+ self.objName) #output trace self.outputTrace(activeEntity.name, "releases "+ self.objName) #output trace
self.waitToDispose=False #the object does not wait to dispose now self.waitToDispose=False
return activeEntity #the object does not wait to dispose now
#gets an entity from the predecessor #gets an entity from the predecessor
#it may handle both Parts and Frames #it may handle both Parts and Frames
...@@ -208,6 +209,7 @@ class Assembly(CoreObject): ...@@ -208,6 +209,7 @@ class Assembly(CoreObject):
self.nameLastEntityEntered=activeEntity.name self.nameLastEntityEntered=activeEntity.name
self.timeLastEntityEntered=now() self.timeLastEntityEntered=now()
activeEntity.currentStation=self activeEntity.currentStation=self
return activeEntity
#actions to be taken after the simulation ends #actions to be taken after the simulation ends
def postProcessing(self, MaxSimtime=None): def postProcessing(self, MaxSimtime=None):
......
...@@ -205,21 +205,15 @@ class Conveyer(CoreObject): ...@@ -205,21 +205,15 @@ class Conveyer(CoreObject):
#gets an entity from the predecessor #gets an entity from the predecessor
def getEntity(self): def getEntity(self):
activeObjectQueue=self.getActiveObjectQueue() activeEntity=CoreObject.getEntity(self)
giverObject=self.getGiverObject()
giverObjectQueue=self.getGiverObjectQueue()
giverObject.sortEntities() #sort the Entities of the giver according to the scheduling rule if applied
activeEntity=giverObjectQueue[0]
activeObjectQueue.append(activeEntity) #get the entity from the predecessor
self.position.append(0) #the entity is placed in the start of the conveyer self.position.append(0) #the entity is placed in the start of the conveyer
giverObject.removeEntity() #remove the entity from the previous object self.outputTrace(activeEntity.name, "got into "+ self.objName) #output trace
self.outputTrace(activeEntity.name, "got into "+ self.objName)
activeEntity.currentStation=self
#check if the conveyer became full to start counting blockage #check if the conveyer became full to start counting blockage
if self.isFull(): if self.isFull():
self.timeBlockageStarted=now() self.timeBlockageStarted=now()
self.wasFull=True self.wasFull=True
return activeEntity
#removes an entity from the Conveyer #removes an entity from the Conveyer
def removeEntity(self): def removeEntity(self):
...@@ -237,6 +231,7 @@ class Conveyer(CoreObject): ...@@ -237,6 +231,7 @@ class Conveyer(CoreObject):
self.timeToBecomeAvailable=((self.position[-1]+self.currentRequestedLength)/float(self.speed))/60 self.timeToBecomeAvailable=((self.position[-1]+self.currentRequestedLength)/float(self.speed))/60
self.conveyerMover.timeToWait=self.timeToBecomeAvailable self.conveyerMover.timeToWait=self.timeToBecomeAvailable
self.call=True self.call=True
return activeEntity
#checks if the Conveyer can dispose an entity to the following object #checks if the Conveyer can dispose an entity to the following object
def haveToDispose(self, callerObject=None): def haveToDispose(self, callerObject=None):
......
...@@ -165,25 +165,20 @@ class Dismantle(CoreObject): ...@@ -165,25 +165,20 @@ class Dismantle(CoreObject):
#gets a frame from the predecessor that the predecessor index points to #gets a frame from the predecessor that the predecessor index points to
def getEntity(self): def getEntity(self):
activeEntity=CoreObject.getEntity(self) #run the default method
activeObjectQueue=self.getActiveObjectQueue() activeObjectQueue=self.getActiveObjectQueue()
giverObject=self.getGiverObject() #get also the parts of the frame so that they can be popped
giverObject.sortEntities() #sort the Entities of the giver according to the scheduling rule if applied
giverObjectQueue=self.getGiverObjectQueue()
activeEntity=giverObjectQueue[0]
activeObjectQueue.append(activeEntity) #get the frame from the predecessor
giverObject.removeEntity()
activeEntity.currentStation=self
#append also the parts in the res so that they can be popped
for part in activeEntity.getFrameQueue(): for part in activeEntity.getFrameQueue():
activeObjectQueue.append(part) activeObjectQueue.append(part)
part.currentStation=self part.currentStation=self
activeEntity.getFrameQueue=[] #empty the frame activeEntity.getFrameQueue=[] #empty the frame
#move the frame to the end of the internal queue since we want the frame to be disposed first #move the frame to the end of the internal queue since we want the frame to be disposed first
activeObjectQueue.append(activeEntity) activeObjectQueue.append(activeEntity)
activeObjectQueue.pop(0) activeObjectQueue.pop(0)
self.outputTrace(activeEntity.name, "got into "+ self.objName) self.outputTrace(activeEntity.name, "got into "+ self.objName)
return activeEntity
#removes an entity from the Dismantle #removes an entity from the Dismantle
def removeEntity(self): def removeEntity(self):
...@@ -196,6 +191,7 @@ class Dismantle(CoreObject): ...@@ -196,6 +191,7 @@ class Dismantle(CoreObject):
else: else:
if(len(activeObjectQueue)==1): if(len(activeObjectQueue)==1):
self.waitToDisposePart=False self.waitToDisposePart=False
return activeEntity
#outputs message to the trace.xls. Format is (Simulation Time | Entity or Frame Name | message) #outputs message to the trace.xls. Format is (Simulation Time | Entity or Frame Name | message)
def outputTrace(self, name, message): def outputTrace(self, name, message):
......
...@@ -295,10 +295,11 @@ class Machine(CoreObject): ...@@ -295,10 +295,11 @@ class Machine(CoreObject):
def removeEntity(self): def removeEntity(self):
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
activeObject.outputTrace("releases "+activeObject.objName) # output to trace that the Entity was released from the currentObject activeObject.outputTrace("releases "+activeObject.objName) # output to trace that the Entity was released from the currentObject
CoreObject.removeEntity(self) #run the default method activeEntity=CoreObject.removeEntity(self) #run the default method
activeObject.timeLastEntityLeft=now() # set the time that the last Entity was removed from this object activeObject.timeLastEntityLeft=now() # set the time that the last Entity was removed from this object
activeObject.waitToDispose=False # update the waitToDispose flag activeObject.waitToDispose=False # update the waitToDispose flag
activeObject.downTimeInTryingToReleaseCurrentEntity=0 # re-initialize the timer downTimeInTryingToReleaseCurrentEntity activeObject.downTimeInTryingToReleaseCurrentEntity=0 # re-initialize the timer downTimeInTryingToReleaseCurrentEntity
return activeEntity
# ======================================================================= # =======================================================================
# checks if the Machine can dispose an entity to the following object # checks if the Machine can dispose an entity to the following object
......
...@@ -168,6 +168,7 @@ class Queue(CoreObject): ...@@ -168,6 +168,7 @@ class Queue(CoreObject):
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
activeEntity=CoreObject.removeEntity(self) #run the default method activeEntity=CoreObject.removeEntity(self) #run the default method
activeObject.outputTrace(activeEntity.name, "releases "+activeObject.objName) #output trace activeObject.outputTrace(activeEntity.name, "releases "+activeObject.objName) #output trace
return activeEntity
#checks if the Queue can accept an entity and there is an entity in some predecessor waiting for it #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 #also updates the predecessorIndex to the one that is to be taken
...@@ -205,6 +206,7 @@ class Queue(CoreObject): ...@@ -205,6 +206,7 @@ class Queue(CoreObject):
activeEntity=CoreObject.getEntity(self) #run the default behavior activeEntity=CoreObject.getEntity(self) #run the default behavior
self.outputTrace(activeEntity.name, "got into "+self.objName) self.outputTrace(activeEntity.name, "got into "+self.objName)
return activeEntity
#sorts the Entities of the Queue according to the scheduling rule #sorts the Entities of the Queue according to the scheduling rule
def sortEntities(self): def sortEntities(self):
......
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