Commit 484ce818 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

change in ShiftScheduler to correctly interrupt the victim. TODO topology53 and starting conditions

parent cd832a16
......@@ -93,6 +93,8 @@ class CoreObject(object):
# ============================== waiting flag ==============================================
self.waitToDispose=False #shows if the object waits to dispose an entity
self.isWorkingOnTheLastBeforeOffShift=False #shows if the object is performing the last processing before it goes offShift
# ============================== the below are currently used in Jobshop =======================
self.giver=None #the CoreObject that the activeObject will take an Entity from
if len(self.previous)>0:
......@@ -135,6 +137,7 @@ class CoreObject(object):
self.interruptedBy=None
self.entityRemoved=self.env.event()
# =======================================================================
# the main process of the core object
# this is dummy, every object must have its own implementation
......
......@@ -528,6 +528,14 @@ class Machine(CoreObject):
self.completedJobs+=1 # Machine completed one more Job
# reseting the shouldPreempt flag
self.shouldPreempt=False
if self.isWorkingOnTheLastBeforeOffShift:
mySS=None
for SS in G.ShiftSchedulerList:
if SS.victim==self:
mySS=SS
break
mySS.victimEndedLastProcessing.succeed()
self.isWorkingOnTheLastBeforeOffShift=False
# =======================================================================
# actions to be carried out when the processing of an Entity ends
......
......@@ -53,6 +53,7 @@ class ShiftScheduler(ObjectInterruption):
def initialize(self):
ObjectInterruption.initialize(self)
self.remainingShiftPattern=list(self.shiftPattern)
self.victimEndedLastProcessing=self.env.event()
# =======================================================================
# The run method for the failure which has to served by a repairman
......@@ -60,10 +61,20 @@ class ShiftScheduler(ObjectInterruption):
def run(self):
self.victim.totalOffShiftTime=0
self.victim.timeLastShiftEnded=self.env.now
# if in the beginning the victim is offShift
if float(self.remainingShiftPattern[0][0])!=self.env.now:
self.victim.onShift=False
yield self.env.timeout(float(self.remainingShiftPattern[0][1]-self.env.now)) # wait until the shift is over
self.interruptVictim() # interrupt processing operations if any
self.victim.onShift=False # get the victim off-shift
self.victim.timeLastShiftEnded=self.env.now
self.outputTrace("is off shift")
self.remainingShiftPattern.pop(0)
while 1:
if not self.victim.onShift:
yield self.env.timeout(float(self.remainingShiftPattern[0][0]-self.env.now)) # wait for the onShift
if(len(self.getVictimQueue())>0 and self.victim.interruptedBy==self.type and not(self.endUnfinished)):
self.reactivateVictim() # re-activate the victim in case it was interrupted
self.victim.totalOffShiftTime+=self.env.now-self.victim.timeLastShiftEnded
......@@ -71,10 +82,12 @@ class ShiftScheduler(ObjectInterruption):
self.victim.timeLastShiftStarted=self.env.now
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
if self.endUnfinished and len(self.victim.getActiveObjectQueue())==1 and (not self.victim.waitToDispose):
self.victim.isWorkingOnTheLastBeforeOffShift=True
yield self.victimEndedLastProcessing
if(len(self.getVictimQueue())>0 and not(self.endUnfinished)):
self.interruptVictim() # interrupt processing operations if any
self.victim.onShift=False # get the victim off-shift
self.victim.timeLastShiftEnded=self.env.now
......
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