Commit 611bbea6 authored by Jérome Perrin's avatar Jérome Perrin

Update DemandPlanningLine plugin to prepare data for OutputPreparationPlugin

parent 11931df4
......@@ -9,10 +9,12 @@ class DemandPlanningLine(plugin.OutputPreparationPlugin, TimeSupportMixin):
def postprocess(self, data):
from dream.simulation.applications.DemandPlanning.Globals import G
utilisation=G.Utilisation
# XXX current implementation for one bottleneck
for bottleneck in ['BE_A_VF78_DSO_3','BE_A_VK18_DKO_5']:
bottleNeckUtilization=G.Utilisation[bottleneck]
result = data['result']['result_list'][-1]
bottleNeckUtilizationDict = result['bottleneck_utilization'] = {}
for bottleneck, bottleNeckUtilization in G.Utilisation.iteritems():
dateList=[]
# get the current date from the data
for record_id,record in bottleNeckUtilization.iteritems():
......@@ -20,13 +22,14 @@ class DemandPlanningLine(plugin.OutputPreparationPlugin, TimeSupportMixin):
week=str(record_id)[4:]
fullDate=datetime.strptime(year+'-'+week+'-0', '%Y-%W-%w')
dateList.append(fullDate)
# XXX We need to make TimeSupportMixin resuable. We should not have to do this.
currentDate=str(min(dateList))
currentDate=currentDate.replace('-', '/')
data['general']['currentDate']=currentDate
data['general']['timeUnit']='week'
self.initializeTimeSupport(data)
result = data['result']['result_list'][-1]
series = []
options = {
"xaxis": {
......@@ -35,23 +38,26 @@ class DemandPlanningLine(plugin.OutputPreparationPlugin, TimeSupportMixin):
}
}
result[bottleneck] = {
bottleNeckUtilizationDict[bottleneck] = {
"series": series,
"options": options
}
# create the 3 lines
for utilizationType in ['averageUtilization','minUtilization','maxUtilization']:
for (utilizationType, utilizationLabel) in [
( 'averageUtilization', 'Average Utilization' ),
( 'minUtilization', 'Min Utilization' ),
( 'maxUtilization', 'Max Utilization' ) ]:
utilizationList=[]
for record_id,record in bottleNeckUtilization.iteritems():
for record_id, record in bottleNeckUtilization.iteritems():
year=str(record_id)[0:4]
week=str(record_id)[4:]
fullDate=datetime.strptime(year+'-'+week+'-0', '%Y-%W-%w')
utilizationList.append([fullDate,record[utilizationType]])
utilizationList.sort(key=lambda x: x[0], reverse=True)
series.append({
"label": utilizationType,
"label": utilizationLabel,
"data": [((time-datetime(1970, 1, 1)).total_seconds()*1000, value) for (time, value) in utilizationList]
})
......
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