Commit 1b82966b authored by Georgios Dagkakis's avatar Georgios Dagkakis

Dismantle to work with state variables

parent 7abdc079
...@@ -150,10 +150,10 @@ class Assembly(CoreObject): ...@@ -150,10 +150,10 @@ class Assembly(CoreObject):
self.timeLastFrameWasFull=self.env.now self.timeLastFrameWasFull=self.env.now
self.nameLastFrameWasFull=self.getActiveObjectQueue()[0].name self.nameLastFrameWasFull=self.getActiveObjectQueue()[0].name
startWorkingTime=self.env.now self.timeLastProcessingStarted=self.env.now
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime() self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime()
yield self.env.timeout(self.totalProcessingTimeInCurrentEntity) #hold for the time the assembly operation is carried yield self.env.timeout(self.totalProcessingTimeInCurrentEntity) #hold for the time the assembly operation is carried
self.totalWorkingTime+=self.env.now-startWorkingTime self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted
self.isProcessing=False self.isProcessing=False
self.outputTrace(self.getActiveObjectQueue()[0].name, "ended processing in " + self.objName) self.outputTrace(self.getActiveObjectQueue()[0].name, "ended processing in " + self.objName)
...@@ -319,11 +319,11 @@ class Assembly(CoreObject): ...@@ -319,11 +319,11 @@ class Assembly(CoreObject):
# if the object is blocked add the blockage time # if the object is blocked add the blockage time
if self.isBlocked: if self.isBlocked:
self.totalBlockageTime+=self.env.now-self.timeLastEntityEnded self.totalBlockageTime+=self.env.now-self.timeLastBlockageStarted
# if the object is processing add the working time # if the object is processing add the working time
if self.isProcessing: if self.isProcessing:
self.totalWorkingTime+=self.env.now-self.timeLastFrameWasFull self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted
self.totalWaitingTime=MaxSimtime-self.totalWorkingTime-self.totalBlockageTime self.totalWaitingTime=MaxSimtime-self.totalWorkingTime-self.totalBlockageTime
......
...@@ -200,10 +200,12 @@ class CoreObject(object): ...@@ -200,10 +200,12 @@ class CoreObject(object):
# removes an Entity from the Object the Entity to be removed is passed # removes an Entity from the Object the Entity to be removed is passed
# as argument by getEntity of the receiver # as argument by getEntity of the receiver
# ======================================================================= # =======================================================================
def removeEntity(self, entity=None): def removeEntity(self, entity=None, resetFlags=True, addBlockage=True):
# reset flags # reset flags
if resetFlags:
self.isBlocked=False self.isBlocked=False
self.isProcessing=False self.isProcessing=False
if addBlockage:
# add the blocking time # add the blocking time
self.addBlockage() self.addBlockage()
......
...@@ -134,12 +134,17 @@ class Dismantle(CoreObject): ...@@ -134,12 +134,17 @@ class Dismantle(CoreObject):
self.getEntity() #get the Frame with the parts self.getEntity() #get the Frame with the parts
self.timeLastEntityEntered=self.env.now self.timeLastEntityEntered=self.env.now
startWorkingTime=self.env.now startWorkingTime=self.env.now
self.isProcessing=True
self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime() self.totalProcessingTimeInCurrentEntity=self.calculateProcessingTime()
#hold for the time the assembly operation is carried #hold for the time the assembly operation is carried
yield self.env.timeout(self.totalProcessingTimeInCurrentEntity) yield self.env.timeout(self.totalProcessingTimeInCurrentEntity)
self.isProcessing=False
self.totalWorkingTime+=self.env.now-startWorkingTime self.totalWorkingTime+=self.env.now-startWorkingTime
self.timeLastEntityEnded=self.env.now self.timeLastEntityEnded=self.env.now
startBlockageTime=self.env.now
self.timeLastBlockageStarted=self.env.now
self.isBlocked=True
self.completedJobs+=1 #Assembly completed a job
self.waitToDispose=True self.waitToDispose=True
self.waitToDisposePart=True #Dismantle is in state to dispose a part self.waitToDisposePart=True #Dismantle is in state to dispose a part
...@@ -159,14 +164,12 @@ class Dismantle(CoreObject): ...@@ -159,14 +164,12 @@ class Dismantle(CoreObject):
yield self.entityRemoved yield self.entityRemoved
self.waitEntityRemoval=False self.waitEntityRemoval=False
self.entityRemoved=self.env.event() self.entityRemoved=self.env.event()
# yield self.env.timeout(0)#(0.000000000000005)
if self.frameIsEmpty() and not self.waitToDisposeFrame: if self.frameIsEmpty() and not self.waitToDisposeFrame:
self.waitToDisposePart=False self.waitToDisposePart=False
self.waitToDisposeFrame=True self.waitToDisposeFrame=True
# if the internal queue is empty then update the corresponding flags and proceed with getting a new entity # if the internal queue is empty then update the corresponding flags and proceed with getting a new entity
if self.isEmpty(): if self.isEmpty():
self.completedJobs+=1 #Dismantle completed a job
self.waitToDisposeFrame=False #the Dismantle has no Frame to dispose now self.waitToDisposeFrame=False #the Dismantle has no Frame to dispose now
break break
...@@ -277,10 +280,13 @@ class Dismantle(CoreObject): ...@@ -277,10 +280,13 @@ class Dismantle(CoreObject):
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
activeObjectQueue=activeObject.getActiveObjectQueue() activeObjectQueue=activeObject.getActiveObjectQueue()
#run the default method #run the default method
activeEntity=CoreObject.removeEntity(self, entity) activeEntity=CoreObject.removeEntity(self, entity, resetFlags=False, addBlockage=False)
#update the flags #update the flags
if(len(activeObjectQueue)==0): if(len(activeObjectQueue)==0):
activeObject.waitToDisposeFrame=False activeObject.waitToDisposeFrame=False
self.isBlocked=False
self.isProcessing=False
self.addBlockage()
else: else:
if(len(activeObjectQueue)==1): if(len(activeObjectQueue)==1):
activeObject.waitToDisposePart=False activeObject.waitToDisposePart=False
...@@ -290,15 +296,12 @@ class Dismantle(CoreObject): ...@@ -290,15 +296,12 @@ class Dismantle(CoreObject):
activeObject.signalGiver() activeObject.signalGiver()
return activeEntity return activeEntity
#=========================================================================== # =======================================================================
# add the blockage only if the very last Entity (Frame) is to depart # adds the blockage time to totalBlockageTime
#=========================================================================== # each time an Entity is removed
# =======================================================================
def addBlockage(self): def addBlockage(self):
if len(self.getActiveObjectQueue())==1: self.totalBlockageTime+=self.env.now-self.timeLastBlockageStarted
self.totalTimeInCurrentEntity=self.env.now-self.timeLastEntityEntered
self.totalTimeWaitingForOperator += self.operatorWaitTimeCurrentEntity
blockage=self.env.now-(self.timeLastEntityEnded+self.downTimeInTryingToReleaseCurrentEntity)
self.totalBlockageTime+=blockage
#=========================================================================== #===========================================================================
# actions to be taken after the simulation ends # actions to be taken after the simulation ends
...@@ -311,12 +314,12 @@ class Dismantle(CoreObject): ...@@ -311,12 +314,12 @@ class Dismantle(CoreObject):
#if there is an entity that finished processing in Dismantle but did not get to reach #if there is an entity that finished processing in Dismantle but did not get to reach
#the following Object #the following Object
#till the end of simulation, we have to add this blockage to the percentage of blockage in Dismantle #till the end of simulation, we have to add this blockage to the percentage of blockage in Dismantle
if (len(self.Res.users)>0) and (self.waitToDisposeFrame) or (self.waitToDisposePart): if self.isBlocked:
self.totalBlockageTime+=self.env.now-self.timeLastEntityEnded self.totalBlockageTime+=self.env.now-self.timeLastBlockageStarted
#if Dismantle is currently processing an entity we should count this working time #if Dismantle is currently processing an entity we should count this working time
if(len(self.Res.users)>0) and (not ((self.waitToDisposeFrame) or (self.waitToDisposePart))): if self.isProcessing:
self.totalWorkingTime+=self.env.now-self.timeLastEntityEntered self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted
self.totalWaitingTime=MaxSimtime-self.totalWorkingTime-self.totalBlockageTime self.totalWaitingTime=MaxSimtime-self.totalWorkingTime-self.totalBlockageTime
......
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