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
16899abd
Commit
16899abd
authored
May 28, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new event entityRemoved added to handle inconsistency of timeout(0) while waiting to dispose a unit
parent
9bf41014
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+9
-1
dream/simulation/Dismantle.py
dream/simulation/Dismantle.py
+10
-6
No files found.
dream/simulation/CoreObject.py
View file @
16899abd
...
@@ -66,6 +66,8 @@ class CoreObject(object):
...
@@ -66,6 +66,8 @@ class CoreObject(object):
# self.interruptionStart=SimEvent('interruptionStart')
# self.interruptionStart=SimEvent('interruptionStart')
self
.
interruptionStart
=
self
.
env
.
event
()
self
.
interruptionStart
=
self
.
env
.
event
()
self
.
entityRemoved
=
self
.
env
.
event
()
def
initialize
(
self
):
def
initialize
(
self
):
# XXX why call super.__init__ outside of __init__ ?
# XXX why call super.__init__ outside of __init__ ?
# Process.__init__(self)
# Process.__init__(self)
...
@@ -149,6 +151,8 @@ class CoreObject(object):
...
@@ -149,6 +151,8 @@ class CoreObject(object):
# self.interruptionStart=SimEvent('interruptionStart')
# self.interruptionStart=SimEvent('interruptionStart')
self
.
interruptionStart
=
self
.
env
.
event
()
self
.
interruptionStart
=
self
.
env
.
event
()
self
.
entityRemoved
=
self
.
env
.
event
()
# =======================================================================
# =======================================================================
# 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
...
@@ -192,6 +196,10 @@ class CoreObject(object):
...
@@ -192,6 +196,10 @@ class CoreObject(object):
# update wipStatList
# update wipStatList
if
self
.
gatherWipStat
:
if
self
.
gatherWipStat
:
self
.
wipStatList
.
append
([
self
.
env
.
now
,
len
(
activeObjectQueue
)])
self
.
wipStatList
.
append
([
self
.
env
.
now
,
len
(
activeObjectQueue
)])
if
not
self
.
entityRemoved
.
triggered
:
self
.
printTrace
(
self
.
id
,
signal
=
'(removedEntity)'
)
self
.
entityRemoved
.
succeed
(
self
.
env
.
now
)
return
entity
return
entity
#===========================================================================
#===========================================================================
...
@@ -431,7 +439,7 @@ class CoreObject(object):
...
@@ -431,7 +439,7 @@ class CoreObject(object):
@
staticmethod
@
staticmethod
def
findGiversFor
(
activeObject
):
def
findGiversFor
(
activeObject
):
givers
=
[]
givers
=
[]
for
object
in
[
x
for
x
in
activeObject
.
previous
if
(
not
x
is
activeObject
)
]:
#
and not x.canDispose.triggered]:
for
object
in
[
x
for
x
in
activeObject
.
previous
if
(
not
x
is
activeObject
)
and
not
x
.
canDispose
.
triggered
]:
if
object
.
haveToDispose
(
activeObject
):
if
object
.
haveToDispose
(
activeObject
):
givers
.
append
(
object
)
givers
.
append
(
object
)
return
givers
return
givers
...
...
dream/simulation/Dismantle.py
View file @
16899abd
...
@@ -121,12 +121,12 @@ class Dismantle(CoreObject):
...
@@ -121,12 +121,12 @@ class Dismantle(CoreObject):
# check if there is WIP and signal receiver
# check if there is WIP and signal receiver
self
.
initialSignalReceiver
()
self
.
initialSignalReceiver
()
while
1
:
while
1
:
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(frame)'
)
#
self.printTrace(self.id, waitEvent='(frame)')
# wait until the Queue can accept an entity and one predecessor requests it
# wait until the Queue can accept an entity and one predecessor requests it
yield
self
.
isRequested
#[self.isRequested,self.canDispose, self.loadOperatorAvailable]
yield
self
.
isRequested
#[self.isRequested,self.canDispose, self.loadOperatorAvailable]
if
self
.
isRequested
.
value
:
if
self
.
isRequested
.
value
:
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
value
.
id
)
#
self.printTrace(self.id, isRequested=self.isRequested.value.id)
# reset the isRequested signal parameter
# reset the isRequested signal parameter
self
.
isRequested
=
self
.
env
.
event
()
self
.
isRequested
=
self
.
env
.
event
()
...
@@ -144,6 +144,7 @@ class Dismantle(CoreObject):
...
@@ -144,6 +144,7 @@ class Dismantle(CoreObject):
self
.
waitToDispose
=
True
self
.
waitToDispose
=
True
self
.
waitToDisposePart
=
True
#Dismantle is in state to dispose a part
self
.
waitToDisposePart
=
True
#Dismantle is in state to dispose a part
# while the object still holds the frame
# while the object still holds the frame
flag
=
False
while
not
self
.
isEmpty
():
while
not
self
.
isEmpty
():
# try and signal the receiver
# try and signal the receiver
if
not
self
.
signalReceiver
():
if
not
self
.
signalReceiver
():
...
@@ -154,8 +155,10 @@ class Dismantle(CoreObject):
...
@@ -154,8 +155,10 @@ class Dismantle(CoreObject):
if
not
self
.
signalReceiver
():
if
not
self
.
signalReceiver
():
continue
continue
# if the receiver was not responsive, release the control to let him remove the entity
# if the receiver was not responsive, release the control to let him remove the entity
yield
self
.
env
.
timeout
(
0
)
yield
self
.
entityRemoved
# if all the parts are removed but not the frame, then set the flag waitToDisposeFrame
self
.
entityRemoved
=
self
.
env
.
event
()
# yield self.env.timeout(0)#(0.000000000000005)
if
self
.
frameIsEmpty
()
and
not
self
.
waitToDisposeFrame
:
if
self
.
frameIsEmpty
()
and
not
self
.
waitToDisposeFrame
:
self
.
waitToDisposePart
=
False
self
.
waitToDisposePart
=
False
self
.
waitToDisposeFrame
=
True
self
.
waitToDisposeFrame
=
True
...
@@ -220,8 +223,9 @@ class Dismantle(CoreObject):
...
@@ -220,8 +223,9 @@ class Dismantle(CoreObject):
#===========================================================================
#===========================================================================
# find possible receivers
# find possible receivers
#===========================================================================
#===========================================================================
def
findReceivers
(
self
):
@
staticmethod
activeObject
=
self
.
getActiveObject
()
def
findReceiversFor
(
activeObject
):
# activeObject=self.getActiveObject()
next
=
[]
next
=
[]
receivers
=
[]
receivers
=
[]
# if the parts are not yet disposed
# if the parts are not yet disposed
...
...
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