Commit a43be552 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

schedulled interruptions approach made more generic

parent f6cc8c75
......@@ -95,9 +95,7 @@ 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
self.isWorkingOnTheLastBeforeMaintenance=False #shows if the object is performing the last processing before maintenance
self.isWorkingOnTheLast=False #shows if the object is performing the last processing before scheduled interruption
# ============================== the below are currently used in Jobshop =======================
self.giver=None #the CoreObject that the activeObject will take an Entity from
......
......@@ -544,29 +544,18 @@ class Machine(CoreObject):
self.completedJobs+=1 # Machine completed one more Job
# reseting the shouldPreempt flag
self.shouldPreempt=False
# in case Machine just performed the last work before end of shift it should signal the ShiftScheduler
if self.isWorkingOnTheLastBeforeOffShift:
# find the ShiftSchedulerList
mySS=None
for SS in G.ShiftSchedulerList:
if SS.victim==self:
mySS=SS
break
# set the signal
mySS.victimEndedLastProcessing.succeed()
# reset the flag
self.isWorkingOnTheLastBeforeOffShift=False
# in case Machine just performed the last work before the maintenance it should signal the ShiftScheduler
if self.isWorkingOnTheLastBeforeMaintenance:
# find the scheduledMaintenanceList
mySM=None
for SM in G.ScheduledMaintenanceList:
if SM.victim==self:
mySM=SM
# set the signal
mySM.victimEndedLastProcessing.succeed(self.env.now)
# reset the flag
self.isWorkingOnTheLastBeforeMaintenance=False
# in case Machine just performed the last work before the scheduled maintenance signal the corresponding object
if self.isWorkingOnTheLast:
# for the scheduled Object interruptions
for interruption in (G.ShiftSchedulerList+G.ScheduledMaintenanceList):
# if the objectInterruption is waiting for a a signal
if interruption.victim==self and interruption.waitingSignal:
# signal it and reset the flags
interruption.victimEndedLastProcessing.succeed(self.env.now)
interruption.waitinSignal=False
self.isWorkingOnTheLast=False
# =======================================================================
# actions to be carried out when the processing of an Entity ends
......
......@@ -56,8 +56,9 @@ class ScheduledMaintenance(ObjectInterruption):
def initialize(self):
ObjectInterruption.initialize(self)
self.victimEndedLastProcessing=self.env.event()
self.waitingSignal=False
# not used yet
self.victimIsEmpty=self.env.now
self.victimIsEmptyBeforeMaintenance=self.env.event()
# =======================================================================
# the run method
......@@ -77,7 +78,8 @@ class ScheduledMaintenance(ObjectInterruption):
self.interruptVictim() # while in process it is interrupted
elif self.endstatus=='loaded':
waitStartTime=self.env.now
self.victim.isWorkingOnTheLastBeforeMaintenance=True
self.victim.isWorkingOnTheLast=True
self.waitingSignal=True
# TODO: signal to be triggered by postProcessingActions of Machines
yield self.victimEndedLastProcessing # there is no signal yet that signals the change of such state (an object getting empty)
assert self.victimEndedLastProcessing.value==self.env.now, 'the processing end signal is not received by maintenance on time'
......@@ -86,10 +88,11 @@ class ScheduledMaintenance(ObjectInterruption):
self.interruptVictim()
elif self.endStatus=='emptied':
waitStartTime=self.env.now
self.waitingSignal=True
# TODO: signal to be triggered by removeEntity of Machines
yield self.victimIsEmpty # there is no signal yet that signals the change of such state (an object getting empty)
assert self.victimIsEmpty.value==self.env.now, 'the processing end signal is not received by maintenance on time'
self.victimIsEmpty=self.env.event()
yield self.victimIsEmptyBeforeMaintenance # there is no signal yet that signals the change of such state (an object getting empty)
assert self.victimIsEmptyBeforeMaintenance.value==self.env.now, 'the processing end signal is not received by maintenance on time'
self.victimIsEmptyBeforeMaintenance=self.env.event()
waitTime=self.env.now-waitStartTime
self.victim.Up=False
self.victim.timeLastFailure=self.env.now
......
......@@ -54,11 +54,13 @@ class ShiftScheduler(ObjectInterruption):
ObjectInterruption.initialize(self)
self.remainingShiftPattern=list(self.shiftPattern)
self.victimEndedLastProcessing=self.env.event()
self.waitingSignal=False
# =======================================================================
# The run method for the failure which has to served by a repairman
# =======================================================================
def run(self):
def run(self):
# the victim should not be interrupted but the scheduler should wait for the processing to finish before the stations turns to off-shift mode
self.victim.totalOffShiftTime=0
self.victim.timeLastShiftEnded=self.env.now
# if in the beginning the victim is offShift set it as such
......@@ -83,7 +85,8 @@ class ShiftScheduler(ObjectInterruption):
# 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):
self.victim.isWorkingOnTheLastBeforeOffShift=True
self.victim.isWorkingOnTheLast=True
self.waitingSignal=True
yield self.victimEndedLastProcessing
self.victimEndedLastProcessing=self.env.event()
......
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