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
51fc56ed
Commit
51fc56ed
authored
Feb 23, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
two new plugins to prepare gantt in CapacityProject instance
parent
d8d5ff6d
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1299 additions
and
1 deletion
+1299
-1
dream/plugins/CapacityProjectGantt.py
dream/plugins/CapacityProjectGantt.py
+99
-0
dream/plugins/CapacityStationGantt.py
dream/plugins/CapacityStationGantt.py
+63
-0
dream/simulation/Examples/GUI_instances/CapacityProjectAllInOneEmpty.json
.../Examples/GUI_instances/CapacityProjectAllInOneEmpty.json
+25
-1
dream/simulation/Examples/GUI_models/CapacityProject1Order.json
...simulation/Examples/GUI_models/CapacityProject1Order.json
+1112
-0
No files found.
dream/plugins/CapacityProjectGantt.py
0 → 100644
View file @
51fc56ed
from
datetime
import
datetime
import
random
from
pprint
import
pformat
from
dream.plugins
import
plugin
from
dream.plugins.TimeSupport
import
TimeSupportMixin
class
CapacityProjectGantt
(
plugin
.
OutputPreparationPlugin
,
TimeSupportMixin
):
def
_generateRandomTaskList
(
self
):
"""Generate some random tasks for the example.
Take care of not using reserved id '0'
"""
for
order_id
in
range
(
3
):
for
order_line_id
in
range
(
random
.
randint
(
1
,
6
)):
start_time
=
random
.
random
()
*
10
duration
=
random
.
random
()
*
10
yield
dict
(
id
=
'%s_%s'
%
(
order_id
,
order_line_id
),
order_id
=
"O%s"
%
order_id
,
start_time
=
start_time
,
duration
=
duration
)
def
postprocess
(
self
,
data
):
"""Post process the data for Gantt gadget
"""
print
1
data
[
'general'
][
'dateFormat'
]
=
'%Y/%m/%d'
self
.
initializeTimeSupport
(
data
)
date_format
=
'%d-%m-%Y %H:%M'
resultElements
=
data
[
'result'
][
'result_list'
][
-
1
][
'elementList'
]
task_dict
=
{}
for
element
in
resultElements
:
if
element
[
'_class'
]
==
"Dream.CapacityProject"
:
# add the project in the gantt
task_dict
[
element
[
'id'
]]
=
dict
(
id
=
element
[
'id'
],
text
=
'Project %s'
%
element
[
'id'
],
type
=
'project'
,
open
=
True
)
projectSchedule
=
element
[
'results'
].
get
(
'schedule'
,{})
for
record
in
projectSchedule
:
task_dict
[
record
[
'stationId'
]]
=
dict
(
id
=
record
[
'stationId'
],
parent
=
element
[
'id'
],
text
=
record
[
'stationId'
],
start_date
=
self
.
convertToRealWorldTime
(
record
[
'entranceTime'
]).
strftime
(
date_format
),
stop_date
=
self
.
convertToRealWorldTime
(
record
[
'exitTime'
]).
strftime
(
date_format
),
open
=
True
,
duration
=
int
(
record
[
'exitTime'
])
-
int
(
record
[
'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
(
'order_id'
),
task
.
get
(
'type'
)
==
'project'
,
task
.
get
(
'start_date'
))))
return
data
#
# date_format = '%d-%m-%Y %H:%M'
#
# task_dict = {}
# for task in self._generateRandomTaskList():
#
# # Add the order if not already present
# if task['order_id'] not in task_dict:
# task_dict[task['order_id']] = dict(
# id=task['order_id'],
# text='Order %s' % task['order_id'],
# type='project',
# open=True)
#
# task_dict[task['id']] = dict(
# id=task['id'],
# parent=task['order_id'],
# text='Task %s' % task['id'],
# start_date=self.convertToRealWorldTime(
# task['start_time']).strftime(date_format),
# stop_date=self.convertToRealWorldTime(
# task['start_time'] + task['duration']).strftime(date_format),
# open=True,
# duration=task['duration'])
#
# 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('order_id'),
# task.get('type') == 'project',
# task.get('start_date'))))
#
# return data
dream/plugins/CapacityStationGantt.py
0 → 100644
View file @
51fc56ed
from
datetime
import
datetime
import
random
from
pprint
import
pformat
from
dream.plugins
import
plugin
from
dream.plugins.TimeSupport
import
TimeSupportMixin
class
CapacityStationGantt
(
plugin
.
OutputPreparationPlugin
,
TimeSupportMixin
):
def
_generateRandomTaskList
(
self
):
"""Generate some random tasks for the example.
Take care of not using reserved id '0'
"""
for
order_id
in
range
(
3
):
for
order_line_id
in
range
(
random
.
randint
(
1
,
6
)):
start_time
=
random
.
random
()
*
10
duration
=
random
.
random
()
*
10
yield
dict
(
id
=
'%s_%s'
%
(
order_id
,
order_line_id
),
order_id
=
"O%s"
%
order_id
,
start_time
=
start_time
,
duration
=
duration
)
def
postprocess
(
self
,
data
):
print
2
"""Post process the data for Gantt gadget
"""
return
data
# self.initializeTimeSupport(data)
#
# date_format = '%d-%m-%Y %H:%M'
#
# task_dict = {}
# for task in self._generateRandomTaskList():
#
# # Add the order if not already present
# if task['order_id'] not in task_dict:
# task_dict[task['order_id']] = dict(
# id=task['order_id'],
# text='Order %s' % task['order_id'],
# type='project',
# open=True)
#
# task_dict[task['id']] = dict(
# id=task['id'],
# parent=task['order_id'],
# text='Task %s' % task['id'],
# start_date=self.convertToRealWorldTime(
# task['start_time']).strftime(date_format),
# stop_date=self.convertToRealWorldTime(
# task['start_time'] + task['duration']).strftime(date_format),
# open=True,
# duration=task['duration'])
#
# 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('order_id'),
# task.get('type') == 'project',
# task.get('start_date'))))
#
# return data
dream/simulation/Examples/GUI_instances/CapacityProjectAllInOneEmpty.json
View file @
51fc56ed
...
...
@@ -547,7 +547,23 @@
"gadget"
:
"Output_viewGraph"
,
"title"
:
"Station Utilization"
,
"type"
:
"object_view"
}
},
"view_project_gantt"
:
{
"configuration"
:
{
"output_id"
:
"capacity_project_gantt"
},
"gadget"
:
"Output_viewGantt"
,
"title"
:
"Project Schedule"
,
"type"
:
"object_view"
},
"view_station_gantt"
:
{
"configuration"
:
{
"output_id"
:
"capacity_station_gantt"
},
"gadget"
:
"Output_viewGantt"
,
"title"
:
"Station Schedule"
,
"type"
:
"object_view"
}
},
"pre_processing"
:
{
"plugin_list"
:
[
...
...
@@ -583,6 +599,14 @@
"_class"
:
"dream.plugins.CapacityProjectStationUtilization.CapacityProjectStationUtilization"
,
"family"
:
"CapacityStation"
,
"output_id"
:
"station_utilization"
},
{
"_class"
:
"dream.plugins.CapacityProjectGantt.CapacityProjectGantt"
,
"output_id"
:
"capacity_project_gantt"
},
{
"_class"
:
"dream.plugins.CapacityStationGantt.CapacityStationGantt"
,
"output_id"
:
"capacity_station_gantt"
}
]
},
...
...
dream/simulation/Examples/GUI_models/CapacityProject1Order.json
0 → 100644
View file @
51fc56ed
This diff is collapsed.
Click to expand it.
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