Commit 6d6129a4 authored by Georgios Dagkakis's avatar Georgios Dagkakis

breaks may be suspended if near the end of the shift

parent 44f488c8
...@@ -35,12 +35,13 @@ from ObjectInterruption import ObjectInterruption ...@@ -35,12 +35,13 @@ from ObjectInterruption import ObjectInterruption
class Break(ObjectInterruption): class Break(ObjectInterruption):
def __init__(self, id='',name='',victim=None, distribution={},deteriorationType='constant', def __init__(self, id='',name='',victim=None, distribution={},deteriorationType='constant',
endUnfinished=True,**kw): endUnfinished=True,offShiftAnticipation=0,**kw):
ObjectInterruption.__init__(self,id,name,victim=victim) ObjectInterruption.__init__(self,id,name,victim=victim)
self.rngTTB=RandomNumberGenerator(self, distribution.get('TTB',{'Fixed':{'mean':100}})) self.rngTTB=RandomNumberGenerator(self, distribution.get('TTB',{'Fixed':{'mean':100}}))
self.rngTTR=RandomNumberGenerator(self, distribution.get('TTR',{'Fixed':{'mean':10}})) self.rngTTR=RandomNumberGenerator(self, distribution.get('TTR',{'Fixed':{'mean':10}}))
self.type="Break" self.type="Break"
self.endUnfinished=endUnfinished self.endUnfinished=endUnfinished
self.offShiftAnticipation=offShiftAnticipation
def initialize(self): def initialize(self):
ObjectInterruption.initialize(self) ObjectInterruption.initialize(self)
...@@ -78,6 +79,17 @@ class Break(ObjectInterruption): ...@@ -78,6 +79,17 @@ class Break(ObjectInterruption):
# reset the signalparam of the victimOffShift event # reset the signalparam of the victimOffShift event
self.victimOffShift=self.env.event() self.victimOffShift=self.env.event()
continue continue
# check if we are close to the end of the shift. If yes then the break may be suspended
# (depending on offShiftAnticipation)
timeToNextOfShift=None
for oi in self.victim.objectInterruptions:
if oi.type=='ShiftScheduler':
if oi.remainingShiftPattern:
timeToNextOfShift=oi.remainingShiftPattern[0][1]
if timeToNextOfShift:
if self.offShiftAnticipation>=timeToNextOfShift-self.env.now:
continue
# interrupt the victim # interrupt the victim
# if the victim is station # if the victim is station
...@@ -121,7 +133,7 @@ class Break(ObjectInterruption): ...@@ -121,7 +133,7 @@ class Break(ObjectInterruption):
breakTime=self.env.now breakTime=self.env.now
yield self.env.timeout(self.rngTTR.generateNumber()) # wait until the repairing process is over yield self.env.timeout(self.rngTTR.generateNumber()) # wait until the repairing process is over
# add the break # add the break
# if victim is off shift add only the fail time before the shift ended # if victim is off shift add only the fail time before the shift ended
if not self.victim.onShift and breakTime < self.victim.timeLastShiftEnded: if not self.victim.onShift and breakTime < self.victim.timeLastShiftEnded:
......
...@@ -349,8 +349,9 @@ def createObjectInterruptions(): ...@@ -349,8 +349,9 @@ def createObjectInterruptions():
victim=Globals.findObjectById(element['id']) victim=Globals.findObjectById(element['id'])
endUnfinished=bool(int(br.get('endUnfinished', 1))) endUnfinished=bool(int(br.get('endUnfinished', 1)))
deteriorationType=br.get('deteriorationType', 'constant') deteriorationType=br.get('deteriorationType', 'constant')
offShiftAnticipation=br.get('offShiftAnticipation',0)
BR=Break(victim=victim, distribution=br,endUnfinished=endUnfinished,deteriorationType=deteriorationType) BR=Break(victim=victim, distribution=br,endUnfinished=endUnfinished,deteriorationType=deteriorationType,
offShiftAnticipation=offShiftAnticipation)
G.ObjectInterruptionList.append(BR) G.ObjectInterruptionList.append(BR)
G.FailureList.append(BR) G.FailureList.append(BR)
......
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