Commit c9e0f839 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Ioannis Papagiannopoulos

plugin for shifts on Batches instance added

parent 31a781d1
...@@ -3,14 +3,54 @@ import json ...@@ -3,14 +3,54 @@ import json
import time import time
import random import random
import operator import operator
from datetime import datetime import datetime
from dream.plugins import plugin from dream.plugins import plugin
class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin): class ReadShiftFromSpreadsheet(plugin.InputPreparationPlugin):
""" Input prepration """ Input prepration
read wip-srpeadsheet data and update the wip property of the stations. read shift-srpeadsheet data and update the wip property of the stations.
""" """
def preprocess(self, data): def preprocess(self, data):
return data strptime = datetime.datetime.strptime
\ No newline at end of file now = strptime(data['general']['currentDate'], '%Y/%m/%d')
shift_by_station = {}
for line in data['input']['machine_shift_spreadsheet'][1:]:
if line[1]:
# Get the dates, and convert them to simulation clock time units.
# In this class, time unit is a minute (XXX it can be an option)
start_date = strptime("%s %s" % (line[0], line[2]), '%Y/%m/%d %H:%M')
start_time = (start_date - now).total_seconds() // 60
stop_date = strptime("%s %s" % (line[0], line[3]), '%Y/%m/%d %H:%M')
stop_time = (stop_date - now).total_seconds() // 60
for station in line[1].split(','):
station = station.strip()
shift_by_station.setdefault(station, []).append(
(start_time, stop_time) )
for line in data['input']['operator_shift_spreadsheet'][1:]:
print line
if line[1]:
# Get the dates, and convert them to simulation clock time units.
# In this class, time unit is a minute (XXX it can be an option)
start_date = strptime("%s %s" % (line[0], line[2]), '%Y/%m/%d %H:%M')
start_time = (start_date - now).total_seconds() // 60
stop_date = strptime("%s %s" % (line[0], line[3]), '%Y/%m/%d %H:%M')
stop_time = (stop_date - now).total_seconds() // 60
for station in line[1].split(','):
station = station.strip()
shift_by_station.setdefault(station, []).append(
(start_time, stop_time) )
for node, node_data in data['graph']['node'].items():
if node in shift_by_station:
interruptions=node_data.get('interruptions',{})
if not interruptions:
node_data['interruptions']={}
node_data['interruptions']['shift'] = {'shiftPattern': shift_by_station.pop(node),
'endUnfinished': 0} # XXX shall we make this
# configurable ?
return data
\ No newline at end of file
...@@ -860,15 +860,16 @@ ...@@ -860,15 +860,16 @@
}, { }, {
"plugin" : "ReadEntryData.ReadEntryData", "plugin" : "ReadEntryData.ReadEntryData",
"input_id" : "EntryData" "input_id" : "EntryData"
}, {
"plugin" : "ReadShiftFromSpreadsheet.ReadShiftFromSpreadsheet",
"input_id" : "ShiftSpreadsheet"
}, { }, {
"plugin" : "BatchesWIPSpreadsheet.BatchesWIPSpreadsheet", "plugin" : "BatchesWIPSpreadsheet.BatchesWIPSpreadsheet",
"input_id" : "WipSpreadsheet" "input_id" : "WipSpreadsheet"
}, { }, {
"plugin" : "ReadSkilledOperators.ReadSkilledOperators", "plugin" : "ReadSkilledOperators.ReadSkilledOperators",
"input_id" : "SkilledOperatorsSpreadsheet" "input_id" : "SkilledOperatorsSpreadsheet"
},
{
"plugin" : "ReadShiftFromSpreadsheet.ReadShiftFromSpreadsheet",
"input_id" : "ShiftSpreadsheet"
} }
] ]
}, },
......
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