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
Hide 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,22 +820,21 @@ class Machine(CoreObject):
...
@@ -818,22 +820,21 @@ 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
self
.
waitEntityRemoval
=
True
activeObjectQueue
=
self
.
getActiveObjectQueue
()
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(entityRemoved)'
)
if
len
(
activeObjectQueue
):
self
.
waitEntityRemoval
=
True
self
.
expectedSignals
[
'entityRemoved'
]
=
1
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(entityRemoved)'
)
yield
self
.
entityRemoved
self
.
expectedSignals
[
'entityRemoved'
]
=
1
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'
self
.
waitEntityRemoval
=
False
self
.
waitEntityRemoval
=
False
self
.
entityRemoved
=
self
.
env
.
event
()
self
.
entityRemoved
=
self
.
env
.
event
()
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
if
not
self
.
haveToDispose
():
if
not
self
.
haveToDispose
():
break
break
#===========================================================================
#===========================================================================
# actions to be performed after an operation (setup or processing)
# actions to be performed after an operation (setup or processing)
...
@@ -923,22 +924,18 @@ class Machine(CoreObject):
...
@@ -923,22 +924,18 @@ 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
activeEntity
=
activeObjectQueue
[
0
]
if
len
(
activeObjectQueue
):
self
.
printTrace
(
activeEntity
.
name
,
interrupted
=
self
.
objName
)
activeEntity
=
activeObjectQueue
[
0
]
# if the interrupt occurred while processing an entity
self
.
printTrace
(
activeEntity
.
name
,
interrupted
=
self
.
objName
)
if
not
self
.
waitToDispose
:
self
.
outputTrace
(
activeObjectQueue
[
0
].
name
,
"Interrupted at "
+
self
.
objName
)
# output to trace that the Machine (self.objName) got interrupted
try
:
self
.
outputTrace
(
activeObjectQueue
[
0
].
name
,
"Interrupted at "
+
self
.
objName
)
except
IndexError
:
pass
# recalculate the processing time left tinM
# recalculate the processing time left tinM
self
.
tinM
=
self
.
tinM
-
(
self
.
env
.
now
-
self
.
timeLastOperationStarted
)
if
self
.
timeLastOperationStarted
:
if
(
self
.
tinM
==
0
):
# sometimes the failure may happen exactly at the time that the processing would finish
self
.
tinM
=
self
.
tinM
-
(
self
.
env
.
now
-
self
.
timeLastOperationStarted
)
# this may produce disagreement with the simul8 because in both SimPy and Simul8
if
(
self
.
tinM
==
0
):
# sometimes the failure may happen exactly at the time that the processing would finish
# it seems to be random which happens 1st
# this may produce disagreement with the simul8 because in both SimPy and Simul8
# this should not appear often to stochastic models though where times are random
# it seems to be random which happens 1st
self
.
interruption
=
True
# this should not appear often to stochastic models though where times are random
self
.
interruption
=
True
# start counting the down time at breatTime dummy variable
# start counting the down time at breatTime dummy variable
self
.
breakTime
=
self
.
env
.
now
# dummy variable that the interruption happened
self
.
breakTime
=
self
.
env
.
now
# dummy variable that the interruption happened
# set isProcessing to False
# set isProcessing to False
...
@@ -957,13 +954,15 @@ class Machine(CoreObject):
...
@@ -957,13 +954,15 @@ class Machine(CoreObject):
# =======================================================================
# =======================================================================
def
postInterruptionActions
(
self
):
def
postInterruptionActions
(
self
):
activeObjectQueue
=
self
.
Res
.
users
activeObjectQueue
=
self
.
Res
.
users
activeEntity
=
activeObjectQueue
[
0
]
if
len
(
activeObjectQueue
):
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
self
.
outputTrace
(
activeObjectQueue
[
0
].
name
,
"passivated in "
+
self
.
objName
+
" for "
+
str
(
self
.
env
.
now
-
self
.
breakTime
))
if
len
(
activeObjectQueue
):
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
:
# calculate the time the Machine was down while trying to dispose the current Entity,
# calculate the time the Machine was down while trying to dispose the current Entity,
...
...
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