Commit f0cc5d49 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Ioannis Papagiannopoulos

examples with failures seem to work. Cleanup needed

parent 05bfdc25
......@@ -57,6 +57,7 @@ class CoreObject(Process):
self.isRequested=SimEvent('isRequested')
self.canDispose=SimEvent('canDispose')
self.interruptionEnd=SimEvent('interruptionEnd')
self.interruptionStart=SimEvent('interruptionStart')
def initialize(self):
# XXX why call super.__init__ outside of __init__ ?
......
......@@ -112,9 +112,9 @@ class Failure(ObjectInterruption):
yield release,self,self.repairman.getResource()
self.repairman.totalWorkingTime+=now()-timeOperationStarted
#===========================================================================
# interrupts the victim
#===========================================================================
def interruptVictim(self):
ObjectInterruption.interrupt(self)
# TODO: check whether it is a good idea to update the failure timers here
\ No newline at end of file
# #===========================================================================
# # interrupts the victim
# #===========================================================================
# def interruptVictim(self):
# ObjectInterruption.interrupt(self)
# # TODO: check whether it is a good idea to update the failure timers here
\ No newline at end of file
......@@ -454,16 +454,18 @@ class Machine(CoreObject):
if not self.signalReceiver():
# if there was no available receiver, get into blocking control
while 1:
# wait the event canDispose, this means that the station can deliver the item to successor
yield waitevent, self, self.canDispose
event=yield waitevent, self, [self.canDispose, self.interruptionStart]
# if there was interruption
if self.interrupted():
#if self.interrupted():
# TODO not good implementation
if self.interruptionStart.signalparam==now():
# wait for the end of the interruption
self.interruptionActions() # execute interruption actions
yield waitevent, self, self.interruptionEnd # interruptionEnd to be triggered by ObjectInterruption
assert self==self.interruptionEnd.signalparam, 'the victim of the failure is not the object that received it'
self.postInterruptionActions()
#=======================================================
# TODO: not sure if this is required now
# #if during the interruption the object became empty break
......
......@@ -86,10 +86,11 @@ class ObjectInterruption(Process):
#interrupts the victim
def interruptVictim(self):
self.interrupt(self.victim)
self.victim.interruptionStart.signal(now())
#reactivate the victim
def reactivateVictim(self):
self.victim.interruptionEnd.signal(victim)
self.victim.interruptionEnd.signal(self.victim)
# reactivate(self.victim)
#outputs message to the trace.xls. Format is (Simulation Time | Victim Name | message)
......
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