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
b8e26195
Commit
b8e26195
authored
Feb 27, 2015
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new plugins preparing gantt data for operators and components. jobShop
parent
6312167f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
0 deletions
+146
-0
dream/plugins/JSComponentGantt.py
dream/plugins/JSComponentGantt.py
+73
-0
dream/plugins/JSOperatorGantt.py
dream/plugins/JSOperatorGantt.py
+73
-0
No files found.
dream/plugins/JSComponentGantt.py
0 → 100644
View file @
b8e26195
from
datetime
import
datetime
import
random
from
pprint
import
pformat
from
dream.plugins
import
plugin
from
dream.plugins.TimeSupport
import
TimeSupportMixin
import
datetime
class
JSComponentGantt
(
plugin
.
OutputPreparationPlugin
,
TimeSupportMixin
):
# XXX hardoced classes of different components to be displayed in the gantt
COMPONENT_CLASS_SET
=
set
([
"Dream.OrderComponent"
,
"Dream.OrderDesign"
,
"Dream.Mould"
])
def
postprocess
(
self
,
data
):
"""Post process the data for Gantt gadget
"""
print
"trying to prepare gantt data for components"
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'
maxSimTime
=
data
[
'general'
][
'maxSimTime'
]
self
.
initializeTimeSupport
(
data
)
date_format
=
'%d-%m-%Y %H:%M'
resultElements
=
data
[
'result'
][
'result_list'
][
-
1
][
'elementList'
]
task_dict
=
{}
# loop in the results to find Operators
for
element
in
resultElements
:
if
element
[
'_class'
]
in
self
.
COMPONENT_CLASS_SET
:
print
element
[
"id"
]
componentId
=
element
[
'id'
]
# add the component in the task_dict
task_dict
[
element
[
'id'
]]
=
dict
(
id
=
componentId
,
text
=
componentId
,
type
=
'component'
,
open
=
False
)
k
=
1
schedule
=
element
[
'results'
].
get
(
'schedule'
,
[])
if
schedule
:
for
record
in
schedule
:
entranceTime
=
record
[
'entranceTime'
]
try
:
exitTime
=
schedule
[
k
][
'entranceTime'
]
except
IndexError
:
exitTime
=
maxSimTime
k
+=
1
task_dict
[
componentId
+
record
[
'stationId'
]
+
str
(
k
)]
=
dict
(
id
=
componentId
+
record
[
'stationId'
]
+
str
(
k
),
parent
=
componentId
,
text
=
record
[
'stationId'
],
start_date
=
self
.
convertToRealWorldTime
(
entranceTime
).
strftime
(
date_format
),
stop_date
=
self
.
convertToRealWorldTime
(
exitTime
).
strftime
(
date_format
),
open
=
False
,
entranceTime
=
entranceTime
,
duration
=
exitTime
-
entranceTime
,
)
# return the result to the gadget
result
=
data
[
'result'
][
'result_list'
][
-
1
]
result
[
self
.
configuration_dict
[
'output_id'
]]
=
dict
(
time_unit
=
self
.
getTimeUnitText
(),
task_list
=
sorted
(
task_dict
.
values
(),
key
=
lambda
task
:
(
task
.
get
(
'parent'
),
task
.
get
(
'type'
)
==
'project'
,
task
.
get
(
'entranceTime'
),
task
.
get
(
'id'
))))
return
data
dream/plugins/JSOperatorGantt.py
0 → 100644
View file @
b8e26195
from
datetime
import
datetime
import
random
from
pprint
import
pformat
from
dream.plugins
import
plugin
from
dream.plugins.TimeSupport
import
TimeSupportMixin
import
datetime
class
JSOperatorGantt
(
plugin
.
OutputPreparationPlugin
,
TimeSupportMixin
):
# XXX hard-coded value of the operator class available
OPERATOR_CLASS_SET
=
set
([
"Dream.Operator"
])
def
postprocess
(
self
,
data
):
"""Post process the data for Gantt gadget
"""
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'
maxSimTime
=
data
[
'general'
][
'maxSimTime'
]
self
.
initializeTimeSupport
(
data
)
date_format
=
'%d-%m-%Y %H:%M'
resultElements
=
data
[
'result'
][
'result_list'
][
-
1
][
'elementList'
]
task_dict
=
{}
# loop in the results to find Operators
for
element
in
resultElements
:
if
element
[
'_class'
]
in
self
.
OPERATOR_CLASS_SET
:
operatorId
=
element
[
'id'
]
# add the operator in the task_dict
task_dict
[
element
[
'id'
]]
=
dict
(
id
=
operatorId
,
text
=
operatorId
,
type
=
'operator'
,
open
=
False
)
k
=
1
schedule
=
element
[
'results'
].
get
(
'schedule'
,
[])
if
schedule
:
for
record
in
schedule
:
entranceTime
=
record
[
'entranceTime'
]
exitTime
=
record
.
get
(
"exitTime"
,
None
)
if
not
exitTime
:
try
:
exitTime
=
schedule
[
k
][
'entranceTime'
]
except
IndexError
:
exitTime
=
maxSimTime
k
+=
1
task_dict
[
operatorId
+
record
[
'stationId'
]
+
str
(
k
)]
=
dict
(
id
=
operatorId
+
record
[
'stationId'
]
+
str
(
k
),
parent
=
operatorId
,
text
=
record
[
'stationId'
],
start_date
=
self
.
convertToRealWorldTime
(
entranceTime
).
strftime
(
date_format
),
stop_date
=
self
.
convertToRealWorldTime
(
exitTime
).
strftime
(
date_format
),
open
=
False
,
entranceTime
=
entranceTime
,
duration
=
exitTime
-
entranceTime
,
)
# return the result to the gadget
result
=
data
[
'result'
][
'result_list'
][
-
1
]
result
[
self
.
configuration_dict
[
'output_id'
]]
=
dict
(
time_unit
=
self
.
getTimeUnitText
(),
task_list
=
sorted
(
task_dict
.
values
(),
key
=
lambda
task
:
(
task
.
get
(
'parent'
),
task
.
get
(
'type'
)
==
'project'
,
task
.
get
(
'entranceTime'
),
task
.
get
(
'id'
))))
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