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
ee20eacb
Commit
ee20eacb
authored
Aug 28, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code commented better
parent
5ea3ae6e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
dream/simulation/Examples/CompoundMachine.py
dream/simulation/Examples/CompoundMachine.py
+15
-9
No files found.
dream/simulation/Examples/CompoundMachine.py
View file @
ee20eacb
...
...
@@ -2,15 +2,20 @@ from dream.simulation.imports import Machine, Exit, Queue, Globals, Part, ExcelH
from
dream.simulation.imports
import
G
from
dream.simulation.Globals
import
runSimulation
# models the behaviour of the buffers in the compound machine
class
InternalQueue
(
Queue
):
def
canAccept
(
self
,
callerObject
=
None
):
# if the next machine holds a part return false
if
len
(
self
.
next
[
0
].
getActiveObjectQueue
()):
return
False
# else use the default Queue logic
return
Queue
.
canAccept
(
self
,
callerObject
)
# models the behaviour of the processes in the compound machine
class
InternalProcess
(
Machine
):
def
canAccept
(
self
,
callerObject
=
None
):
# do not start processing unless there are 3 parts in the internal server
# do not start processing unless there are enough parts
# (i.e. equal to the number of processes) in the compound machine
if
not
self
.
countInternalParts
()
==
len
(
G
.
InternalProcessList
):
return
False
return
Machine
.
canAccept
(
self
,
callerObject
)
...
...
@@ -20,31 +25,32 @@ class InternalProcess(Machine):
activeEntity
=
Machine
.
getEntity
(
self
)
for
queue
in
G
.
InternalQueueList
:
station
=
queue
.
next
[
0
]
# do not send
if it is not
already triggered
# do not send
the signal if it is
already triggered
if
not
queue
.
canDispose
.
triggered
:
self
.
sendSignal
(
receiver
=
queue
,
signal
=
queue
.
canDispose
,
sender
=
station
)
return
activeEntity
#
if there is one machine that is processing do not return true
#
do not allow parts to proceed until all the processes are over
def
haveToDispose
(
self
,
callerObject
=
None
):
for
object
in
G
.
InternalProcessList
:
# if there is one other machine processing return False
if
(
len
(
object
.
getActiveObjectQueue
())
)
and
(
not
object
.
isBlocked
):
return
False
# if there is one other machine that got signal to dispose return false
if
object
.
canDispose
.
triggered
:
if
object
.
isProcessing
:
return
False
# # if there is one other machine that got signal to dispose return false
# if object.canDispose.triggered:
# return False
return
Machine
.
haveToDispose
(
self
,
callerObject
)
# check if all the machines got empty and send signal to QB
def
removeEntity
(
self
,
entity
=
None
):
activeEntity
=
Machine
.
removeEntity
(
self
,
entity
)
# run the default method
# count the number of parts in the server
# count the number of parts in the server.
# If it is empty have one internal queue to signal the queue before the compound object
if
not
self
.
countInternalParts
():
self
.
sendSignal
(
receiver
=
QB
,
signal
=
QB
.
canDispose
,
sender
=
Q1
)
return
activeEntity
# returns the
total
number of internal parts in the server
# returns the number of internal parts in the server
def
countInternalParts
(
self
):
totalParts
=
0
for
object
in
G
.
InternalProcessList
+
G
.
InternalQueueList
:
...
...
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