Commit 2ab3d3d1 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

changes so that capacity station buffer can wait for the project to be...

changes so  that capacity station buffer can wait for the project to be assembled before work proceeds. Not tested yet
parent c5c338ea
...@@ -35,9 +35,10 @@ class CapacityStationBuffer(Queue): ...@@ -35,9 +35,10 @@ class CapacityStationBuffer(Queue):
#=========================================================================== #===========================================================================
# the __init__ method of the CapacityStationBuffer # the __init__ method of the CapacityStationBuffer
#=========================================================================== #===========================================================================
def __init__(self, id, name, capacity=float("inf"), isDummy=False, schedulingRule="FIFO", gatherWipStat=False): def __init__(self, id, name, capacity=float("inf"), isDummy=False, schedulingRule="FIFO", gatherWipStat=False, isAssembly=False):
Queue.__init__(self, id, name, capacity=capacity) Queue.__init__(self, id, name, capacity=capacity)
self.isLocked=True self.isLocked=True
self.isAssembly=isAssembly # flag that shows if here the whole project is assembled
def initialize(self): def initialize(self):
......
...@@ -180,39 +180,77 @@ class CapacityStationController(EventGenerator): ...@@ -180,39 +180,77 @@ class CapacityStationController(EventGenerator):
for buffer in G.CapacityStationBufferList: for buffer in G.CapacityStationBufferList:
station=buffer.next[0] # get the station station=buffer.next[0] # get the station
totalAvailableCapacity=station.remainingIntervalCapacity[0] # get the available capacity of the station totalAvailableCapacity=station.remainingIntervalCapacity[0] # get the available capacity of the station
# for this interval # for this interval
# if there is no capacity continue with the next buffer # if there is no capacity continue with the next buffer
if totalAvailableCapacity<=0: if totalAvailableCapacity<=0:
continue continue
# calculate the total capacity that is requested # if the buffer is not assembly
totalRequestedCapacity=0 if not buffer.isAssembly:
for entity in buffer.getActiveObjectQueue(): # calculate the total capacity that is requested
totalRequestedCapacity+=entity.requiredCapacity totalRequestedCapacity=0
# if there is enough capacity for all the entities set them that they all should move
if totalRequestedCapacity<=totalAvailableCapacity:
for entity in buffer.getActiveObjectQueue(): for entity in buffer.getActiveObjectQueue():
entity.shouldMove=True totalRequestedCapacity+=entity.requiredCapacity
# else calculate the capacity for every entity and create the entities # if there is enough capacity for all the entities set them that they all should move
if totalRequestedCapacity<=totalAvailableCapacity:
for entity in buffer.getActiveObjectQueue():
entity.shouldMove=True
# else calculate the capacity for every entity and create the entities
else:
entitiesInBuffer=list(buffer.getActiveObjectQueue())
# loop through the entities
for entity in entitiesInBuffer:
# calculate what is the capacity that should proceed and what that should remain
capacityToMove=totalAvailableCapacity*(entity.requiredCapacity)/float(totalRequestedCapacity)
capacityToStay=entity.requiredCapacity-capacityToMove
# remove the capacity entity by the buffer so that the broken ones are created
buffer.getActiveObjectQueue().remove(entity)
entityToMoveName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToMove)
entityToMove=CapacityEntity(name=entityToMoveName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToMove)
entityToMove.initialize()
entityToMove.currentStation=buffer
entityToMove.shouldMove=True
entityToStayName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToStay)
entityToStay=CapacityEntity(name=entityToStayName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToStay)
entityToStay.initialize()
entityToStay.currentStation=buffer
import Globals
Globals.setWIP([entityToMove,entityToStay]) #set the new components as wip
# if the buffer is assembly there are different calculations
else: else:
entitiesInBuffer=list(buffer.getActiveObjectQueue()) # calculate the total capacity that is requested
# loop through the entities # note that only the assembled projects do request capacity
for entity in entitiesInBuffer: totalRequestedCapacity=0
# calculate what is the capacity that should proceed and what that should remain for entity in buffer.getActiveObjectQueue():
capacityToMove=totalAvailableCapacity*(entity.requiredCapacity)/float(totalRequestedCapacity) if self.checkIfProjectAssembledInBuffer(entity.capacityProject, buffer):
capacityToStay=entity.requiredCapacity-capacityToMove totalRequestedCapacity+=entity.requiredCapacity
# remove the capacity entity by the buffer so that the broken ones are created # if there is enough capacity for all the assembled entities set them that they all should move
buffer.getActiveObjectQueue().remove(entity) if totalRequestedCapacity<=totalAvailableCapacity:
entityToMoveName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToMove) for entity in buffer.getActiveObjectQueue():
entityToMove=CapacityEntity(name=entityToMoveName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToMove) if self.checkIfProjectAssembledInBuffer(entity.capacityProject, buffer):
entityToMove.initialize() entity.shouldMove=True
entityToMove.currentStation=buffer # else calculate the capacity for every entity and create the entities
entityToMove.shouldMove=True else:
entityToStayName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToStay) entitiesInBuffer=list(buffer.getActiveObjectQueue())
entityToStay=CapacityEntity(name=entityToStayName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToStay) # loop through the entities
entityToStay.initialize() for entity in entitiesInBuffer:
entityToStay.currentStation=buffer # break only the assembled projects
import Globals if self.checkIfProjectAssembledInBuffer(entity.capacityProject, buffer):
Globals.setWIP([entityToMove,entityToStay]) #set the new components as wip # calculate what is the capacity that should proceed and what that should remain
capacityToMove=totalAvailableCapacity*(entity.requiredCapacity)/float(totalRequestedCapacity)
capacityToStay=entity.requiredCapacity-capacityToMove
# remove the capacity entity by the buffer so that the broken ones are created
buffer.getActiveObjectQueue().remove(entity)
entityToMoveName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToMove)
entityToMove=CapacityEntity(name=entityToMoveName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToMove)
entityToMove.initialize()
entityToMove.currentStation=buffer
entityToMove.shouldMove=True
entityToStayName=entity.capacityProjectId+'_'+station.objName+'_'+str(capacityToStay)
entityToStay=CapacityEntity(name=entityToStayName, capacityProjectId=entity.capacityProjectId, requiredCapacity=capacityToStay)
entityToStay.initialize()
entityToStay.currentStation=buffer
import Globals
Globals.setWIP([entityToMove,entityToStay]) #set the new components as wip
# merges the capacity entities if they belong to the same project # merges the capacity entities if they belong to the same project
def mergeEntities(self): def mergeEntities(self):
...@@ -256,4 +294,19 @@ class CapacityStationController(EventGenerator): ...@@ -256,4 +294,19 @@ class CapacityStationController(EventGenerator):
if entry['stationId']==station.id: if entry['stationId']==station.id:
return False return False
return True return True
# checks if the given project is all in the buffer
def checkIfProjectAssembledInBuffer(self, project, buffer):
# loop through all the stations of the system
for object in G.CapacityStationList+G.CapacityStationBufferList+G.CapacityStationExitList:
# skip the given buffer
if object is buffer:
continue
# if there is one entity from the same project which we check somewhere else return false
for entity in object.getActiveObjectQueue():
if entity.capacityProject==project:
return False
# if nothing was found return true
return True
\ No newline at end of file
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