Commit d4b71719 authored by Georgios Dagkakis's avatar Georgios Dagkakis

2 plugins added

parent 0240879b
from copy import copy
import json
import time
import random
import operator
import datetime
from dream.plugins import plugin
class AddDemandPlannerGenerator(plugin.InputPreparationPlugin):
""" Input preparation
adds an EventGenerator that will call the Demand Planning algorithm once
"""
def preprocess(self, data):
nodes=data['graph']['node']
nodes['DPG']={
"name": "DemandPlannerGenerator",
"prioritizeIfCanFinish": 1,
"interval": 1,
"start": 0,
"stop": 0.5,
"_class": "dream.simulation.EventGenerator.EventGenerator",
"method": "dream.simulation.applications.DemandPlanning.executor_ACO.main"
}
#print nodes
return data
\ No newline at end of file
from copy import copy
import json
import time
import random
import operator
import StringIO
import xlrd
from dream.plugins import plugin
class ReadDemandPlannerExcelInput(plugin.OutputPreparationPlugin):
""" Example on how to read an excel spreadsheet
"""
def preprocess(self, data):
""" Example showing how to read an attached file
"""
# Attachement is encoded in data uri, ie data:application/excel;base64,***
data_uri_encoded_input_data = data['input'].get(self.configuration_dict['input_id'], {})
if data_uri_encoded_input_data:
mime_type, attachement_data = data_uri_encoded_input_data[len('data:'):].split(';base64,', 1)
attachement_data = attachement_data.decode('base64')
workbook = xlrd.open_workbook(file_contents=attachement_data)
print "This spreadsheet contains sheets:", workbook.sheet_names()
#raise ValueError(workbook.sheet_names())
return data
\ No newline at end of file
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