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
14bb3fc6
Commit
14bb3fc6
authored
Sep 09, 2014
by
Ioannis Papagiannopoulos
Committed by
Georgios Dagkakis
Nov 03, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
batch objects follow the expectedSignals paradeigm
parent
7323512c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
4 deletions
+78
-4
dream/simulation/BatchDecomposition.py
dream/simulation/BatchDecomposition.py
+36
-1
dream/simulation/BatchReassembly.py
dream/simulation/BatchReassembly.py
+39
-1
dream/simulation/NonStarvingEntry.py
dream/simulation/NonStarvingEntry.py
+3
-2
No files found.
dream/simulation/BatchDecomposition.py
View file @
14bb3fc6
...
...
@@ -73,6 +73,10 @@ class BatchDecomposition(CoreObject):
G
.
BatchWaitingList
=
[]
# batches waiting to be reassembled
CoreObject
.
initialize
(
self
)
# using the default CoreObject Functionality
self
.
Res
=
simpy
.
Resource
(
self
.
env
,
self
.
numberOfSubBatches
)
# initialize the Internal resource (Queue) functionality
self
.
expectedSignals
[
'isRequested'
]
=
1
self
.
expectedSignals
[
'interruptionStart'
]
=
1
self
.
expectedSignals
[
'initialWIP'
]
=
1
# =======================================================================
# the run method of the BatchDecomposition
...
...
@@ -82,6 +86,11 @@ class BatchDecomposition(CoreObject):
self
.
initialSignalReceiver
()
while
1
:
# wait for an event or an interruption
self
.
expectedSignals
[
'isRequested'
]
=
1
self
.
expectedSignals
[
'interruptionStart'
]
=
1
self
.
expectedSignals
[
'initialWIP'
]
=
1
while
1
:
receivedEvent
=
yield
self
.
env
.
any_of
([
self
.
isRequested
,
self
.
interruptionStart
,
self
.
initialWIP
])
# if an interruption has occurred
...
...
@@ -90,7 +99,13 @@ class BatchDecomposition(CoreObject):
assert
eventTime
==
self
.
env
.
now
,
'the interruption received by batchDecomposition was created earlier'
self
.
interruptionStart
=
self
.
env
.
event
()
# wait till it is over
self
.
expectedSignals
[
'interruptionEnd'
]
=
1
yield
self
.
interruptionEnd
self
.
expectedSignals
[
'interruptionEnd'
]
=
0
transmitter
,
eventTime
=
self
.
interruptionEnd
.
value
assert
self
==
transmitter
,
'the victim of the failure is not the object that received the interruptionEnd event'
self
.
interruptionEnd
=
self
.
env
.
event
()
...
...
@@ -109,6 +124,10 @@ class BatchDecomposition(CoreObject):
assert
requestingObject
==
self
.
giver
,
'the giver is not the requestingObject'
self
.
isRequested
=
self
.
env
.
event
()
break
self
.
expectedSignals
[
'isRequested'
]
=
0
self
.
expectedSignals
[
'interruptionStart'
]
=
0
self
.
expectedSignals
[
'initialWIP'
]
=
0
if
not
self
.
isProcessingInitialWIP
:
# if we are in the state of having initial wip no need to take an Entity
self
.
currentEntity
=
self
.
getEntity
()
...
...
@@ -126,6 +145,8 @@ class BatchDecomposition(CoreObject):
# reset the variable
self
.
isProcessingInitialWIP
=
False
self
.
expectedSignals
[
'canDispose'
]
=
1
# TODO: add failure control
# as long as there are sub-Batches in the internal Resource
numberOfSubBatches
=
int
(
len
(
self
.
getActiveObjectQueue
()))
...
...
@@ -146,7 +167,13 @@ class BatchDecomposition(CoreObject):
# signal the receiver again and break
if
self
.
signalReceiver
():
self
.
waitEntityRemoval
=
True
self
.
expectedSignals
[
'entityRemoved'
]
=
1
yield
self
.
entityRemoved
self
.
expectedSignals
[
'entityRemoved'
]
=
0
transmitter
,
eventTime
=
self
.
entityRemoved
.
value
self
.
waitEntityRemoval
=
False
break
...
...
@@ -161,13 +188,21 @@ class BatchDecomposition(CoreObject):
signaling
=
self
.
signalReceiver
()
if
signaling
:
self
.
waitEntityRemoval
=
True
self
.
expectedSignals
[
'entityRemoved'
]
=
1
yield
self
.
entityRemoved
self
.
expectedSignals
[
'entityRemoved'
]
=
0
transmitter
,
eventTime
=
self
.
entityRemoved
.
value
self
.
waitEntityRemoval
=
False
break
self
.
entityRemoved
=
self
.
env
.
event
()
self
.
expectedSignals
[
'canDispose'
]
=
0
# =======================================================================
# removes an entity from the Machine
# =======================================================================
...
...
dream/simulation/BatchReassembly.py
View file @
14bb3fc6
...
...
@@ -69,6 +69,10 @@ class BatchReassembly(CoreObject):
def
initialize
(
self
):
CoreObject
.
initialize
(
self
)
# using the default CoreObject Functionality
self
.
Res
=
simpy
.
Resource
(
self
.
env
,
self
.
numberOfSubBatches
)
# initialize the Internal resource (Queue) functionality
self
.
expectedSignals
[
'isRequested'
]
=
1
self
.
expectedSignals
[
'interruptionStart'
]
=
1
self
.
expectedSignals
[
'initialWIP'
]
=
1
# =======================================================================
# the main method of the object
...
...
@@ -78,13 +82,24 @@ class BatchReassembly(CoreObject):
# check if there is WIP and signal receiver
self
.
initialSignalReceiver
()
while
1
:
self
.
expectedSignals
[
'isRequested'
]
=
1
self
.
expectedSignals
[
'interruptionStart'
]
=
1
self
.
expectedSignals
[
'initialWIP'
]
=
1
while
1
:
receivedEvent
=
yield
self
.
env
.
any_of
([
self
.
isRequested
,
self
.
interruptionStart
,
self
.
initialWIP
])
if
self
.
interruptionStart
in
receivedEvent
:
transmitter
,
eventTime
=
self
.
interruptionStart
.
value
assert
eventTime
==
self
.
env
.
now
,
'the interruptionStart received by BatchReassembly later than created'
self
.
interruptionStart
=
self
.
env
.
event
()
self
.
expectedSignals
[
'interruptionEnd'
]
=
1
yield
self
.
interruptionEnd
self
.
expectedSignals
[
'interruptionEnd'
]
=
0
transmitter
,
eventTime
=
self
.
interruptionEnd
.
value
assert
self
==
transmitter
,
'the victim of the failure is not the object that received the interruptionEnd event'
self
.
interruptionEnd
=
self
.
env
.
event
()
...
...
@@ -105,6 +120,10 @@ class BatchReassembly(CoreObject):
self
.
isProcessingInitialWIP
=
False
break
self
.
expectedSignals
[
'isRequested'
]
=
0
self
.
expectedSignals
[
'interruptionStart'
]
=
0
self
.
expectedSignals
[
'initialWIP'
]
=
0
if
not
self
.
isProcessingInitialWIP
:
# if we are in the state of having initial wip no need to take an Entity
self
.
currentEntity
=
self
.
getEntity
()
...
...
@@ -121,6 +140,10 @@ class BatchReassembly(CoreObject):
self
.
reassemble
()
self
.
isProcessingInitialWIP
=
False
# signal the receiver that the activeObject has something to dispose of
self
.
expectedSignals
[
'interruptionStart'
]
=
1
self
.
expectedSignals
[
'canDispose'
]
=
1
if
not
self
.
signalReceiver
():
# if there was no available receiver, get into blocking control
while
1
:
...
...
@@ -138,7 +161,13 @@ class BatchReassembly(CoreObject):
self
.
interruptionActions
()
# execute interruption actions
# loop until we reach at a state that there is no interruption
while
1
:
self
.
expectedSignals
[
'interruptionEnd'
]
=
1
yield
self
.
interruptionEnd
# interruptionEnd to be triggered by ObjectInterruption
self
.
expectedSignals
[
'interruptionEnd'
]
=
0
transmitter
,
eventTime
=
self
.
interruptionEnd
.
value
assert
eventTime
==
self
.
env
.
now
,
'the victim of the failure is not the object that received it'
self
.
interruptionEnd
=
self
.
env
.
event
()
...
...
@@ -170,7 +199,13 @@ class BatchReassembly(CoreObject):
break
self
.
waitEntityRemoval
=
True
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(entityRemoved)'
)
self
.
expectedSignals
[
'entityRemoved'
]
=
1
yield
self
.
entityRemoved
self
.
expectedSignals
[
'entityRemoved'
]
=
0
transmitter
,
eventTime
=
self
.
entityRemoved
.
value
self
.
printTrace
(
self
.
id
,
entityRemoved
=
eventTime
)
assert
eventTime
==
self
.
env
.
now
,
'entityRemoved event activated earlier than received'
...
...
@@ -179,7 +214,10 @@ class BatchReassembly(CoreObject):
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
if
not
self
.
haveToDispose
():
break
self
.
expectedSignals
[
'interruptionStart'
]
=
0
self
.
expectedSignals
[
'canDispose'
]
=
0
# =======================================================================
# removes an entity from the Machine
# =======================================================================
...
...
dream/simulation/NonStarvingEntry.py
View file @
14bb3fc6
...
...
@@ -80,6 +80,7 @@ class NonStarvingEntry(Queue):
Globals
.
setWIP
([
E
])
G
.
numberOfEntities
+=
1
if
not
self
.
canDispose
.
triggered
:
succeedTuple
=
(
self
,
self
.
env
.
now
)
self
.
canDispose
.
succeed
(
succeedTuple
)
if
self
.
expectedSignals
[
'canDispose'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
self
.
canDispose
.
succeed
(
succeedTuple
)
\ No newline at end of file
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