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

Transpose available capacity input spreadsheet

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