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
5e3129ab
Commit
5e3129ab
authored
Apr 02, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
methods used by broker and router collapsed to ObjectInterruption
parent
5a9dfa2d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
80 deletions
+52
-80
dream/simulation/Machine.py
dream/simulation/Machine.py
+13
-13
dream/simulation/ObjectInterruption.py
dream/simulation/ObjectInterruption.py
+31
-1
dream/simulation/OperatedPoolBroker.py
dream/simulation/OperatedPoolBroker.py
+2
-37
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+6
-29
No files found.
dream/simulation/Machine.py
View file @
5e3129ab
...
@@ -229,7 +229,7 @@ class Machine(CoreObject):
...
@@ -229,7 +229,7 @@ class Machine(CoreObject):
self
.
router
.
startCycle
.
signal
(
self
.
id
)
self
.
router
.
startCycle
.
signal
(
self
.
id
)
# the machine must wait until the router has decided which machine will operated by which operator
# the machine must wait until the router has decided which machine will operated by which operator
# yield waitevent, self, self.routerCycleOver
# yield waitevent, self, self.routerCycleOver
yield
waituntil
,
self
,
self
.
router
.
routerI
sSet
yield
waituntil
,
self
,
self
.
router
.
i
sSet
self
.
router
.
victim
=
None
self
.
router
.
victim
=
None
# if the machine is not picked by the router the it should wait again
# if the machine is not picked by the router the it should wait again
if
not
self
.
canProceedWithGetEntity
:
if
not
self
.
canProceedWithGetEntity
:
...
@@ -250,7 +250,7 @@ class Machine(CoreObject):
...
@@ -250,7 +250,7 @@ class Machine(CoreObject):
self
.
requestOperator
()
self
.
requestOperator
()
self
.
timeWaitForLoadOperatorStarted
=
now
()
self
.
timeWaitForLoadOperatorStarted
=
now
()
# wait until the Broker has waited times equal to loadTime (if any)
# wait until the Broker has waited times equal to loadTime (if any)
yield
waituntil
,
self
,
self
.
broker
.
brokerI
sSet
yield
waituntil
,
self
,
self
.
broker
.
i
sSet
self
.
timeWaitForLoadOperatorEnded
=
now
()
self
.
timeWaitForLoadOperatorEnded
=
now
()
self
.
loadOperatorWaitTimeCurrentEntity
+=
self
.
timeWaitForLoadOperatorEnded
-
self
.
timeWaitForLoadOperatorStarted
self
.
loadOperatorWaitTimeCurrentEntity
+=
self
.
timeWaitForLoadOperatorEnded
-
self
.
timeWaitForLoadOperatorStarted
self
.
totalTimeWaitingForLoadOperator
+=
self
.
loadOperatorWaitTimeCurrentEntity
self
.
totalTimeWaitingForLoadOperator
+=
self
.
loadOperatorWaitTimeCurrentEntity
...
@@ -274,7 +274,7 @@ class Machine(CoreObject):
...
@@ -274,7 +274,7 @@ class Machine(CoreObject):
# machine has to release the operator
# machine has to release the operator
self
.
releaseOperator
()
self
.
releaseOperator
()
# wait until the Broker has finished processing
# wait until the Broker has finished processing
yield
waituntil
,
self
,
self
.
broker
.
brokerI
sSet
yield
waituntil
,
self
,
self
.
broker
.
i
sSet
# TODO: reset the requestinEntity before receiving the currentEntity
# TODO: reset the requestinEntity before receiving the currentEntity
self
.
requestingEntity
=
None
self
.
requestingEntity
=
None
...
@@ -296,7 +296,7 @@ class Machine(CoreObject):
...
@@ -296,7 +296,7 @@ class Machine(CoreObject):
self
.
requestOperator
()
self
.
requestOperator
()
self
.
timeWaitForOperatorStarted
=
now
()
self
.
timeWaitForOperatorStarted
=
now
()
# wait until the Broker has waited times equal to loadTime (if any)
# wait until the Broker has waited times equal to loadTime (if any)
yield
waituntil
,
self
,
self
.
broker
.
brokerI
sSet
yield
waituntil
,
self
,
self
.
broker
.
i
sSet
self
.
timeWaitForOperatorEnded
=
now
()
self
.
timeWaitForOperatorEnded
=
now
()
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
...
@@ -325,7 +325,7 @@ class Machine(CoreObject):
...
@@ -325,7 +325,7 @@ class Machine(CoreObject):
# machine has to release the operator
# machine has to release the operator
self
.
releaseOperator
()
self
.
releaseOperator
()
# wait until the Broker has finished processing
# wait until the Broker has finished processing
yield
waituntil
,
self
,
self
.
broker
.
brokerI
sSet
yield
waituntil
,
self
,
self
.
broker
.
i
sSet
# variables used to flag any interruptions and the end of the processing
# variables used to flag any interruptions and the end of the processing
interruption
=
False
interruption
=
False
...
@@ -370,7 +370,7 @@ class Machine(CoreObject):
...
@@ -370,7 +370,7 @@ class Machine(CoreObject):
and
self
.
isOperated
()
\
and
self
.
isOperated
()
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
):
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
):
self
.
releaseOperator
()
self
.
releaseOperator
()
yield
waituntil
,
self
,
self
.
broker
.
brokerI
sSet
yield
waituntil
,
self
,
self
.
broker
.
i
sSet
# if there is a failure in the machine or interruption due to preemption, it is passivated
# if there is a failure in the machine or interruption due to preemption, it is passivated
yield
passivate
,
self
yield
passivate
,
self
...
@@ -392,7 +392,7 @@ class Machine(CoreObject):
...
@@ -392,7 +392,7 @@ class Machine(CoreObject):
and
not
interruption
:
and
not
interruption
:
self
.
timeWaitForOperatorStarted
=
now
()
self
.
timeWaitForOperatorStarted
=
now
()
self
.
requestOperator
()
self
.
requestOperator
()
yield
waituntil
,
self
,
self
.
broker
.
brokerI
sSet
yield
waituntil
,
self
,
self
.
broker
.
i
sSet
self
.
timeWaitForOperatorEnded
=
now
()
self
.
timeWaitForOperatorEnded
=
now
()
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
...
@@ -410,7 +410,7 @@ class Machine(CoreObject):
...
@@ -410,7 +410,7 @@ class Machine(CoreObject):
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
not
interruption
:
and
not
interruption
:
self
.
releaseOperator
()
self
.
releaseOperator
()
yield
waituntil
,
self
,
self
.
broker
.
brokerI
sSet
yield
waituntil
,
self
,
self
.
broker
.
i
sSet
continue
continue
# output to trace that the processing in the Machine self.objName ended
# output to trace that the processing in the Machine self.objName ended
...
@@ -444,7 +444,7 @@ class Machine(CoreObject):
...
@@ -444,7 +444,7 @@ class Machine(CoreObject):
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
not
interruption
:
and
not
interruption
:
self
.
releaseOperator
()
self
.
releaseOperator
()
yield
waituntil
,
self
,
self
.
broker
.
brokerI
sSet
yield
waituntil
,
self
,
self
.
broker
.
i
sSet
while
1
:
while
1
:
...
@@ -738,14 +738,14 @@ class Machine(CoreObject):
...
@@ -738,14 +738,14 @@ class Machine(CoreObject):
# # TESTING
# # TESTING
# print now(), self.id, 'requested router'
# print now(), self.id, 'requested router'
self
.
inPositionToGet
=
True
self
.
inPositionToGet
=
True
if
not
self
.
router
.
routerI
sCalled
():
if
not
self
.
router
.
i
sCalled
():
self
.
router
.
invoke
Router
()
self
.
router
.
invoke
()
# =======================================================================
# =======================================================================
# prepare the machine to be operated
# prepare the machine to be operated
# =======================================================================
# =======================================================================
def
requestOperator
(
self
):
def
requestOperator
(
self
):
self
.
broker
.
invoke
Broker
()
self
.
broker
.
invoke
()
self
.
toBeOperated
=
True
self
.
toBeOperated
=
True
# =======================================================================
# =======================================================================
...
@@ -762,7 +762,7 @@ class Machine(CoreObject):
...
@@ -762,7 +762,7 @@ class Machine(CoreObject):
or
any
(
type
==
'Processing'
for
type
in
self
.
multOperationTypeList
)):
or
any
(
type
==
'Processing'
for
type
in
self
.
multOperationTypeList
)):
self
.
currentOperator
.
activeCallersList
=
[]
self
.
currentOperator
.
activeCallersList
=
[]
self
.
broker
.
invoke
Broker
()
self
.
broker
.
invoke
()
self
.
toBeOperated
=
False
self
.
toBeOperated
=
False
# =======================================================================
# =======================================================================
...
...
dream/simulation/ObjectInterruption.py
View file @
5e3129ab
...
@@ -33,15 +33,45 @@ class ObjectInterruption(Process):
...
@@ -33,15 +33,45 @@ class ObjectInterruption(Process):
def
__init__
(
self
,
victim
=
None
):
def
__init__
(
self
,
victim
=
None
):
Process
.
__init__
(
self
)
Process
.
__init__
(
self
)
self
.
victim
=
victim
self
.
victim
=
victim
# variable used to hand in control to the objectInterruption
self
.
call
=
False
def
initialize
(
self
):
def
initialize
(
self
):
Process
.
__init__
(
self
)
Process
.
__init__
(
self
)
self
.
call
=
False
#the main process of the core object
#the main process of the core object
#this is dummy, every object must have its own implementation
#this is dummy, every object must have its own implementation
def
run
(
self
):
def
run
(
self
):
raise
NotImplementedError
(
"Subclass must define 'run' method"
)
raise
NotImplementedError
(
"Subclass must define 'run' method"
)
# =======================================================================
# hand in the control to the objectIterruption.run
# to be called by the machine
# =======================================================================
def
invoke
(
self
):
self
.
call
=
True
# =======================================================================
# return control to the Machine.run
# =======================================================================
def
exit
(
self
):
self
.
call
=
False
# =======================================================================
# call the objectInterruption
# filter for object interruption - yield waituntil isCalled
# =======================================================================
def
isCalled
(
self
):
return
self
.
call
# =======================================================================
# the objectIterruption returns control to machine.Run
# filter for Machine - yield request/release operator
# =======================================================================
def
isSet
(
self
):
return
not
self
.
call
#outputs data to "output.xls"
#outputs data to "output.xls"
def
outputTrace
(
self
,
message
):
def
outputTrace
(
self
,
message
):
pass
pass
...
...
dream/simulation/OperatedPoolBroker.py
View file @
5e3129ab
...
@@ -43,8 +43,6 @@ class Broker(ObjectInterruption):
...
@@ -43,8 +43,6 @@ class Broker(ObjectInterruption):
def
__init__
(
self
,
operatedMachine
):
def
__init__
(
self
,
operatedMachine
):
ObjectInterruption
.
__init__
(
self
,
operatedMachine
)
ObjectInterruption
.
__init__
(
self
,
operatedMachine
)
self
.
type
=
"Broker"
self
.
type
=
"Broker"
# variable used to hand in control to the Broker
self
.
call
=
False
# variables that have to do with timing
# variables that have to do with timing
self
.
timeOperationStarted
=
0
self
.
timeOperationStarted
=
0
self
.
timeLastOperationEnded
=
0
self
.
timeLastOperationEnded
=
0
...
@@ -55,7 +53,6 @@ class Broker(ObjectInterruption):
...
@@ -55,7 +53,6 @@ class Broker(ObjectInterruption):
#===========================================================================
#===========================================================================
def
initialize
(
self
):
def
initialize
(
self
):
ObjectInterruption
.
initialize
(
self
)
ObjectInterruption
.
initialize
(
self
)
self
.
call
=
False
self
.
timeLastOperationEnded
=
0
self
.
timeLastOperationEnded
=
0
self
.
timeOperationStarted
=
0
self
.
timeOperationStarted
=
0
self
.
timeWaitForOperatorStarted
=
0
self
.
timeWaitForOperatorStarted
=
0
...
@@ -65,7 +62,7 @@ class Broker(ObjectInterruption):
...
@@ -65,7 +62,7 @@ class Broker(ObjectInterruption):
# =======================================================================
# =======================================================================
def
run
(
self
):
def
run
(
self
):
while
1
:
while
1
:
yield
waituntil
,
self
,
self
.
brokerI
sCalled
# wait until the broker is called
yield
waituntil
,
self
,
self
.
i
sCalled
# wait until the broker is called
# ======= request a resource
# ======= request a resource
if
self
.
victim
.
isOperated
()
\
if
self
.
victim
.
isOperated
()
\
and
any
(
type
==
"Load"
or
type
==
"Setup"
or
type
==
"Processing"
\
and
any
(
type
==
"Load"
or
type
==
"Setup"
or
type
==
"Processing"
\
...
@@ -109,37 +106,5 @@ class Broker(ObjectInterruption):
...
@@ -109,37 +106,5 @@ class Broker(ObjectInterruption):
else
:
else
:
pass
pass
# return the control the machine.run
# return the control the machine.run
self
.
exitBroker
()
self
.
exit
()
# =======================================================================
# call the broker
# filter for Broker - yield waituntil brokerIsCalled
# =======================================================================
def
brokerIsCalled
(
self
):
return
self
.
call
# =======================================================================
# the broker returns control to OperatedMachine.Run
# filter for Machine - yield request/release operator
# =======================================================================
def
brokerIsSet
(
self
):
return
not
self
.
call
# =======================================================================
# hand in the control to the Broker.run
# to be called by the machine
# =======================================================================
def
invokeBroker
(
self
):
self
.
call
=
True
# =======================================================================
# return control to the Machine.run
# =======================================================================
def
exitBroker
(
self
):
self
.
call
=
False
\ No newline at end of file
dream/simulation/OperatorRouter.py
View file @
5e3129ab
...
@@ -44,8 +44,6 @@ class Router(ObjectInterruption):
...
@@ -44,8 +44,6 @@ class Router(ObjectInterruption):
def
__init__
(
self
):
def
__init__
(
self
):
ObjectInterruption
.
__init__
(
self
)
ObjectInterruption
.
__init__
(
self
)
self
.
type
=
"Router"
self
.
type
=
"Router"
# variable used to hand in control to the Broker
self
.
call
=
False
# signal used to initiate the generator of the Router
# signal used to initiate the generator of the Router
self
.
startCycle
=
SimEvent
(
'startCycle'
)
self
.
startCycle
=
SimEvent
(
'startCycle'
)
# TODO: create an initialise method for router to reset the attributes for every replication
# TODO: create an initialise method for router to reset the attributes for every replication
...
@@ -59,7 +57,6 @@ class Router(ObjectInterruption):
...
@@ -59,7 +57,6 @@ class Router(ObjectInterruption):
#===========================================================================
#===========================================================================
def
initialize
(
self
):
def
initialize
(
self
):
ObjectInterruption
.
initialize
(
self
)
ObjectInterruption
.
initialize
(
self
)
self
.
call
=
False
# list that holds all the objects that can receive
# list that holds all the objects that can receive
self
.
pendingObjects
=
[]
self
.
pendingObjects
=
[]
self
.
calledOperator
=
[]
self
.
calledOperator
=
[]
...
@@ -87,7 +84,8 @@ class Router(ObjectInterruption):
...
@@ -87,7 +84,8 @@ class Router(ObjectInterruption):
yield
waitevent
,
self
,
self
.
startCycle
yield
waitevent
,
self
,
self
.
startCycle
self
.
victim
=
findObjectById
(
self
.
startCycle
.
signalparam
)
self
.
victim
=
findObjectById
(
self
.
startCycle
.
signalparam
)
# yield waituntil,self,self.routerIsCalled
# yield waituntil,self,self.isCalled
# when the router is called for the first time wait till all the entities
# when the router is called for the first time wait till all the entities
# finished all their moves in stations of non-Machine-type
# finished all their moves in stations of non-Machine-type
# before they can enter again a type-Machine object
# before they can enter again a type-Machine object
...
@@ -214,7 +212,7 @@ class Router(ObjectInterruption):
...
@@ -214,7 +212,7 @@ class Router(ObjectInterruption):
# print [str(object.id) for object in self.pendingObjects if object.canProceedWithGetEntity]
# print [str(object.id) for object in self.pendingObjects if object.canProceedWithGetEntity]
#===================================================================
#===================================================================
self
.
exit
Router
()
self
.
exit
()
#===========================================================================
#===========================================================================
# have the entities that have ended their processing when the router
# have the entities that have ended their processing when the router
...
@@ -259,31 +257,10 @@ class Router(ObjectInterruption):
...
@@ -259,31 +257,10 @@ class Router(ObjectInterruption):
return
True
return
True
return
True
return
True
# =======================================================================
# call the Scheduler
# filter for Broker - yield waituntil brokerIsCalled
# =======================================================================
def
routerIsCalled
(
self
):
return
self
.
call
# =======================================================================
# the broker returns control to OperatedMachine.Run
# filter for Machine - yield request/release operator
# =======================================================================
def
routerIsSet
(
self
):
return
not
self
.
call
# =======================================================================
# hand in the control to the Broker.run
# to be called by the machine
# =======================================================================
def
invokeRouter
(
self
):
self
.
call
=
True
# =======================================================================
# =======================================================================
# return control to the Machine.run
# return control to the Machine.run
# =======================================================================
# =======================================================================
def
exit
Router
(
self
):
def
exit
(
self
):
from
Globals
import
G
from
Globals
import
G
# reset the variables that are used from the Router
# reset the variables that are used from the Router
for
operator
in
self
.
candidateOperators
:
for
operator
in
self
.
candidateOperators
:
...
@@ -298,8 +275,8 @@ class Router(ObjectInterruption):
...
@@ -298,8 +275,8 @@ class Router(ObjectInterruption):
del
self
.
pendingObjects
[:]
del
self
.
pendingObjects
[:]
del
self
.
multipleCriterionList
[:]
del
self
.
multipleCriterionList
[:]
self
.
schedulingRule
=
'WT'
self
.
schedulingRule
=
'WT'
# reset the call flag of the Router
self
.
call
=
False
ObjectInterruption
.
exit
(
self
)
# self.victim.routerCycleOver.signal('router has implemented its logic')
# self.victim.routerCycleOver.signal('router has implemented its logic')
#=======================================================================
#=======================================================================
...
...
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