Commit edb0a270 authored by Georgios Dagkakis's avatar Georgios Dagkakis

correction in failure and synchronization

parent 3a882e9d
......@@ -90,9 +90,9 @@ class Failure(ObjectInterruption):
def run(self):
while 1:
# if the time that the victim is off-shift should not be counted
if self.offshift:
timeToFailure=self.rngTTF.generateNumber()
remainingTimeToFailure=timeToFailure
self.victim.expectedDownTime=self.env.now+remainingTimeToFailure
failureNotTriggered=True
while failureNotTriggered:
......@@ -104,14 +104,15 @@ class Failure(ObjectInterruption):
# TODO: the signal interruptionStart is reset by the time it is received by the victim. not sure if will be still triggered when it is checked here
assert self.victim.onShift==False, 'shiftFailure cannot recalculate TTF if the victim is onShift'
remainingTimeToFailure=remainingTimeToFailure-(self.env.now-timeRestartedCounting)
self.victim.expectedDownTime=self.env.now+remainingTimeToFailure
# wait for the shift to start again
yield self.victim.interruptionEnd
assert self.victim.onShift==True, 'the victim of shiftFailure must be onShift to continue counting the TTF'
# TODO: the signal interruptionStart is reset by the time it is received by the victim. not sure if will be still triggered when it is checked here
else:
failureNotTriggered=False
else:
yield self.env.timeout(self.rngTTF.generateNumber()) # wait until a failure happens
self.interruptVictim() # interrupt the victim
self.victim.Up=False
self.victim.timeLastFailure=self.env.now
......
......@@ -189,6 +189,7 @@ class Machine(CoreObject):
self.preemptQueue=self.env.event()
# signal used for informing objectInterruption objects that the current entity processed has finished processnig
self.endedLastProcessing=self.env.event()
self.expectedDownTime=-1 # the time the next failure is expected
#===========================================================================
# create an operatorPool if needed
......@@ -692,7 +693,10 @@ class Machine(CoreObject):
# checks if the machine is Up
# =======================================================================
def checkIfMachineIsUp(self):
return self.Up
# the second part is added for synchronisation.
# if Machine is to get failure at the current time but did not get it yet
# return also false
return self.Up and not self.expectedDownTime==self.env.now
# =======================================================================
# checks if the Machine can accept an entity
......
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