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
593bef3e
Commit
593bef3e
authored
May 11, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin to parse data for operator breaks
parent
18eba440
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
dream/plugins/Batches/BatchesOperatorBreaks.py
dream/plugins/Batches/BatchesOperatorBreaks.py
+63
-0
No files found.
dream/plugins/Batches/BatchesOperatorBreaks.py
0 → 100644
View file @
593bef3e
from
dream.plugins
import
plugin
from
dream.plugins.TimeSupport
import
TimeSupportMixin
import
datetime
class
BatchesOperatorBreaks
(
plugin
.
InputPreparationPlugin
,
TimeSupportMixin
):
""" Output the schedule of operators in an Excel file to be downloaded
"""
def
preprocess
(
self
,
data
):
strptime
=
datetime
.
datetime
.
strptime
# read the current date and define dateFormat from it
try
:
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d %H:%M'
)
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d %H:%M'
except
ValueError
:
now
=
strptime
(
data
[
'general'
][
'currentDate'
],
'%Y/%m/%d'
)
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d'
self
.
initializeTimeSupport
(
data
)
breakData
=
data
[
'input'
][
'operator_shift_spreadsheet'
]
for
row
in
breakData
:
if
row
[
0
]
in
[
'Date'
,
''
,
None
]:
continue
date
=
strptime
(
row
[
0
],
'%Y/%m/%d'
)
operators
=
row
[
1
].
split
(
','
)
i
=
4
while
row
[
i
]
not
in
[
''
,
None
]:
breakStart
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
row
[
0
],
row
[
i
]),
'%Y/%m/%d %H:%M'
))
i
+=
1
breakEnd
=
self
.
convertToSimulationTime
(
strptime
(
"%s %s"
%
(
row
[
0
],
row
[
i
]),
'%Y/%m/%d %H:%M'
))
i
+=
1
# if the end of break shift already finished we do not need to consider in simulation
if
breakStart
<
0
and
breakEnd
<=
0
:
continue
# if the start of the shift is before now, set the start to 0
if
breakStart
<
0
:
breakStart
=
0
# sometimes the date may change (e.g. break from 23:00 to 01:00).
# these would be declared in the date of the start so add a date (self.timeUnitPerDay) to the end
if
breakEnd
<
breakEnd
:
breakEnd
+=
self
.
timeUnitPerDay
# add the break to the operator
for
operator
in
operators
:
PB
=
data
[
'graph'
][
'node'
][
operator
]
interruptions
=
PB
.
get
(
'interruptions'
,{})
scheduledBreaks
=
interruptions
.
get
(
'scheduledBreak'
,{})
if
scheduledBreaks
:
scheduledBreaks
[
'breakPattern'
].
append
([
breakStart
,
breakEnd
])
else
:
PB
[
'interruptions'
][
'scheduledBreak'
]
=
{
"endUnfinished"
:
0
,
"breakPattern"
:
[
[
breakStart
,
breakEnd
]
]
}
# import json
# outputJSONString=json.dumps(data['graph']['node'], indent=5)
# outputJSONFile=open('h.json', mode='w')
# outputJSONFile.write(outputJSONString)
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