Commit edb0a270 authored by Georgios Dagkakis's avatar Georgios Dagkakis

correction in failure and synchronization

parent 3a882e9d
...@@ -87,37 +87,38 @@ class Failure(ObjectInterruption): ...@@ -87,37 +87,38 @@ class Failure(ObjectInterruption):
# ======================================================================= # =======================================================================
# 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):
while 1: while 1:
# if the time that the victim is off-shift should not be counted # if the time that the victim is off-shift should not be counted
if self.offshift: timeToFailure=self.rngTTF.generateNumber()
timeToFailure=self.rngTTF.generateNumber() remainingTimeToFailure=timeToFailure
remainingTimeToFailure=timeToFailure self.victim.expectedDownTime=self.env.now+remainingTimeToFailure
failureNotTriggered=True failureNotTriggered=True
while failureNotTriggered: while failureNotTriggered:
timeRestartedCounting=self.env.now timeRestartedCounting=self.env.now
# TODO: can also wait for interruptionStart signal of the victim and check whether the interruption is caused by a shiftScheduler # TODO: can also wait for interruptionStart signal of the victim and check whether the interruption is caused by a shiftScheduler
receivedEvent=yield self.env.timeout(remainingTimeToFailure) | self.victim.interruptionStart #offShift receivedEvent=yield self.env.timeout(remainingTimeToFailure) | self.victim.interruptionStart #offShift
# the failure should receive a signal if there is a shift-off triggered # the failure should receive a signal if there is a shift-off triggered
if self.victim.interruptionStart in receivedEvent: if self.victim.interruptionStart in receivedEvent:
# 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 # 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' assert self.victim.onShift==False, 'shiftFailure cannot recalculate TTF if the victim is onShift'
remainingTimeToFailure=remainingTimeToFailure-(self.env.now-timeRestartedCounting) remainingTimeToFailure=remainingTimeToFailure-(self.env.now-timeRestartedCounting)
# wait for the shift to start again self.victim.expectedDownTime=self.env.now+remainingTimeToFailure
yield self.victim.interruptionEnd
assert self.victim.onShift==True, 'the victim of shiftFailure must be onShift to continue counting the TTF' # wait for the shift to start again
# 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 yield self.victim.interruptionEnd
else: assert self.victim.onShift==True, 'the victim of shiftFailure must be onShift to continue counting the TTF'
failureNotTriggered=False # 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: else:
yield self.env.timeout(self.rngTTF.generateNumber()) # wait until a failure happens failureNotTriggered=False
self.interruptVictim() # interrupt the victim self.interruptVictim() # interrupt the victim
self.victim.Up=False self.victim.Up=False
self.victim.timeLastFailure=self.env.now self.victim.timeLastFailure=self.env.now
self.outputTrace("is down") self.outputTrace("is down")
# update the failure time # update the failure time
failTime=self.env.now failTime=self.env.now
if(self.repairman and self.repairman!="None"): #if the failure needs a resource to be fixed, the machine waits until the if(self.repairman and self.repairman!="None"): #if the failure needs a resource to be fixed, the machine waits until the
#resource is available #resource is available
# print self.env.now, self.repairman.id, 'will be requested by', self.victim.id # print self.env.now, self.repairman.id, 'will be requested by', self.victim.id
......
...@@ -189,6 +189,7 @@ class Machine(CoreObject): ...@@ -189,6 +189,7 @@ class Machine(CoreObject):
self.preemptQueue=self.env.event() self.preemptQueue=self.env.event()
# signal used for informing objectInterruption objects that the current entity processed has finished processnig # signal used for informing objectInterruption objects that the current entity processed has finished processnig
self.endedLastProcessing=self.env.event() self.endedLastProcessing=self.env.event()
self.expectedDownTime=-1 # the time the next failure is expected
#=========================================================================== #===========================================================================
# create an operatorPool if needed # create an operatorPool if needed
...@@ -692,7 +693,10 @@ class Machine(CoreObject): ...@@ -692,7 +693,10 @@ class Machine(CoreObject):
# checks if the machine is Up # checks if the machine is Up
# ======================================================================= # =======================================================================
def checkIfMachineIsUp(self): 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 # 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