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

changes in postProcessing of machine so that off-shift is added correctly

parent 29dbb708
...@@ -69,11 +69,15 @@ class CoreObject(Process): ...@@ -69,11 +69,15 @@ class CoreObject(Process):
self.nameLastEntityEnded="" #holds the name of the last entity that ended processing in the object self.nameLastEntityEnded="" #holds the name of the last entity that ended processing in the object
self.timeLastEntityEntered=0 #holds the last time that an entity entered in the object self.timeLastEntityEntered=0 #holds the last time that an entity entered in the object
self.nameLastEntityEntered="" #holds the name of the last entity that entered in the object self.nameLastEntityEntered="" #holds the name of the last entity that entered in the object
self.timeLastFailure=0 #holds the time that the last failure of the object started
self.timeLastFailureEnded=0 #holds the time that the last failure of the object ended # ============================== shift related times =====================================
self.timeLastShiftStarted=0 #holds the time that the last shift of the object started self.timeLastShiftStarted=0 #holds the time that the last shift of the object started
self.timeLastShiftEnded=0 #holds the time that the last shift of the object ended self.timeLastShiftEnded=0 #holds the time that the last shift of the object ended
self.offShiftTimeTryingToReleaseCurrentEntity=0 #holds the time that the object was off-shift while trying
#to release the current entity
# ============================== failure related times ===================================== # ============================== failure related times =====================================
self.timeLastFailure=0 #holds the time that the last failure of the object started
self.timeLastFailureEnded=0 #holds the time that the last failure of the object ended
self.downTimeProcessingCurrentEntity=0 #holds the time that the machine was down while self.downTimeProcessingCurrentEntity=0 #holds the time that the machine was down while
#processing the current entity #processing the current entity
self.downTimeInTryingToReleaseCurrentEntity=0 #holds the time that the object was down while trying self.downTimeInTryingToReleaseCurrentEntity=0 #holds the time that the object was down while trying
...@@ -137,6 +141,7 @@ class CoreObject(Process): ...@@ -137,6 +141,7 @@ class CoreObject(Process):
self.failureTimeInCurrentEntity=0 self.failureTimeInCurrentEntity=0
self.downTimeInTryingToReleaseCurrentEntity=0 self.downTimeInTryingToReleaseCurrentEntity=0
self.offShiftTimeTryingToReleaseCurrentEntity=0
self.timeLastEntityLeft=now() self.timeLastEntityLeft=now()
self.outputTrace(activeEntity.name, "released "+self.objName) self.outputTrace(activeEntity.name, "released "+self.objName)
...@@ -149,7 +154,9 @@ class CoreObject(Process): ...@@ -149,7 +154,9 @@ class CoreObject(Process):
def addBlockage(self): def addBlockage(self):
self.totalTimeInCurrentEntity=now()-self.timeLastEntityEntered self.totalTimeInCurrentEntity=now()-self.timeLastEntityEntered
self.totalTimeWaitingForOperator += self.operatorWaitTimeCurrentEntity self.totalTimeWaitingForOperator += self.operatorWaitTimeCurrentEntity
blockage=now()-(self.timeLastEntityEnded+self.downTimeInTryingToReleaseCurrentEntity) if self.timeLastEntityEnded<self.timeLastShiftStarted:
self.offShiftTimeTryingToReleaseCurrentEntity=self.timeLastShiftStarted-self.timeLastEntityEnded
blockage=now()-(self.timeLastEntityEnded+self.downTimeInTryingToReleaseCurrentEntity+self.offShiftTimeTryingToReleaseCurrentEntity)
self.totalBlockageTime+=blockage self.totalBlockageTime+=blockage
# ======================================================================= # =======================================================================
......
...@@ -374,6 +374,11 @@ class Machine(CoreObject): ...@@ -374,6 +374,11 @@ class Machine(CoreObject):
# 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
#do this so that if it is overtime working it is not counted as off-shift time
if not self.onShift:
self.timeLastShiftEnded=now()
# update the total working time # update the total working time
self.totalWorkingTime+=self.totalProcessingTimeInCurrentEntity # the total processing time for this entity self.totalWorkingTime+=self.totalProcessingTimeInCurrentEntity # the total processing time for this entity
# is what the distribution initially gave # is what the distribution initially gave
...@@ -668,16 +673,15 @@ class Machine(CoreObject): ...@@ -668,16 +673,15 @@ class Machine(CoreObject):
mightBeBlocked=False mightBeBlocked=False
#calculate the offShift time for current entity #calculate the offShift time for current entity
if self.onShift==False:
offShiftTimeInCurrentEntity=now()-activeObject.timeLastShiftEnded
else:
offShiftTimeInCurrentEntity=0 offShiftTimeInCurrentEntity=0
if self.interruptCause:
if self.onShift==False and self.interruptCause.type=='ShiftScheduler':
offShiftTimeInCurrentEntity=now()-activeObject.timeLastShiftEnded
# if there is an entity that finished processing in a Machine but did not get to reach # 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, # the following Object till the end of simulation,
# we have to add this blockage to the percentage of blockage in Machine # we have to add this blockage to the percentage of blockage in Machine
# we should exclude the failure time in current entity though! # we should exclude the failure time in current entity though!
# if (len(self.Res.activeQ)>0) and (len(self.next[0].Res.activeQ)>0) and ((self.nameLastEntityEntered == self.nameLastEntityEnded)):
if (len(activeObjectQueue)>0) and (mightBeBlocked)\ if (len(activeObjectQueue)>0) and (mightBeBlocked)\
and ((activeObject.nameLastEntityEntered == activeObject.nameLastEntityEnded)): and ((activeObject.nameLastEntityEntered == activeObject.nameLastEntityEnded)):
# be careful here, might have to reconsider # be careful here, might have to reconsider
...@@ -721,6 +725,11 @@ class Machine(CoreObject): ...@@ -721,6 +725,11 @@ class Machine(CoreObject):
#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 # we also need to add the last blocking time to total blockage time
if activeObject.onShift==False: if activeObject.onShift==False:
#add the time only if the object is interrupted because of off-shift
if self.interruptCause:
if self.interruptCause.type=='ShiftScheduler':
self.totalOffShiftTime+=now()-self.timeLastShiftEnded
elif len(self.getActiveObjectQueue())==0 or self.waitToDispose:
self.totalOffShiftTime+=now()-self.timeLastShiftEnded self.totalOffShiftTime+=now()-self.timeLastShiftEnded
# we add the value only if it hasn't already been added # we add the value only if it hasn't already been added
if((mightBeBlocked) and (activeObject.nameLastEntityEnded==activeObject.nameLastEntityEntered) and (not alreadyAdded)): if((mightBeBlocked) and (activeObject.nameLastEntityEnded==activeObject.nameLastEntityEntered) and (not alreadyAdded)):
......
...@@ -40,6 +40,7 @@ class ShiftScheduler(ObjectInterruption): ...@@ -40,6 +40,7 @@ class ShiftScheduler(ObjectInterruption):
# ======================================================================= # =======================================================================
def __init__(self, victim=None, shiftPattern=[], endUnfinished=False): def __init__(self, victim=None, shiftPattern=[], endUnfinished=False):
ObjectInterruption.__init__(self,victim) ObjectInterruption.__init__(self,victim)
self.type='ShiftScheduler'
self.shiftPattern=shiftPattern self.shiftPattern=shiftPattern
self.endUnfinished=endUnfinished #flag that shows if half processed Jobs should end after the shift ends self.endUnfinished=endUnfinished #flag that shows if half processed Jobs should end after the shift ends
...@@ -57,14 +58,14 @@ class ShiftScheduler(ObjectInterruption): ...@@ -57,14 +58,14 @@ class ShiftScheduler(ObjectInterruption):
# ======================================================================= # =======================================================================
def run(self): def run(self):
self.victim.totalOffShiftTime=0 self.victim.totalOffShiftTime=0
offShiftTime=now() self.victim.timeLastShiftEnded=now()
self.victim.onShift=False self.victim.onShift=False
while 1: while 1:
yield hold,self,float(self.remainingShiftPattern[0][0]-now()) # wait for the onShift yield hold,self,float(self.remainingShiftPattern[0][0]-now()) # wait for the onShift
if(len(self.getVictimQueue())>0 and self.victim.interruptCause and not(self.endUnfinished)): if(len(self.getVictimQueue())>0 and self.victim.interruptCause and not(self.endUnfinished)):
self.reactivateVictim() # re-activate the victim in case it was interrupted self.reactivateVictim() # re-activate the victim in case it was interrupted
self.victim.totalOffShiftTime+=now()-offShiftTime self.victim.totalOffShiftTime+=now()-self.victim.timeLastShiftEnded
self.victim.onShift=True self.victim.onShift=True
self.victim.timeLastShiftStarted=now() self.victim.timeLastShiftStarted=now()
self.outputTrace("is on shift") self.outputTrace("is on shift")
...@@ -75,7 +76,6 @@ class ShiftScheduler(ObjectInterruption): ...@@ -75,7 +76,6 @@ class ShiftScheduler(ObjectInterruption):
if(len(self.getVictimQueue())>0 and not(self.endUnfinished)): if(len(self.getVictimQueue())>0 and not(self.endUnfinished)):
self.interruptVictim() # interrupt processing operations if any self.interruptVictim() # interrupt processing operations if any
self.victim.onShift=False # get the victim off-shift self.victim.onShift=False # get the victim off-shift
offShiftTime=now()
self.victim.timeLastShiftEnded=now() self.victim.timeLastShiftEnded=now()
self.outputTrace("is off shift") self.outputTrace("is off shift")
......
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