Commit 03f872ba authored by Georgios Dagkakis's avatar Georgios Dagkakis

CapacityStationController does not start the assembly of a project if there is not enough space

parent 274f5afd
...@@ -208,6 +208,7 @@ class CapacityStationController(EventGenerator): ...@@ -208,6 +208,7 @@ class CapacityStationController(EventGenerator):
exit.currentlyObtainedEntities=[] exit.currentlyObtainedEntities=[]
def calculateWhatIsToBeProcessed(self): def calculateWhatIsToBeProcessed(self):
availableSpace=self.assemblySpace
# loop through the capacity station buffers # loop through the capacity station buffers
for buffer in G.CapacityStationBufferList: for buffer in G.CapacityStationBufferList:
activeObjectQueue=buffer.getActiveObjectQueue() activeObjectQueue=buffer.getActiveObjectQueue()
...@@ -245,15 +246,20 @@ class CapacityStationController(EventGenerator): ...@@ -245,15 +246,20 @@ class CapacityStationController(EventGenerator):
totalRequestedCapacity=0 totalRequestedCapacity=0
for entity in entitiesWithinThreshold: for entity in entitiesWithinThreshold:
if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\ if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)): (not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)) and\
self.checkIfThereIsEnoughSpace(entity, buffer, availableSpace):
totalRequestedCapacity+=entity.requiredCapacity totalRequestedCapacity+=entity.requiredCapacity
# if there is enough capacity for all the entities set them that they all should move # if there is enough capacity for all the entities set them that they all should move
if totalRequestedCapacity<=totalAvailableCapacity: if totalRequestedCapacity<=totalAvailableCapacity:
for entity in entitiesWithinThreshold: for entity in entitiesWithinThreshold:
if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\ if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)): (not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)) and\
self.checkIfThereIsEnoughSpace(entity, buffer, availableSpace):
entity.shouldMove=True entity.shouldMove=True
# reduce the available space if there is need to
if buffer.requireFullProject:
availableSpace-=entity.capacityProject.assemblySpaceRequirement
# remove the entity from the none allocated ones # remove the entity from the none allocated ones
entitiesNotAllocated.remove(entity) entitiesNotAllocated.remove(entity)
# check if all the capacity is consumed to update the flag and break the loop # check if all the capacity is consumed to update the flag and break the loop
...@@ -267,7 +273,8 @@ class CapacityStationController(EventGenerator): ...@@ -267,7 +273,8 @@ class CapacityStationController(EventGenerator):
haveMoreEntitiesToAllocate=False haveMoreEntitiesToAllocate=False
for entity in entitiesOutsideThreshold: for entity in entitiesOutsideThreshold:
if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\ if self.checkIfProjectCanStartInStation(entity.capacityProject, station) and\
(not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)): (not self.checkIfProjectNeedsToBeAssembled(entity.capacityProject, buffer)) and\
self.checkIfThereIsEnoughSpace(entity, buffer, availableSpace):
haveMoreEntitiesToAllocate=True haveMoreEntitiesToAllocate=True
break break
...@@ -293,12 +300,19 @@ class CapacityStationController(EventGenerator): ...@@ -293,12 +300,19 @@ class CapacityStationController(EventGenerator):
and self.prioritizeIfCanFinish: and self.prioritizeIfCanFinish:
# set that the entity can move # set that the entity can move
entity.shouldMove=True entity.shouldMove=True
# reduce the available space if there is need to
if buffer.requireFullProject:
availableSpace-=entity.capacityProject.assemblySpaceRequirement
# update the values # update the values
totalAvailableCapacity-=entity.requiredCapacity totalAvailableCapacity-=entity.requiredCapacity
totalRequestedCapacity-=entity.requiredCapacity totalRequestedCapacity-=entity.requiredCapacity
# else break the entity according to rule # else break the entity according to rule
else: else:
self.breakEntity(entity, buffer, station, totalAvailableCapacity, totalRequestedCapacity) self.breakEntity(entity, buffer, station, totalAvailableCapacity,
totalRequestedCapacity)
# reduce the available space if there is need to
if buffer.requireFullProject:
availableSpace-=entity.capacityProject.assemblySpaceRequirement
# the capacity will be 0 since we consumed it all # the capacity will be 0 since we consumed it all
totalAvailableCapacity=0 totalAvailableCapacity=0
# if the station shares capacity with other stations then we have to # if the station shares capacity with other stations then we have to
...@@ -432,6 +446,16 @@ class CapacityStationController(EventGenerator): ...@@ -432,6 +446,16 @@ class CapacityStationController(EventGenerator):
return True return True
return False return False
# returns true if there is enough space for the entity to move
def checkIfThereIsEnoughSpace(self, entity, buffer, availableSpace):
if buffer.requireFullProject:
return entity.capacityProject.assemblySpaceRequirement<=availableSpace
return True
def checkIfEntityCanMove(self):
pass
# sorts the buffers so if they have shared resources the ones with highest priority will go in front # sorts the buffers so if they have shared resources the ones with highest priority will go in front
def sortBuffers(self): def sortBuffers(self):
for buffer in G.CapacityStationBufferList: for buffer in G.CapacityStationBufferList:
......
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