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
3a1323c0
Commit
3a1323c0
authored
Aug 13, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first attempt to make Operator working with shifts
parent
250e7090
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
13 deletions
+36
-13
dream/simulation/Machine.py
dream/simulation/Machine.py
+2
-1
dream/simulation/ObjectResource.py
dream/simulation/ObjectResource.py
+3
-2
dream/simulation/OperatorPool.py
dream/simulation/OperatorPool.py
+6
-1
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+7
-4
dream/simulation/ShiftScheduler.py
dream/simulation/ShiftScheduler.py
+18
-5
No files found.
dream/simulation/Machine.py
View file @
3a1323c0
...
...
@@ -1118,6 +1118,7 @@ class Machine(CoreObject):
# find an available operator
candidateOperator
=
self
.
operatorPool
.
findAvailableOperator
()
# append the station into its candidateStations
if
candidateOperator
:
candidateOperator
.
candidateStations
.
append
(
self
)
return
candidateOperator
...
...
dream/simulation/ObjectResource.py
View file @
3a1323c0
...
...
@@ -58,12 +58,13 @@ class ObjectResource(ManPyObject):
self
.
coreObjectIds
=
[]
# list with the coreObjects that the resource services
self
.
coreObjects
=
[]
self
.
onShift
=
True
# =======================================================================
# checks if the worker is available
# =======================================================================
def
checkIfResourceIsAvailable
(
self
,
callerObject
=
None
):
return
len
(
self
.
Res
.
users
)
<
self
.
capacity
return
len
(
self
.
Res
.
users
)
<
self
.
capacity
and
self
.
onShift
# =======================================================================
...
...
dream/simulation/OperatorPool.py
View file @
3a1323c0
...
...
@@ -99,7 +99,12 @@ class OperatorPool(ObjectResource):
# =======================================================================
def
findAvailableOperator
(
self
):
# may need to implement different sorting of the operators
# find the free operator if any
freeOperator
=
next
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceIsAvailable
())
# freeOperator = next(x for x in self.operators if x.checkIfResourceIsAvailable())
freeOperator
=
None
for
operator
in
self
.
operators
:
if
operator
.
checkIfResourceIsAvailable
():
freeOperator
=
operator
break
return
freeOperator
# =======================================================================
...
...
dream/simulation/OperatorRouter.py
View file @
3a1323c0
...
...
@@ -322,7 +322,7 @@ class Router(ObjectInterruption):
# find candidateOperators for each object operator
candidateOperator
=
object
.
findCandidateOperator
()
# TODO: this way no sorting is performed
if
not
candidateOperator
in
self
.
candidateOperators
:
if
candidateOperator
and
(
not
candidateOperator
in
self
.
candidateOperators
)
:
self
.
candidateOperators
.
append
(
candidateOperator
)
# for each pendingQueue
for
object
in
self
.
pendingQueues
:
...
...
@@ -357,8 +357,11 @@ class Router(ObjectInterruption):
# update the schedulingRule/multipleCriterionList of the Router
if
self
.
sorting
:
self
.
updateSchedulingRule
()
if
self
.
candidateOperators
:
self
.
printTrace
(
'router found candidate operators'
+
' '
*
3
,
[(
operator
.
id
,
[
station
.
id
for
station
in
operator
.
candidateStations
])
for
operator
in
self
.
candidateOperators
])
else
:
self
.
printTrace
(
'router'
,
'found NO candidate operators'
)
#===========================================================================
# find the candidate entities for each candidateOperator
...
...
dream/simulation/ShiftScheduler.py
View file @
3a1323c0
...
...
@@ -60,20 +60,29 @@ class ShiftScheduler(ObjectInterruption):
# The run method for the failure which has to served by a repairman
# =======================================================================
def
run
(
self
):
from
CoreObject
import
CoreObject
# the victim should not be interrupted but the scheduler should wait for the processing to finish before the stations turns to off-shift mode
self
.
victim
.
totalOffShiftTime
=
0
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
now
# if in the beginning the victim is offShift set it as such
if
float
(
self
.
remainingShiftPattern
[
0
][
0
])
!=
self
.
env
.
now
:
self
.
victim
.
onShift
=
False
self
.
interruptVictim
()
# interrupt processing operations if any
if
issubclass
(
self
.
victim
.
__class__
,
CoreObject
):
if
not
self
.
victim
.
interruptionStart
.
triggered
:
self
.
interruptVictim
()
# interrupt the victim
else
:
CoreObject
.
requestAllocation
()
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
now
self
.
outputTrace
(
self
.
victim
.
name
,
"is off shift"
)
while
1
:
if
not
self
.
victim
.
onShift
:
yield
self
.
env
.
timeout
(
float
(
self
.
remainingShiftPattern
[
0
][
0
]
-
self
.
env
.
now
))
# wait for the onShift
if
issubclass
(
self
.
victim
.
__class__
,
CoreObject
):
self
.
reactivateVictim
()
# re-activate the victim in case it was interrupted
else
:
CoreObject
.
requestAllocation
()
# if the victim has interruptions that measure only the on-shift time, they have to be notified
for
oi
in
self
.
victim
.
objectInterruptions
:
...
...
@@ -116,8 +125,12 @@ class ShiftScheduler(ObjectInterruption):
oi
.
victimOffShift
.
succeed
(
succeedTuple
)
# interrupt the victim only if it was not previously interrupted
if
issubclass
(
self
.
victim
.
__class__
,
CoreObject
):
if
not
self
.
victim
.
interruptionStart
.
triggered
:
self
.
interruptVictim
()
# interrupt the victim
else
:
CoreObject
.
requestAllocation
()
self
.
victim
.
onShift
=
False
# get the victim off-shift
self
.
victim
.
timeLastShiftEnded
=
self
.
env
.
now
self
.
outputTrace
(
self
.
victim
.
name
,
"is off shift"
)
...
...
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