Commit 5aec2254 authored by Georgios Dagkakis's avatar Georgios Dagkakis

merged changes

parents 19ecf7d2 3ce1606c
from datetime import datetime
import random
from pprint import pformat
from dream.plugins import plugin
from dream.plugins.TimeSupport import TimeSupportMixin
import datetime
class BatchesOperatorGantt(plugin.OutputPreparationPlugin, TimeSupportMixin):
def postprocess(self, data):
"""Post process the data for Gantt gadget
"""
strptime = datetime.datetime.strptime
# read the current date and define dateFormat from it
try:
now = strptime(data['general']['currentDate'], '%Y/%m/%d %H:%M')
data['general']['dateFormat']='%Y/%m/%d %H:%M'
except ValueError:
now = strptime(data['general']['currentDate'], '%Y/%m/%d')
data['general']['dateFormat']='%Y/%m/%d'
maxSimTime=data['general']['maxSimTime']
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 Operators
for element in resultElements:
if element['_class']=="Dream.Operator":
operatorId=element['id']
# add the operator in the task_dict
task_dict[element['id']] = dict(
id=operatorId,
text=operatorId,
type='operator',
open=False)
k=1
for record in schedule:
entranceTime=record['entranceTime']
try:
exitTime=schedule[k]['entranceTime']
except IndexError:
exitTime=maxSimTime
k+=1
task_dict[operatorId+record['stationId']+str(k)] = dict(
id=operatorId+record['stationId']+str(k),
parent=operatorId,
text=record['stationId'],
start_date=self.convertToRealWorldTime(
entranceTime).strftime(date_format),
stop_date=self.convertToRealWorldTime(
exitTime).strftime(date_format),
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
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]
ticks = []
working_data = []
waiting_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": "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') == 'Dream.Operator':
if obj['results']['working_ratio']:
working_data.append((i, obj['results']['working_ratio'][0]))
if obj['results']['waiting_ratio']:
waiting_data.append((i, obj['results']['waiting_ratio'][0]))
if obj['results']['off_shift_ratio']:
off_shift_data.append((i, obj['results']['off_shift_ratio'][0]))
ticks.append((i, obj.get('name', self.getNameFromId(data, obj['id']))))
i += 1
return data
......@@ -29,7 +29,11 @@ class BatchesTabularExit(plugin.OutputPreparationPlugin):
batchesThroughput=record['results']['throughput'][0]
data['result']['result_list'][0]['exit_output'].append(['Number of batches produced','Batches',
batchesThroughput])
unitsThroughput=record['results']['unitsThroughput'][0]
unitsThroughput=record['results'].get('unitsThroughput',None)
if unitsThroughput:
unitsThroughput=unitsThroughput[0]
if not unitsThroughput:
unitsThroughput=batchesThroughput
data['result']['result_list'][0]['exit_output'].append(['Number of units produced','Units',
unitsThroughput])
lineThroughput=batchesThroughput/float(maxSimTime)
......@@ -62,6 +66,9 @@ class BatchesTabularExit(plugin.OutputPreparationPlugin):
"%.2f" % batchesThroughputCI['lb'],
"%.2f" % batchesThroughputCI['ub']]
)
unitsThroughputList=record['results'].get('unitsThroughput',None)
if not unitsThroughputList:
unitsThroughputList=batchesThroughputList
unitsThroughputList=record['results']['unitsThroughput']
unitsThroughputCI=self.getConfidenceInterval(unitsThroughputList,confidenceLevel)
data['result']['result_list'][0]['exit_output'].append(['Number of units produced','Units',
......
......@@ -34,12 +34,17 @@ class ReadSkilledOperators(plugin.InputPreparationPlugin):
"ouputSchedule" : 1
}
operatorPresent = True
# for every station that has one or more skilled operators set operation type to MT-Load-Processing
for stationId in skills:
node[stationId]["operationType"]="MT-Load-Processing"
# add EventGenerator for the allocation every 10 minutes
# if there is at least one operator
if operatorPresent:
node['EV123454321']={ #(random id)
nodes=data['graph']['node']
for station_id,station in nodes.iteritems():
# set the operation type of all machines to MT-Load-Processing
if station['_class'] in ['Dream.BatchScrapMachine','Dream.BatchScrapMachineBeforeReassembly',
'Dream.BatchScrapMachineAfterDecompose','Dream.M3']:
station["operationType"]="MT-Load-Processing"
# add EventGenerator for the allocation every 10 minutes
node['EV123454321']={ #(random id)
"name": "Allocator",
"argumentDict": "{}",
"interval": 10,
......@@ -49,9 +54,6 @@ class ReadSkilledOperators(plugin.InputPreparationPlugin):
"interruptions": {},
"_class": "Dream.EventGenerator",
"method": "Dream.ManPyObject.requestAllocation"
}
# print '---------------------------------'
# print data['graph']['node']
# print '---------------------------------'
}
return data
......@@ -224,16 +224,14 @@
"title": "Buffer Levels",
"type": "object_view"
},
"view_operator_gantt": {
"configuration": {
"data": {
"Operator": []
}
},
"gadget": "Output_viewGantt",
"title": "Operator Gantt",
"type": "object_view"
},
"view_operator_gantt": {
"configuration": {
"output_id": "operator_gantt"
},
"gadget": "Output_viewGantt",
"title": "Operator Schedule",
"type": "object_view"
},
"view_queue_stats": {
"configuration": {
"output_id": "queue_statistics"
......@@ -249,6 +247,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": {
......@@ -270,6 +276,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