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)
...@@ -79,6 +80,17 @@ class Break(ObjectInterruption): ...@@ -79,6 +80,17 @@ class Break(ObjectInterruption):
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
if issubclass(self.victim.__class__, CoreObject): if issubclass(self.victim.__class__, CoreObject):
......
...@@ -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