Commit d00abf64 authored by Georgios Dagkakis's avatar Georgios Dagkakis

first version of ManPyObject.sendSignal

parent 6ec9f4a1
...@@ -567,10 +567,8 @@ class CoreObject(ManPyObject): ...@@ -567,10 +567,8 @@ class CoreObject(ManPyObject):
self.giver=giver self.giver=giver
self.giver.receiver=self self.giver.receiver=self
if self.giver.expectedSignals['canDispose']: if self.giver.expectedSignals['canDispose']:
self.sendSignal(receiver=self.giver, signal=self.giver.canDispose)
self.printTrace(self.id, signalGiver=self.giver.id) self.printTrace(self.id, signalGiver=self.giver.id)
succeedTuple=(self,self.env.now)
self.giver.canDispose.succeed(succeedTuple)
self.giver.expectedSignals['canDispose']=0
return True return True
return False return False
......
...@@ -146,6 +146,23 @@ class ManPyObject(object): ...@@ -146,6 +146,23 @@ class ManPyObject(object):
G.sheetIndex+=1 G.sheetIndex+=1
G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True) G.traceSheet=G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True)
#===========================================================================
# sends a signal
#===========================================================================
def sendSignal(self,sender=None,receiver=None,signal=None,succeedTuple=None):
assert signal, 'there is no signal defined'
assert receiver, 'there is no receiver defined for the signal'
# give default values if not given
if not sender:
sender=self
if not succeedTuple:
succeedTuple=(self,self.env.now)
# send the signal
signal.succeed(succeedTuple)
# reset the expected signals of the receiver to 0
for key, value in receiver.expectedSignals.iteritems():
receiver.expectedSignals[key]=0
#=========================================================================== #===========================================================================
# actions to be performed after the end of the simulation # actions to be performed after the end of the simulation
#=========================================================================== #===========================================================================
......
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