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
1d7a4aeb
Commit
1d7a4aeb
authored
Aug 21, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup, ObjectInterruptions to be all created by the same method
parent
2b494f50
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
58 deletions
+60
-58
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+60
-58
No files found.
dream/simulation/LineGenerationJSON.py
View file @
1d7a4aeb
...
...
@@ -184,7 +184,6 @@ def createObjects():
G
.
CapacityStationList
=
[]
G
.
CapacityStationExitList
=
[]
G
.
CapacityStationControllerList
=
[]
G
.
ObjectInterruptionList
=
[]
'''
loop through all the model resources
...
...
@@ -277,61 +276,6 @@ def createObjects():
# get the successorList for the 'Frames'
coreObject
.
nextFrameIds
=
getSuccessorList
(
element
[
'id'
],
lambda
source
,
destination
,
edge_data
:
edge_data
.
get
(
'entity'
)
==
'Frame'
)
# -----------------------------------------------------------------------
# loop through all the nodes to
# search for Event Generator and create them
# this is put last, since the EventGenerator
# may take other objects as argument
# -----------------------------------------------------------------------
for
(
element_id
,
element
)
in
nodes
.
iteritems
():
# use an iterator to go through all the nodes
# the key is the element_id and the second is the
# element itself
element
[
'id'
]
=
element_id
# create a new entry for the element (dictionary)
# with key 'id' and value the the element_id
elementClass
=
element
.
get
(
'_class'
,
'not found'
)
# get the class type of the element
if
elementClass
==
'Dream.EventGenerator'
:
# check the object type
id
=
element
.
get
(
'id'
,
'not found'
)
# get the id of the element / default 'not_found'
name
=
element
.
get
(
'name'
,
'not found'
)
# get the name of the element / default 'not_found'
start
=
float
(
element
.
get
(
'start'
)
or
0
)
stop
=
float
(
element
.
get
(
'stop'
)
or
-
1
)
# infinity (had to be done to make it as float)
if
stop
<
0
:
stop
=
float
(
'inf'
)
interval
=
float
(
element
.
get
(
'interval'
)
or
1
)
duration
=
float
(
element
.
get
(
'duration'
)
or
0
)
method
=
(
element
.
get
(
'method'
,
None
))
# get the method to be run / default None
method
=
method
.
split
(
'.'
)
#the method is given as 'Path.MethodName'
method
=
getattr
(
str_to_class
(
method
[
0
]),
method
[
1
])
#and then parsed with getattr
argumentDict
=
(
element
.
get
(
'argumentDict'
,
{}))
# get the arguments of the method as a dict / default {}
EV
=
EventGenerator
(
id
,
name
,
start
=
start
,
stop
=
stop
,
interval
=
interval
,
duration
=
duration
,
method
=
method
,
argumentDict
=
argumentDict
)
# create the EventGenerator object
G
.
EventGeneratorList
.
append
(
EV
)
G
.
ObjectInterruptionList
.
append
(
EV
)
elif
elementClass
==
'Dream.CapacityStationController'
:
# check the object type
id
=
element
.
get
(
'id'
,
'not found'
)
# get the id of the element / default 'not_found'
name
=
element
.
get
(
'name'
,
'not found'
)
# get the name of the element / default 'not_found'
start
=
float
(
element
.
get
(
'start'
)
or
0
)
stop
=
float
(
element
.
get
(
'stop'
)
or
-
1
)
# infinity (had to be done to make it as float)
if
stop
<
0
:
stop
=
float
(
'inf'
)
interval
=
float
(
element
.
get
(
'interval'
)
or
1
)
duration
=
float
(
element
.
get
(
'duration'
)
or
0
)
dueDateThreshold
=
float
(
element
.
get
(
'dueDateThreshold'
)
or
float
(
'inf'
))
prioritizeIfCanFinish
=
bool
(
element
.
get
(
'prioritizeIfCanFinish'
,
0
))
argumentDict
=
(
element
.
get
(
'argumentDict'
,
{}))
# get the arguments of the method as a dict / default {}
# create the CapacityStationController object
CSC
=
CapacityStationController
(
id
,
name
,
start
=
start
,
stop
=
stop
,
interval
=
interval
,
duration
=
duration
,
argumentDict
=
argumentDict
,
dueDateThreshold
=
dueDateThreshold
,
prioritizeIfCanFinish
=
prioritizeIfCanFinish
)
G
.
EventGeneratorList
.
append
(
CSC
)
G
.
CapacityStationControllerList
.
append
(
CSC
)
G
.
ObjectInterruptionList
.
append
(
CSC
)
# -----------------------------------------------------------------------
# loop through all the core objects
# to read predecessors
...
...
@@ -732,13 +676,71 @@ def createWIP():
# reads the interruptions of the stations
# ===========================================================================
def
createObjectInterruptions
():
G
.
ObjectInterruptionList
=
[]
G
.
ScheduledMaintenanceList
=
[]
G
.
FailureList
=
[]
G
.
ShiftSchedulerList
=
[]
G
.
EventGeneratorList
=
[]
G
.
CapacityStationControllerList
=
[]
json_data
=
G
.
JSONData
#Read the json data
nodes
=
json_data
[
'nodes'
]
# read from the dictionary the dicts with key 'nodes'
# -----------------------------------------------------------------------
# loop through all the nodes to
# search for Event Generator and create them
# this is put last, since the EventGenerator
# may take other objects as argument
# -----------------------------------------------------------------------
for
(
element_id
,
element
)
in
nodes
.
iteritems
():
# use an iterator to go through all the nodes
# the key is the element_id and the second is the
# element itself
element
[
'id'
]
=
element_id
# create a new entry for the element (dictionary)
# with key 'id' and value the the element_id
elementClass
=
element
.
get
(
'_class'
,
'not found'
)
# get the class type of the element
if
elementClass
==
'Dream.EventGenerator'
:
# check the object type
id
=
element
.
get
(
'id'
,
'not found'
)
# get the id of the element / default 'not_found'
name
=
element
.
get
(
'name'
,
'not found'
)
# get the name of the element / default 'not_found'
start
=
float
(
element
.
get
(
'start'
)
or
0
)
stop
=
float
(
element
.
get
(
'stop'
)
or
-
1
)
# infinity (had to be done to make it as float)
if
stop
<
0
:
stop
=
float
(
'inf'
)
interval
=
float
(
element
.
get
(
'interval'
)
or
1
)
duration
=
float
(
element
.
get
(
'duration'
)
or
0
)
method
=
(
element
.
get
(
'method'
,
None
))
# get the method to be run / default None
method
=
method
.
split
(
'.'
)
#the method is given as 'Path.MethodName'
method
=
getattr
(
str_to_class
(
method
[
0
]),
method
[
1
])
#and then parsed with getattr
argumentDict
=
(
element
.
get
(
'argumentDict'
,
{}))
# get the arguments of the method as a dict / default {}
EV
=
EventGenerator
(
id
,
name
,
start
=
start
,
stop
=
stop
,
interval
=
interval
,
duration
=
duration
,
method
=
method
,
argumentDict
=
argumentDict
)
# create the EventGenerator object
G
.
EventGeneratorList
.
append
(
EV
)
G
.
ObjectInterruptionList
.
append
(
EV
)
elif
elementClass
==
'Dream.CapacityStationController'
:
# check the object type
id
=
element
.
get
(
'id'
,
'not found'
)
# get the id of the element / default 'not_found'
name
=
element
.
get
(
'name'
,
'not found'
)
# get the name of the element / default 'not_found'
start
=
float
(
element
.
get
(
'start'
)
or
0
)
stop
=
float
(
element
.
get
(
'stop'
)
or
-
1
)
# infinity (had to be done to make it as float)
if
stop
<
0
:
stop
=
float
(
'inf'
)
interval
=
float
(
element
.
get
(
'interval'
)
or
1
)
duration
=
float
(
element
.
get
(
'duration'
)
or
0
)
dueDateThreshold
=
float
(
element
.
get
(
'dueDateThreshold'
)
or
float
(
'inf'
))
prioritizeIfCanFinish
=
bool
(
element
.
get
(
'prioritizeIfCanFinish'
,
0
))
argumentDict
=
(
element
.
get
(
'argumentDict'
,
{}))
# get the arguments of the method as a dict / default {}
# create the CapacityStationController object
CSC
=
CapacityStationController
(
id
,
name
,
start
=
start
,
stop
=
stop
,
interval
=
interval
,
duration
=
duration
,
argumentDict
=
argumentDict
,
dueDateThreshold
=
dueDateThreshold
,
prioritizeIfCanFinish
=
prioritizeIfCanFinish
)
G
.
EventGeneratorList
.
append
(
CSC
)
G
.
CapacityStationControllerList
.
append
(
CSC
)
G
.
ObjectInterruptionList
.
append
(
CSC
)
# for the elements in the nodes dict
for
(
element_id
,
element
)
in
nodes
.
iteritems
():
element
[
'id'
]
=
element_id
...
...
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