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
8db470a8
Commit
8db470a8
authored
Apr 14, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generator of Source updated, minor bug fixed
parent
12aee243
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
18 deletions
+35
-18
dream/simulation/Source.py
dream/simulation/Source.py
+35
-18
No files found.
dream/simulation/Source.py
View file @
8db470a8
...
...
@@ -56,6 +56,7 @@ class EntityGenerator(Process):
# the generator of the EntitiesGenerator
#===========================================================================
def
run
(
self
):
# print 'entity generator starts'
while
1
:
entity
=
self
.
victim
.
createEntity
()
# create the Entity object and assign its name
entity
.
creationTime
=
now
()
# assign the current simulation time as the Entity's creation time
...
...
@@ -66,8 +67,8 @@ class EntityGenerator(Process):
self
.
victim
.
getActiveObjectQueue
().
append
(
entity
)
# append the entity to the resource
self
.
victim
.
numberOfArrivals
+=
1
# we have one new arrival
G
.
numberOfEntities
+=
1
yield
hold
,
self
,
self
.
victim
.
calculateInterarrivalTime
()
# wait until the next arrival
self
.
victim
.
entityCreated
.
signal
(
str
(
entity
.
name
)
+
' created'
)
yield
hold
,
self
,
self
.
victim
.
calculateInterarrivalTime
()
# wait until the next arrival
#============================================================================
# The Source object is a Process
...
...
@@ -111,8 +112,9 @@ class Source(CoreObject):
self
.
Res
.
activeQ
=
[]
self
.
Res
.
waitQ
=
[]
activate
(
self
.
entityGenerator
,
self
.
entityGenerator
.
run
())
self
.
entityGenerator
.
initialize
()
activate
(
self
.
entityGenerator
,
self
.
entityGenerator
.
run
())
#===========================================================================
# the generator of the Source class
...
...
@@ -123,19 +125,34 @@ class Source(CoreObject):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
while
1
:
# if the source has no entity to dispose of has to wait till it has something
if
not
self
.
haveToDispose
():
yield
waitevent
,
self
,
self
.
entityCreated
# if there is no available successor to signal the source has to wait till there is one available
if
not
activeObject
.
signalReceiver
():
while
1
:
yield
waitevent
,
self
,
self
.
canDispose
if
activeObject
.
signalReceiver
():
break
# note, it needs to lose the control here.
# TODO Need to think
else
:
yield
hold
,
self
,
0
# wait for any event (entity creation or request for disposal of entity)
yield
waitevent
,
self
,
[
self
.
entityCreated
,
self
.
canDispose
]
# if an entity is created try to signal the receiver and continue
if
self
.
entityCreated
.
signalparam
:
self
.
entityCreated
.
signalparam
=
None
if
self
.
signalReceiver
():
continue
# otherwise, if the receiver requests availability then try to signal him if there is anything to dispose of
if
self
.
canDispose
.
signalparam
:
self
.
canDispose
.
signalparam
=
None
if
self
.
haveToDispose
():
if
self
.
signalReceiver
():
continue
# # if the source has no entity to dispose of has to wait till it has something
# if not self.haveToDispose():
# yield waitevent, self, self.entityCreated
# # if there is no available successor to signal the source has to wait till there is one available
# if not activeObject.signalReceiver():
# while 1:
# yield waitevent, self, self.canDispose
# if activeObject.signalReceiver():
# break
# # note, it needs to lose the control here.
# # TODO Need to think
# else:
# yield hold, self, 0
#============================================================================
# sets the routing out element for the Source
...
...
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