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
66004ac5
Commit
66004ac5
authored
Aug 27, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CapacityStationController inherits run from EventGenerator
parent
c8aae66a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
25 deletions
+20
-25
dream/simulation/CapacityStationController.py
dream/simulation/CapacityStationController.py
+6
-22
dream/simulation/EventGenerator.py
dream/simulation/EventGenerator.py
+14
-3
No files found.
dream/simulation/CapacityStationController.py
View file @
66004ac5
...
@@ -33,7 +33,7 @@ from Globals import G
...
@@ -33,7 +33,7 @@ from Globals import G
class
CapacityStationController
(
EventGenerator
):
class
CapacityStationController
(
EventGenerator
):
def
__init__
(
self
,
id
=
id
,
name
=
None
,
start
=
0
,
stop
=
float
(
'inf'
),
interval
=
1
,
def
__init__
(
self
,
id
=
id
,
name
=
None
,
start
=
0
,
stop
=
float
(
'inf'
),
interval
=
1
,
duration
=
0
,
method
=
None
,
argumentDict
=
None
,
dueDateThreshold
=
float
(
'inf'
),
duration
=
0
,
method
=
None
,
argumentDict
=
{}
,
dueDateThreshold
=
float
(
'inf'
),
prioritizeIfCanFinish
=
False
,
**
kw
):
prioritizeIfCanFinish
=
False
,
**
kw
):
EventGenerator
.
__init__
(
self
,
id
,
name
,
start
,
stop
,
interval
,
EventGenerator
.
__init__
(
self
,
id
,
name
,
start
,
stop
,
interval
,
duration
,
method
,
argumentDict
)
duration
,
method
,
argumentDict
)
...
@@ -45,27 +45,12 @@ class CapacityStationController(EventGenerator):
...
@@ -45,27 +45,12 @@ class CapacityStationController(EventGenerator):
self
.
prioritizeIfCanFinish
=
bool
(
int
(
prioritizeIfCanFinish
))
self
.
prioritizeIfCanFinish
=
bool
(
int
(
prioritizeIfCanFinish
))
# the total assemblySpace in the system
# the total assemblySpace in the system
self
.
assemblySpace
=
float
(
G
.
extraPropertyDict
.
get
(
'assemblySpace'
,
float
(
'inf'
)))
self
.
assemblySpace
=
float
(
G
.
extraPropertyDict
.
get
(
'assemblySpace'
,
float
(
'inf'
)))
self
.
method
=
self
.
steps
def
initialize
(
self
):
def
initialize
(
self
):
EventGenerator
.
initialize
(
self
)
EventGenerator
.
initialize
(
self
)
self
.
stepsAreComplete
=
self
.
env
.
event
()
def
run
(
self
):
# sort the buffers so if they have shared resources the ones with highest priority will go in front
# sort the buffers so if they have shared resources the ones with highest priority will go in front
self
.
sortBuffers
()
self
.
sortBuffers
()
yield
self
.
env
.
timeout
(
self
.
start
)
#wait until the start time
#loop until the end of the simulation
while
1
:
#if the stop time is exceeded then break the loop
if
self
.
stop
:
if
self
.
env
.
now
>
self
.
stop
:
break
# activate the main loop
self
.
env
.
process
(
self
.
steps
())
# wait until the main loop is completed
yield
self
.
stepsAreComplete
self
.
stepsAreComplete
=
self
.
env
.
event
()
yield
self
.
env
.
timeout
(
self
.
interval
)
#wait for the predetermined interval
# the main loop that is carried in every interval
# the main loop that is carried in every interval
def
steps
(
self
):
def
steps
(
self
):
...
@@ -99,6 +84,8 @@ class CapacityStationController(EventGenerator):
...
@@ -99,6 +84,8 @@ class CapacityStationController(EventGenerator):
# if the last exits led to an empty system then the simulation must be stopped
# if the last exits led to an empty system then the simulation must be stopped
# step returns and the generator never yields the stepsAreComplete signal
# step returns and the generator never yields the stepsAreComplete signal
if
self
.
checkIfSystemEmpty
():
if
self
.
checkIfSystemEmpty
():
# if the system is empty set stop to now so that the generator stops and return
self
.
stop
=
self
.
env
.
now
return
return
# if there is need to merge entities in a buffer
# if there is need to merge entities in a buffer
...
@@ -160,9 +147,6 @@ class CapacityStationController(EventGenerator):
...
@@ -160,9 +147,6 @@ class CapacityStationController(EventGenerator):
for
station
in
G
.
CapacityStationList
:
for
station
in
G
.
CapacityStationList
:
station
.
remainingIntervalCapacity
.
pop
(
0
)
station
.
remainingIntervalCapacity
.
pop
(
0
)
# send message that the main loop is completed
self
.
stepsAreComplete
.
succeed
()
# invoked after entities have exited one station to create
# invoked after entities have exited one station to create
# the corresponding entities to the following buffer
# the corresponding entities to the following buffer
def
createInCapacityStationBuffers
(
self
):
def
createInCapacityStationBuffers
(
self
):
...
...
dream/simulation/EventGenerator.py
View file @
66004ac5
...
@@ -32,7 +32,7 @@ from ObjectInterruption import ObjectInterruption
...
@@ -32,7 +32,7 @@ from ObjectInterruption import ObjectInterruption
class
EventGenerator
(
ObjectInterruption
):
class
EventGenerator
(
ObjectInterruption
):
def
__init__
(
self
,
id
=
id
,
name
=
None
,
start
=
0
,
stop
=
float
(
'inf'
),
interval
=
1
,
def
__init__
(
self
,
id
=
id
,
name
=
None
,
start
=
0
,
stop
=
float
(
'inf'
),
interval
=
1
,
duration
=
0
,
method
=
None
,
argumentDict
=
None
,
**
kw
):
duration
=
0
,
method
=
None
,
argumentDict
=
None
,
**
kw
):
ObjectInterruption
.
__init__
(
self
)
ObjectInterruption
.
__init__
(
self
)
self
.
id
=
id
self
.
id
=
id
self
.
name
=
name
self
.
name
=
name
...
@@ -48,6 +48,10 @@ class EventGenerator(ObjectInterruption):
...
@@ -48,6 +48,10 @@ class EventGenerator(ObjectInterruption):
import
Globals
import
Globals
self
.
method
=
Globals
.
getMethodFromName
(
method
)
self
.
method
=
Globals
.
getMethodFromName
(
method
)
def
initialize
(
self
):
ObjectInterruption
.
initialize
(
self
)
self
.
methodEnded
=
self
.
env
.
event
()
def
run
(
self
):
def
run
(
self
):
yield
self
.
env
.
timeout
(
self
.
start
)
#wait until the start time
yield
self
.
env
.
timeout
(
self
.
start
)
#wait until the start time
#loop until the end of the simulation
#loop until the end of the simulation
...
@@ -56,8 +60,15 @@ class EventGenerator(ObjectInterruption):
...
@@ -56,8 +60,15 @@ class EventGenerator(ObjectInterruption):
if
self
.
stop
:
if
self
.
stop
:
if
self
.
env
.
now
>
self
.
stop
:
if
self
.
env
.
now
>
self
.
stop
:
break
break
self
.
method
(
**
self
.
argumentDict
)
#call the method
import
inspect
yield
self
.
env
.
timeout
(
self
.
interval
)
#wait for the predetermined interval
# if the method is generator yield it
if
inspect
.
isgeneratorfunction
(
self
.
method
):
yield
self
.
env
.
process
(
self
.
method
(
**
self
.
argumentDict
))
# else just call the method
else
:
self
.
method
(
**
self
.
argumentDict
)
# wait for the predetermined interval
yield
self
.
env
.
timeout
(
self
.
interval
)
...
...
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