Commit 21201865 authored by Georgios Dagkakis's avatar Georgios Dagkakis

fix in Source

parent 4524f62f
...@@ -68,6 +68,7 @@ class EntityGenerator(Process): ...@@ -68,6 +68,7 @@ class EntityGenerator(Process):
self.victim.numberOfArrivals+=1 # we have one new arrival self.victim.numberOfArrivals+=1 # we have one new arrival
G.numberOfEntities+=1 G.numberOfEntities+=1
# if there is only one entity in the Source send entityCreated signal # if there is only one entity in the Source send entityCreated signal
self.victim.appendEntity(entity)
if len(self.victim.getActiveObjectQueue())==1: if len(self.victim.getActiveObjectQueue())==1:
self.victim.entityCreated.signal(entity) self.victim.entityCreated.signal(entity)
yield hold,self,self.victim.calculateInterarrivalTime() # wait until the next arrival yield hold,self,self.victim.calculateInterarrivalTime() # wait until the next arrival
...@@ -101,6 +102,8 @@ class Source(CoreObject): ...@@ -101,6 +102,8 @@ class Source(CoreObject):
self.entityGenerator=EntityGenerator(victim=self) # the EntityGenerator of the Source self.entityGenerator=EntityGenerator(victim=self) # the EntityGenerator of the Source
self.entityCreated=SimEvent('an entity is created') self.entityCreated=SimEvent('an entity is created')
# event used by router
self.loadOperatorAvailable=SimEvent('loadOperatorAvailable')
#=========================================================================== #===========================================================================
# The initialize method of the Source class # The initialize method of the Source class
...@@ -128,16 +131,16 @@ class Source(CoreObject): ...@@ -128,16 +131,16 @@ class Source(CoreObject):
while 1: while 1:
# wait for any event (entity creation or request for disposal of entity) # wait for any event (entity creation or request for disposal of entity)
yield waitevent, self, [self.entityCreated, self.canDispose] yield waitevent, self, [self.entityCreated, self.canDispose, self.loadOperatorAvailable]
# if an entity is created try to signal the receiver and continue # if an entity is created try to signal the receiver and continue
if self.entityCreated.signalparam: if self.entityCreated.signalparam:
self.appendEntity(self.entityCreated.signalparam)
self.entityCreated.signalparam=None self.entityCreated.signalparam=None
if self.signalReceiver(): if self.signalReceiver():
continue continue
# otherwise, if the receiver requests availability then try to signal him if there is anything to dispose of # otherwise, if the receiver requests availability then try to signal him if there is anything to dispose of
if self.canDispose.signalparam: if self.canDispose.signalparam or self.loadOperatorAvailable.signalparam:
self.canDispose.signalparam=None self.canDispose.signalparam=None
self.loadOperatorAvailable.signalparam=None
if self.haveToDispose(): if self.haveToDispose():
if self.signalReceiver(): if self.signalReceiver():
continue continue
......
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