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
1690ed88
Commit
1690ed88
authored
Mar 23, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exit to be able to end the simulation - not working correct yet
parent
cf9e01f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
dream/simulation/Exit.py
dream/simulation/Exit.py
+9
-2
dream/simulation/ManPyObject.py
dream/simulation/ManPyObject.py
+20
-1
No files found.
dream/simulation/Exit.py
View file @
1690ed88
...
...
@@ -37,7 +37,7 @@ class Exit(CoreObject):
family
=
'Exit'
def
__init__
(
self
,
id
,
name
,
**
kw
):
def
__init__
(
self
,
id
,
name
,
cancelCondition
=
{},
**
kw
):
self
.
type
=
"Exit"
# XXX needed ?
#lists to hold statistics of multiple runs
self
.
Exits
=
[]
...
...
@@ -47,7 +47,8 @@ class Exit(CoreObject):
# if input is given in a dictionary
CoreObject
.
__init__
(
self
,
id
,
name
)
from
Globals
import
G
G
.
ExitList
.
append
(
self
)
G
.
ExitList
.
append
(
self
)
self
.
cancelCondition
=
cancelCondition
def
initialize
(
self
):
# using the Process __init__ and not the CoreObject __init__
...
...
@@ -121,6 +122,12 @@ class Exit(CoreObject):
self
.
timeLastEntityLeft
=
self
.
env
.
now
# update the time that the last entity left from the Exit
activeObjectQueue
=
self
.
getActiveObjectQueue
()
del
self
.
Res
.
users
[:]
# if there is a cancelCondition the exit may end the simulation
if
self
.
cancelCondition
:
if
self
.
cancelCondition
.
get
(
'reason'
,
None
)
==
'throughput'
and
int
(
self
.
cancelCondition
.
get
(
'number'
,
-
1
))
==
self
.
numOfExits
:
self
.
endSimulation
()
if
self
.
cancelCondition
.
get
(
'reason'
,
None
)
==
'empty'
and
self
.
checkIfSystemEmpty
():
self
.
endSimulation
()
return
activeEntity
@
staticmethod
...
...
dream/simulation/ManPyObject.py
View file @
1690ed88
...
...
@@ -174,4 +174,23 @@ class ManPyObject(object):
# outputs results to JSON File
# =======================================================================
def
outputResultsJSON
(
self
):
pass
\ No newline at end of file
pass
# =======================================================================
# ends the simulation
# ======================================================================
@
staticmethod
def
endSimulation
():
from
Globals
import
G
G
.
env
.
exit
()
# =======================================================================
# checks if there are entities in the system
# ======================================================================
@
staticmethod
def
checkIfSystemEmpty
():
from
Globals
import
G
for
object
in
G
.
ObjList
:
if
len
(
object
.
getActiveObjectQueue
()):
return
False
return
True
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