Commit 13451009 authored by Georgios Dagkakis's avatar Georgios Dagkakis

EntityGenerator has to call the constructor of process in every replication

parent 550cdd88
...@@ -49,14 +49,13 @@ class EntityGenerator(Process): ...@@ -49,14 +49,13 @@ class EntityGenerator(Process):
# initialize method of the EntityGenerator # initialize method of the EntityGenerator
#=========================================================================== #===========================================================================
def initialize(self): def initialize(self):
pass Process.__init__(self)
#Process.initialize(self)
#=========================================================================== #===========================================================================
# the generator of the EntitiesGenerator # the generator of the EntitiesGenerator
#=========================================================================== #===========================================================================
def run(self): def run(self):
# print 'entity generator starts' print '1'
while 1: while 1:
entity=self.victim.createEntity() # create the Entity object and assign its name entity=self.victim.createEntity() # create the Entity object and assign its name
entity.creationTime=now() # assign the current simulation time as the Entity's creation time entity.creationTime=now() # assign the current simulation time as the Entity's creation time
...@@ -104,6 +103,7 @@ class Source(CoreObject): ...@@ -104,6 +103,7 @@ class Source(CoreObject):
self.entityCreated=SimEvent('an entity is created') self.entityCreated=SimEvent('an entity is created')
# event used by router # event used by router
self.loadOperatorAvailable=SimEvent('loadOperatorAvailable') self.loadOperatorAvailable=SimEvent('loadOperatorAvailable')
#=========================================================================== #===========================================================================
# The initialize method of the Source class # The initialize method of the Source class
...@@ -111,15 +111,17 @@ class Source(CoreObject): ...@@ -111,15 +111,17 @@ class Source(CoreObject):
def initialize(self): def initialize(self):
# using the Process __init__ and not the CoreObject __init__ # using the Process __init__ and not the CoreObject __init__
CoreObject.initialize(self) CoreObject.initialize(self)
# initialize the internal Queue (type Resource) of the Source # initialize the internal Queue (type Resource) of the Source
self.Res=Resource(capacity=infinity) self.Res=Resource(capacity=infinity)
self.Res.activeQ=[] self.Res.activeQ=[]
self.Res.waitQ=[] self.Res.waitQ=[]
self.numberOfArrivals = 0
self.entityGenerator.initialize() self.entityGenerator.initialize()
activate(self.entityGenerator,self.entityGenerator.run()) activate(self.entityGenerator,self.entityGenerator.run())
self.entityCreated=SimEvent('an entity is created')
# event used by router
self.loadOperatorAvailable=SimEvent('loadOperatorAvailable')
#=========================================================================== #===========================================================================
# the generator of the Source class # the generator of the Source class
...@@ -128,7 +130,6 @@ class Source(CoreObject): ...@@ -128,7 +130,6 @@ class Source(CoreObject):
# get active object and its queue # get active object and its queue
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue() activeObjectQueue=self.getActiveObjectQueue()
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, self.loadOperatorAvailable] yield waitevent, self, [self.entityCreated, self.canDispose, self.loadOperatorAvailable]
......
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