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
03476640
Commit
03476640
authored
May 29, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ScheduledMaintenance updated
parent
91b8bce2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
dream/simulation/ScheduledMaintenance.py
dream/simulation/ScheduledMaintenance.py
+6
-5
No files found.
dream/simulation/ScheduledMaintenance.py
View file @
03476640
...
@@ -26,7 +26,8 @@ Created on 3 Jan 2014
...
@@ -26,7 +26,8 @@ Created on 3 Jan 2014
models an one time scheduled maintenance. It happens and stops at fixed times and it is also deterministic
models an one time scheduled maintenance. It happens and stops at fixed times and it is also deterministic
'''
'''
from
SimPy.Simulation
import
now
,
Process
,
hold
,
request
,
release
,
infinity
# from SimPy.Simulation import now, Process, hold, request, release, infinity
import
simpy
from
RandomNumberGenerator
import
RandomNumberGenerator
from
RandomNumberGenerator
import
RandomNumberGenerator
from
ObjectInterruption
import
ObjectInterruption
from
ObjectInterruption
import
ObjectInterruption
...
@@ -41,24 +42,24 @@ class ScheduledMaintenance(ObjectInterruption):
...
@@ -41,24 +42,24 @@ class ScheduledMaintenance(ObjectInterruption):
ObjectInterruption
.
__init__
(
self
,
victim
)
ObjectInterruption
.
__init__
(
self
,
victim
)
self
.
start
=
start
self
.
start
=
start
self
.
duration
=
duration
self
.
duration
=
duration
# =======================================================================
# =======================================================================
# the run method
# the run method
# holds till the defined start time, interrupts the victim,
# holds till the defined start time, interrupts the victim,
# holds for the maintenance duration, and finally reactivates the victim
# holds for the maintenance duration, and finally reactivates the victim
# =======================================================================
# =======================================================================
def
run
(
self
):
def
run
(
self
):
yield
hold
,
self
,
self
.
start
#wait until the start time
yield
self
.
env
.
timeout
(
self
.
start
)
#wait until the start time
try
:
try
:
if
(
len
(
self
.
getVictimQueue
())
>
0
):
# when a Machine gets failure
if
(
len
(
self
.
getVictimQueue
())
>
0
):
# when a Machine gets failure
self
.
interruptVictim
()
# while in process it is interrupted
self
.
interruptVictim
()
# while in process it is interrupted
self
.
victim
.
Up
=
False
self
.
victim
.
Up
=
False
self
.
victim
.
timeLastFailure
=
now
()
self
.
victim
.
timeLastFailure
=
self
.
env
.
now
self
.
outputTrace
(
"is down"
)
self
.
outputTrace
(
"is down"
)
except
AttributeError
:
except
AttributeError
:
print
"AttributeError1"
print
"AttributeError1"
yield
hold
,
self
,
self
.
duration
# wait for the defined duration of the interruption
yield
self
.
env
.
timeout
(
self
.
duration
)
# wait for the defined duration of the interruption
self
.
victim
.
totalFailureTime
+=
self
.
duration
self
.
victim
.
totalFailureTime
+=
self
.
duration
try
:
try
:
...
...
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