Commit 18801ee9 authored by Georgios Dagkakis's avatar Georgios Dagkakis

plugin for operator gantt

parent 9d39a004
...@@ -4,52 +4,65 @@ from pprint import pformat ...@@ -4,52 +4,65 @@ from pprint import pformat
from dream.plugins import plugin from dream.plugins import plugin
from dream.plugins.TimeSupport import TimeSupportMixin from dream.plugins.TimeSupport import TimeSupportMixin
import datetime
class BatchesOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin): class BatchesOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
def postprocess(self, data): def postprocess(self, data):
"""Post process the data for Gantt gadget """Post process the data for Gantt gadget
""" """
print 2 strptime = datetime.datetime.strptime
# # in this instance there is not need to define start time # read the current date and define dateFormat from it
# data['general']['dateFormat']='%Y/%m/%d' try:
# self.initializeTimeSupport(data) now = strptime(data['general']['currentDate'], '%Y/%m/%d %H:%M')
# date_format = '%d-%m-%Y %H:%M' data['general']['dateFormat']='%Y/%m/%d %H:%M'
# resultElements=data['result']['result_list'][-1]['elementList'] except ValueError:
# task_dict = {} now = strptime(data['general']['currentDate'], '%Y/%m/%d')
# # loop in the results to find CapacityProjects data['general']['dateFormat']='%Y/%m/%d'
# for element in resultElements: maxSimTime=data['general']['maxSimTime']
# if element['_class']=="Dream.CapacityProject": self.initializeTimeSupport(data)
# # add the project in the task_dict date_format = '%d-%m-%Y %H:%M'
# task_dict[element['id']] = dict( resultElements=data['result']['result_list'][-1]['elementList']
# id=element['id'], task_dict = {}
# text='Project %s' % element['id'], # loop in the results to find Operators
# type='project', for element in resultElements:
# open=False) if element['_class']=="Dream.Operator":
# operatorId=element['id']
# # loop in the project schedule to create the sub-tasks # add the operator in the task_dict
# projectSchedule=element['results'].get('schedule',{}) task_dict[element['id']] = dict(
# id=operatorId,
# for record in projectSchedule: text=operatorId,
# task_dict[element['id']+record['stationId']] = dict( type='operator',
# id=element['id']+record['stationId'], open=False)
# parent=element['id'],
# text=record['stationId'], k=1
# start_date=self.convertToRealWorldTime(
# record['entranceTime']).strftime(date_format), for record in schedule:
# stop_date=self.convertToRealWorldTime( entranceTime=record['entranceTime']
# record['exitTime']).strftime(date_format), try:
# open=False, exitTime=schedule[k]['entranceTime']
# duration=int(record['exitTime'])-int(record['entranceTime']), except IndexError:
# entranceTime=record['entranceTime'] exitTime=maxSimTime
# ) k+=1
# task_dict[operatorId+record['stationId']] = dict(
# # return the result to the gadget id=operatorId+record['stationId'],
# result = data['result']['result_list'][-1] parent=operatorId,
# result[self.configuration_dict['output_id']] = dict( text=record['stationId'],
# time_unit=self.getTimeUnitText(), start_date=self.convertToRealWorldTime(
# task_list=sorted(task_dict.values(), entranceTime).strftime(date_format),
# key=lambda task: (task.get('parent'), stop_date=self.convertToRealWorldTime(
# task.get('type') == 'project', exitTime).strftime(date_format),
# task.get('entranceTime'),task.get('id')))) open=False,
entranceTime=entranceTime,
duration=exitTime-entranceTime,
)
# return the result to the gadget
result = data['result']['result_list'][-1]
result[self.configuration_dict['output_id']] = dict(
time_unit=self.getTimeUnitText(),
task_list=sorted(task_dict.values(),
key=lambda task: (task.get('parent'),
task.get('type') == 'project',
task.get('entranceTime'),task.get('id'))))
return data return data
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