Commit a01083db authored by Georgios Dagkakis's avatar Georgios Dagkakis

Failure time to be counted only if Machine is onShift

parent ac5526b4
......@@ -178,9 +178,20 @@ class Failure(ObjectInterruption):
yield self.env.timeout(self.rngTTR.generateNumber()) # wait until the repairing process is over
# add the failure time only if the victim was interrupted by this failure
if self.victim.interruptedBy == 'Failure':
self.victim.totalFailureTime+=self.env.now-failTime
# add the failure
# if victim is off shift add only the fail time before the shift ended
if not self.victim.onShift and failTime < self.victim.timeLastShiftEnded:
self.victim.totalFailureTime+=self.victim.timeLastShiftEnded-failTime
# if the victim was off shift since the start of the failure add nothing
elif not self.victim.onShift and failTime >= self.victim.timeLastShiftEnded:
pass
# if victim was off shift in the start of the fail time, add on
elif self.victim.onShift and failTime < self.victim.timeLastShiftStarted:
self.victim.totalFailureTime+=self.env.now-self.victim.timeLastShiftStarted
# this can happen only if deteriorationType is constant
assert self.deteriorationType=='constant', 'object got failure while off-shift and deterioration type not constant'
else:
self.victim.totalFailureTime+=self.env.now-failTime
self.reactivateVictim() # since repairing is over, the Machine is reactivated
self.victim.Up=True
self.outputTrace("is up")
......@@ -615,7 +615,7 @@ class Machine(CoreObject):
# set the variable that flags an Entity is ready to be disposed
self.waitToDispose=True
#do this so that if it is overtime working it is not counted as off-shift time
if not self.onShift:
if not self.onShift and self.interruptedBy=='ShiftScheduler':
self.timeLastShiftEnded=self.env.now
# update the total working time
# the total processing time for this entity is what the distribution initially gave
......@@ -937,7 +937,7 @@ class Machine(CoreObject):
#calculate the offShift time for current entity
offShiftTimeInCurrentEntity=0
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
# if there is an entity that finished processing in a Machine but did not get to reach
......@@ -988,13 +988,7 @@ class Machine(CoreObject):
#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:
#add the time only if the object is interrupted because of off-shift
if self.interruptedBy:
if self.interruptedBy=='ShiftScheduler':
self.totalOffShiftTime+=self.env.now-self.timeLastShiftEnded
elif len(self.getActiveObjectQueue())==0 or self.waitToDispose:
self.totalOffShiftTime+=self.env.now-self.timeLastShiftEnded
# we add the value only if it hasn't already been added
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
......
......@@ -74,7 +74,6 @@ class ShiftScheduler(ObjectInterruption):
if not self.victim.onShift:
yield self.env.timeout(float(self.remainingShiftPattern[0][0]-self.env.now)) # wait for the onShift
self.reactivateVictim() # re-activate the victim in case it was interrupted
self.victim.totalOffShiftTime+=self.env.now-self.victim.timeLastShiftEnded
self.victim.onShift=True
self.victim.timeLastShiftStarted=self.env.now
......
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