Commit 0a0e0d1e authored by Georgios Dagkakis's avatar Georgios Dagkakis

correction in RoutingQueue

parent 849bc6ca
...@@ -51,13 +51,12 @@ class RoutingQueue(Queue): ...@@ -51,13 +51,12 @@ class RoutingQueue(Queue):
isInRouting=False isInRouting=False
# for each entity in the buffer # for each entity in the buffer
for entity in activeObjectQueue: for entity in activeObjectQueue:
# if the receiver is None then they can proceed if thecaller==entity.receiver:
if not entity.receiver:
isInRouting=True isInRouting=True
break break
# otherwise check if the calleObject is the receiver of the entity if not isInRouting:
elif thecaller==entity.receiver: for entity in activeObjectQueue:
# if yes then that entity can proceed if not entity.receiver:
isInRouting=True isInRouting=True
break break
return len(activeObjectQueue)>0 and (thecaller in self.next) and isInRouting return len(activeObjectQueue)>0 and (thecaller in self.next) and isInRouting
...@@ -70,30 +69,51 @@ class RoutingQueue(Queue): ...@@ -70,30 +69,51 @@ class RoutingQueue(Queue):
activeObjectQueue=self.getActiveObjectQueue() activeObjectQueue=self.getActiveObjectQueue()
# find the entities that have None as receiver and update their receiver to the receiver provided as argument to the method # find the entities that have None as receiver and update their receiver to the receiver provided as argument to the method
# the entities that have no receiver can proceed as none of their siblings have gone through the next of the activeObject # the entities that have no receiver can proceed as none of their siblings have gone through the next of the activeObject
for entity in activeObjectQueue: # for entity in activeObjectQueue:
if not entity.receiver: # if not entity.receiver:
entity.receiver=receiver # entity.receiver=receiver
activeObjectQueue.sort(key=lambda x: x.receiver==receiver, reverse=True) # print '='*10
# print '----------------- Before'
# print self.env.now, receiver.id
# for entity in activeObjectQueue:
# print entity.id, entity.receiver
# if entity.receiver:
# print entity.receiver.id
activeObjectQueue.sort(key=lambda x: not(x.receiver is receiver), reverse=False)
activeObjectQueue.sort(key=lambda x: x.receiver==None, reverse=True)
activeObjectQueue.sort(key=lambda x: (x.receiver is receiver), reverse=True)
# print '----------------- After'
# print self.env.now, receiver.id
# for entity in activeObjectQueue:
# print entity.id, entity.receiver
# if entity.receiver:
# print entity.receiver.id
# ======================================================================= # =======================================================================
# gets an entity from the predecessor that # gets an entity from the predecessor that
# the predecessor index points to # the predecessor index points to
# ======================================================================= # =======================================================================
def getEntity(self): def removeEntity(self, entity=None, resetFlags=True, addBlockage=True):
activeEntity=Queue.getEntity(self) #run the default behavior activeEntity=Queue.removeEntity(self, entity)
# update the receiver object of the entity just received according to the routing of the parent batch parentBatch=activeEntity.parentBatch
route = activeEntity.parentBatch.routing() for subbatch in parentBatch.subBatchList:
activeEntity.receiver=None subbatch.receiver=activeEntity.currentStation
try:
for nextObj in self.next:
if nextObj in activeEntity.parentBatch.routing():
activeEntity.receiver=nextObj
break
# if none of the siblings (same parentBatch) has gone through the buffer then the receiver should remain None
except:
pass
return activeEntity return activeEntity
# 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
# route = activeEntity.parentBatch.routing()
# activeEntity.receiver=None
# try:
# for nextObj in self.next:
# if nextObj in activeEntity.parentBatch.routing():
# activeEntity.receiver=nextObj
# break
# # if none of the siblings (same parentBatch) has gone through the buffer then the receiver should remain None
# except:
# pass
# return activeEntity
# ======================================================================= # =======================================================================
# sorts the Entities of the Queue according to the scheduling rule # sorts the Entities of the Queue according to the scheduling rule
# TODO: sort the entities according to the schedulingRUle and then sort them again # TODO: sort the entities according to the schedulingRUle and then sort them again
......
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