Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
dfd9e767
Commit
dfd9e767
authored
Feb 19, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shift WIP
parent
a4c91417
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
+32
-2
dream/simulation/GUI/Shifts.py
dream/simulation/GUI/Shifts.py
+32
-2
No files found.
dream/simulation/GUI/Shifts.py
View file @
dfd9e767
...
...
@@ -3,13 +3,43 @@ import json
import
time
import
random
import
operator
import
datetime
from
dream.simulation.GUI.Default
import
Simulation
as
DefaultSimulation
import
logging
logger
=
logging
.
getLogger
(
'dream.platform'
)
class
Simulation
(
DefaultSimulation
):
def
_preprocess
(
self
,
data
):
"""Preprocess data, reading shift spreadsheet"""
# TODO
"""Preprocess data, reading shift spreadsheet
"""
strptime
=
datetime
.
datetime
.
strptime
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d'
)
shift_by_station
=
{}
for
line
in
data
[
'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
).
seconds
//
60
stop_date
=
strptime
(
"%s %s"
%
(
line
[
0
],
line
[
3
]),
'%Y/%m/%d %H:%M'
)
stop_time
=
(
stop_date
-
now
).
seconds
//
60
for
station
in
line
[
1
].
split
(
','
):
shift_by_station
.
setdefault
(
station
,
[]).
append
(
(
start_time
,
stop_time
)
)
for
node
,
node_data
in
data
[
'nodes'
].
items
():
if
node
in
shift_by_station
:
node_data
[
'shift'
]
=
{
'shiftPattern'
:
shift_by_station
.
pop
(
node
),
'endUnfinished'
:
0
}
# XXX shall we make this
# configurable ?
assert
not
shift_by_station
,
\
"Some stations only exist in shift but not in graph: %r"
\
%
shift_by_station
.
keys
()
return
data
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment