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
484ce818
Commit
484ce818
authored
Jun 06, 2014
by
Georgios Dagkakis
Committed by
Jérome Perrin
Jun 06, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change in ShiftScheduler to correctly interrupt the victim. TODO topology53 and starting conditions
parent
cd832a16
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
18 deletions
+42
-18
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+4
-1
dream/simulation/Machine.py
dream/simulation/Machine.py
+9
-1
dream/simulation/ShiftScheduler.py
dream/simulation/ShiftScheduler.py
+29
-16
No files found.
dream/simulation/CoreObject.py
View file @
484ce818
...
...
@@ -92,6 +92,8 @@ class CoreObject(object):
self
.
processingTimeOfCurrentEntity
=
0
#holds the total processing time that the current entity required
# ============================== waiting flag ==============================================
self
.
waitToDispose
=
False
#shows if the object waits to dispose an entity
self
.
isWorkingOnTheLastBeforeOffShift
=
False
#shows if the object is performing the last processing before it goes offShift
# ============================== the below are currently used in Jobshop =======================
self
.
giver
=
None
#the CoreObject that the activeObject will take an Entity from
...
...
@@ -119,7 +121,7 @@ class CoreObject(object):
self
.
totalProcessingTimeInCurrentEntity
=
0
self
.
failureTimeInCurrentEntity
=
0
self
.
setupTimeCurrentEntity
=
0
self
.
shouldPreempt
=
False
#flag that shows that the machine should preempt or not
self
.
lastGiver
=
None
# variable that holds the last giver of the object, used by machine in case of preemption
...
...
@@ -134,6 +136,7 @@ class CoreObject(object):
self
.
interruptionStart
=
self
.
env
.
event
()
self
.
interruptedBy
=
None
self
.
entityRemoved
=
self
.
env
.
event
()
# =======================================================================
# the main process of the core object
...
...
dream/simulation/Machine.py
View file @
484ce818
...
...
@@ -527,7 +527,15 @@ class Machine(CoreObject):
self
.
nameLastEntityEnded
=
self
.
currentEntity
.
name
# this holds the name of the last entity that ended processing in Machine
self
.
completedJobs
+=
1
# Machine completed one more Job
# reseting the shouldPreempt flag
self
.
shouldPreempt
=
False
self
.
shouldPreempt
=
False
if
self
.
isWorkingOnTheLastBeforeOffShift
:
mySS
=
None
for
SS
in
G
.
ShiftSchedulerList
:
if
SS
.
victim
==
self
:
mySS
=
SS
break
mySS
.
victimEndedLastProcessing
.
succeed
()
self
.
isWorkingOnTheLastBeforeOffShift
=
False
# =======================================================================
# actions to be carried out when the processing of an Entity ends
...
...
dream/simulation/ShiftScheduler.py
View file @
484ce818
...
...
@@ -53,6 +53,7 @@ class ShiftScheduler(ObjectInterruption):
def
initialize
(
self
):
ObjectInterruption
.
initialize
(
self
)
self
.
remainingShiftPattern
=
list
(
self
.
shiftPattern
)
self
.
victimEndedLastProcessing
=
self
.
env
.
event
()
# =======================================================================
# The run method for the failure which has to served by a repairman
...
...
@@ -60,26 +61,38 @@ class ShiftScheduler(ObjectInterruption):
def
run
(
self
):
self
.
victim
.
totalOffShiftTime
=
0
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
now
self
.
victim
.
onShift
=
False
while
1
:
yield
self
.
env
.
timeout
(
float
(
self
.
remainingShiftPattern
[
0
][
0
]
-
self
.
env
.
now
))
# wait for the onShift
if
(
len
(
self
.
getVictimQueue
())
>
0
and
self
.
victim
.
interruptedBy
==
self
.
type
and
not
(
self
.
endUnfinished
)):
self
.
reactivateVictim
()
# re-activate the victim in case it was interrupted
self
.
victim
.
totalOffShiftTime
+=
self
.
env
.
now
-
self
.
victim
.
timeLastShiftEnded
self
.
victim
.
onShift
=
True
self
.
victim
.
timeLastShiftStarted
=
self
.
env
.
now
self
.
outputTrace
(
"is on shift"
)
startShift
=
self
.
env
.
now
# if in the beginning the victim is offShift
if
float
(
self
.
remainingShiftPattern
[
0
][
0
])
!=
self
.
env
.
now
:
self
.
victim
.
onShift
=
False
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
)):
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
.
timeLastShiftEnded
=
self
.
env
.
now
self
.
outputTrace
(
"is off shift"
)
self
.
remainingShiftPattern
.
pop
(
0
)
while
1
:
if
not
self
.
victim
.
onShift
:
yield
self
.
env
.
timeout
(
float
(
self
.
remainingShiftPattern
[
0
][
0
]
-
self
.
env
.
now
))
# wait for the onShift
self
.
reactivateVictim
()
# re-activate the victim in case it was interrupted
self
.
victim
.
totalOffShiftTime
+=
self
.
env
.
now
-
self
.
victim
.
timeLastShiftEnded
self
.
victim
.
onShift
=
True
self
.
victim
.
timeLastShiftStarted
=
self
.
env
.
now
self
.
outputTrace
(
"is on shift"
)
startShift
=
self
.
env
.
now
else
:
yield
self
.
env
.
timeout
(
float
(
self
.
remainingShiftPattern
[
0
][
1
]
-
self
.
env
.
now
))
# wait until the shift is over
if
self
.
endUnfinished
and
len
(
self
.
victim
.
getActiveObjectQueue
())
==
1
and
(
not
self
.
victim
.
waitToDispose
):
self
.
victim
.
isWorkingOnTheLastBeforeOffShift
=
True
yield
self
.
victimEndedLastProcessing
self
.
interruptVictim
()
# interrupt processing operations if any
self
.
victim
.
onShift
=
False
# get the victim off-shift
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
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