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
05c15eeb
Commit
05c15eeb
authored
Jan 27, 2014
by
Ioannis Papagiannopoulos
Committed by
Jérome Perrin
Feb 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OperatorPreemptive corrected
parent
2f71f199
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
25 deletions
+28
-25
dream/simulation/OperatorPreemptive.py
dream/simulation/OperatorPreemptive.py
+28
-25
No files found.
dream/simulation/OperatorPreemptive.py
View file @
05c15eeb
...
@@ -46,29 +46,32 @@ class OperatorPreemptive(Operator):
...
@@ -46,29 +46,32 @@ class OperatorPreemptive(Operator):
def
checkIfResourceIsAvailable
(
self
,
callerObject
=
None
):
def
checkIfResourceIsAvailable
(
self
,
callerObject
=
None
):
activeResource
=
self
.
getResource
()
activeResource
=
self
.
getResource
()
activeResourceQueue
=
activeResource
.
getResourceQueue
()
activeResourceQueue
=
activeResource
.
getResourceQueue
()
try
:
# find out which station is requesting the operator?
# read the station operated by the operator
thecaller
=
callerObject
victim
=
activeResourceQueue
[
0
]
# if the operator is occupied return True
# read its activeQ
if
len
(
activeResourceQueue
)
==
0
:
victimQueue
=
victim
.
getActiveObjectQueue
()
return
True
# find out which station is requesting the operator?
# read the station currently operated by the operator
thecaller
=
callerObject
victim
=
activeResourceQueue
[
0
]
thecallerQueue
=
thecaller
.
getActiveObjectQueue
()
# read its activeQ
victimQueue
=
victim
.
getActiveObjectQueue
()
#if the receiver is not empty
# if the callerObject is None then return False as the operator is occupied
if
len
(
victimQueue
)
>
0
:
if
thecaller
==
None
:
# and the caller is not empty
return
False
if
len
(
thecallerQueue
)
>
0
:
thecallerQueue
=
thecaller
.
getActiveObjectQueue
()
#if the Entity to be forwarded to the station currently processed by the operator is critical
#if the receiver is not empty and the caller is not empty
if
thecallerQueue
[
0
].
isCritical
:
if
len
(
victimQueue
)
>
0
and
len
(
theCallerQueue
):
#if the receiver does not hold an Entity that is also critical
try
:
if
not
victimQueue
[
0
].
isCritical
:
#if the Entity to be forwarded to the station currently processed by the operator is critical
# then the receiver must be preemptied before it can receive any entities from the calerObject
if
thecallerQueue
[
0
].
isCritical
:
victim
.
shouldPreempt
=
True
#if the receiver does not hold an Entity that is also critical
victim
.
preempt
()
if
not
victimQueue
[
0
].
isCritical
:
victim
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
# then the receiver must be preemptied before it can receive any entities from the calerObject
return
True
victim
.
shouldPreempt
=
True
# if the operator is not occupied, or if the caller is None then perform the default behaviour
victim
.
preempt
()
except
:
victim
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
pass
return
True
# if the entity has no isCritical property then ran the default behaviour
except
:
pass
return
len
(
self
.
Res
.
activeQ
)
<
self
.
capacity
return
len
(
self
.
Res
.
activeQ
)
<
self
.
capacity
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