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
838eed7d
Commit
838eed7d
authored
Apr 03, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
print comments added to Router
parent
227a45a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
0 deletions
+76
-0
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+76
-0
No files found.
dream/simulation/OperatorRouter.py
View file @
838eed7d
...
...
@@ -92,16 +92,65 @@ class Router(ObjectInterruption):
yield
waituntil
,
self
,
self
.
entitiesFinishedMoving
# update the objects to be served list (pendingObjects)
self
.
pendingObjects
=
[
object
for
object
in
G
.
MachineList
if
object
.
inPositionToGet
]
#===================================================================
# # TESTING
# print now(), '================================================================================'
# print ' the pending objects are ', [str(object.id) for object in self.pendingObjects]
#===================================================================
# update the calledOperators list
self
.
calledOperators
=
[
operator
for
operator
in
G
.
OperatorsList
if
len
(
operator
.
activeCallersList
)]
#===================================================================
# # TESTING
# print ' (calledOperators, activeCallers, callerEntities): ', [(str(operator.id),\
# [str(x.id) for x in operator.activeCallersList],\
# [str(x.giver.getActiveObjectQueue()[0].id)for x in operator.activeCallersList])\
# for operator in self.calledOperators]
#===================================================================
# find the operators that can start working now even if they are not called
self
.
findCandidateOperators
()
#===================================================================
# # TESTING
# print ' {} the candidateOperators ',
# print [str(op.id) for op in self.candidateOperators]
# print [str(entity.id) for entity in G.pendingEntities]
#===================================================================
# sort the pendingEntities list
self
.
sortPendingEntities
()
#===================================================================
# # TESTING
# print [str(entity.id) for entity in G.pendingEntities]
# if G.pendingEntities:
# print ' {} the pending entities that can proceed are: ',
# print [str(entity.id) for entity in G.pendingEntities if entity.canProceed]
#===================================================================
# find the operators candidateEntities
self
.
findCandidateEntities
()
#===================================================================
# # TESTING
# print ' {} candidate entities for each candidateOperator ',
# print [(str(operator.id),[str(candidateEntity.id) for candidateEntity in operator.candidateEntities],)\
# for operator in self.candidateOperators]
#===================================================================
# find the entity that will occupy the resource, and the station that will receive it (if any available)
self
.
findCandidateReceivers
()
#===================================================================
# # TESTING
# print ' {} (candidateOperator, candidateEntity, candidateReceiver) ',
# print [(str(op.id), str(op.candidateEntity.id), str(op.candidateEntity.candidateReceiver.id))\
# for op in self.candidateOperators if op.candidateEntity.candidateReceiver]
#===================================================================
# sort the givers for the operators that will process the entities
self
.
sortGiverQueue
()
# for all the operators that are requested
...
...
@@ -113,6 +162,13 @@ class Router(ObjectInterruption):
and
operator
.
candidateEntity
.
candidateReceiver
in
self
.
pendingObjects
)
except
:
receiverIsActive
=
True
#===============================================================
# # TESTING
# print ' calledOperator', operator.id,
# print 'will receive?',operator.checkIfResourceIsAvailable() and receiverIsActive
#===============================================================
# check if the candidateOperators are available, if the are requested and reside in the pendingObjects list
if
operator
.
checkIfResourceIsAvailable
()
and
\
receiverIsActive
:
...
...
@@ -120,10 +176,23 @@ class Router(ObjectInterruption):
operator
.
sortActiveCallers
()
# find the activeCaller that has priority
priorityObject
=
next
(
x
for
x
in
operator
.
activeCallersList
if
x
in
self
.
pendingObjects
)
#===========================================================
# # TESTING
# print [str(caller.id) for caller in operator.activeCallersList]
# print ' the PRIORITY object is', priorityObject.id
#===========================================================
# and if the priorityObject is indeed pending
if
priorityObject
in
self
.
pendingObjects
:
# assign an operator to the priorityObject
operator
.
operatorAssignedTo
=
priorityObject
#=======================================================
# # TESTING
# print operator.id, 'got assigned to', priorityObject.id
#=======================================================
# and let it proceed withGetEntity
priorityObject
.
canProceedWithGetEntity
=
True
priorityObject
.
inPositionToGet
=
False
...
...
@@ -134,6 +203,13 @@ class Router(ObjectInterruption):
for
object
in
self
.
pendingObjects
:
if
not
object
.
canProceedWithGetEntity
:
object
.
giver
.
unAssignExit
()
#===================================================================
# # TESTING
# print ' these objects will proceed with getting entities',
# print [str(object.id) for object in self.pendingObjects if object.canProceedWithGetEntity]
#===================================================================
self
.
exit
()
#===========================================================================
...
...
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