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
Show 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):
...
@@ -330,9 +330,10 @@ class Machine(CoreObject):
#===========================================================================
#===========================================================================
def
shouldYield
(
self
,
operationTypes
=
{},
methods
=
{}):
def
shouldYield
(
self
,
operationTypes
=
{},
methods
=
{}):
'''
'''
"methods":{'isInterrupted':'0'},
Method that controls if the machine should yield for releasing the operator
"operationTypes"={"Processing":1, % must
"methods":{'isInterrupted':'0'}, % the method isInterrupted should return False (0) or True (1)
"Setup":0 % must NOT
"operationTypes"={"Processing":1, % processing must be in multiOperationTypeList
"Setup":0 % setup must not be in multiOperationTypeList
}
}
'''
'''
operationsRequired
=
[]
operationsRequired
=
[]
...
@@ -346,6 +347,7 @@ class Machine(CoreObject):
...
@@ -346,6 +347,7 @@ class Machine(CoreObject):
else
:
else
:
operationsNotRequired
.
append
(
tup
)
operationsNotRequired
.
append
(
tup
)
required
=
False
required
=
False
# operations that should be in the multOperationTypeList
if
operationsRequired
:
if
operationsRequired
:
for
opTup
in
operationsRequired
:
for
opTup
in
operationsRequired
:
operation
,
func
=
opTup
operation
,
func
=
opTup
...
@@ -353,6 +355,7 @@ class Machine(CoreObject):
...
@@ -353,6 +355,7 @@ class Machine(CoreObject):
else
:
else
:
required
=
True
required
=
True
notRequired
=
False
notRequired
=
False
# operations that should NOT be in the multOperationTypeList
if
operationsNotRequired
:
if
operationsNotRequired
:
for
opTup
in
operationsNotRequired
:
for
opTup
in
operationsNotRequired
:
operation
,
func
=
opTup
operation
,
func
=
opTup
...
@@ -369,6 +372,7 @@ class Machine(CoreObject):
...
@@ -369,6 +372,7 @@ class Machine(CoreObject):
methodsRequired
.
append
(
tup
)
methodsRequired
.
append
(
tup
)
else
:
else
:
methodsNotRequired
.
append
(
tup
)
methodsNotRequired
.
append
(
tup
)
# methods that should return TRUE
required
=
True
required
=
True
from
Globals
import
getMethodFromName
from
Globals
import
getMethodFromName
if
methodsRequired
:
if
methodsRequired
:
...
@@ -376,6 +380,7 @@ class Machine(CoreObject):
...
@@ -376,6 +380,7 @@ class Machine(CoreObject):
method
,
func
=
methodTup
method
,
func
=
methodTup
objMethod
=
getMethodFromName
(
'Dream.Machine.'
+
method
)
objMethod
=
getMethodFromName
(
'Dream.Machine.'
+
method
)
required
=
required
and
(
objMethod
(
self
))
required
=
required
and
(
objMethod
(
self
))
# methods that should return FALSE
notRequired
=
True
notRequired
=
True
if
methodsNotRequired
:
if
methodsNotRequired
:
for
methodTup
in
methodsNotRequired
:
for
methodTup
in
methodsNotRequired
:
...
@@ -496,7 +501,7 @@ class Machine(CoreObject):
...
@@ -496,7 +501,7 @@ class Machine(CoreObject):
#===========================================================
#===========================================================
# # release the operator if there is interruption
# # release the operator if there is interruption
#===========================================================
#===========================================================
if
self
.
shouldYield
(
operationTypes
=
{
str
(
self
.
currentlyPerforming
):
1
},
methods
=
{
'isOperated'
:
1
}):
if
self
.
shouldYield
(
operationTypes
=
{
str
(
type
):
1
},
methods
=
{
'isOperated'
:
1
}):
yield
self
.
env
.
process
(
self
.
release
())
yield
self
.
env
.
process
(
self
.
release
())
# loop until we reach at a state that there is no interruption
# loop until we reach at a state that there is no interruption
while
1
:
while
1
:
...
@@ -505,17 +510,25 @@ class Machine(CoreObject):
...
@@ -505,17 +510,25 @@ class Machine(CoreObject):
transmitter
,
eventTime
=
self
.
interruptionEnd
.
value
transmitter
,
eventTime
=
self
.
interruptionEnd
.
value
assert
eventTime
==
self
.
env
.
now
,
'the interruptionEnd was received later than anticipated'
assert
eventTime
==
self
.
env
.
now
,
'the interruptionEnd was received later than anticipated'
self
.
interruptionEnd
=
self
.
env
.
event
()
self
.
interruptionEnd
=
self
.
env
.
event
()
# check if the machine is active and break
if
self
.
checkIfActive
():
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
break
self
.
postInterruptionActions
()
# execute interruption actions
self
.
postInterruptionActions
()
# execute interruption actions
#===========================================================
#===========================================================
# # request a resource after the repair
# # 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
self
.
timeWaitForOperatorStarted
=
self
.
env
.
now
yield
self
.
env
.
process
(
self
.
request
())
yield
self
.
env
.
process
(
self
.
request
())
self
.
timeWaitForOperatorEnded
=
self
.
env
.
now
self
.
timeWaitForOperatorEnded
=
self
.
env
.
now
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
# if the processing operator left
# if the processing operator left
elif
self
.
processOperatorUnavailable
in
receivedEvent
:
elif
self
.
processOperatorUnavailable
in
receivedEvent
:
transmitter
,
eventTime
=
self
.
processOperatorUnavailable
.
value
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