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
7f1e82b8
Commit
7f1e82b8
authored
Nov 03, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more robust tests on Machine now that it can deliver on interruption
parent
9380a23a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
33 deletions
+32
-33
dream/simulation/Machine.py
dream/simulation/Machine.py
+32
-33
No files found.
dream/simulation/Machine.py
View file @
7f1e82b8
...
@@ -753,6 +753,8 @@ class Machine(CoreObject):
...
@@ -753,6 +753,8 @@ class Machine(CoreObject):
# if there was no available receiver, get into blocking control
# if there was no available receiver, get into blocking control
while
1
:
while
1
:
if
not
len
(
self
.
getActiveObjectQueue
()):
break
self
.
expectedSignals
[
'interruptionStart'
]
=
1
self
.
expectedSignals
[
'interruptionStart'
]
=
1
self
.
expectedSignals
[
'canDispose'
]
=
1
self
.
expectedSignals
[
'canDispose'
]
=
1
self
.
timeLastBlockageStarted
=
self
.
env
.
now
# blockage is starting
self
.
timeLastBlockageStarted
=
self
.
env
.
now
# blockage is starting
...
@@ -818,14 +820,13 @@ class Machine(CoreObject):
...
@@ -818,14 +820,13 @@ class Machine(CoreObject):
# the preceding machine gets the canDispose signal which is actually useless, is emptied by the following station
# the preceding machine gets the canDispose signal which is actually useless, is emptied by the following station
# and then cannot exit an infinite loop.
# and then cannot exit an infinite loop.
# notify that the station waits the entity to be removed
# notify that the station waits the entity to be removed
activeObjectQueue
=
self
.
getActiveObjectQueue
()
if
len
(
activeObjectQueue
):
self
.
waitEntityRemoval
=
True
self
.
waitEntityRemoval
=
True
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(entityRemoved)'
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(entityRemoved)'
)
self
.
expectedSignals
[
'entityRemoved'
]
=
1
self
.
expectedSignals
[
'entityRemoved'
]
=
1
yield
self
.
entityRemoved
yield
self
.
entityRemoved
transmitter
,
eventTime
=
self
.
entityRemoved
.
value
transmitter
,
eventTime
=
self
.
entityRemoved
.
value
self
.
printTrace
(
self
.
id
,
entityRemoved
=
eventTime
)
self
.
printTrace
(
self
.
id
,
entityRemoved
=
eventTime
)
assert
eventTime
==
self
.
env
.
now
,
'entityRemoved event activated earlier than received'
assert
eventTime
==
self
.
env
.
now
,
'entityRemoved event activated earlier than received'
...
@@ -923,16 +924,12 @@ class Machine(CoreObject):
...
@@ -923,16 +924,12 @@ class Machine(CoreObject):
# the machine is currently performing nothing
# the machine is currently performing nothing
self
.
currentlyPerforming
=
None
self
.
currentlyPerforming
=
None
activeObjectQueue
=
self
.
Res
.
users
activeObjectQueue
=
self
.
Res
.
users
if
len
(
activeObjectQueue
):
activeEntity
=
activeObjectQueue
[
0
]
activeEntity
=
activeObjectQueue
[
0
]
self
.
printTrace
(
activeEntity
.
name
,
interrupted
=
self
.
objName
)
self
.
printTrace
(
activeEntity
.
name
,
interrupted
=
self
.
objName
)
# if the interrupt occurred while processing an entity
if
not
self
.
waitToDispose
:
# output to trace that the Machine (self.objName) got interrupted
try
:
self
.
outputTrace
(
activeObjectQueue
[
0
].
name
,
"Interrupted at "
+
self
.
objName
)
self
.
outputTrace
(
activeObjectQueue
[
0
].
name
,
"Interrupted at "
+
self
.
objName
)
except
IndexError
:
pass
# recalculate the processing time left tinM
# recalculate the processing time left tinM
if
self
.
timeLastOperationStarted
:
self
.
tinM
=
self
.
tinM
-
(
self
.
env
.
now
-
self
.
timeLastOperationStarted
)
self
.
tinM
=
self
.
tinM
-
(
self
.
env
.
now
-
self
.
timeLastOperationStarted
)
if
(
self
.
tinM
==
0
):
# sometimes the failure may happen exactly at the time that the processing would finish
if
(
self
.
tinM
==
0
):
# sometimes the failure may happen exactly at the time that the processing would finish
# this may produce disagreement with the simul8 because in both SimPy and Simul8
# this may produce disagreement with the simul8 because in both SimPy and Simul8
...
@@ -957,12 +954,14 @@ class Machine(CoreObject):
...
@@ -957,12 +954,14 @@ class Machine(CoreObject):
# =======================================================================
# =======================================================================
def
postInterruptionActions
(
self
):
def
postInterruptionActions
(
self
):
activeObjectQueue
=
self
.
Res
.
users
activeObjectQueue
=
self
.
Res
.
users
if
len
(
activeObjectQueue
):
activeEntity
=
activeObjectQueue
[
0
]
activeEntity
=
activeObjectQueue
[
0
]
# if the machine returns from an failure while processing an entity
# if the machine returns from an failure while processing an entity
if
not
self
.
waitToDispose
:
if
not
self
.
waitToDispose
:
# use the timers to count the time that Machine is down and related
# use the timers to count the time that Machine is down and related
self
.
timeLastFailureEnded
=
self
.
env
.
now
# set the timeLastFailureEnded
self
.
timeLastFailureEnded
=
self
.
env
.
now
# set the timeLastFailureEnded
# output to trace that the Machine self.objName was passivated for the current failure time
# output to trace that the Machine self.objName was passivated for the current failure time
if
len
(
activeObjectQueue
):
self
.
outputTrace
(
activeObjectQueue
[
0
].
name
,
"passivated in "
+
self
.
objName
+
" for "
+
str
(
self
.
env
.
now
-
self
.
breakTime
))
self
.
outputTrace
(
activeObjectQueue
[
0
].
name
,
"passivated in "
+
self
.
objName
+
" for "
+
str
(
self
.
env
.
now
-
self
.
breakTime
))
# when a machine returns from failure while trying to deliver an entity
# when a machine returns from failure while trying to deliver an entity
else
:
else
:
...
...
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