Commit 8952b42c authored by Georgios Dagkakis's avatar Georgios Dagkakis

comments and cleanup

parent 9986bb6c
...@@ -201,7 +201,10 @@ class CoreObject(object): ...@@ -201,7 +201,10 @@ class CoreObject(object):
# as argument by getEntity of the receiver # as argument by getEntity of the receiver
# ======================================================================= # =======================================================================
def removeEntity(self, entity=None): def removeEntity(self, entity=None):
# reset flags
self.isBlocked=False self.isBlocked=False
self.isProcessing=False
# add the blocking time
self.addBlockage() self.addBlockage()
activeObjectQueue=self.Res.users activeObjectQueue=self.Res.users
......
...@@ -486,8 +486,7 @@ class Machine(CoreObject): ...@@ -486,8 +486,7 @@ class Machine(CoreObject):
yield self.brokerIsSet yield self.brokerIsSet
self.brokerIsSet=self.env.event() self.brokerIsSet=self.env.event()
# if there is a failure in the machine or interruption due to preemption, it is passivated # loop until we reach at a state that there is no interruption
# passivate the Machine for as long as there is no repair
while 1: while 1:
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it' assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it'
...@@ -543,18 +542,18 @@ class Machine(CoreObject): ...@@ -543,18 +542,18 @@ class Machine(CoreObject):
if not self.signalReceiver(): if not self.signalReceiver():
# if there was no available receiver, get into blocking control # if there was no available receiver, get into blocking control
while 1: while 1:
self.timeLastBlockageStarted=self.env.now self.timeLastBlockageStarted=self.env.now # blockage is starting
# wait the event canDispose, this means that the station can deliver the item to successor # wait the event canDispose, this means that the station can deliver the item to successor
self.printTrace(self.id, waitEvent='(canDispose or interruption start)') self.printTrace(self.id, waitEvent='(canDispose or interruption start)')
receivedEvent=yield self.env.any_of([self.canDispose , self.interruptionStart]) receivedEvent=yield self.env.any_of([self.canDispose , self.interruptionStart])
# if there was interruption # if there was interruption
#if self.interrupted():
# TODO not good implementation # TODO not good implementation
if self.interruptionStart in receivedEvent: if self.interruptionStart in receivedEvent:
assert self.interruptionStart.value==self.env.now, 'the interruption has not been processed on the time of activation' assert self.interruptionStart.value==self.env.now, 'the interruption has not been processed on the time of activation'
self.interruptionStart=self.env.event() self.interruptionStart=self.env.event()
# wait for the end of the interruption # wait for the end of the interruption
self.interruptionActions() # execute interruption actions self.interruptionActions() # execute interruption actions
# loop until we reach at a state that there is no interruption
while 1: while 1:
yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption yield self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it' assert self.env.now==self.interruptionEnd.value, 'the victim of the failure is not the object that received it'
...@@ -602,7 +601,10 @@ class Machine(CoreObject): ...@@ -602,7 +601,10 @@ class Machine(CoreObject):
# add working time # add working time
self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted
# blocking starts
self.isBlocked=True
self.timeLastBlockageStarted=self.env.now self.timeLastBlockageStarted=self.env.now
activeObjectQueue=self.Res.users activeObjectQueue=self.Res.users
activeEntity=activeObjectQueue[0] activeEntity=activeObjectQueue[0]
self.printTrace(self.getActiveObjectQueue()[0].name, processEnd=self.objName) self.printTrace(self.getActiveObjectQueue()[0].name, processEnd=self.objName)
...@@ -632,8 +634,7 @@ class Machine(CoreObject): ...@@ -632,8 +634,7 @@ class Machine(CoreObject):
G.pendingEntities.append(activeObjectQueue[0]) G.pendingEntities.append(activeObjectQueue[0])
# set the variable that flags an Entity is ready to be disposed # set the variable that flags an Entity is ready to be disposed
self.waitToDispose=True self.waitToDispose=True
# blocking starts
self.isBlocked=True
# update the variables keeping track of Entity related attributes of the machine # update the variables keeping track of Entity related attributes of the machine
self.timeLastEntityEnded=self.env.now # this holds the time that the last entity ended processing in Machine self.timeLastEntityEnded=self.env.now # this holds the time that the last entity ended processing in Machine
self.nameLastEntityEnded=self.currentEntity.name # this holds the name of the last entity that ended processing in Machine self.nameLastEntityEnded=self.currentEntity.name # this holds the name of the last entity that ended processing in Machine
...@@ -668,11 +669,12 @@ class Machine(CoreObject): ...@@ -668,11 +669,12 @@ class Machine(CoreObject):
# actions to be carried out when the processing of an Entity ends # actions to be carried out when the processing of an Entity ends
# ======================================================================= # =======================================================================
def interruptionActions(self): def interruptionActions(self):
# if we are processing add the working time # if object was processing add the working time
# only if object is not preempting though # only if object is not preempting though
# in case of preemption endProcessingActions will be called # in case of preemption endProcessingActions will be called
if self.isProcessing and not self.shouldPreempt: if self.isProcessing and not self.shouldPreempt:
self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted
# if object was blocked add the working time
if self.isBlocked: if self.isBlocked:
self.addBlockage() self.addBlockage()
...@@ -959,44 +961,20 @@ class Machine(CoreObject): ...@@ -959,44 +961,20 @@ class Machine(CoreObject):
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue() activeObjectQueue=self.getActiveObjectQueue()
alreadyAdded=False # a flag that shows if the blockage time has already been added
# checks all the successors. If no one can accept an Entity then the machine might be blocked
mightBeBlocked=True
for nextObject in self.next:
if nextObject.canAccept():
mightBeBlocked=False
#calculate the offShift time for current entity #calculate the offShift time for current entity
offShiftTimeInCurrentEntity=0 offShiftTimeInCurrentEntity=0
if self.interruptedBy: if self.interruptedBy:
if self.onShift==False: # and self.interruptedBy=='ShiftScheduler': if self.onShift==False: # and self.interruptedBy=='ShiftScheduler':
offShiftTimeInCurrentEntity=self.env.now-activeObject.timeLastShiftEnded offShiftTimeInCurrentEntity=self.env.now-activeObject.timeLastShiftEnded
# # if there is an entity that finished processing in a Machine but did not get to reach
# # the following Object till the end of simulation,
# # we have to add this blockage to the percentage of blockage in Machine
# # we should exclude the failure time in current entity though!
# if (len(activeObjectQueue)>0) and (mightBeBlocked)\
# and ((activeObject.nameLastEntityEntered == activeObject.nameLastEntityEnded)) and self.onShift:
# # be careful here, might have to reconsider
# activeObject.totalBlockageTime+=self.env.now-(activeObject.timeLastEntityEnded+activeObject.downTimeInTryingToReleaseCurrentEntity)
# if activeObject.Up==False:
# activeObject.totalBlockageTime-=self.env.now-activeObject.timeLastFailure
# alreadyAdded=True
if self.isBlocked: if self.isBlocked:
self.addBlockage() self.addBlockage()
#if Machine is currently processing an entity we should count this working time #if Machine is currently processing an entity we should count this working time
if(self.isProcessing): if self.isProcessing:
#if Machine is down we should add this last failure time to the time that it has been down in current entity
# if self.Up==False:
# # if(len(activeObjectQueue)>0) and (self.Up==False):
# activeObject.downTimeProcessingCurrentEntity+=self.env.now-activeObject.timeLastFailure
activeObject.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted activeObject.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted
activeObject.totalTimeWaitingForOperator+=activeObject.operatorWaitTimeCurrentEntity # activeObject.totalTimeWaitingForOperator+=activeObject.operatorWaitTimeCurrentEntity
elif(len(activeObject.getActiveObjectQueue())>0)\ elif(len(activeObject.getActiveObjectQueue())>0)\
and (not (activeObject.nameLastEntityEnded==activeObject.nameLastEntityEntered))\ and (not (activeObject.nameLastEntityEnded==activeObject.nameLastEntityEntered))\
...@@ -1011,17 +989,10 @@ class Machine(CoreObject): ...@@ -1011,17 +989,10 @@ class Machine(CoreObject):
# we also need to add the last blocking time to total blockage time # we also need to add the last blocking time to total blockage time
if(activeObject.Up==False): if(activeObject.Up==False):
activeObject.totalFailureTime+=self.env.now-activeObject.timeLastFailure activeObject.totalFailureTime+=self.env.now-activeObject.timeLastFailure
# # we add the value only if it hasn't already been added
# if((mightBeBlocked) and (activeObject.nameLastEntityEnded==activeObject.nameLastEntityEntered) and (not alreadyAdded)):
# activeObject.totalBlockageTime+=(self.env.now-activeObject.timeLastEntityEnded)-(self.env.now-activeObject.timeLastFailure)-activeObject.downTimeInTryingToReleaseCurrentEntity
# alreadyAdded=True
#if the machine is off shift,add this to the off-shift time #if the machine is off shift,add this to the off-shift time
# we also need to add the last blocking time to total blockage time
if activeObject.onShift==False: if activeObject.onShift==False:
self.totalOffShiftTime+=self.env.now-self.timeLastShiftEnded self.totalOffShiftTime+=self.env.now-self.timeLastShiftEnded
# if((mightBeBlocked) and (activeObject.nameLastEntityEnded==activeObject.nameLastEntityEntered) and (not alreadyAdded)):
# activeObject.totalBlockageTime+=(self.env.now-activeObject.timeLastEntityEnded)-offShiftTimeInCurrentEntity
#Machine was idle when it was not in any other state #Machine was idle when it was not in any other state
activeObject.totalWaitingTime=MaxSimtime-activeObject.totalWorkingTime-activeObject.totalBlockageTime-activeObject.totalFailureTime-activeObject.totalLoadTime-activeObject.totalSetupTime-self.totalOffShiftTime activeObject.totalWaitingTime=MaxSimtime-activeObject.totalWorkingTime-activeObject.totalBlockageTime-activeObject.totalFailureTime-activeObject.totalLoadTime-activeObject.totalSetupTime-self.totalOffShiftTime
......
...@@ -48,6 +48,9 @@ class MachineJobShop(Machine): ...@@ -48,6 +48,9 @@ class MachineJobShop(Machine):
self.isProcessing=False self.isProcessing=False
# add working time # add working time
self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted
# blocking starts
self.isBlocked=True
self.timeLastBlockageStarted=self.env.now self.timeLastBlockageStarted=self.env.now
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
...@@ -97,8 +100,6 @@ class MachineJobShop(Machine): ...@@ -97,8 +100,6 @@ class MachineJobShop(Machine):
# reset flags # reset flags
self.shouldPreempt=False self.shouldPreempt=False
self.isProcessingInitialWIP=False self.isProcessingInitialWIP=False
# blocking starts
self.isBlocked=True
# TODO: collapse that to Machine # TODO: collapse that to Machine
......
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