Commit 10eef807 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Georgios Dagkakis

failure to signal Router if it is not initiated fixed

parent 59855e0f
...@@ -89,12 +89,15 @@ class RoutingQueue(Queue): ...@@ -89,12 +89,15 @@ class RoutingQueue(Queue):
def removeEntity(self, entity=None): def removeEntity(self, entity=None):
activeEntity=Queue.removeEntity(self, entity) #run the default method activeEntity=Queue.removeEntity(self, entity) #run the default method
# check if the queue is empty, if yes then try to signal the router, operators may need reallocation # check if the queue is empty, if yes then try to signal the router, operators may need reallocation
try:
if self.level: if self.level:
if not len(self.getActiveObjectQueue()): if not len(self.getActiveObjectQueue()):
from Globals import G from Globals import G
if not G.Router.invoked: if not G.Router.invoked:
G.Router.invoked=True G.Router.invoked=True
G.Router.isCalled.succeed(G.env.now) G.Router.isCalled.succeed(G.env.now)
except:
pass
return activeEntity return activeEntity
# ======================================================================= # =======================================================================
...@@ -104,22 +107,26 @@ class RoutingQueue(Queue): ...@@ -104,22 +107,26 @@ class RoutingQueue(Queue):
def getEntity(self): def getEntity(self):
activeEntity=Queue.getEntity(self) #run the default behavior activeEntity=Queue.getEntity(self) #run the default behavior
# update the receiver object of the entity just received according to the routing of the parent batch # update the receiver object of the entity just received according to the routing of the parent batch
route = activeEntity.parentBatch.routing()
activeEntity.receiver=None activeEntity.receiver=None
try: try:
for nextObj in self.next: for nextObj in self.next:
if nextObj in entity.parentBatch.routing(): if nextObj in activeEntity.parentBatch.routing():
entity.receiver=nextObj activeEntity.receiver=nextObj
break break
# if none of the siblings (same parentBatch) has gone through the buffer then the receiver should remain None # if none of the siblings (same parentBatch) has gone through the buffer then the receiver should remain None
except: except:
pass pass
# if the level is reached then try to signal the Router to reallocate the operators # if the level is reached then try to signal the Router to reallocate the operators
try:
if self.level: if self.level:
if len(self.getActiveObjectQueue())==self.level: if len(self.getActiveObjectQueue())==self.level:
from Globals import G from Globals import G
if not G.Router.invoked: if not G.Router.invoked:
G.Router.invoked=True G.Router.invoked=True
G.Router.isCalled.succeed(G.env.now) G.Router.isCalled.succeed(G.env.now)
except:
pass
return activeEntity return activeEntity
# ======================================================================= # =======================================================================
...@@ -137,4 +144,7 @@ class RoutingQueue(Queue): ...@@ -137,4 +144,7 @@ class RoutingQueue(Queue):
self.activeQSorter() self.activeQSorter()
# sort again according to the existence or not of receiver attribute of the entities # sort again according to the existence or not of receiver attribute of the entities
activeObjectQueue=self.getActiveObjectQueue() activeObjectQueue=self.getActiveObjectQueue()
activeObjectQueue.sort(key=lambda x: x.receiver, reverse=True) # if no entity.receiver, then show preference to these entities
activeObjectQueue.sort(key=lambda x: x.receiver==None, reverse=True)
# if there is entity.receiver then check if it is the same as the self.receiver of the queue (if any)
activeObjectQueue.sort(key=lambda x: x.receiver==self.receiver, reverse=True)
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