def sortEntities(self): activeObject = self.getActiveObject() # perform the default sorting QueueJobShop.sortEntities(activeObject) # and in the end sort according to the ConditionalBuffer sorting rule activeObjectQueue = activeObject.getActiveObjectQueue() # for every entity in the activeObjectQueue for entity in activeObjectQueue: # check if the requiredParts (if any) have concluded the steps with sequence smaller # than the sequence of the entity next step entity.mayProceed=entity.checkIfRequiredPartsReady() activeObjectQueue.sort(key=lambda x: x.mayProceed, reverse=True)
def sortEntities(self): activeObject = self.getActiveObject() # perform the default sorting QueueJobShop.sortEntities(activeObject) # and in the end sort according to the ConditionalBuffer sorting rule activeObjectQueue = activeObject.getActiveObjectQueue() # for every entity in the activeObjectQueue for entity in activeObjectQueue: # check if the requiredParts (if any) have concluded the steps with sequence smaller # than the sequence of the entity next step entity.mayProceed = entity.checkIfRequiredPartsReady() activeObjectQueue.sort(key=lambda x: x.mayProceed, reverse=True)
def sortEntities(self): QueueJobShop.sortEntities(self) #do the default sorting first activeObjectQueue=self.getActiveObjectQueue() # search for the entities in the activeObjectQueue that have available manager for entity in activeObjectQueue: entity.managerAvailable=False # if the entity has manager assigned if entity.manager: # check his availability if entity.manager.checkIfResourceIsAvailable(self.objectSortingFor): entity.managerAvailable=True # sort the active queue according to the availability of the managers activeObjectQueue.sort(key=lambda x: x.managerAvailable, reverse=True)
def __init__(self, id, name, capacity=-1, isDummy=False, schedulingRule="FIFO", **kw): QueueJobShop.__init__(self, id=id, name=name, capacity=capacity, isDummy=isDummy, schedulingRule=schedulingRule)
def sortEntities(self): QueueJobShop.sortEntities(self) #do the default sorting first activeObjectQueue = self.getActiveObjectQueue() # search for the entities in the activeObjectQueue that have available manager for entity in activeObjectQueue: entity.managerAvailable = False # if the entity has manager assigned if entity.manager: # check his availability if entity.manager.checkIfResourceIsAvailable( self.objectSortingFor): entity.managerAvailable = True # sort the active queue according to the availability of the managers activeObjectQueue.sort(key=lambda x: x.managerAvailable, reverse=True)
def haveToDispose(self, callerObject=None): # get active object and its queue activeObject=self.getActiveObject() activeObjectQueue=self.getActiveObjectQueue() thecaller=callerObject # update the objectSortingFor variable to hold the value of the callerObject activeObject.objectSortingFor=thecaller # TODO: when the callerObject is not defined will receive error ass the checkIfResourceIsAvailable requests a caller #search if for one or more of the Entities the operator is available haveEntityWithAvailableManager=False for entity in activeObjectQueue: if entity.manager: if entity.manager.checkIfResourceIsAvailable(thecaller): haveEntityWithAvailableManager=True break else: haveEntityWithAvailableManager=True break # for entity in [x for x in activeObjectQueue if x.manager]: # if entity.manager.checkIfResourceIsAvailable(thecaller): # haveEntityWithAvailableManager=True # break #if none of the Entities has an available manager return False if not haveEntityWithAvailableManager: return False #sort the internal queue so that the Entities that have an available manager go in the front # the sortEntities method needs a receiver defined to sort the entities according to the availability of the manager # so if there is a caller define him ass receiver and after the sorting set the receiver again to None activeObject.sortEntities() activeObject.sortEntitiesForReceiver(activeObject.objectSortingFor) # and then perform the default behaviour return QueueJobShop.haveToDispose(self,thecaller)
def haveToDispose(self, callerObject=None): # get active object and its queue activeObject = self.getActiveObject() activeObjectQueue = self.getActiveObjectQueue() thecaller = callerObject # update the objectSortingFor variable to hold the value of the callerObject activeObject.objectSortingFor = thecaller # TODO: when the callerObject is not defined will receive error ass the checkIfResourceIsAvailable requests a caller #search if for one or more of the Entities the operator is available haveEntityWithAvailableManager = False for entity in activeObjectQueue: if entity.manager: if entity.manager.checkIfResourceIsAvailable(thecaller): haveEntityWithAvailableManager = True break else: haveEntityWithAvailableManager = True break #if none of the Entities has an available manager return False if not haveEntityWithAvailableManager: return False #sort the internal queue so that the Entities that have an available manager go in the front # the sortEntities method needs a receiver defined to sort the entities according to the availability of the manager # so if there is a caller define him ass receiver and after the sorting set the receiver again to None activeObject.sortEntities() activeObject.sortEntitiesForReceiver(activeObject.objectSortingFor) # and then perform the default behaviour return QueueJobShop.haveToDispose(self, thecaller)
def __init__(self, id, name, capacity=1, isDummy=False, schedulingRule="FIFO", **kw): QueueJobShop.__init__(self, id=id, name=name, capacity=capacity, isDummy=isDummy, schedulingRule=schedulingRule) # variable used by the sortEntities method # to identify the object it will be sorting for (manager.checkIfResourceIsAvailable(self.objectSortingFor)) self.objectSortingFor = None
def haveToDispose(self, callerObject=None): # get active object and its queue activeObject = self.getActiveObject() activeObjectQueue = self.getActiveObjectQueue() # and then perform the default behaviour if QueueJobShop.haveToDispose(self, callerObject): # sort the activeObjectQueue to brink the entities that can proceed to front activeObject.sortEntities() # return True if the first object of the queue can proceed return activeObjectQueue[0].mayProceed return False
def haveToDispose(self, callerObject=None): # get active object and its queue activeObject=self.getActiveObject() activeObjectQueue=self.getActiveObjectQueue() # and then perform the default behaviour if QueueJobShop.haveToDispose(self,callerObject): # sort the activeObjectQueue to brink the entities that can proceed to front activeObject.sortEntities() # return True if the first object of the queue can proceed return activeObjectQueue[0].mayProceed return False
def getEntity(self): activeEntity=QueueJobShop.getEntity(self) from Globals import G # for all the entities in the EntityList for entity in G.EntityList: requiredParts=entity.getRequiredParts() if requiredParts: # if the activeEntity is in the requierdParts of the entity if activeEntity in requiredParts: # if the entity that requires the activeEntity can proceed then signal the currentStation of the entity if entity.checkIfRequiredPartsReady() and entity.currentStation.expectedSignals['canDispose']: entity.mayProceed=True self.sendSignal(receiver=entity.currentStation, signal=entity.currentStation.canDispose) return activeEntity
def getEntity(self): activeEntity = QueueJobShop.getEntity(self) from Globals import G # for all the entities in the EntityList for entity in G.EntityList: requiredParts = entity.getRequiredParts() if requiredParts: # if the activeEntity is in the requierdParts of the entity if activeEntity in requiredParts: # if the entity that requires the activeEntity can proceed then signal the currentStation of the entity if entity.checkIfRequiredPartsReady( ) and entity.currentStation.expectedSignals['canDispose']: entity.mayProceed = True self.sendSignal( receiver=entity.currentStation, signal=entity.currentStation.canDispose) return activeEntity
def initialize(self): QueueJobShop.initialize(self) #run default behaviour # variable used by the sortEntities method # to identify the object it will be sorting for (manager.checkIfResourceIsAvailable(self.objectSortingFor)) self.objectSortingFor=None
def __init__(self, id, name, capacity=1, isDummy=False, schedulingRule="FIFO", **kw): QueueJobShop.__init__(self, id=id, name=name,capacity=capacity, isDummy=isDummy, schedulingRule=schedulingRule) # variable used by the sortEntities method # to identify the object it will be sorting for (manager.checkIfResourceIsAvailable(self.objectSortingFor)) self.objectSortingFor=None
def initialize(self): QueueJobShop.initialize(self) #run default behaviour # variable used by the sortEntities method # to identify the object it will be sorting for (manager.checkIfResourceIsAvailable(self.objectSortingFor)) self.objectSortingFor = None
def __init__(self, id, name, capacity=-1, isDummy=False, schedulingRule="FIFO",**kw): QueueJobShop.__init__(self, id=id, name=name, capacity=capacity, isDummy=isDummy, schedulingRule=schedulingRule)