Commit df071c74 authored by Jérome Perrin's avatar Jérome Perrin

Transpose available capacity input spreadsheet

parent d4861bec
......@@ -106,7 +106,10 @@
var capacity_by_station_spreadsheet_data = data.capacity_by_station_spreadsheet;
if (capacity_by_station_spreadsheet_data !== undefined) {
var spreadsheet = $('#capacity_by_station_spreadsheet');
spreadsheet.handsontable('populateFromArray', 0, 0, capacity_by_station_spreadsheet_data);
var hot = spreadsheet.handsontable('getInstance');
hot.updateSettings({
minCols: Math.min(capacity_by_station_spreadsheet_data.length, 3) })
hot.populateFromArray(0, 0, capacity_by_station_spreadsheet_data);
}
var preference = data.preference !== undefined ?
......
......@@ -189,16 +189,15 @@
var capacity_by_station_spreadsheet = $('#capacity_by_station_spreadsheet');
var data = [
[
"Machine",
"Day 0",
"Day 1",
"Day 2",
"Day 3",
"Day",
"CS1",
"CS2"
]
];
capacity_by_station_spreadsheet.handsontable({
data: data,
minSpareRows: 1,
minSpareCols: 1, // Allow adding columns
stretchH: 'all',
width: function () {
return $(window).width() -
......
......@@ -24,28 +24,28 @@
"capacity_by_station_spreadsheet": [
[
"Machine",
"Day 0",
"Day 1",
"Day 2",
"Day 3"
"SMF",
"WELD"
],
[
"SMF",
"Day 0",
"100",
"200",
"300",
""
"150",
null
],
[
"WELD",
"150",
"Day 1",
"200",
"60",
null
],
[
"Day 2",
"300",
"350",
null
],
[
null,
"",
null,
null,
null
......
......@@ -4,6 +4,7 @@ import time
import random
import operator
from datetime import datetime
from collections import defaultdict
from dream.simulation.GUI.Default import Simulation as DefaultSimulation
from dream.simulation.GUI.Default import schema
......@@ -58,9 +59,14 @@ class Simulation(DefaultSimulation):
# read the spreadsheets
# a mapping station id -> list of interval capacity
available_capacity_by_station = dict()
for line in data.pop('capacity_by_station_spreadsheet')[1:]:
available_capacity_by_station[line[0]] = [float(x) for x in line[1:] if x]
available_capacity_by_station = defaultdict(list)
capacity_by_station_spreadsheet = data.pop('capacity_by_station_spreadsheet')
station_id_list = copy([x for x in capacity_by_station_spreadsheet[0][1:] if x])
for line in capacity_by_station_spreadsheet[1:]:
for station_id, capacity in zip(station_id_list, line[1:]):
available_capacity_by_station[station_id].append(float(capacity or 0))
assert set(station_id_list) == set(data['nodes'].keys()), "Check stations ids in capacity spreadsheet"
# a mapping project id -> mapping station_id -> required capacity
required_capacity_by_project = dict()
......
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