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
08306ac6
Commit
08306ac6
authored
May 19, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
findCandidateReceiver() added to Entity for use by the Router
parent
cd90a83e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
dream/simulation/Entity.py
dream/simulation/Entity.py
+26
-0
No files found.
dream/simulation/Entity.py
View file @
08306ac6
...
@@ -71,6 +71,32 @@ class Entity(object):
...
@@ -71,6 +71,32 @@ class Entity(object):
# variables used to avoid signalling the same object twice before it receives an entity
# variables used to avoid signalling the same object twice before it receives an entity
self
.
receiver
=
None
self
.
receiver
=
None
self
.
timeOfAssignement
=
0
self
.
timeOfAssignement
=
0
#===========================================================================
# method that finds a receiver for a candidate entity
#===========================================================================
def
findCandidateReceiver
(
self
):
from
Globals
import
G
router
=
G
.
Router
# initiate the local list variable available receivers
availableReceivers
=
[
x
for
x
in
self
.
candidateReceivers
\
if
not
x
in
router
.
occupiedReceivers
]
# and pick the object that is waiting for the most time
if
availableReceivers
:
# find the receiver that waits the most
availableReceiver
=
self
.
currentStation
.
selectReceiver
(
availableReceivers
)
router
.
occupiedReceivers
.
append
(
availableReceiver
)
# if there is no available receiver add the entity to the entitiesWithOccupiedReceivers list
else
:
router
.
entitiesWithOccupiedReceivers
.
append
(
self
)
availableReceiver
=
None
# if the sorting flag is not set then the sorting of each queue must prevail in case of operators conflict
if
not
router
.
sorting
and
not
availableReceiver
and
bool
(
availableReceivers
):
availableReceiver
=
self
.
currentStation
.
selectReceiver
(
self
.
candidateReceivers
)
if
not
self
in
router
.
conflictingEntities
:
router
.
conflictingEntities
.
append
(
self
)
return
availableReceiver
#===========================================================================
#===========================================================================
# assign the entity to a station
# assign the entity to a station
#===========================================================================
#===========================================================================
...
...
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