Commit 5e8936a8 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

CanAccept() of MachineManagedJob overrides MachineJobShop method in order to...

CanAccept() of MachineManagedJob overrides MachineJobShop method in order to avoid manager update problem
parent 8c720089
...@@ -52,6 +52,27 @@ class MachineManagedJob(MachineJobShop): ...@@ -52,6 +52,27 @@ class MachineManagedJob(MachineJobShop):
self.broker = Broker(self) self.broker = Broker(self)
activate(self.broker,self.broker.run()) activate(self.broker,self.broker.run())
# =======================================================================
# checks if the Queue can accept an entity
# it checks also the next station of the Entity
# and returns true only if the active object is the next station
# =======================================================================
def canAccept(self, callerObject=None):
activeObject=self.getActiveObject()
activeObjectQueue=activeObject.getActiveObjectQueue()
thecaller=callerObject
if (thecaller!=None):
#check it the caller object holds an Entity that requests for current object
if len(thecaller.getActiveObjectQueue())>0:
# TODO: make sure that the first entity of the callerObject is to be disposed
activeEntity=thecaller.getActiveObjectQueue()[0]
# if the machine's Id is in the list of the entity's next stations
if activeObject.id in activeEntity.remainingRoute[0].get('stationIdsList',[]):
#return according to the state of the Queue
return len(activeObject.getActiveObjectQueue())<activeObject.capacity\
and activeObject.Up
return False
# ======================================================================= # =======================================================================
# checks if the Machine can accept an entity and there is an entity in # checks if the Machine can accept an entity and there is an entity in
# some possible giver waiting for it # some possible giver waiting for it
...@@ -96,7 +117,7 @@ class MachineManagedJob(MachineJobShop): ...@@ -96,7 +117,7 @@ class MachineManagedJob(MachineJobShop):
activeObject.operatorPool.receivingObject=activeObject activeObject.operatorPool.receivingObject=activeObject
if activeObject.Up and len(activeObjectQueue)<activeObject.capacity\ if activeObject.Up and len(activeObjectQueue)<activeObject.capacity\
and isRequested and not activeObject.giver.exitIsAssigned(): and not activeObject.giver.exitIsAssigned():
activeObject.giver.assignExit() activeObject.giver.assignExit()
#make the operatorsList so that it holds only the manager of the current order #make the operatorsList so that it holds only the manager of the current order
activeObject.operatorPool.operatorsList=[activeObject.giver.getActiveObjectQueue()[0].manager] activeObject.operatorPool.operatorsList=[activeObject.giver.getActiveObjectQueue()[0].manager]
......
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