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

CapacityProjects to output the start and finish time on each station

parent b0be22a6
......@@ -33,8 +33,25 @@ from Entity import Entity
# ===========================================================================
class CapacityProject(Entity):
type="CapacityProject"
class_name = 'Dream.CapacityProject'
def __init__(self, id=None, name=None, capacityRequirementDict={}):
Entity.__init__(self, id, name)
# a dict that shows the required capacity from every station
self.capacityRequirementDict=capacityRequirementDict
def initialize(self):
self.projectSchedule=[] # a list of dicts to keep the schedule
# =======================================================================
# outputs results to JSON File
# =======================================================================
def outputResultsJSON(self):
from Globals import G
json = {'_class': self.class_name,
'id': self.id,
'results': {}}
if (G.numberOfReplications == 1):
# if we had just one replication output the results as numbers
json['results']['schedule']=self.projectSchedule
G.outputJSON['elementList'].append(json)
......@@ -71,6 +71,10 @@ class CapacityStationController(EventGenerator):
yield station.entityRemoved
exit.currentlyObtainedEntities.append(entity)
station.entityRemoved=self.env.event()
project=entity.capacityProject
for entry in project.projectSchedule:
if entry['station']==station.id:
entry['finish']=self.env.now
# lock the exit again
exit.isLocked=True
......@@ -110,8 +114,11 @@ class CapacityStationController(EventGenerator):
# wait until the entity is removed
yield buffer.entityRemoved
buffer.entityRemoved=self.env.event()
periodDict[entity.capacityProject.id]=entity.requiredCapacity
project=entity.capacityProject
periodDict[project.id]=entity.requiredCapacity
capacityAllocated+=entity.requiredCapacity
if self.checkIfProjectJustStartsInStation(project, station):
project.projectSchedule.append({"station": station.id,"start": self.env.now})
# lock the station
station.isLocked=True
periodDict['utilization']=capacityAllocated/float(capacityAvailable)
......@@ -231,4 +238,11 @@ class CapacityStationController(EventGenerator):
if len(object.getActiveObjectQueue()):
return False
return True
# checks if a project is just starting in station
def checkIfProjectJustStartsInStation(self, project, station):
for entry in project.projectSchedule:
if entry['station']==station.id:
return False
return True
\ No newline at end of file
......@@ -1415,6 +1415,9 @@ def main(argv=[], input_data=None):
for job in G.JobList:
job.outputResultsJSON()
for capacityProject in G.CapacityProjectList:
capacityProject.outputResultsJSON()
outputJSONString=json.dumps(G.outputJSON, indent=True)
G.outputJSONFile.write(outputJSONString)
......
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