Commit 9bd9d4e8 authored by Georgios Dagkakis's avatar Georgios Dagkakis

correction in object interruptions. If Shift waits for last process and...

correction in object interruptions. If Shift waits for last process and failure happens, then shift should end
parent 63dcf96f
......@@ -165,7 +165,13 @@ class Failure(ObjectInterruption):
# interrupt the victim
self.interruptVictim() # interrupt the victim
from ShiftScheduler import ShiftScheduler
# check in the ObjectInterruptions of the victim. If there is a one that is waiting for victimFailed send it
for oi in self.victim.objectInterruptions:
if oi.__class__ is ShiftScheduler:
if oi.expectedSignals['victimFailed']:
self.sendSignal(receiver=oi, signal=oi.victimFailed)
self.victim.Up=False
self.victim.timeLastFailure=self.env.now
self.outputTrace(self.victim.name,"is down")
......
......@@ -56,15 +56,17 @@ class ObjectInterruption(ManPyObject):
"endedLastProcessing":0,
"victimIsEmptyBeforeMaintenance":0,
"resourceAvailable":0,
"victimFailed":0
}
def initialize(self):
from Globals import G
self.env=G.env
self.call=False
# events that are send by the ShiftScheduler to all the other interruptions that might wait for them
# events that are send by one interruption to all the other interruptions that might wait for them
self.victimOffShift=self.env.event()
self.victimOnShift=self.env.event()
self.victimFailed=self.env.event()
# flags that show if the interruption waits for the event
self.isWaitingForVictimOffShift=False
self.isWaitingForVictimOnShift=False
......@@ -78,6 +80,7 @@ class ObjectInterruption(ManPyObject):
"endedLastProcessing":0,
"victimIsEmptyBeforeMaintenance":0,
"resourceAvailable":0,
"victimFailed":0
}
#===========================================================================
......
......@@ -116,15 +116,21 @@ class ShiftScheduler(ObjectInterruption):
# if the victim is station
if issubclass(self.victim.__class__, CoreObject):
# if the mode is to end current work before going off-shift and there is current work,
# wait for victimEndedLastProcessing
# wait for victimEndedLastProcessing or victimFailed
# signal before going off-shift
if self.endUnfinished and self.victim.isProcessing:
self.victim.isWorkingOnTheLast=True
self.waitingSignal=True
self.expectedSignals['endedLastProcessing']=1
yield self.victim.endedLastProcessing
transmitter, eventTime=self.victim.endedLastProcessing.value
self.victim.endedLastProcessing=self.env.event()
self.expectedSignals['victimFailed']=1
receivedEvent=yield self.env.any_of([self.victim.endedLastProcessing , self.victimFailed])
if self.victim.endedLastProcessing in receivedEvent:
transmitter, eventTime=self.victim.endedLastProcessing.value
self.victim.endedLastProcessing=self.env.event()
elif self.victimFailed in receivedEvent:
print self.env.now,self.victim.id, 'received victim failed'
transmitter, eventTime=self.victimFailed.value
self.victimFailed=self.env.event()
# sometimes the time to end the last process may overcome the time to restart theshift
# so off-shift should not happen at such a case
if len(self.remainingShiftPattern)>1:
......
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