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
5db2ef98
Commit
5db2ef98
authored
Apr 02, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Router now waits for event triggered by Machine
parent
5a39d707
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
27 deletions
+23
-27
dream/simulation/Machine.py
dream/simulation/Machine.py
+8
-2
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+15
-25
No files found.
dream/simulation/Machine.py
View file @
5db2ef98
...
...
@@ -25,8 +25,8 @@ Created on 8 Nov 2012
Models a machine that can also have failures
'''
from
SimPy.Simulation
import
Process
,
Resource
from
SimPy.Simulation
import
activate
,
passivate
,
waituntil
,
now
,
hold
,
request
,
release
from
SimPy.Simulation
import
Process
,
Resource
,
SimEvent
from
SimPy.Simulation
import
activate
,
passivate
,
waituntil
,
now
,
hold
,
request
,
release
,
waitevent
from
Failure
import
Failure
from
CoreObject
import
CoreObject
...
...
@@ -137,10 +137,13 @@ class Machine(CoreObject):
self
.
isPreemptive
=
isPreemptive
self
.
resetOnPreemption
=
resetOnPreemption
self
.
routerCycleOver
=
SimEvent
(
'routerCycleOver'
)
# =======================================================================
# initialize the machine
# =======================================================================
def
initialize
(
self
):
# TODO: initialise Router for every replication
# using the Process __init__ and not the CoreObject __init__
CoreObject
.
initialize
(
self
)
# initialize the internal Queue (type Resource) of the Machine
...
...
@@ -216,8 +219,11 @@ class Machine(CoreObject):
and
any
(
type
==
"Load"
for
type
in
self
.
multOperationTypeList
):
# the machine informs the router that it can receive from a requesting object
self
.
requestRouter
()
self
.
router
.
startCycle
.
signal
(
self
.
id
)
# the machine must wait until the router has decided which machine will operated by which operator
# yield waitevent, self, self.routerCycleOver
yield
waituntil
,
self
,
self
.
router
.
routerIsSet
self
.
router
.
victim
=
None
# if the machine is not picked by the router the it should wait again
if
not
self
.
canProceedWithGetEntity
:
continue
...
...
dream/simulation/OperatorRouter.py
View file @
5db2ef98
...
...
@@ -26,9 +26,9 @@ Created on 19 Feb 2013
Models an Interruption that schedules the operation of the machines by different managers
'''
from
SimPy.Simulation
import
Process
,
Resource
from
SimPy.Simulation
import
Process
,
Resource
,
SimEvent
from
ObjectInterruption
import
ObjectInterruption
from
SimPy.Simulation
import
waituntil
,
now
,
hold
,
request
,
release
from
SimPy.Simulation
import
waituntil
,
now
,
hold
,
request
,
release
,
waitevent
# ===========================================================================
...
...
@@ -49,6 +49,8 @@ class Router(ObjectInterruption):
# list that holds all the objects that can receive
self
.
pendingObjects
=
[]
self
.
calledOperators
=
[]
# signal used to initiate the generator of the Router
self
.
startCycle
=
SimEvent
(
'startCycle'
)
# # TODO: consider if there must be an argument set for the schedulingRules of the Router
# self.schedulingRule=''
# list of the operators that may handle a machine at the current simulation time
...
...
@@ -57,6 +59,7 @@ class Router(ObjectInterruption):
self
.
multipleCriterionList
=
[]
# TODO: find out which must be the default for the scheduling Rule
self
.
schedulingRule
=
'WT'
# TODO: create an initialise method for router to reset the attributes for every replication
# =======================================================================
# the run method
...
...
@@ -68,15 +71,17 @@ class Router(ObjectInterruption):
returns canAcceptAndIsRequested (inPositionToGet is True)
'''
def
run
(
self
):
from
Globals
import
G
from
Globals
import
G
,
findObjectById
while
1
:
# wait until the router is called
yield
waituntil
,
self
,
self
.
routerIsCalled
yield
waitevent
,
self
,
self
.
startCycle
self
.
victim
=
findObjectById
(
self
.
startCycle
.
signalparam
)
# yield waituntil,self,self.routerIsCalled
# when the router is called for the first time wait till all the entities
# finished all their moves in stations of non-Machine-type
# before they can enter again a type-Machine object
yield
waituntil
,
self
,
self
.
entitiesFinishedMoving
# update the objects to be served list (pendingObjects)
self
.
pendingObjects
=
[
object
for
object
in
G
.
MachineList
if
object
.
inPositionToGet
]
...
...
@@ -178,6 +183,10 @@ class Router(ObjectInterruption):
# 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
...
...
@@ -281,6 +290,7 @@ class Router(ObjectInterruption):
self
.
schedulingRule
=
'WT'
# reset the call flag of the Router
self
.
call
=
False
# self.victim.routerCycleOver.signal('router has implemented its logic')
#=======================================================================
# Sort pendingEntities
...
...
@@ -461,26 +471,6 @@ class Router(ObjectInterruption):
if
operator
.
candidateEntity
:
operator
.
candidateEntity
.
candidateReceiver
=
findCandidateReceiver
()
# # initiate the local list variable available receivers
# availableReceivers=[x for x in operator.candidateEntity.candidateReceivers\
# if not x in occupiedReceivers]
# # and pick the object that is waiting for the most time
# if availableReceivers:
# # TODO: must find the receiver that waits the most
# maxTimeWaiting=0
# for object in availableReceivers:
# timeWaiting=now()-object.timeLastEntityLeft
# if(timeWaiting>maxTimeWaiting or maxTimeWaiting==0):
# maxTimeWaiting=timeWaiting
# availableReceiver=object
#
# operator.candidateEntity.candidateReceiver=availableReceiver
# occupiedReceivers.append(availableReceiver)
# # if there is no available receiver add the entity to the entitiesWithOccupiedReceivers list
# else:
# entitiesWithOccupiedReceivers.append(availableEntity)
# operator.candidateEntity.candidateReceiver=None
#=======================================================================
# Sort Givers
...
...
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