Commit b49f75a6 authored by Georgios Dagkakis's avatar Georgios Dagkakis

batches instance set with two more post processing plugins (empty for now)

parent 2a951bc7
from datetime import datetime
import random
from pprint import pformat
from dream.plugins import plugin
from dream.plugins.TimeSupport import TimeSupportMixin
class BatchesOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
def postprocess(self, data):
"""Post process the data for Gantt gadget
"""
print 2
# # in this instance there is not need to define start time
# data['general']['dateFormat']='%Y/%m/%d'
# self.initializeTimeSupport(data)
# date_format = '%d-%m-%Y %H:%M'
# resultElements=data['result']['result_list'][-1]['elementList']
# task_dict = {}
# # loop in the results to find CapacityProjects
# for element in resultElements:
# if element['_class']=="Dream.CapacityProject":
# # add the project in the task_dict
# task_dict[element['id']] = dict(
# id=element['id'],
# text='Project %s' % element['id'],
# type='project',
# open=False)
#
# # loop in the project schedule to create the sub-tasks
# projectSchedule=element['results'].get('schedule',{})
#
# for record in projectSchedule:
# task_dict[element['id']+record['stationId']] = dict(
# id=element['id']+record['stationId'],
# parent=element['id'],
# text=record['stationId'],
# start_date=self.convertToRealWorldTime(
# record['entranceTime']).strftime(date_format),
# stop_date=self.convertToRealWorldTime(
# record['exitTime']).strftime(date_format),
# open=False,
# duration=int(record['exitTime'])-int(record['entranceTime']),
# entranceTime=record['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
from dream.plugins import plugin
from copy import copy
class BatchesOperatorUtilization(plugin.OutputPreparationPlugin):
""" Output the station utilization metrics in a format compatible with
"""
def postprocess(self, data):
result = data['result']['result_list'][-1]
print 1
# ticks = []
# working_data = []
# waiting_data = []
# failure_data = []
# blockage_data = []
# off_shift_data = []
#
# options = {
# "xaxis": {
# "minTickSize": 1,
# "ticks": ticks
# },
# "yaxis": {
# "max": 100
# },
# "series": {
# "bars": {
# "show": True,
# "barWidth": 0.8,
# "align": "center"
# },
# "stack": True
# }
# }
#
# series = [{
# "label": "Working",
# "data": working_data
# }, {
# "label": "Waiting",
# "data": waiting_data
# }, {
# "label": "Failures",
# "data": failure_data
# }, {
# "label": "Blockage",
# "data": blockage_data
# },
# {
# "label": "off_shift",
# "data": off_shift_data
# }];
#
# out = result[self.configuration_dict['output_id']] = {
# "series": series,
# "options": options
# }
#
# i = 0
# for obj in result['elementList']:
# if obj.get('_class').startswith('Dream.BatchScrapMachine') or obj.get('_class')=='Dream.M3':
# nextId=self.getSuccessors(data, obj['id'])[0]
# nextClass=data['graph']['node'][nextId]['_class']
# objResults=copy(obj['results'])
#
# # if a station is before batch-reassembly then the blockage of reassembly is added to the station
# # and reducted from its waiting
# nextResults={}
# if nextClass.startswith('Dream.BatchReassembly'):
# for nextObj in result['elementList']:
# if nextObj['id']==nextId:
# nextResults=nextObj["results"]
# if nextResults:
# nextBlockage=nextResults['blockage_ratio'][0]
# objResults['blockage_ratio'][0]=nextBlockage
# objResults['waiting_ratio'][0]-=nextBlockage
#
# if objResults['working_ratio']:
# working_data.append((i, objResults['working_ratio'][0]))
# if objResults['waiting_ratio']:
# waiting_data.append((i, objResults['waiting_ratio'][0]))
# if objResults['failure_ratio']:
# failure_data.append((i, objResults['failure_ratio'][0]))
# if objResults['blockage_ratio']:
# blockage_data.append((i, objResults['blockage_ratio'][0]))
# if objResults['off_shift_ratio']:
# off_shift_data.append((i, objResults['off_shift_ratio'][0]))
#
# ticks.append((i, obj.get('name', self.getNameFromId(data, obj['id']))))
# i += 1
#
return data
......@@ -221,12 +221,10 @@
},
"view_operator_gantt": {
"configuration": {
"data": {
"Operator": []
}
"output_id": "operator_gantt"
},
"gadget": "Output_viewGantt",
"title": "Operator Gantt",
"title": "Operator Schedule",
"type": "object_view"
},
"view_queue_stats": {
......@@ -244,6 +242,14 @@
"gadget": "Output_viewGraph",
"title": "Station Utilization",
"type": "object_view"
},
"view_operator_utilization": {
"configuration": {
"output_id": "operator_utilization"
},
"gadget": "Output_viewGraph",
"title": "Operator Utilization",
"type": "object_view"
}
},
"post_processing": {
......@@ -265,6 +271,14 @@
{
"_class": "dream.plugins.BatchesTabularQueues.BatchesTabularQueues",
"output_id": "buffer_output"
},
{
"_class": "dream.plugins.BatchesOperatorUtilization.BatchesOperatorUtilization",
"output_id": "operator_utilization"
},
{
"_class": "dream.plugins.BatchesOperatorGantt.BatchesOperatorGantt",
"output_id": "operator_gantt"
}
]
},
......
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