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
1cd8a6b3
Commit
1cd8a6b3
authored
Mar 27, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Batch plugin to be able to work even if there are no operators
parent
a63bfcbd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
42 deletions
+44
-42
dream/plugins/Batches/BatchesOperatorSpreadsheet.py
dream/plugins/Batches/BatchesOperatorSpreadsheet.py
+44
-42
No files found.
dream/plugins/Batches/BatchesOperatorSpreadsheet.py
View file @
1cd8a6b3
...
...
@@ -18,55 +18,57 @@ class BatchesOperatorSpreadsheet(plugin.OutputPreparationPlugin):
scheduleSheet
.
write
(
rowIndex
,
3
,
'End Time'
,
headingStyle
)
rowIndex
+=
1
solutionList
=
None
# get the result the the router gives
for
element
in
data
[
'result'
][
'result_list'
][
-
1
][
'elementList'
]:
if
element
[
'_class'
]
==
'Dream.SkilledRouter'
:
solutionList
=
element
[
'results'
][
'solutionList'
]
# create a list with all the operator ids that were at least in one allocation
operatorList
=
[]
for
record
in
solutionList
:
for
key
in
record
[
'allocation'
]:
if
key
not
in
operatorList
:
operatorList
.
append
(
key
)
# create for every operator a list like [time,machineId]. If the operator is not in the solution latter is to None
normalizedSchedule
=
{}
for
operator
in
operatorList
:
operatorSchedule
=
[]
normalizedSchedule
[
operator
]
=
[]
if
solutionList
:
# create a list with all the operator ids that were at least in one allocation
operatorList
=
[]
for
record
in
solutionList
:
time
=
record
[
'time'
]
allocation
=
record
[
'allocation'
]
machineId
=
None
if
operator
in
allocation
.
keys
():
machineId
=
allocation
[
operator
]
operatorSchedule
.
append
([
time
,
machineId
])
# now create a normalized schedule for the operator like [MachineId, EntranceTime, ExitTime]
k
=
0
for
record
in
operatorSchedule
:
normalizedSchedule
[
operator
].
append
([
record
[
1
],
record
[
0
]])
for
nextRecord
in
operatorSchedule
[
k
+
1
:]:
if
nextRecord
[
1
]
==
record
[
1
]:
operatorSchedule
.
remove
(
nextRecord
)
else
:
normalizedSchedule
[
operator
][
-
1
].
append
(
nextRecord
[
0
])
break
k
+=
1
for
key
in
record
[
'allocation'
]:
if
key
not
in
operatorList
:
operatorList
.
append
(
key
)
# create for every operator a list like [time,machineId]. If the operator is not in the solution latter is to None
normalizedSchedule
=
{}
for
operator
in
operatorList
:
operatorSchedule
=
[]
normalizedSchedule
[
operator
]
=
[]
for
record
in
solutionList
:
time
=
record
[
'time'
]
allocation
=
record
[
'allocation'
]
machineId
=
None
if
operator
in
allocation
.
keys
():
machineId
=
allocation
[
operator
]
operatorSchedule
.
append
([
time
,
machineId
])
# now create a normalized schedule for the operator like [MachineId, EntranceTime, ExitTime]
k
=
0
for
record
in
operatorSchedule
:
normalizedSchedule
[
operator
].
append
([
record
[
1
],
record
[
0
]])
for
nextRecord
in
operatorSchedule
[
k
+
1
:]:
if
nextRecord
[
1
]
==
record
[
1
]:
operatorSchedule
.
remove
(
nextRecord
)
else
:
normalizedSchedule
[
operator
][
-
1
].
append
(
nextRecord
[
0
])
break
k
+=
1
# output the results in excel
for
operator
in
normalizedSchedule
.
keys
():
scheduleSheet
.
write
(
rowIndex
,
0
,
operator
,
PBstyle
)
for
record
in
normalizedSchedule
[
operator
]:
# skip the records that have 'None'
if
not
record
[
0
]:
continue
scheduleSheet
.
write
(
rowIndex
,
1
,
record
[
0
])
scheduleSheet
.
write
(
rowIndex
,
2
,
record
[
1
])
scheduleSheet
.
write
(
rowIndex
,
3
,
record
[
2
])
rowIndex
+=
1
# output the results in excel
for
operator
in
normalizedSchedule
.
keys
():
scheduleSheet
.
write
(
rowIndex
,
0
,
operator
,
PBstyle
)
for
record
in
normalizedSchedule
[
operator
]:
# skip the records that have 'None'
if
not
record
[
0
]:
continue
scheduleSheet
.
write
(
rowIndex
,
1
,
record
[
0
])
scheduleSheet
.
write
(
rowIndex
,
2
,
record
[
1
])
scheduleSheet
.
write
(
rowIndex
,
3
,
record
[
2
])
rowIndex
+=
1
# return the workbook as encoded
scheduleStringIO
=
StringIO
.
StringIO
()
scheduleFile
.
save
(
scheduleStringIO
)
...
...
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