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