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
fecffa5c
Commit
fecffa5c
authored
May 30, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Machine, new variable interruptedBy (holds the type of interruptions). ShiftScheduler update.
parent
f52b2011
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
27 deletions
+25
-27
dream/simulation/Machine.py
dream/simulation/Machine.py
+6
-6
dream/simulation/ObjectInterruption.py
dream/simulation/ObjectInterruption.py
+5
-8
dream/simulation/ShiftScheduler.py
dream/simulation/ShiftScheduler.py
+13
-12
dream/simulation/Source.py
dream/simulation/Source.py
+1
-1
No files found.
dream/simulation/Machine.py
View file @
fecffa5c
...
@@ -542,8 +542,8 @@ class Machine(CoreObject):
...
@@ -542,8 +542,8 @@ class Machine(CoreObject):
def
interruptionActions
(
self
):
def
interruptionActions
(
self
):
activeObjectQueue
=
self
.
Res
.
users
activeObjectQueue
=
self
.
Res
.
users
activeEntity
=
activeObjectQueue
[
0
]
activeEntity
=
activeObjectQueue
[
0
]
#
self.printTrace(activeEntity.name, interrupted=self.objName)
self
.
printTrace
(
activeEntity
.
name
,
interrupted
=
self
.
objName
)
# if the interrupt occured while processing an entity
# if the interrupt occur
r
ed while processing an entity
if
not
self
.
waitToDispose
:
if
not
self
.
waitToDispose
:
# output to trace that the Machine (self.objName) got interrupted
# output to trace that the Machine (self.objName) got interrupted
try
:
try
:
...
@@ -817,8 +817,8 @@ class Machine(CoreObject):
...
@@ -817,8 +817,8 @@ class Machine(CoreObject):
#calculate the offShift time for current entity
#calculate the offShift time for current entity
offShiftTimeInCurrentEntity
=
0
offShiftTimeInCurrentEntity
=
0
if
self
.
interrupt
Cause
:
if
self
.
interrupt
edBy
:
if
self
.
onShift
==
False
and
self
.
interrupt
Cause
.
type
==
'ShiftScheduler'
:
if
self
.
onShift
==
False
and
self
.
interrupt
edBy
==
'ShiftScheduler'
:
offShiftTimeInCurrentEntity
=
self
.
env
.
now
-
activeObject
.
timeLastShiftEnded
offShiftTimeInCurrentEntity
=
self
.
env
.
now
-
activeObject
.
timeLastShiftEnded
# if there is an entity that finished processing in a Machine but did not get to reach
# if there is an entity that finished processing in a Machine but did not get to reach
...
@@ -870,8 +870,8 @@ class Machine(CoreObject):
...
@@ -870,8 +870,8 @@ class Machine(CoreObject):
# we also need to add the last blocking time to total blockage time
# we also need to add the last blocking time to total blockage time
if
activeObject
.
onShift
==
False
:
if
activeObject
.
onShift
==
False
:
#add the time only if the object is interrupted because of off-shift
#add the time only if the object is interrupted because of off-shift
if
self
.
interrupt
Cause
:
if
self
.
interrupt
edBy
:
if
self
.
interrupt
Cause
.
type
==
'ShiftScheduler'
:
if
self
.
interrupt
edBy
==
'ShiftScheduler'
:
self
.
totalOffShiftTime
+=
self
.
env
.
now
-
self
.
timeLastShiftEnded
self
.
totalOffShiftTime
+=
self
.
env
.
now
-
self
.
timeLastShiftEnded
elif
len
(
self
.
getActiveObjectQueue
())
==
0
or
self
.
waitToDispose
:
elif
len
(
self
.
getActiveObjectQueue
())
==
0
or
self
.
waitToDispose
:
self
.
totalOffShiftTime
+=
self
.
env
.
now
-
self
.
timeLastShiftEnded
self
.
totalOffShiftTime
+=
self
.
env
.
now
-
self
.
timeLastShiftEnded
...
...
dream/simulation/ObjectInterruption.py
View file @
fecffa5c
...
@@ -37,13 +37,11 @@ class ObjectInterruption(object):
...
@@ -37,13 +37,11 @@ class ObjectInterruption(object):
def
__init__
(
self
,
victim
=
None
):
def
__init__
(
self
,
victim
=
None
):
from
Globals
import
G
from
Globals
import
G
self
.
env
=
G
.
env
self
.
env
=
G
.
env
# Process.__init__(self)
self
.
victim
=
victim
self
.
victim
=
victim
# variable used to hand in control to the objectInterruption
# variable used to hand in control to the objectInterruption
self
.
call
=
False
self
.
call
=
False
def
initialize
(
self
):
def
initialize
(
self
):
# Process.__init__(self)
self
.
call
=
False
self
.
call
=
False
#===========================================================================
#===========================================================================
...
@@ -90,12 +88,9 @@ class ObjectInterruption(object):
...
@@ -90,12 +88,9 @@ class ObjectInterruption(object):
# interrupts the victim
# interrupts the victim
#===========================================================================
#===========================================================================
def
interruptVictim
(
self
):
def
interruptVictim
(
self
):
# # if the victim is not in position to dispose an entity, then interrupt the processing
# inform the victim by whom will it be interrupted
# if not self.victim.waitToDispose and self.victim.getActiveObjectQueue():
# TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously
# self.interrupt(self.victim)
self
.
victim
.
interruptedBy
=
self
.
type
# otherwise it waits for an interruption event
# else:
# self.victim.interruptionStart.signal(now())
self
.
victim
.
interruptionStart
.
succeed
(
self
.
env
.
now
)
self
.
victim
.
interruptionStart
.
succeed
(
self
.
env
.
now
)
#===========================================================================
#===========================================================================
...
@@ -105,6 +100,8 @@ class ObjectInterruption(object):
...
@@ -105,6 +100,8 @@ class ObjectInterruption(object):
self
.
victim
.
interruptionEnd
.
succeed
(
self
.
env
.
now
)
self
.
victim
.
interruptionEnd
.
succeed
(
self
.
env
.
now
)
#reset the interruptionStart event of the victim
#reset the interruptionStart event of the victim
self
.
victim
.
interruptionStart
=
self
.
env
.
event
()
self
.
victim
.
interruptionStart
=
self
.
env
.
event
()
# TODO: reconsider what happens when failure and ShiftScheduler (e.g.) signal simultaneously
self
.
victim
.
interruptedBy
=
None
#===========================================================================
#===========================================================================
# outputs message to the trace.xls. Format is (Simulation Time | Victim Name | message)
# outputs message to the trace.xls. Format is (Simulation Time | Victim Name | message)
...
...
dream/simulation/ShiftScheduler.py
View file @
fecffa5c
...
@@ -26,7 +26,8 @@ Created on 3 Jan 2014
...
@@ -26,7 +26,8 @@ Created on 3 Jan 2014
schedules the availability of an object according to its shift pattern
schedules the availability of an object according to its shift pattern
'''
'''
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
...
@@ -58,25 +59,25 @@ class ShiftScheduler(ObjectInterruption):
...
@@ -58,25 +59,25 @@ class ShiftScheduler(ObjectInterruption):
# =======================================================================
# =======================================================================
def
run
(
self
):
def
run
(
self
):
self
.
victim
.
totalOffShiftTime
=
0
self
.
victim
.
totalOffShiftTime
=
0
self
.
victim
.
timeLastShiftEnded
=
now
()
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
now
self
.
victim
.
onShift
=
False
self
.
victim
.
onShift
=
False
while
1
:
while
1
:
yield
hold
,
self
,
float
(
self
.
remainingShiftPattern
[
0
][
0
]
-
now
())
# wait for the onShift
yield
self
.
env
.
timeout
(
float
(
self
.
remainingShiftPattern
[
0
][
0
]
-
self
.
env
.
now
))
# wait for the onShift
if
(
len
(
self
.
getVictimQueue
())
>
0
and
self
.
victim
.
interrupt
Caus
e
and
not
(
self
.
endUnfinished
)):
if
(
len
(
self
.
getVictimQueue
())
>
0
and
self
.
victim
.
interrupt
edBy
==
self
.
typ
e
and
not
(
self
.
endUnfinished
)):
self
.
reactivateVictim
()
# re-activate the victim in case it was interrupted
self
.
reactivateVictim
()
# re-activate the victim in case it was interrupted
self
.
victim
.
totalOffShiftTime
+=
now
()
-
self
.
victim
.
timeLastShiftEnded
self
.
victim
.
totalOffShiftTime
+=
self
.
env
.
now
-
self
.
victim
.
timeLastShiftEnded
self
.
victim
.
onShift
=
True
self
.
victim
.
onShift
=
True
self
.
victim
.
timeLastShiftStarted
=
now
()
self
.
victim
.
timeLastShiftStarted
=
self
.
env
.
now
self
.
outputTrace
(
"is on shift"
)
self
.
outputTrace
(
"is on shift"
)
startShift
=
now
()
startShift
=
self
.
env
.
now
yield
hold
,
self
,
float
(
self
.
remainingShiftPattern
[
0
][
1
]
-
now
(
))
# wait until the shift is over
yield
self
.
env
.
timeout
(
float
(
self
.
remainingShiftPattern
[
0
][
1
]
-
self
.
env
.
now
))
# wait until the shift is over
if
(
len
(
self
.
getVictimQueue
())
>
0
and
not
(
self
.
endUnfinished
)):
if
(
len
(
self
.
getVictimQueue
())
>
0
and
not
(
self
.
endUnfinished
)):
self
.
interruptVictim
()
# interrupt processing operations if any
self
.
interruptVictim
()
# interrupt processing operations if any
self
.
victim
.
onShift
=
False
# get the victim off-shift
self
.
victim
.
onShift
=
False
# get the victim off-shift
self
.
victim
.
timeLastShiftEnded
=
now
()
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
now
self
.
outputTrace
(
"is off shift"
)
self
.
outputTrace
(
"is off shift"
)
self
.
remainingShiftPattern
.
pop
(
0
)
self
.
remainingShiftPattern
.
pop
(
0
)
...
...
dream/simulation/Source.py
View file @
fecffa5c
...
@@ -180,7 +180,7 @@ class Source(CoreObject):
...
@@ -180,7 +180,7 @@ class Source(CoreObject):
# creates an Entity
# creates an Entity
#============================================================================
#============================================================================
def
createEntity
(
self
):
def
createEntity
(
self
):
#
self.printTrace(self.id, create='')
self
.
printTrace
(
self
.
id
,
create
=
''
)
return
self
.
item
(
id
=
self
.
item
.
type
+
str
(
G
.
numberOfEntities
),
name
=
self
.
item
.
type
+
str
(
self
.
numberOfArrivals
))
#return the newly created Entity
return
self
.
item
(
id
=
self
.
item
.
type
+
str
(
G
.
numberOfEntities
),
name
=
self
.
item
.
type
+
str
(
self
.
numberOfArrivals
))
#return the newly created Entity
#============================================================================
#============================================================================
# calculates the processing time
# calculates the processing time
...
...
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