예제 #1
0
 def sortEntities(self):
     activeObject = self.getActiveObject()
     # run the default sorting of the Queue first
     ConditionalBuffer.sortEntities(self)
     # and in the end sort according to the ConditionalBuffer sorting rule
     activeObjectQueue = activeObject.getActiveObjectQueue()
     # if all the components of the same mould are present then move them to the front of the activeQ
     activeObjectQueue.sort(key=lambda x: x.order.componentsReadyForAssembly, reverse=True)
     if activeObjectQueue:
         # keep the first entity of the activeQ
         activeEntity = activeObjectQueue[0]
         # bring the entities that have the same parentOrder as the first entity to the front
         activeObjectQueue.sort(key=lambda x: not x.order.name == activeEntity.order.name)
예제 #2
0
 def __init__(self,
              id,
              name,
              capacity=-1,
              isDummy=False,
              schedulingRule="FIFO",
              **kw):
     ConditionalBuffer.__init__(self,
                                id=id,
                                name=name,
                                capacity=capacity,
                                isDummy=isDummy,
                                schedulingRule=schedulingRule)
예제 #3
0
 def sortEntities(self):
     activeObject = self.getActiveObject()
     # run the default sorting of the Queue first
     ConditionalBuffer.sortEntities(self)
     # and in the end sort according to the ConditionalBuffer sorting rule
     activeObjectQueue = activeObject.getActiveObjectQueue()
     # if all the components of the same mould are present then move them to the front of the activeQ
     activeObjectQueue.sort(
         key=lambda x: x.order.componentsReadyForAssembly, reverse=True)
     if activeObjectQueue:
         # keep the first entity of the activeQ
         activeEntity = activeObjectQueue[0]
         # bring the entities that have the same parentOrder as the first entity to the front
         activeObjectQueue.sort(
             key=lambda x: not x.order.name == activeEntity.order.name)
예제 #4
0
 def getEntity(self):
     '''
     it checks if the activeQ has received all the entities
         of the same parentOrder needed to assemble the mould and set 
         the corresponding componentsReadyForAssembly flag of the parentOrder.
     We suppose that only one MouldAssembly buffer is present in the topology
         and thus there is no need to check if entities of the same parentOrder
         are present in other MouldAssemblyBuffers
     '''
     # execute default behaviour
     from Globals import G
     activeObject = self.getActiveObject()
     activeObjectQueue = activeObject.getActiveObjectQueue()
     activeEntity = ConditionalBuffer.getEntity(self)
     # if the activeEntity is of type orderComponent
     try:
         if activeEntity.componentType in self.assemblyValidTypes:
             activeEntity.readyForAssembly = 1
         # for all the components that have the same parent Order as the activeEntity
         activeEntity.order.componentsReadyForAssembly = 1
         for entity in activeEntity.order.getAssemblyComponents():
             # if one of them has not reach the Buffer yet,
             if not entity.readyForAssembly:
                 # the mould is not ready for assembly
                 activeEntity.order.componentsReadyForAssembly = 0
                 break
     # if the activeEntity is of type Mould
     except:
         pass
     return activeEntity
예제 #5
0
    def haveToDispose(self, callerObject=None):
        '''
        checks if the Buffer can dispose an entity. 
        Returns True only to the potential receiver
        Returns True when all the mould components/parts reside either
        in the internal buffer activeQ or in the callerObject's activeQ
        '''
        # get active object and its queue
        activeObject = self.getActiveObject()
        activeObjectQueue = self.getActiveObjectQueue()
        thecaller = callerObject
        # and then perform the default behaviour
        if ConditionalBuffer.haveToDispose(self, callerObject):
            # update the local variable activeEntity
            activeEntity = activeObjectQueue[0]
            # if we are at the start of the simulation then check if all the child components
            # of a specific order are present in the buffer and ready to be delivered to the assembly station
            try:
                # for all the components that have the same parent Order as the activeEntity
                activeEntity.order.componentsReadyForAssembly = 1
                for entity in activeEntity.order.getAssemblyComponents():
                    # if one of them has not reach the Buffer yet,
                    if not entity.readyForAssembly:
                        # the mould is not ready for assembly
                        activeEntity.order.componentsReadyForAssembly = 0
                        break
            # if the activeEntity is of type Mould
            except:
                pass

            try:
                return thecaller.getActiveObjectQueue()[0].order is activeEntity.order\
                       and activeEntity.order.componentsReadyForAssembly
            except:
                return activeEntity.order.componentsReadyForAssembly
