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

small change made to checkIfResourceIsAvailable() method of the objectResource

parent 05c15eeb
...@@ -45,7 +45,7 @@ class ObjectResource(object): ...@@ -45,7 +45,7 @@ class ObjectResource(object):
# ======================================================================= # =======================================================================
# checks if the worker is available # checks if the worker is available
# ======================================================================= # =======================================================================
def checkIfResourceIsAvailable(self): def checkIfResourceIsAvailable(self,callerObject=None):
return len(self.Res.activeQ)<self.capacity return len(self.Res.activeQ)<self.capacity
# ======================================================================= # =======================================================================
......
...@@ -450,7 +450,6 @@ class OperatedMachine(Machine): ...@@ -450,7 +450,6 @@ class OperatedMachine(Machine):
activeObject=self.getActiveObject() activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue() activeObjectQueue=self.getActiveObjectQueue()
giverObject=self.getGiverObject() giverObject=self.getGiverObject()
# if we have only one predecessor just check if there is a place, # if we have only one predecessor just check if there is a place,
# the machine is up and the predecessor has an entity to dispose # the machine is up and the predecessor has an entity to dispose
# if the machine has to compete for an Operator that loads the entities onto it # if the machine has to compete for an Operator that loads the entities onto it
...@@ -462,7 +461,7 @@ class OperatedMachine(Machine): ...@@ -462,7 +461,7 @@ class OperatedMachine(Machine):
if activeObject.operatorPool.checkIfResourceIsAvailable()\ if activeObject.operatorPool.checkIfResourceIsAvailable()\
and activeObject.Up and len(activeObjectQueue)<activeObject.capacity\ and activeObject.Up and len(activeObjectQueue)<activeObject.capacity\
and giverObject.haveToDispose(activeObject) and not giverObject.exitIsAssigned(): and giverObject.haveToDispose(activeObject) and not giverObject.exitIsAssigned():
giverObject.assignExit() activeObject.giver.assignExit()
return True return True
else: else:
return False return False
...@@ -480,11 +479,11 @@ class OperatedMachine(Machine): ...@@ -480,11 +479,11 @@ class OperatedMachine(Machine):
# and activeObject.Up and len(activeObjectQueue)<activeObject.capacity\ # and activeObject.Up and len(activeObjectQueue)<activeObject.capacity\
# and giverObject.haveToDispose() # and giverObject.haveToDispose()
# dummy variables that help prioritize the objects requesting to give objects to the Machine (activeObject) # dummy variables that help prioritise the objects requesting to give objects to the Machine (activeObject)
isRequested=False # is requested is dummyVariable checking if it is requested to accept an item isRequested=False # is requested is dummyVariable checking if it is requested to accept an item
maxTimeWaiting=0 # dummy variable counting the time a predecessor is blocked maxTimeWaiting=0 # dummy variable counting the time a predecessor is blocked
# loop through the possible givers to see which have to dispose and which is the one blocked for longer # index used to set the predecessorIndex to the giver waiting the most # loop through the possible givers to see which have to dispose and which is the one blocked for longer
for object in activeObject.previous: for object in activeObject.previous:
if(object.haveToDispose(activeObject)):# and not object.exitIsAssigned()): if(object.haveToDispose(activeObject)):# and not object.exitIsAssigned()):
isRequested=True # if the possible giver have entities to dispose of isRequested=True # if the possible giver have entities to dispose of
...@@ -501,8 +500,8 @@ class OperatedMachine(Machine): ...@@ -501,8 +500,8 @@ class OperatedMachine(Machine):
if (activeObject.operatorPool!='None' and any(type=='Load' for type in activeObject.multOperationTypeList)): if (activeObject.operatorPool!='None' and any(type=='Load' for type in activeObject.multOperationTypeList)):
if activeObject.operatorPool.checkIfResourceIsAvailable()\ if activeObject.operatorPool.checkIfResourceIsAvailable()\
and activeObject.Up and len(activeObjectQueue)<activeObject.capacity\ and activeObject.Up and len(activeObjectQueue)<activeObject.capacity\
and isRequested and not giverObject.exitIsAssigned(): and isRequested and not activeObject.giver.exitIsAssigned():
giverObject.assignExit() activeObject.giver.assignExit()
return True return True
else: else:
return False return False
......
...@@ -89,14 +89,15 @@ class OperatorPool(ObjectResource): ...@@ -89,14 +89,15 @@ class OperatorPool(ObjectResource):
# ======================================================================= # =======================================================================
# checks if there are operators available # checks if there are operators available
# ======================================================================= # =======================================================================
def checkIfResourceIsAvailable(self): def checkIfResourceIsAvailable(self, callerObject=None):
# maxTimeWaiting = 0 # maxTimeWaiting = 0
# for operator in self.operators: # for operator in self.operators:
# for machine in operator.coreObjects: # for machine in operator.coreObjects:
# timeWaiting = now()-machine.broker.timeWaitForOperatorStarted # timeWaiting = now()-machine.broker.timeWaitForOperatorStarted
# if (timeWaiting>=maxTimeWaiting): # if (timeWaiting>=maxTimeWaiting):
# maxTimeWaiting=timeWaiting # maxTimeWaiting=timeWaiting
return any(operator.checkIfResourceIsAvailable()==True for operator in self.operators) thecaller=callerObject
return any(operator.checkIfResourceIsAvailable(callerObject=thecaller)==True for operator in self.operators)
# ======================================================================= # =======================================================================
# find the first available operator and return it # find the first available operator and return it
......
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