Commit 5de2d166 authored by Georgios Dagkakis's avatar Georgios Dagkakis

shift to be able to work as rolling

parent 1a03a489
......@@ -337,9 +337,12 @@ def createObjectInterruptions():
endUnfinished=bool(int(shift.get('endUnfinished', 0)))
receiveBeforeEndThreshold=float(shift.get('receiveBeforeEndThreshold', 0))
thresholdTimeIsOnShift=bool(int(shift.get('thresholdTimeIsOnShift', 1)))
rolling=bool(int(shift.get('rolling', 0)))
lastOffShiftDuration=float(shift.get('lastOffShiftDuration', 10))
SS=ShiftScheduler(victim=victim, shiftPattern=shiftPattern, endUnfinished=endUnfinished,
receiveBeforeEndThreshold=receiveBeforeEndThreshold,
thresholdTimeIsOnShift=thresholdTimeIsOnShift)
thresholdTimeIsOnShift=thresholdTimeIsOnShift,
rolling=rolling, lastOffShiftDuration=lastOffShiftDuration)
G.ObjectInterruptionList.append(SS)
G.ShiftSchedulerList.append(SS)
br=element.get('interruptions',{}).get('break', None)
......
......@@ -30,6 +30,7 @@ schedules the availability of an object according to its shift pattern
import simpy
from RandomNumberGenerator import RandomNumberGenerator
from ObjectInterruption import ObjectInterruption
from copy import deepcopy
# ===========================================================================
# the shift scheduler class
......@@ -40,7 +41,7 @@ class ShiftScheduler(ObjectInterruption):
# the __init__() method of the class
# =======================================================================
def __init__(self, id='', name='', victim=None, shiftPattern=[], endUnfinished=False, receiveBeforeEndThreshold=0.0,
thresholdTimeIsOnShift=True,**kw):
thresholdTimeIsOnShift=True,rolling=False,lastOffShiftDuration=10,**kw):
ObjectInterruption.__init__(self,victim=victim)
self.type='ShiftScheduler'
self.shiftPattern=shiftPattern
......@@ -49,6 +50,8 @@ class ShiftScheduler(ObjectInterruption):
self.receiveBeforeEndThreshold=receiveBeforeEndThreshold
# flag that shows if the threshold time is counted as off-shift or waiting
self.thresholdTimeIsOnShift=thresholdTimeIsOnShift
self.rolling=rolling
self.lastOffShiftDuration=lastOffShiftDuration
# =======================================================================
# initialize for every replications
......@@ -177,6 +180,15 @@ class ShiftScheduler(ObjectInterruption):
self.outputTrace(self.victim.name,"is off shift")
self.remainingShiftPattern.pop(0)
# if there is no more shift data break the loop
if len(self.remainingShiftPattern)==0:
break
# if there is no more shift data
if not len(self.remainingShiftPattern):
# if the shift is rolling recreate the pattern
if self.rolling:
self.remainingShiftPattern=deepcopy(self.shiftPattern)
for record in self.remainingShiftPattern:
# for value in record:
record[0]+=(self.env.now+self.lastOffShiftDuration)
record[1]+=(self.env.now+self.lastOffShiftDuration)
# else break the loop
else:
break
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