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
5bb1846e
Commit
5bb1846e
authored
May 12, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor clean-up
parent
a33f0ef3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
130 deletions
+16
-130
dream/simulation/Machine.py
dream/simulation/Machine.py
+0
-7
dream/simulation/OperatedPoolBroker.py
dream/simulation/OperatedPoolBroker.py
+1
-111
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+15
-12
No files found.
dream/simulation/Machine.py
View file @
5bb1846e
...
...
@@ -742,13 +742,6 @@ class Machine(CoreObject):
if
activeObject
.
canAccept
():
# print self.id, now(), 'will try signalling a giver from removeEntity'
activeObject
.
signalGiver
()
# # if the Machine is operated then signal Broker that the internal queue is now empty
# if activeObject.currentOperator:
# #===================================================================
# # # TESTING
# # print now(), self.id, 'signalling broker that removed entity'
# #===================================================================
# activeObject.broker.victimQueueIsEmpty.signal(now())
return
activeEntity
# =======================================================================
...
...
dream/simulation/OperatedPoolBroker.py
View file @
5bb1846e
...
...
@@ -79,10 +79,6 @@ class Broker(ObjectInterruption):
# print now(), self.victim.id, 'broker is invoked'
# update the time that the station is waiting for the operator
self
.
timeWaitForOperatorStarted
=
now
()
#===============================================================
# if the victim already holds an entity that means that the machine's operation type
# is no Load or setup, in that case the router is already invoked and the machine is already assigned an operator
...
...
@@ -108,31 +104,6 @@ class Broker(ObjectInterruption):
self
.
waitForOperator
=
False
# print self.victim.id, 'received resourceAvailable event'
#===============================================================
# # if the resource is not available wait until a rousourceAvailable event
# if not self.victim.operatorPool.checkIfResourceIsAvailable():
# self.waitForOperator=True
# # print now(), self.victim.id, 'broker waits till resource is available1'
# print now(), self.victim.id, 'NO OPERATOR AVAILABLE NOW, FROM BROKER',' .'*8
# yield waitevent, self, self.resourceAvailable
# self.waitForOperator=False
# # print self.victim.id, 'received resourceAvailable event'
# # if there are machines waiting for the same resources (broker.waitForOperator==True) check if they wait for longer
# # and if yes then wait also for the same event
# else:
# from Globals import G
# for machine in [station for station in G.MachineList if station.operatorPool is self.victim.operatorPool]:
# if machine.broker.waitForOperator:
# self.waitForOperator=True
# print now(), self.victim.id, 'MANY MACHINES WAITING FOR THE SAME OPERATOR, FROM BROKER',' .'*8
# # print now(), self.victim.id, 'broker waits till resource is available2'
# yield waitevent, self, self.resourceAvailable
# self.waitForOperator=False
# # print self.victim.id, 'received resourceAvailable event'
assert
self
.
victim
.
operatorPool
.
checkIfResourceIsAvailable
(),
'there is no available operator to request'
# set the available resource as the currentOperator
self
.
victim
.
currentOperator
=
self
.
victim
.
operatorPool
.
findAvailableOperator
()
...
...
@@ -150,19 +121,7 @@ class Broker(ObjectInterruption):
# ======= release a resource
elif
not
self
.
victim
.
isOperated
():
self
.
victim
.
currentOperator
.
totalWorkingTime
+=
now
()
-
self
.
victim
.
currentOperator
.
timeLastOperationStarted
# TODO: cannot be implemented at the moment as the Machine first releases the operator and then
# signals the receiver when the removeEntity signals the victimQueueIsEmpty
# if the victim releasing the operator has receiver
# if self.victim.receiver:
# # if the following object is not of type Machine
# if self.victim.receiver.type!='Machine':
# # if the processingType is 'Processing' and not only 'Load' or 'Setup'
# if any(type=='Processing' for type in self.victim.multOperationTypeList):
# # wait until the victim has released the entity it was processing
# # TODO: add new event, to be signalled from the Machine removeEntity
# yield waitevent, self, self.victimQueueIsEmpty
# assert self.victimQueueIsEmpty.signalparam==now(), 'the broker should be granted control instantly'
#self.victim.outputTrace(self.victim.currentOperator.objName, "left "+ self.victim.objName)
self
.
victim
.
outputTrace
(
self
.
victim
.
currentOperator
.
objName
,
"left "
+
self
.
victim
.
objName
)
yield
release
,
self
,
self
.
victim
.
operatorPool
.
getResource
(
self
.
victim
.
currentOperator
)
# signal the other brokers waiting for the same operators that they are now free
# also signal the stations that were not requested to receive because the operator was occupied
...
...
@@ -191,73 +150,4 @@ class Broker(ObjectInterruption):
pass
# TODO: the victim must have a new event brokerIsSet
self
.
victim
.
brokerIsSet
.
signal
(
now
())
# #===========================================================================
# # signal stations that wait for load operators
# #===========================================================================
# def signalLoadStations(self):
# # signal the other brokers waiting for the same operators that they are now free
# # also signal the stations that were not requested to receive because the operator was occupied
# # but now must have the option to proceed
# from Globals import G
# candidateMachines=[]
# loadPendingMachines=[]
# # print ' have to signal machines that are waiting for operator', self.victim.id, 'broker'
# # run through the operatorPools
# # TODO: MachineManagedJob operatorPool is not in the global OperatorPoolsList
# for operatorpool in G.OperatorPoolsList:
# # print operatorpool.id
# # and find the machines the share the currentOperator with the Broker.victim
# if self.victim.currentOperator in operatorpool.operators:
# # print ' current operator in other operatorPools', operatorpool.id
# # print ' ', [str(x.id) for x in operatorpool.coreObjects]
# for machine in operatorpool.coreObjects:
# # if the machine waits to get an operator add it to the candidateMachines local list
# if machine.broker.waitForOperator:
# candidateMachines.append(machine)
# # cause an loadOperatorAvailable event if any of this machines can accept and has Load operation type defined
# if machine.canAccept() and any(type=='Load' for type in machine.multOperationTypeList):
# loadPendingMachines.append(machine)
# #===============================================
# # # TESTING
# print now(), self.victim.id, 'broker signalling', machine.id, 'loadOperatorAvailable1'
# #===============================================
# machine.loadOperatorAvailable.signal(now())
#
# # if the machines are MachineManagedJobs their OperatorPool is empty while their canAcceptAndIsRequested has not returned True
# # In order to signal them that the loadOperator is free, find the entities that have that operator, search for the possible receivers that
# # can accept signal them
# for machine in G.MachineManagedJobList:
# if self.victim.currentOperator in machine.operatorPool.operators:
# if machine.broker.waitForOperator:
# candidateMachines.append(machine)
# for entity in G.pendingEntities:
# if machine.canAcceptEntity(entity) and any(type=='Load' for type in machine.multOperationTypeList):
# loadPendingMachines.append(machine)
# #===============================================
# # # TESTING
# print now(), self.victim.id, 'broker signalling ', machine.id, 'loadOperatorAvailable2'
# #===============================================
# machine.loadOperatorAvailable.signal(now())
#
# # print 'machines waitingForLoadOperator',[str(x.id) for x in loadPendingMachines]
# # print 'machines waitingForOperator',[str(x.id) for x in candidateMachines]
#
#
# # for the candidateMachines
# if candidateMachines:
# maxTimeWaiting=0
# receiver=None
# # choose the one that waits the most time and give it the chance to grasp the resource
# for machine in candidateMachines:
# timeWaiting=now()-machine.broker.timeWaitForOperatorStarted
# if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):
# maxTimeWaiting=timeWaiting
# receiver=machine
# #===========================================================
# # # TESTING
# # print now(), self.victim.id, 'broker signalling', machine.id, 'resourceAvailable'
# #===========================================================
# # finally signal the machine to receive the operator
# receiver.broker.resourceAvailable.signal(now())
\ No newline at end of file
dream/simulation/OperatorRouter.py
View file @
5bb1846e
...
...
@@ -315,9 +315,9 @@ class Router(ObjectInterruption):
self
.
pendingObjects
=
self
.
pendingQueues
+
self
.
pendingMachines
#=======================================================================
# # testing
# print 'router found pending objects',
[object.id
for object in self.pendingObjects]
# print 'pendingMachines',
[object.id
for object in self.pendingMachines]
# print 'pendingQueues',
[object.id
for object in self.pendingQueues]
# print 'router found pending objects',
'-'*6,'>', [str(object.id)
for object in self.pendingObjects]
# print 'pendingMachines',
'-'*19,'>', [str(object.id)
for object in self.pendingMachines]
# print 'pendingQueues',
'-'*21,'>', [str(object.id)
for object in self.pendingQueues]
#=======================================================================
#===========================================================================
...
...
@@ -340,9 +340,7 @@ class Router(ObjectInterruption):
self
.
managed
=
True
#=======================================================================
# # testing
# print 'found pending entities'
# print 'ROUTER PENDING',[entity.id for entity in self.pending if not entity.type=='Part']
# print 'GLOBAL PENDING',[entity.id for entity in G.pendingEntities if not entity.type=='Part']
# print 'found pending entities', '-'*12,'>', [str(entity.id) for entity in self.pending if not entity.type=='Part']
#=======================================================================
#========================================================================
...
...
@@ -361,15 +359,20 @@ class Router(ObjectInterruption):
if
not
self
.
managed
:
# if there are pendingEntities
if
self
.
pendingObjects
:
# for each pendingObject
for
object
in
self
.
pendingObjects
:
# if it is a machine
if
object
in
self
.
pendingMachines
:
if
object
.
operatorPool
.
checkIfResourceIsAvailable
():
candidateOperator
=
object
.
operatorPool
.
findAvailableOperator
()
# TODO: this way no sorting is performed
if
not
candidateOperator
in
self
.
candidateOperators
:
self
.
candidateOperators
.
append
(
candidateOperator
)
candidateOperator
.
candidateStations
.
append
(
object
)
# find an available operator
candidateOperator
=
object
.
operatorPool
.
findAvailableOperator
()
# TODO: this way no sorting is performed
if
not
candidateOperator
in
self
.
candidateOperators
:
self
.
candidateOperators
.
append
(
candidateOperator
)
# for each operator append the station into its candidateStations
candidateOperator
.
candidateStations
.
append
(
object
)
# if it is a queue
elif
object
in
self
.
pendingQueues
:
# find available operator for then machines that follow
for
nextobject
in
object
.
next
:
if
nextobject
.
canAccept
(
object
):
candidateOperator
=
nextobject
.
operatorPool
.
findAvailableOperator
()
...
...
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