Commit 2d4941fa authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

expectectedSignals dict added to ObjectInterruption for describing its state...

expectectedSignals dict added to ObjectInterruption for describing its state regarding the event signalling
parent 3dd9e49d
...@@ -46,6 +46,17 @@ class ObjectInterruption(ManPyObject): ...@@ -46,6 +46,17 @@ class ObjectInterruption(ManPyObject):
if self.victim: if self.victim:
if isinstance(self.victim.objectInterruptions, list): if isinstance(self.victim.objectInterruptions, list):
self.victim.objectInterruptions.append(self) self.victim.objectInterruptions.append(self)
# list of expected signals of an interruption (values can be used as flags to inform on which signals is the interruption currently yielding)
self.expectedSignals={
"victimOffShift":0,
"victimOnShift":0,
"victimStartsProcessing":0,
"victimEndsProcessing":0,
"isCalled":0,
"endedLastProcessing":0,
"victimIsEmptyBeforeMaintenance":0,
"resourceAvailable":0,
}
def initialize(self): def initialize(self):
from Globals import G from Globals import G
...@@ -57,6 +68,17 @@ class ObjectInterruption(ManPyObject): ...@@ -57,6 +68,17 @@ class ObjectInterruption(ManPyObject):
# flags that show if the interruption waits for the event # flags that show if the interruption waits for the event
self.isWaitingForVictimOffShift=False self.isWaitingForVictimOffShift=False
self.isWaitingForVictimOnShift=False self.isWaitingForVictimOnShift=False
# list of expected signals of an interruption (values can be used as flags to inform on which signals is the interruption currently yielding)
self.expectedSignals={
"victimOffShift":0,
"victimOnShift":0,
"victimStartsProcessing":0,
"victimEndsProcessing":0,
"isCalled":0,
"endedLastProcessing":0,
"victimIsEmptyBeforeMaintenance":0,
"resourceAvailable":0,
}
#=========================================================================== #===========================================================================
# the main process of the core object # the main process of the core object
...@@ -72,6 +94,7 @@ class ObjectInterruption(ManPyObject): ...@@ -72,6 +94,7 @@ class ObjectInterruption(ManPyObject):
# signalling can be done via Machine request/releaseOperator # signalling can be done via Machine request/releaseOperator
# ======================================================================= # =======================================================================
def invoke(self): def invoke(self):
if self.expectedSignals['isCalled']:
succeedTuple=(self.victim,self.env.now) succeedTuple=(self.victim,self.env.now)
self.isCalled.succeed(succeedTuple) self.isCalled.succeed(succeedTuple)
...@@ -94,6 +117,7 @@ class ObjectInterruption(ManPyObject): ...@@ -94,6 +117,7 @@ class ObjectInterruption(ManPyObject):
def interruptVictim(self): def interruptVictim(self):
# inform the victim by whom will it be interrupted # inform the victim by whom will it be interrupted
# TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously # TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously
if self.victim.expectedSignals['interruptionStart']:
self.victim.interruptedBy=self.type self.victim.interruptedBy=self.type
succeedTuple=(self,self.env.now) succeedTuple=(self,self.env.now)
self.victim.interruptionStart.succeed(succeedTuple) self.victim.interruptionStart.succeed(succeedTuple)
...@@ -106,6 +130,7 @@ class ObjectInterruption(ManPyObject): ...@@ -106,6 +130,7 @@ class ObjectInterruption(ManPyObject):
# reactivate the victim # reactivate the victim
#=========================================================================== #===========================================================================
def reactivateVictim(self): def reactivateVictim(self):
if self.victim.expectedSignals['interruptionEnd']:
succeedTuple=(self,self.env.now) succeedTuple=(self,self.env.now)
self.victim.interruptionEnd.succeed(succeedTuple) self.victim.interruptionEnd.succeed(succeedTuple)
#reset the interruptionStart event of the victim #reset the interruptionStart event of the victim
......
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