new method added to OperatorRouter to monitor the movement of pendingEntities

parent 0168e35c
...@@ -52,17 +52,20 @@ class Router(ObjectInterruption): ...@@ -52,17 +52,20 @@ class Router(ObjectInterruption):
# ======================================================================= # =======================================================================
def run(self): def run(self):
while 1: while 1:
yield waituntil,self,self.routerIsCalled # wait until the router is called # wait until the router is called
# # TESTING yield waituntil,self,self.routerIsCalled
# print 'Router got called' # when the router is called for the first time wait till all the entities
# finished all their moves in stations of non-Machine-type
# before they can enter again a type-Machine object
yield waituntil, self,self.entitiesFinishedMoving
from Globals import G from Globals import G
for object in G.MachineList: for object in G.MachineList:
if object.inPositionToGet: if object.inPositionToGet:
object.canProceedWithGetEntity=True object.canProceedWithGetEntity=True
self.inPositionToGet=False self.inPositionToGet=False
# have to check also the activeCallersList of each machine about to receive something
# # TESTING # # TESTING
# import Globals # import Globals
...@@ -84,7 +87,33 @@ class Router(ObjectInterruption): ...@@ -84,7 +87,33 @@ class Router(ObjectInterruption):
# got first called finished their moves through queues? # got first called finished their moves through queues?
#=========================================================================== #===========================================================================
def entitiesFinishedMoving(self): def entitiesFinishedMoving(self):
pass # check if the entities waiting to be disposed from different Machines
# the first time the Router is called, have reached the last queue (if any)
# before the next Machine in their route
# from Globals import G
# # pending entities are entities about to enter an other machine, updated by endProcessingActions()
# # if there are any pending entities
# if len(G.pendingEntities):
# # for each one of them
# for entity in G.pendingEntities:
# # if they are residing in a machine which waits to dispose and is functional
# if entity.currentStation in G.MachineList:
# if entity.currentStation.checkIfMachineIsUp()\
# and entity.currentStation.waitToDispose:
# # if the next step in the entity's route is machine with Load operationType then continue
# if (not (entity.currentStation.receiver.type in G.MachineList)\
# and entity.currentStation.receiver.canAccept()\
# or\
# ((entity.currentStation.receiver.type in G.MachineList)\
# and not any(type=='Load' for type in entity.currentStation.receiver.multOperationTypeList))):
# return False
# elif entity.currentStation in G.QueueList:
# pass
# elif entity.currentStation in G.LineClearanceList:
# pass
# # this list can check all the available object in G.objList
return True
# ======================================================================= # =======================================================================
# call the Scheduler # call the Scheduler
......
...@@ -83,9 +83,12 @@ class Queue(CoreObject): ...@@ -83,9 +83,12 @@ class Queue(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 Queue object # initialise the internal Queue (type Resource) of the Queue object
self.Res=Resource(self.capacity) self.Res=Resource(self.capacity)
#===========================================================================
# run method of the queue
#===========================================================================
def run(self): def run(self):
activeObjectQueue=self.getActiveObjectQueue() activeObjectQueue=self.getActiveObjectQueue()
...@@ -97,6 +100,7 @@ class Queue(CoreObject): ...@@ -97,6 +100,7 @@ class Queue(CoreObject):
#if entity just got to the dummyQ set its startTime as the current time #if entity just got to the dummyQ set its startTime as the current time
if self.isDummy: if self.isDummy:
activeObjectQueue[0].startTime=now() activeObjectQueue[0].startTime=now()
# ======================================================================= # =======================================================================
# checks if the Queue can accept an entity # checks if the Queue can accept an entity
# it checks also who called it and returns TRUE # it checks also who called it and returns TRUE
...@@ -139,10 +143,6 @@ class Queue(CoreObject): ...@@ -139,10 +143,6 @@ class Queue(CoreObject):
if(len(activeObject.next)==1 or callerObject==None): if(len(activeObject.next)==1 or callerObject==None):
return len(self.Res.activeQ)>0 return len(self.Res.activeQ)>0
# #if the Queue is empty it returns false right away
# if(len(activeObjectQueue)==0):
# return False
thecaller=callerObject thecaller=callerObject
#give the entity to the possible receiver that is waiting for the most time. #give the entity to the possible receiver that is waiting for the most time.
......
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