Commit 94870873 authored by Georgios Dagkakis's avatar Georgios Dagkakis

possibility to input a threshold in the ShiftScheduler. If the time to end...

possibility to input a threshold in the ShiftScheduler. If the time to end shift is below this threshold then machine does not accept new jobs
parent 0e4a576b
......@@ -152,6 +152,8 @@ class CoreObject(object):
# attributes/indices used for printing the route, hold the cols corresponding to the machine (entities route and operators route)
self.station_col_inds=[]
self.op_col_indx=None
# flag that locks the entry of an object so that it cannot receive entities
self.isLocked=False
# =======================================================================
# the main process of the core object
......
......@@ -1351,7 +1351,9 @@ def createObjectInterruptions():
element[1]=next[1]
shiftPattern.remove(next)
endUnfinished=bool(int(shift.get('endUnfinished', 0)))
SS=ShiftScheduler(victim, shiftPattern, endUnfinished)
receiveBeforeEndThreshold=float(shift.get('receiveBeforeEndThreshold', 0))
SS=ShiftScheduler(victim, shiftPattern=shiftPattern, endUnfinished=endUnfinished,
receiveBeforeEndThreshold=receiveBeforeEndThreshold)
victim.objectInterruptions.append(SS)
G.ObjectInterruptionList.append(SS)
G.ShiftSchedulerList.append(SS)
......
......@@ -715,6 +715,8 @@ class Machine(CoreObject):
# that will give the entity.
# =======================================================================
def canAccept(self, callerObject=None):
if self.isLocked:
return False
activeObjectQueue=self.Res.users
# if we have only one predecessor just check if there is a place and the machine is up
# this is done to achieve better (cpu) processing time
......
......@@ -39,13 +39,13 @@ class ShiftScheduler(ObjectInterruption):
# =======================================================================
# the __init__() method of the class
# =======================================================================
def __init__(self, victim=None, shiftPattern=[], endUnfinished=False):
def __init__(self, victim=None, shiftPattern=[], endUnfinished=False, receiveBeforeEndThreshold=0.0):
ObjectInterruption.__init__(self,victim)
self.type='ShiftScheduler'
self.shiftPattern=shiftPattern
self.endUnfinished=endUnfinished #flag that shows if half processed Jobs should end after the shift ends
# if the end of shift is below this threshold then the victim is on shift but does not accept new entities
self.receiveBeforeEndThreshold=receiveBeforeEndThreshold
# =======================================================================
# initialize for every replications
......@@ -80,7 +80,11 @@ class ShiftScheduler(ObjectInterruption):
self.outputTrace("is on shift")
startShift=self.env.now
else:
yield self.env.timeout(float(self.remainingShiftPattern[0][1]-self.env.now)) # wait until the shift is over
timeToEndShift=float(self.remainingShiftPattern[0][1]-self.env.now)
yield self.env.timeout(timeToEndShift-self.receiveBeforeEndThreshold) # wait until the entry threshold
self.victim.isLocked=True # lock the entry of the victim
yield self.env.timeout(self.receiveBeforeEndThreshold) # wait until the shift is over
self.victim.isLocked=False # unlock the entry of the victim
# if the mode is to end current work before going off-shift and there is current work, wait for victimEndedLastProcessing
# signal before going off-shift
if self.endUnfinished and len(self.victim.getActiveObjectQueue())==1 and (not self.victim.waitToDispose):
......
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