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
21201865
Commit
21201865
authored
May 23, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix in Source
parent
4524f62f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
dream/simulation/Source.py
dream/simulation/Source.py
+6
-3
No files found.
dream/simulation/Source.py
View file @
21201865
...
@@ -68,6 +68,7 @@ class EntityGenerator(Process):
...
@@ -68,6 +68,7 @@ class EntityGenerator(Process):
self
.
victim
.
numberOfArrivals
+=
1
# we have one new arrival
self
.
victim
.
numberOfArrivals
+=
1
# we have one new arrival
G
.
numberOfEntities
+=
1
G
.
numberOfEntities
+=
1
# if there is only one entity in the Source send entityCreated signal
# if there is only one entity in the Source send entityCreated signal
self
.
victim
.
appendEntity
(
entity
)
if
len
(
self
.
victim
.
getActiveObjectQueue
())
==
1
:
if
len
(
self
.
victim
.
getActiveObjectQueue
())
==
1
:
self
.
victim
.
entityCreated
.
signal
(
entity
)
self
.
victim
.
entityCreated
.
signal
(
entity
)
yield
hold
,
self
,
self
.
victim
.
calculateInterarrivalTime
()
# wait until the next arrival
yield
hold
,
self
,
self
.
victim
.
calculateInterarrivalTime
()
# wait until the next arrival
...
@@ -101,6 +102,8 @@ class Source(CoreObject):
...
@@ -101,6 +102,8 @@ class Source(CoreObject):
self
.
entityGenerator
=
EntityGenerator
(
victim
=
self
)
# the EntityGenerator of the Source
self
.
entityGenerator
=
EntityGenerator
(
victim
=
self
)
# the EntityGenerator of the Source
self
.
entityCreated
=
SimEvent
(
'an entity is created'
)
self
.
entityCreated
=
SimEvent
(
'an entity is created'
)
# event used by router
self
.
loadOperatorAvailable
=
SimEvent
(
'loadOperatorAvailable'
)
#===========================================================================
#===========================================================================
# The initialize method of the Source class
# The initialize method of the Source class
...
@@ -128,16 +131,16 @@ class Source(CoreObject):
...
@@ -128,16 +131,16 @@ class Source(CoreObject):
while
1
:
while
1
:
# wait for any event (entity creation or request for disposal of entity)
# wait for any event (entity creation or request for disposal of entity)
yield
waitevent
,
self
,
[
self
.
entityCreated
,
self
.
canDispose
]
yield
waitevent
,
self
,
[
self
.
entityCreated
,
self
.
canDispose
,
self
.
loadOperatorAvailable
]
# if an entity is created try to signal the receiver and continue
# if an entity is created try to signal the receiver and continue
if
self
.
entityCreated
.
signalparam
:
if
self
.
entityCreated
.
signalparam
:
self
.
appendEntity
(
self
.
entityCreated
.
signalparam
)
self
.
entityCreated
.
signalparam
=
None
self
.
entityCreated
.
signalparam
=
None
if
self
.
signalReceiver
():
if
self
.
signalReceiver
():
continue
continue
# otherwise, if the receiver requests availability then try to signal him if there is anything to dispose of
# otherwise, if the receiver requests availability then try to signal him if there is anything to dispose of
if
self
.
canDispose
.
signalparam
:
if
self
.
canDispose
.
signalparam
or
self
.
loadOperatorAvailable
.
signalparam
:
self
.
canDispose
.
signalparam
=
None
self
.
canDispose
.
signalparam
=
None
self
.
loadOperatorAvailable
.
signalparam
=
None
if
self
.
haveToDispose
():
if
self
.
haveToDispose
():
if
self
.
signalReceiver
():
if
self
.
signalReceiver
():
continue
continue
...
...
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