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