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
a689804e
Commit
a689804e
authored
Apr 23, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Broker code rearranged. Prints added
parent
1acc04cb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
57 deletions
+153
-57
dream/simulation/Machine.py
dream/simulation/Machine.py
+1
-0
dream/simulation/MachineManagedJob.py
dream/simulation/MachineManagedJob.py
+1
-0
dream/simulation/MouldAssemblyBuffer.py
dream/simulation/MouldAssemblyBuffer.py
+1
-0
dream/simulation/OperatedPoolBroker.py
dream/simulation/OperatedPoolBroker.py
+143
-55
dream/simulation/OrderDecomposition.py
dream/simulation/OrderDecomposition.py
+2
-0
dream/simulation/Queue.py
dream/simulation/Queue.py
+5
-2
No files found.
dream/simulation/Machine.py
View file @
a689804e
...
...
@@ -237,6 +237,7 @@ class Machine(CoreObject):
# if an interruption caused the control to be taken by the machine or
# if an operator was rendered available while it was needed by the machine to proceed with getEntity
if
self
.
interruptionEnd
.
signalparam
==
now
()
or
self
.
loadOperatorAvailable
.
signalparam
==
now
():
# print now(), self.id, 'received an other type of event sent at ', self.loadOperatorAvailable.signalparam
# try to signal the Giver, otherwise wait until it is requested
if
self
.
signalGiver
():
break
...
...
dream/simulation/MachineManagedJob.py
View file @
a689804e
...
...
@@ -125,6 +125,7 @@ class MachineManagedJob(MachineJobShop):
if
activeObject
.
checkIfActive
()
and
len
(
activeObjectQueue
)
<
activeObject
.
capacity
\
and
activeObject
.
checkOperator
():
if
not
giverObject
.
exitIsAssignedTo
():
# print self.id, 'assigning givers exit'
giverObject
.
assignExitTo
()
elif
giverObject
.
exitIsAssignedTo
()
!=
activeObject
:
return
False
...
...
dream/simulation/MouldAssemblyBuffer.py
View file @
a689804e
...
...
@@ -108,6 +108,7 @@ class MouldAssemblyBuffer(QueueManagedJob):
# TODO: has to signal ConditionalBuffer to start sending entities again
for
secondary
in
[
x
for
x
in
activeEntity
.
order
.
secondaryComponentsList
if
activeEntity
.
order
.
basicsEnded
]:
if
secondary
.
currentStation
.
__class__
.
__name__
==
'ConditionalBuffer'
:
# print now(), self.id, ' signalling conditional buffer'
secondary
.
currentStation
.
canDispose
.
signal
(
now
())
break
# for all the components that have the same parent Order as the activeEntity
...
...
dream/simulation/OperatedPoolBroker.py
View file @
a689804e
...
...
@@ -80,7 +80,7 @@ class Broker(ObjectInterruption):
# 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 available
'
# print now(), self.victim.id, 'broker waits till resource is available1
'
yield
waitevent
,
self
,
self
.
resourceAvailable
self
.
waitForOperator
=
False
# print self.victim.id, 'received resourceAvailable event'
...
...
@@ -91,7 +91,7 @@ class Broker(ObjectInterruption):
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
,
'broker waits till resource is available
'
# 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'
...
...
@@ -128,68 +128,70 @@ class Broker(ObjectInterruption):
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
# 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
# TODO: find the machineManagedJobs.entityToGet.managerers and search there
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, 'loadOperatorAvailable'
#===============================================
machine
.
loadOperatorAvailable
.
signal
(
now
())
# print 'machines waitingForLoadOperator',[str(x.id) for x in loadPendingMachines]
# print 'machines waitingForOperator',[str(x.id) for x in candidateMachines]
self
.
signalLoadStations
()
# # 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
# # TODO: find the machineManagedJobs.entityToGet.managerers and search there
# 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, 'loadOperatorAvailable'
# #===============================================
# 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 loadPendingMachines:
# # maxTimeWaiting=0
# # receiver=None
# # # choose the one that waits the most time and give it the chance to grasp the resource
# # # TODO: failures after the end of processing are not considered here
# # for machine in loadPendingMachines:
# # timeWaiting=now()-machine.timeLastEntityEnded
# # if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):
# # maxTimeWaiting=timeWaiting
# # receiver=machine
# # #===============================================
# # # # TESTING
# # # print now(), self.victim.id, 'broker signalling', machine.id, 'loadOperatorAvailable'
# # #===============================================
# # # finally signal the machine to receive the operator
# # receiver.loadOperatorAvailable.signal(now())
#
# # for the candidateMachines
# if
loadPending
Machines:
# if
candidate
Machines:
# maxTimeWaiting=0
# receiver=None
# # choose the one that waits the most time and give it the chance to grasp the resource
# # TODO: failures after the end of processing are not considered here
# for machine in loadPendingMachines:
# timeWaiting=now()-machine.timeLastEntityEnded
# 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, '
loadOperator
Available'
# #===============================================
# # print now(), self.victim.id, 'broker signalling', machine.id, '
resource
Available'
# #===============================================
============
# # finally signal the machine to receive the operator
# receiver.loadOperatorAvailable.signal(now())
# 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
())
# receiver.broker.resourceAvailable.signal(now())
#===============================================================
# # TESTING
...
...
@@ -203,4 +205,90 @@ class Broker(ObjectInterruption):
# TODO: exit method can perform the signalling
# 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 loadPendingMachines:
# maxTimeWaiting=0
# receiver=None
# # choose the one that waits the most time and give it the chance to grasp the resource
# # TODO: failures after the end of processing are not considered here
# for machine in loadPendingMachines:
# timeWaiting=now()-machine.timeLastEntityEnded
# if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):
# maxTimeWaiting=timeWaiting
# receiver=machine
# #===============================================
# # # TESTING
# # print now(), self.victim.id, 'broker signalling', machine.id, 'loadOperatorAvailable'
# #===============================================
# # finally signal the machine to receive the operator
# receiver.loadOperatorAvailable.signal(now())
# 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/OrderDecomposition.py
View file @
a689804e
...
...
@@ -79,6 +79,7 @@ class OrderDecomposition(CoreObject):
self
.
decompose
()
# if the event that activated the thread is canDispose then signalReceiver
if
self
.
haveToDispose
():
# print now(), self.id, 'will try to signal a receiver from generator'
self
.
signalReceiver
()
# =======================================================================
...
...
@@ -90,6 +91,7 @@ class OrderDecomposition(CoreObject):
if
self
.
canAccept
():
self
.
signalGiver
()
if
self
.
haveToDispose
():
# print now(), self.id, 'will try to signal a receiver from removeEntity'
self
.
signalReceiver
()
return
activeEntity
...
...
dream/simulation/Queue.py
View file @
a689804e
...
...
@@ -97,14 +97,17 @@ class Queue(CoreObject):
# print now(), self.id, 'just received an event'
# if the event that activated the thread is isRequested then getEntity
if
self
.
isRequested
.
signalparam
:
# print now(), self.id, 'received a isRequested event from', self.isRequested.signalparam.id
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
self
.
getEntity
()
#if entity just got to the dummyQ set its startTime as the current time
if
self
.
isDummy
:
activeObjectQueue
[
0
].
startTime
=
now
()
# if self.canDispose.signalparam:
# print now(), self.id, 'received a canDispose event from', self.canDispose.signalparam.id
# if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer
if
self
.
canDispose
.
signalparam
:
# print now(), self.id, 'received a canDispose event from', self.canDispose.signalparam
self
.
canDispose
.
signalparam
=
None
# if the event that activated the thread is canDispose then signalReceiver
if
self
.
haveToDispose
():
# print now(), self.id, 'will try to signal a receiver from generator'
...
...
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