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
c97edf9f
Commit
c97edf9f
authored
Feb 11, 2014
by
Georgios Dagkakis
Committed by
Jérome Perrin
Feb 19, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ShiftScheduler added and main script updated to read it
parent
8d2a4e35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
0 deletions
+95
-0
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+12
-0
dream/simulation/ShiftScheduler.py
dream/simulation/ShiftScheduler.py
+83
-0
No files found.
dream/simulation/LineGenerationJSON.py
View file @
c97edf9f
...
...
@@ -94,6 +94,7 @@ from ConditionalBuffer import ConditionalBuffer
from
MouldAssemblyBuffer
import
MouldAssemblyBuffer
from
MachineManagedJob
import
MachineManagedJob
from
QueueManagedJob
import
QueueManagedJob
from
ShiftScheduler
import
ShiftScheduler
import
ExcelHandler
import
time
...
...
@@ -1260,6 +1261,7 @@ def createObjectInterruptions():
G
.
ObjectInterruptionList
=
[]
G
.
ScheduledMaintenanceList
=
[]
G
.
FailureList
=
[]
G
.
ShiftSchedulerList
=
[]
json_data
=
G
.
JSONData
#Read the json data
...
...
@@ -1292,6 +1294,16 @@ def createObjectInterruptions():
F
=
Failure
(
victim
,
distributionType
,
MTTF
,
MTTR
,
availability
,
victim
.
id
,
victim
.
repairman
)
G
.
ObjectInterruptionList
.
append
(
F
)
G
.
FailureList
.
append
(
F
)
# if there is a shift pattern defined
# initiate them
shift
=
element
.
get
(
'shift'
,
{})
if
len
(
shift
):
victim
=
Globals
.
findObjectById
(
element
[
'id'
])
shiftPattern
=
list
(
shift
.
get
(
'shiftPattern'
,
[]))
endUnfinished
=
bool
(
int
(
shift
.
get
(
'endUnfinished'
,
0
)))
SS
=
ShiftScheduler
(
victim
,
shiftPattern
,
endUnfinished
)
G
.
ObjectInterruptionList
.
append
(
SS
)
G
.
ShiftSchedulerList
.
append
(
SS
)
# ===========================================================================
# used to convert a string read from the input to object type
...
...
dream/simulation/ShiftScheduler.py
0 → 100644
View file @
c97edf9f
# ===========================================================================
# 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
'''
'''
schedules the availability of an object according to its shift pattern
'''
from
SimPy.Simulation
import
now
,
Process
,
hold
,
request
,
release
,
infinity
from
RandomNumberGenerator
import
RandomNumberGenerator
from
ObjectInterruption
import
ObjectInterruption
# ===========================================================================
# the shift scheduler class
# ===========================================================================
class
ShiftScheduler
(
ObjectInterruption
):
# =======================================================================
# the __init__() method of the class
# =======================================================================
def
__init__
(
self
,
victim
=
None
,
shiftPattern
=
[],
endUnfinished
=
False
):
ObjectInterruption
.
__init__
(
self
,
victim
)
self
.
shiftPattern
=
shiftPattern
self
.
endUnfinished
=
endUnfinished
#flag that shows if half processed Jobs should end after the shift ends
# =======================================================================
# initialize for every replications
# =======================================================================
def
initialize
(
self
):
ObjectInterruption
.
initialize
(
self
)
self
.
remainingShiftPattern
=
self
.
shiftPattern
# =======================================================================
# The run method for the failure which has to served by a repairman
# =======================================================================
def
run
(
self
):
self
.
victim
.
totalOffShiftTime
=
0
offShiftTime
=
now
()
self
.
victim
.
onShift
=
False
while
1
:
yield
hold
,
self
,
float
(
self
.
remainingShiftPattern
[
0
][
0
]
-
now
())
# wait for the onShift
if
(
len
(
self
.
getVictimQueue
())
>
0
and
self
.
victim
.
interruptCause
and
not
(
self
.
endUnfinished
)):
self
.
reactivateVictim
()
# re-activate the victim in case it was interrupted
#self.victim.totalFailureTime+=now()-offShiftTime
self
.
victim
.
onShift
=
True
self
.
victim
.
timeLastShiftStarted
=
now
()
self
.
outputTrace
(
"is on shift"
)
startShift
=
now
()
yield
hold
,
self
,
float
(
self
.
remainingShiftPattern
[
0
][
1
]
-
now
())
# wait until the shift is over
if
(
len
(
self
.
getVictimQueue
())
>
0
and
not
(
self
.
endUnfinished
)):
self
.
interruptVictim
()
# interrupt processing operations if any
self
.
victim
.
onShift
=
False
# get the victim off-shift
offShiftTime
=
now
()
self
.
outputTrace
(
"is off shift"
)
self
.
remainingShiftPattern
.
pop
(
0
)
if
len
(
self
.
remainingShiftPattern
)
==
0
:
break
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