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
7471841a
Commit
7471841a
authored
Aug 13, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comments and cleanup
parent
3a1323c0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
3 deletions
+13
-3
dream/simulation/Machine.py
dream/simulation/Machine.py
+1
-1
dream/simulation/ObjectResource.py
dream/simulation/ObjectResource.py
+2
-0
dream/simulation/OperatorPool.py
dream/simulation/OperatorPool.py
+0
-1
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+2
-0
dream/simulation/ShiftScheduler.py
dream/simulation/ShiftScheduler.py
+8
-1
No files found.
dream/simulation/Machine.py
View file @
7471841a
...
...
@@ -1118,7 +1118,7 @@ class Machine(CoreObject):
# find an available operator
candidateOperator
=
self
.
operatorPool
.
findAvailableOperator
()
# append the station into its candidateStations
if
candidateOperator
:
if
candidateOperator
:
# if there was an operator found append the Machine on his candidateStations
candidateOperator
.
candidateStations
.
append
(
self
)
return
candidateOperator
...
...
dream/simulation/ObjectResource.py
View file @
7471841a
...
...
@@ -58,12 +58,14 @@ class ObjectResource(ManPyObject):
self
.
coreObjectIds
=
[]
# list with the coreObjects that the resource services
self
.
coreObjects
=
[]
# flag that shows if the resourse is on shift
self
.
onShift
=
True
# =======================================================================
# checks if the worker is available
# =======================================================================
def
checkIfResourceIsAvailable
(
self
,
callerObject
=
None
):
# return true if the operator is idle and on shift
return
len
(
self
.
Res
.
users
)
<
self
.
capacity
and
self
.
onShift
...
...
dream/simulation/OperatorPool.py
View file @
7471841a
...
...
@@ -99,7 +99,6 @@ 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
=
None
for
operator
in
self
.
operators
:
if
operator
.
checkIfResourceIsAvailable
():
...
...
dream/simulation/OperatorRouter.py
View file @
7471841a
...
...
@@ -321,6 +321,7 @@ class Router(ObjectInterruption):
for
object
in
self
.
pendingMachines
:
# find candidateOperators for each object operator
candidateOperator
=
object
.
findCandidateOperator
()
# if there is candidateOperator that is not already in self.candidateOperators add him
# TODO: this way no sorting is performed
if
candidateOperator
and
(
not
candidateOperator
in
self
.
candidateOperators
):
self
.
candidateOperators
.
append
(
candidateOperator
)
...
...
@@ -357,6 +358,7 @@ class Router(ObjectInterruption):
# update the schedulingRule/multipleCriterionList of the Router
if
self
.
sorting
:
self
.
updateSchedulingRule
()
# if there are candidate operators
if
self
.
candidateOperators
:
self
.
printTrace
(
'router found candidate operators'
+
' '
*
3
,
[(
operator
.
id
,
[
station
.
id
for
station
in
operator
.
candidateStations
])
for
operator
in
self
.
candidateOperators
])
...
...
dream/simulation/ShiftScheduler.py
View file @
7471841a
...
...
@@ -67,7 +67,10 @@ class ShiftScheduler(ObjectInterruption):
# 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
# if the victim is CoreObject interrupt it. Else ask the router for allocation of operators
# TODO more generic implementation
if
issubclass
(
self
.
victim
.
__class__
,
CoreObject
):
# interrupt the victim only if it was not previously interrupted
if
not
self
.
victim
.
interruptionStart
.
triggered
:
self
.
interruptVictim
()
# interrupt the victim
else
:
...
...
@@ -79,6 +82,8 @@ class ShiftScheduler(ObjectInterruption):
while
1
:
if
not
self
.
victim
.
onShift
:
yield
self
.
env
.
timeout
(
float
(
self
.
remainingShiftPattern
[
0
][
0
]
-
self
.
env
.
now
))
# wait for the onShift
# if the victim is CoreObject reactivate it. Else ask the router for allocation of operators
# TODO more generic implementation
if
issubclass
(
self
.
victim
.
__class__
,
CoreObject
):
self
.
reactivateVictim
()
# re-activate the victim in case it was interrupted
else
:
...
...
@@ -124,8 +129,10 @@ class ShiftScheduler(ObjectInterruption):
succeedTuple
=
(
self
,
self
.
env
.
now
)
oi
.
victimOffShift
.
succeed
(
succeedTuple
)
# interrupt the victim only if it was not previously interrupted
# if the victim is CoreObject interrupt it. Else ask the router for allocation of operators
# TODO more generic implementation
if
issubclass
(
self
.
victim
.
__class__
,
CoreObject
):
# interrupt the victim only if it was not previously interrupted
if
not
self
.
victim
.
interruptionStart
.
triggered
:
self
.
interruptVictim
()
# interrupt the victim
else
:
...
...
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