Commit 312659ea authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

methods of interrupting and reactivating an object were passed to generic...

methods of interrupting and reactivating an object were passed to generic ObjectInterruption. This will make the interruptions more flexible
parent 675339d7
...@@ -26,7 +26,7 @@ Created on 9 Nov 2012 ...@@ -26,7 +26,7 @@ Created on 9 Nov 2012
models the failures that servers can have models the failures that servers can have
''' '''
from SimPy.Simulation import now, Process, hold, request, reactivate, release from SimPy.Simulation import now, Process, hold, request, release
import math import math
from RandomNumberGenerator import RandomNumberGenerator from RandomNumberGenerator import RandomNumberGenerator
from ObjectInterruption import ObjectInterruption from ObjectInterruption import ObjectInterruption
...@@ -86,7 +86,7 @@ class Failure(ObjectInterruption): ...@@ -86,7 +86,7 @@ class Failure(ObjectInterruption):
yield hold,self,self.rngTTF.generateNumber() # wait until a failure happens yield hold,self,self.rngTTF.generateNumber() # wait until a failure happens
try: try:
if(len(self.getVictimQueue())>0): # when a Machine gets failure if(len(self.getVictimQueue())>0): # when a Machine gets failure
self.interrupt(self.victim) # while in process it is interrupted self.interruptVictim() # while in process it is interrupted
self.victim.Up=False self.victim.Up=False
self.victim.timeLastFailure=now() self.victim.timeLastFailure=now()
self.outputTrace("is down") self.outputTrace("is down")
...@@ -106,7 +106,7 @@ class Failure(ObjectInterruption): ...@@ -106,7 +106,7 @@ class Failure(ObjectInterruption):
try: try:
if(len(self.getVictimQueue())>0): if(len(self.getVictimQueue())>0):
reactivate(self.victim) # since repairing is over, the Machine is reactivated self.reactivateVictim() # since repairing is over, the Machine is reactivated
self.victim.Up=True self.victim.Up=True
self.outputTrace("is up") self.outputTrace("is up")
if(self.repairman!="None"): #if a resource was used, it is now released if(self.repairman!="None"): #if a resource was used, it is now released
......
...@@ -26,7 +26,7 @@ Created on 18 Aug 2013 ...@@ -26,7 +26,7 @@ Created on 18 Aug 2013
Class that acts as an abstract. It should have no instances. All object interruptions (eg failures, breaks) should inherit from it Class that acts as an abstract. It should have no instances. All object interruptions (eg failures, breaks) should inherit from it
''' '''
from SimPy.Simulation import Process, Resource from SimPy.Simulation import Process, Resource, reactivate
class ObjectInterruption(Process): class ObjectInterruption(Process):
...@@ -53,5 +53,12 @@ class ObjectInterruption(Process): ...@@ -53,5 +53,12 @@ class ObjectInterruption(Process):
def postProcessing(self): def postProcessing(self):
pass pass
#interrupts the victim
def interruptVictim(self):
self.interrupt(self.victim)
#reactivate the victim
def reactivateVictim(self):
reactivate(self.victim)
\ No newline at end of file
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