Commit 40253aa2 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Sebastien Robin

getEntity and removeEntity code cleaned in many CoreObjects

parent faa167cd
......@@ -183,11 +183,9 @@ class Assembly(CoreObject):
#removes an entity from the Assembly
def removeEntity(self):
activeObjectQueue=self.getActiveObjectQueue()
self.outputTrace(activeObjectQueue[0].name, "releases "+ self.objName)
activeObjectQueue.pop(0)
self.waitToDispose=False
activeEntity=CoreObject.removeEntity(self) #run the default method
self.outputTrace(activeEntity.name, "releases "+ self.objName) #output trace
self.waitToDispose=False #the object does not wait to dispose now
#gets an entity from the predecessor
#it may handle both Parts and Frames
......
......@@ -223,11 +223,9 @@ class Conveyer(CoreObject):
#removes an entity from the Conveyer
def removeEntity(self):
activeObjectQueue=self.getActiveObjectQueue()
activeEntity=activeObjectQueue[0]
activeEntity=CoreObject.removeEntity(self) #run the default method
self.outputTrace(activeEntity.name, "releases "+ self.objName)
activeObjectQueue.pop(0)
self.position.pop(0)
self.waitToDispose=False
#if the conveyer was full, it means that it also was blocked
......
......@@ -75,8 +75,10 @@ class CoreObject(Process):
# ================================== removes an entity from the Object ==========================
def removeEntity(self):
activeObjectQueue=self.getActiveObjectQueue()
activeObjectQueue.pop(0) #remove the Entity from the queue
activeObjectQueue=self.getActiveObjectQueue()
activeEntity=activeObjectQueue[0]
activeObjectQueue.pop(0) #remove the Entity from the queue
return activeEntity
# ================================== gets an entity from the ====================================
# ===================== predecessor that the predecessor index points to ========================
......
......@@ -187,18 +187,16 @@ class Dismantle(CoreObject):
#removes an entity from the Dismantle
def removeEntity(self):
#to release the Frame if it is empty
if(len(self.Res.activeQ)==1):
self.outputTrace(self.Res.activeQ[0].name, " releases "+ self.objName)
self.Res.activeQ.pop(0)
activeObjectQueue=self.getActiveObjectQueue()
activeEntity=CoreObject.removeEntity(self) #run the default method
self.outputTrace(activeEntity.name, " releases "+ self.objName) #output the trace
#update the flags
if(len(activeObjectQueue)==0):
self.waitToDisposeFrame=False
elif(len(self.Res.activeQ)>1):
self.outputTrace(self.Res.activeQ[0].name, " releases "+ self.objName)
self.Res.activeQ.pop(0)
if(len(self.Res.activeQ)==1):
else:
if(len(activeObjectQueue)==1):
self.waitToDisposePart=False
#outputs message to the trace.xls. Format is (Simulation Time | Entity or Frame Name | message)
def outputTrace(self, name, message):
from Globals import G
......
......@@ -144,32 +144,10 @@ class Exit(CoreObject):
# gets an entity from the predecessor
# =======================================================================
def getEntity(self):
# # get giver object, its queue, and sort the entities according to this object priorities
# giverObject=self.getGiverObject()
# # sort the Entities of the giver according to the scheduling rule if applied
# giverObject.sortEntities()
# giverObjectQueue=self.getGiverObjectQueue()
# # get active object and its queue, as well as the active (to be) entity
# #(after the sorting of the entities in the queue of the giver object)
# activeObject=self.getActiveObject()
# activeObjectQueue=self.getActiveObjectQueue()
# activeEntity=giverObjectQueue[0]
# #get the entity from the previous object and put it in front of the activeQ
# activeObjectQueue.append(activeEntity)
# #remove the entity from the previous object
# giverObject.removeEntity()
# #append the time to schedule so that it can be read in the result
# #remember that every entity has it's schedule which is supposed to be updated every time
# # the entity enters a new object
# activeEntity.schedule.append([activeObject.id,now()])
# activeEntity.currentStation=self
activeEntity = CoreObject.getEntity(self)
# get the name of the entity for the trace
# Add the entity's lifespan to the total one.
name=activeEntity.name
self.totalLifespan+=now()-activeEntity.startTime
self.outputTrace(name)
activeEntity = CoreObject.getEntity(self) #run the default method
self.totalLifespan+=now()-activeEntity.startTime #Add the entity's lifespan to the total one.
self.outputTrace(activeEntity.name)
return activeEntity
# =======================================================================
# actions to be taken after the simulation ends
......
......@@ -42,6 +42,7 @@ class ExitJobShop(Exit):
#gets an entity from the previous station
def getEntity(self):
activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
giverObject=self.getGiverObject()
......@@ -51,8 +52,11 @@ class ExitJobShop(Exit):
name=activeEntity.name #get the name of the entity for the trace
self.totalLifespan+=now()-activeEntity.startTime #Add the entity's lifespan to the total one.
giverObject.removeEntity() #remove the entity from the previous object
self.outputTrace(name)
activeEntity.schedule.append([activeObject.id,now()]) #append the time to schedule so that it can be read in the result
self.outputTrace(name)
#activeEntity=Exit.getEntity(self)
#activeEntity.remainingRoute=[]
activeEntity.schedule.append([self.id,now()]) #append the time to schedule so that it can be read in the result
activeEntity.currentStation=self
#get the giver object in a getEntity transaction.
......
......@@ -237,10 +237,6 @@ class Machine(CoreObject):
# this is done to achieve better (cpu) processing time
if(len(activeObject.previous)==1 or callerObject==None):
return activeObject.Up and len(activeObjectQueue)==0
# # if the machine is busy return False immediately
# if len(activeObjectQueue)==activeObject.capacity:
# return False
thecaller=callerObject
# return True ONLY if the length of the activeOjbectQue is smaller than
......@@ -297,14 +293,11 @@ class Machine(CoreObject):
# removes an entity from the Machine
# =======================================================================
def removeEntity(self):
# get active and its queue
activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
activeObject.timeLastEntityLeft=now() # set the time that the last Entity was removed from this object
activeObject=self.getActiveObject()
activeObject.outputTrace("releases "+activeObject.objName) # output to trace that the Entity was released from the currentObject
CoreObject.removeEntity(self) #run the default method
activeObject.timeLastEntityLeft=now() # set the time that the last Entity was removed from this object
activeObject.waitToDispose=False # update the waitToDispose flag
activeObjectQueue.pop(0) # remove the Entity from the activeQ
activeObject.downTimeInTryingToReleaseCurrentEntity=0 # re-initialize the timer downTimeInTryingToReleaseCurrentEntity
# =======================================================================
......@@ -409,7 +402,7 @@ class Machine(CoreObject):
if(G.trace=="Yes"): #output only if the user has selected to
#handle the 3 columns
G.traceSheet.write(G.traceIndex,0,str(now()))
G.traceSheet.write(G.traceIndex,1,self.Res.activeQ[0].name)
G.traceSheet.write(G.traceIndex,1,self.getActiveObjectQueue()[0].name)
G.traceSheet.write(G.traceIndex,2,message)
G.traceIndex+=1 #increment the row
......
......@@ -164,12 +164,10 @@ class Queue(CoreObject):
return len(self.Res.activeQ)>0 and (thecaller is receiverObject)
#removes an entity from the Object
def removeEntity(self):
activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
activeObject.outputTrace(activeObjectQueue[0].name, "releases "+self.objName)
activeObjectQueue.pop(0) #remove the Entity
def removeEntity(self):
activeObject=self.getActiveObject()
activeEntity=CoreObject.removeEntity(self) #run the default method
activeObject.outputTrace(activeEntity.name, "releases "+activeObject.objName) #output trace
#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
......
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