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
67eabf82
Commit
67eabf82
authored
Jan 03, 2014
by
Georgios Dagkakis
Committed by
Jérome Perrin
Jan 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first version of ScheduledMaintenance added
parent
c625e609
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
1 deletion
+78
-1
dream/simulation/ObjectInterruption.py
dream/simulation/ObjectInterruption.py
+15
-1
dream/simulation/ScheduledMaintenance.py
dream/simulation/ScheduledMaintenance.py
+63
-0
No files found.
dream/simulation/ObjectInterruption.py
View file @
67eabf82
...
...
@@ -26,7 +26,7 @@ Created on 18 Aug 2013
Class that acts as an abstract. It should have no instances. All object interruptions (eg failures, breaks) should inherit from it
'''
from
SimPy.Simulation
import
Process
,
Resource
,
reactivate
from
SimPy.Simulation
import
Process
,
Resource
,
reactivate
,
now
class
ObjectInterruption
(
Process
):
...
...
@@ -61,4 +61,18 @@ class ObjectInterruption(Process):
def
reactivateVictim
(
self
):
reactivate
(
self
.
victim
)
#outputs message to the trace.xls. Format is (Simulation Time | Victim Name | message)
def
outputTrace
(
self
,
message
):
from
Globals
import
G
if
(
G
.
trace
==
"Yes"
):
#output only if the user has selected to
#handle the 3 columns
G
.
traceSheet
.
write
(
G
.
traceIndex
,
0
,
str
(
now
()))
G
.
traceSheet
.
write
(
G
.
traceIndex
,
1
,
self
.
victim
.
objName
)
G
.
traceSheet
.
write
(
G
.
traceIndex
,
2
,
message
)
G
.
traceIndex
+=
1
#increment the row
#if we reach row 65536 we need to create a new sheet (excel limitation)
if
(
G
.
traceIndex
==
65536
):
G
.
traceIndex
=
0
G
.
sheetIndex
+=
1
G
.
traceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
sheetIndex
),
cell_overwrite_ok
=
True
)
\ No newline at end of file
dream/simulation/ScheduledMaintenance.py
0 → 100644
View file @
67eabf82
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 3 Jan 2014
@author: George
'''
'''
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
RandomNumberGenerator
import
RandomNumberGenerator
from
ObjectInterruption
import
ObjectInterruption
class
ScheduledMaintenance
(
ObjectInterruption
):
def
__init__
(
self
,
victim
=
None
,
start
=
0
,
duration
=
1
):
ObjectInterruption
.
__init__
(
self
,
victim
)
self
.
start
=
start
self
.
duration
=
duration
def
run
(
self
):
yield
hold
,
self
,
self
.
start
#wait until the start time
try
:
if
(
len
(
self
.
getVictimQueue
())
>
0
):
# when a Machine gets failure
self
.
interruptVictim
()
# while in process it is interrupted
self
.
victim
.
Up
=
False
self
.
victim
.
timeLastFailure
=
now
()
self
.
outputTrace
(
"is down"
)
except
AttributeError
:
print
"AttributeError1"
yield
hold
,
self
,
self
.
duration
#wait until the start time
self
.
victim
.
totalFailureTime
+=
self
.
duration
try
:
if
(
len
(
self
.
getVictimQueue
())
>
0
):
self
.
reactivateVictim
()
# since the maintenance is over, the victim is reactivated
self
.
victim
.
Up
=
True
self
.
outputTrace
(
"is up"
)
except
AttributeError
:
print
"AttributeError2"
\ No newline at end of file
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