Commit d00abf64 authored by Georgios Dagkakis's avatar Georgios Dagkakis

first version of ManPyObject.sendSignal

parent 6ec9f4a1
......@@ -567,10 +567,8 @@ class CoreObject(ManPyObject):
self.giver=giver
self.giver.receiver=self
if self.giver.expectedSignals['canDispose']:
self.sendSignal(receiver=self.giver, signal=self.giver.canDispose)
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 False
......
......@@ -145,7 +145,24 @@ class ManPyObject(object):
G.traceIndex=0
G.sheetIndex+=1
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
#===========================================================================
......
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