예제 #6
0
    def haveToDispose(self, callerObject=None):
        '''
        checks if the Buffer can dispose an entity. 
        Returns True only to the potential receiver
        Returns True when all the mould components/parts reside either
        in the internal buffer activeQ or in the callerObject's activeQ
        '''
        # get active object and its queue
        activeObject=self.getActiveObject()
        activeObjectQueue=self.getActiveObjectQueue()
        thecaller=callerObject
        # and then perform the default behaviour
        if ConditionalBuffer.haveToDispose(self,callerObject):
            # update the local variable activeEntity
            activeEntity=activeObjectQueue[0]
            # if we are at the start of the simulation then check if all the child components 
            # of a specific order are present in the buffer and ready to be delivered to the assembly station
            try:
                # for all the components that have the same parent Order as the activeEntity
                activeEntity.order.componentsReadyForAssembly = 1
                for entity in activeEntity.order.getAssemblyComponents():
                # if one of them has not reach the Buffer yet,
                    if not entity.readyForAssembly:
                # the mould is not ready for assembly
                        activeEntity.order.componentsReadyForAssembly = 0
                        break
            # if the activeEntity is of type Mould
            except:
                pass

            try:
                return thecaller.getActiveObjectQueue()[0].order is activeEntity.order\
                       and activeEntity.order.componentsReadyForAssembly
            except:
                return activeEntity.order.componentsReadyForAssembly
예제 #7
0
 def getEntity(self):
     '''
     it checks if the activeQ has received all the entities
         of the same parentOrder needed to assemble the mould and set 
         the corresponding componentsReadyForAssembly flag of the parentOrder.
     We suppose that only one MouldAssembly buffer is present in the topology
         and thus there is no need to check if entities of the same parentOrder
         are present in other MouldAssemblyBuffers
     '''
     # execute default behaviour
     from Globals import G
     activeObject = self.getActiveObject()
     activeObjectQueue = activeObject.getActiveObjectQueue()
     activeEntity=ConditionalBuffer.getEntity(self)
     # if the activeEntity is of type orderComponent
     try:
         if activeEntity.componentType in self.assemblyValidTypes:
             activeEntity.readyForAssembly=1
         # for all the components that have the same parent Order as the activeEntity
         activeEntity.order.componentsReadyForAssembly = 1
         for entity in activeEntity.order.getAssemblyComponents():
         # if one of them has not reach the Buffer yet,
             if not entity.readyForAssembly:
         # the mould is not ready for assembly
                 activeEntity.order.componentsReadyForAssembly = 0
                 break
     # if the activeEntity is of type Mould
     except:
         pass
     return activeEntity
예제 #8
0
 def haveToDispose(self, callerObject=None):
     '''
     checks if the Buffer can dispose an entity. 
     Returns True only to the potential receiver
     Returns True when all the mould components/parts reside either
     in the internal buffer activeQ or in the callerObject's activeQ
     '''
     # get active object and its queue
     activeObject = self.getActiveObject()
     activeObjectQueue = self.getActiveObjectQueue()
     thecaller = callerObject
     # and then perform the default behaviour
     if ConditionalBuffer.haveToDispose(self, callerObject):
         # update the local variable activeEntity
         activeEntity = activeObjectQueue[0]
         try:
             return thecaller.getActiveObjectQueue()[0].order is activeEntity.order\
                    and activeEntity.order.componentsReadyForAssembly
         except:
             return activeEntity.order.componentsReadyForAssembly
예제 #9
0
 def haveToDispose(self, callerObject=None):
     '''
     checks if the Buffer can dispose an entity. 
     Returns True only to the potential receiver
     Returns True when all the mould components/parts reside either
     in the internal buffer activeQ or in the callerObject's activeQ
     '''
     # get active object and its queue
     activeObject=self.getActiveObject()
     activeObjectQueue=self.getActiveObjectQueue()
     thecaller=callerObject
     # and then perform the default behaviour
     if ConditionalBuffer.haveToDispose(self,callerObject):
         # update the local variable activeEntity
         activeEntity=activeObjectQueue[0]
         try:
             return thecaller.getActiveObjectQueue()[0].order is activeEntity.order\
                    and activeEntity.order.componentsReadyForAssembly
         except:
             return activeEntity.order.componentsReadyForAssembly
예제 #10
0
 def __init__(self,  id, name, capacity=-1, isDummy=False,
              schedulingRule="FIFO",**kw):
     ConditionalBuffer.__init__(self, id=id, name=name, capacity=capacity,
                              isDummy=isDummy, schedulingRule=schedulingRule)