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
Hide 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
class
CapacityStationController
(
EventGenerator
):
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
):
EventGenerator
.
__init__
(
self
,
id
,
name
,
start
,
stop
,
interval
,
duration
,
method
,
argumentDict
)
...
...
@@ -45,27 +45,12 @@ class CapacityStationController(EventGenerator):
self
.
prioritizeIfCanFinish
=
bool
(
int
(
prioritizeIfCanFinish
))
# the total assemblySpace in the system
self
.
assemblySpace
=
float
(
G
.
extraPropertyDict
.
get
(
'assemblySpace'
,
float
(
'inf'
)))
self
.
method
=
self
.
steps
def
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
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
def
steps
(
self
):
...
...
@@ -99,6 +84,8 @@ class CapacityStationController(EventGenerator):
# 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
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
# if there is need to merge entities in a buffer
...
...
@@ -158,10 +145,7 @@ class CapacityStationController(EventGenerator):
# for every station update the remaining interval capacity so that it is ready for next loop
for
station
in
G
.
CapacityStationList
:
station
.
remainingIntervalCapacity
.
pop
(
0
)
# send message that the main loop is completed
self
.
stepsAreComplete
.
succeed
()
station
.
remainingIntervalCapacity
.
pop
(
0
)
# invoked after entities have exited one station to create
# the corresponding entities to the following buffer
...
...
dream/simulation/EventGenerator.py
View file @
66004ac5
...
...
@@ -32,7 +32,7 @@ from ObjectInterruption import ObjectInterruption
class
EventGenerator
(
ObjectInterruption
):
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
)
self
.
id
=
id
self
.
name
=
name
...
...
@@ -47,6 +47,10 @@ class EventGenerator(ObjectInterruption):
if
method
:
import
Globals
self
.
method
=
Globals
.
getMethodFromName
(
method
)
def
initialize
(
self
):
ObjectInterruption
.
initialize
(
self
)
self
.
methodEnded
=
self
.
env
.
event
()
def
run
(
self
):
yield
self
.
env
.
timeout
(
self
.
start
)
#wait until the start time
...
...
@@ -56,8 +60,15 @@ class EventGenerator(ObjectInterruption):
if
self
.
stop
:
if
self
.
env
.
now
>
self
.
stop
:
break
self
.
method
(
**
self
.
argumentDict
)
#call the method
yield
self
.
env
.
timeout
(
self
.
interval
)
#wait for the predetermined interval
import
inspect
# 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