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
Show 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
...
...
@@ -93,6 +93,8 @@ class CoreObject(object):
# ============================== 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
if
len
(
self
.
previous
)
>
0
:
...
...
@@ -135,6 +137,7 @@ class CoreObject(object):
self
.
interruptedBy
=
None
self
.
entityRemoved
=
self
.
env
.
event
()
# =======================================================================
# the main process of the core object
# this is dummy, every object must have its own implementation
...
...
dream/simulation/Machine.py
View file @
484ce818
...
...
@@ -528,6 +528,14 @@ class Machine(CoreObject):
self
.
completedJobs
+=
1
# Machine completed one more Job
# reseting the shouldPreempt flag
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,10 +61,20 @@ class ShiftScheduler(ObjectInterruption):
def
run
(
self
):
self
.
victim
.
totalOffShiftTime
=
0
self
.
victim
.
timeLastShiftEnded
=
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
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
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
...
...
@@ -71,10 +82,12 @@ class ShiftScheduler(ObjectInterruption):
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
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
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
now
...
...
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