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
664d0895
Commit
664d0895
authored
Jun 16, 2015
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correction to machines operation() method. comments added to shouldYield() method
parent
6ea9e7c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
dream/simulation/Machine.py
dream/simulation/Machine.py
+19
-6
No files found.
dream/simulation/Machine.py
View file @
664d0895
...
...
@@ -330,9 +330,10 @@ class Machine(CoreObject):
#===========================================================================
def
shouldYield
(
self
,
operationTypes
=
{},
methods
=
{}):
'''
"methods":{'isInterrupted':'0'},
"operationTypes"={"Processing":1, % must
"Setup":0 % must NOT
Method that controls if the machine should yield for releasing the operator
"methods":{'isInterrupted':'0'}, % the method isInterrupted should return False (0) or True (1)
"operationTypes"={"Processing":1, % processing must be in multiOperationTypeList
"Setup":0 % setup must not be in multiOperationTypeList
}
'''
operationsRequired
=
[]
...
...
@@ -346,6 +347,7 @@ class Machine(CoreObject):
else
:
operationsNotRequired
.
append
(
tup
)
required
=
False
# operations that should be in the multOperationTypeList
if
operationsRequired
:
for
opTup
in
operationsRequired
:
operation
,
func
=
opTup
...
...
@@ -353,6 +355,7 @@ class Machine(CoreObject):
else
:
required
=
True
notRequired
=
False
# operations that should NOT be in the multOperationTypeList
if
operationsNotRequired
:
for
opTup
in
operationsNotRequired
:
operation
,
func
=
opTup
...
...
@@ -369,6 +372,7 @@ class Machine(CoreObject):
methodsRequired
.
append
(
tup
)
else
:
methodsNotRequired
.
append
(
tup
)
# methods that should return TRUE
required
=
True
from
Globals
import
getMethodFromName
if
methodsRequired
:
...
...
@@ -376,6 +380,7 @@ class Machine(CoreObject):
method
,
func
=
methodTup
objMethod
=
getMethodFromName
(
'Dream.Machine.'
+
method
)
required
=
required
and
(
objMethod
(
self
))
# methods that should return FALSE
notRequired
=
True
if
methodsNotRequired
:
for
methodTup
in
methodsNotRequired
:
...
...
@@ -496,8 +501,8 @@ class Machine(CoreObject):
#===========================================================
# # release the operator if there is interruption
#===========================================================
if
self
.
shouldYield
(
operationTypes
=
{
str
(
self
.
currentlyPerforming
):
1
},
methods
=
{
'isOperated'
:
1
}):
yield
self
.
env
.
process
(
self
.
release
())
if
self
.
shouldYield
(
operationTypes
=
{
str
(
type
):
1
},
methods
=
{
'isOperated'
:
1
}):
yield
self
.
env
.
process
(
self
.
release
())
# loop until we reach at a state that there is no interruption
while
1
:
self
.
expectedSignals
[
'interruptionEnd'
]
=
1
...
...
@@ -505,17 +510,25 @@ class Machine(CoreObject):
transmitter
,
eventTime
=
self
.
interruptionEnd
.
value
assert
eventTime
==
self
.
env
.
now
,
'the interruptionEnd was received later than anticipated'
self
.
interruptionEnd
=
self
.
env
.
event
()
# check if the machine is active and break
if
self
.
checkIfActive
():
if
self
.
shouldYield
(
operationTypes
=
{
str
(
type
):
1
},
methods
=
{
"isInterrupted"
:
0
}):
self
.
timeWaitForOperatorStarted
=
self
.
env
.
now
yield
self
.
env
.
process
(
self
.
request
())
self
.
timeWaitForOperatorEnded
=
self
.
env
.
now
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
break
self
.
postInterruptionActions
()
# execute interruption actions
#===========================================================
# # request a resource after the repair
#===========================================================
if
self
.
shouldYield
(
operationTypes
=
{
str
(
self
.
currentlyPerforming
):
1
},
methods
=
{
"isInterrupted"
:
0
}):
if
self
.
shouldYield
(
operationTypes
=
{
str
(
type
):
1
},
methods
=
{
"isInterrupted"
:
0
}):
self
.
timeWaitForOperatorStarted
=
self
.
env
.
now
yield
self
.
env
.
process
(
self
.
request
())
self
.
timeWaitForOperatorEnded
=
self
.
env
.
now
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
# if the processing operator left
elif
self
.
processOperatorUnavailable
in
receivedEvent
:
transmitter
,
eventTime
=
self
.
processOperatorUnavailable
.
value
...
...
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