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
d86425de
Commit
d86425de
authored
Mar 13, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Router clean-up
parent
af1e72e0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
16 deletions
+29
-16
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+29
-16
No files found.
dream/simulation/OperatorRouter.py
View file @
d86425de
...
@@ -55,6 +55,8 @@ class Router(ObjectInterruption):
...
@@ -55,6 +55,8 @@ class Router(ObjectInterruption):
self
.
candidateOperators
=
[]
self
.
candidateOperators
=
[]
# list of criteria
# list of criteria
self
.
multipleCriterionList
=
[]
self
.
multipleCriterionList
=
[]
# TODO: find out which must be the default for the scheduling Rule
self
.
schedulingRule
=
'WT'
# =======================================================================
# =======================================================================
# the run method
# the run method
...
@@ -163,7 +165,6 @@ class Router(ObjectInterruption):
...
@@ -163,7 +165,6 @@ class Router(ObjectInterruption):
# sort the activeCallersList of the operator
# sort the activeCallersList of the operator
operator
.
sortActiveCallers
()
operator
.
sortActiveCallers
()
# find the activeCaller that has priority
# find the activeCaller that has priority
priorityObject
=
next
(
x
for
x
in
operator
.
activeCallersList
if
x
in
self
.
pendingObjects
)
priorityObject
=
next
(
x
for
x
in
operator
.
activeCallersList
if
x
in
self
.
pendingObjects
)
#===========================================================
#===========================================================
...
@@ -277,6 +278,7 @@ class Router(ObjectInterruption):
...
@@ -277,6 +278,7 @@ class Router(ObjectInterruption):
del
self
.
calledOperators
[:]
del
self
.
calledOperators
[:]
del
self
.
pendingObjects
[:]
del
self
.
pendingObjects
[:]
del
self
.
multipleCriterionList
[:]
del
self
.
multipleCriterionList
[:]
self
.
schedulingRule
=
'WT'
# reset the call flag of the Router
# reset the call flag of the Router
self
.
call
=
False
self
.
call
=
False
...
@@ -292,19 +294,7 @@ class Router(ObjectInterruption):
...
@@ -292,19 +294,7 @@ class Router(ObjectInterruption):
# TODO: move that piece of code elsewhere, it doesn't look nice here. and there is not point in doing it here
# TODO: move that piece of code elsewhere, it doesn't look nice here. and there is not point in doing it here
# maybe it's better in findCandidateOperators method
# maybe it's better in findCandidateOperators method
if
self
.
candidateOperators
:
if
self
.
candidateOperators
:
for
operator
in
self
.
candidateOperators
:
self
.
activePendingQSorter
(
criterion
=
self
.
schedulingRule
)
if
operator
.
multipleCriterionList
:
for
criterion
in
operator
.
multipleCriterionList
:
if
not
criterion
in
self
.
multipleCriterionList
:
self
.
multipleCriterionList
.
append
(
criterion
)
else
:
if
not
operator
.
schedulingRule
in
self
.
multipleCriterionList
:
self
.
multipleCriterionList
.
append
(
operator
.
schedulingRule
)
# TODO: For the moment all operators should have only one scheduling rule and the same among them
# added for testing
assert
len
(
self
.
multipleCriterionList
)
==
1
,
'The operators must have the same (one) scheduling rule'
self
.
activePendingQSorter
(
criterion
=
self
.
multipleCriterionList
[
0
])
#=======================================================================
#=======================================================================
# Sort candidateOperators
# Sort candidateOperators
...
@@ -314,8 +304,9 @@ class Router(ObjectInterruption):
...
@@ -314,8 +304,9 @@ class Router(ObjectInterruption):
def
sortOperators
(
self
):
def
sortOperators
(
self
):
# TODO: there must be criteria for sorting the cadidateOperators
# TODO: there must be criteria for sorting the cadidateOperators
#if we have sorting according to multiple criteria we have to call the sorter many times
#if we have sorting according to multiple criteria we have to call the sorter many times
if
self
.
multipleCriterionList
:
# TODO: find out what happens in case of multiple criteria
self
.
activeOperatorQSorter
(
criterion
=
self
.
multipleCriterionList
[
0
])
if
self
.
candidateOperators
:
self
.
activeOperatorQSorter
(
criterion
=
self
.
schedulingRule
)
#========================================================================
#========================================================================
# Find candidate Operators
# Find candidate Operators
...
@@ -353,6 +344,28 @@ class Router(ObjectInterruption):
...
@@ -353,6 +344,28 @@ class Router(ObjectInterruption):
# if the entity can proceed, add its manager to the candidateOperators list
# if the entity can proceed, add its manager to the candidateOperators list
if
entity
.
canProceed
and
not
entity
.
manager
in
self
.
candidateOperators
:
if
entity
.
canProceed
and
not
entity
.
manager
in
self
.
candidateOperators
:
self
.
candidateOperators
.
append
(
entity
.
manager
)
self
.
candidateOperators
.
append
(
entity
.
manager
)
# update the schedulingRule/multipleCriterionList of the Router
self
.
updateSchedulingRule
()
#=======================================================================
# find the schedulingRules of the candidateOperators
#=======================================================================
def
updateSchedulingRule
(
self
):
if
self
.
candidateOperators
:
for
operator
in
self
.
candidateOperators
:
if
operator
.
multipleCriterionList
:
for
criterion
in
operator
.
multipleCriterionList
:
if
not
criterion
in
self
.
multipleCriterionList
:
self
.
multipleCriterionList
.
append
(
criterion
)
else
:
# if operator has only simple scheduling Rule
if
not
operator
.
schedulingRule
in
self
.
multipleCriterionList
:
self
.
multipleCriterionList
.
append
(
operator
.
schedulingRule
)
# TODO: For the moment all operators should have only one scheduling rule and the same among them
# added for testing
assert
len
(
self
.
multipleCriterionList
)
==
1
,
'The operators must have the same (one) scheduling rule'
if
len
(
self
.
multipleCriterionList
)
==
1
:
self
.
schedulingRule
=
self
.
multipleCriterionList
[
0
]
#=======================================================================
#=======================================================================
# Find the candidateEntities for each candidateOperator
# Find the candidateEntities for each candidateOperator
...
...
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