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