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
ea3ca76d
Commit
ea3ca76d
authored
Jan 23, 2014
by
Ioannis Papagiannopoulos
Committed by
Jérome Perrin
Feb 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConditionalBuffer corrected - MouldAssemblyBuffer haveToDispose modified
parent
16ba284e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
10 deletions
+45
-10
dream/simulation/ConditionalBuffer.py
dream/simulation/ConditionalBuffer.py
+31
-9
dream/simulation/MouldAssemblyBuffer.py
dream/simulation/MouldAssemblyBuffer.py
+14
-1
No files found.
dream/simulation/ConditionalBuffer.py
View file @
ea3ca76d
...
@@ -39,6 +39,12 @@ class NoCallerError(Exception):
...
@@ -39,6 +39,12 @@ class NoCallerError(Exception):
# the QueuePreemptive object
# the QueuePreemptive object
# ===========================================================================
# ===========================================================================
class
ConditionalBuffer
(
QueuePreemptive
):
class
ConditionalBuffer
(
QueuePreemptive
):
# =======================================================================
# the default __init__ method of the QueuePreemptive class
# whereas the default capacity is set to infinity
# =======================================================================
def
__init__
(
self
,
id
,
name
,
capacity
=-
1
,
dummy
=
False
,
schedulingRule
=
"FIFO"
):
QueuePreemptive
.
__init__
(
self
,
id
=
id
,
name
=
name
,
capacity
=
capacity
,
dummy
=
dummy
,
schedulingRule
=
schedulingRule
)
# =======================================================================
# =======================================================================
# checks if the Buffer can dispose an entity.
# checks if the Buffer can dispose an entity.
...
@@ -92,14 +98,30 @@ class ConditionalBuffer(QueuePreemptive):
...
@@ -92,14 +98,30 @@ class ConditionalBuffer(QueuePreemptive):
activeObject
=
self
.
getActiveObject
()
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
# read the entity to be disposed
# read the entity to be disposed
activeEntity
=
activeObjectQueue
[
0
]
index
=
0
# assert that the entity.type is OrderComponent
activeEntity
=
None
assert
activeEntity
.
type
==
'OrderComponent'
,
\
for
index
in
range
(
len
(
activeObjectQueue
)):
"the entity to be disposed is not of type OrderComponent"
if
activeObjectQueue
[
index
].
componentType
==
'Basic'
:
# if the type of the component is Secondary then verify that the basics of the same Order
activeEntity
=
activeObjectQueue
[
index
]
# are already processed before disposing them to the next object
return
True
return
activeEntity
.
componentType
==
'Secondary'
\
elif
activeObjectQueue
[
index
].
order
.
basicsEnded
:
and
(
activeEntity
.
order
.
basicsEnded
)
activeEntity
=
activeObjectQueue
[
index
]
return
True
index
+=
1
# if there is no entity in the activeQ that its parentOrder has the flag componentsReadyForAssembly set
if
not
activeEntity
:
# return false
return
False
# # activeEntity = activeObjectQueue[0]
# # assert that the entity.type is OrderComponent
# assert activeEntity.type=='OrderComponent',\
# "the entity to be disposed is not of type OrderComponent"
# # if the type of the component is Secondary then verify that the basics of the same Order
# # are already processed before disposing them to the next object
# # TODO: the activeEntity is already checked if it has the basicsEnded flag set
# return activeEntity.componentType=='Secondary'\
# and (activeEntity.order.basicsEnded)
# =======================================================================
# =======================================================================
# sort the entities of the activeQ
# sort the entities of the activeQ
...
...
dream/simulation/MouldAssemblyBuffer.py
View file @
ea3ca76d
...
@@ -133,7 +133,19 @@ class MouldAssemblyBuffer(QueuePreemptive):
...
@@ -133,7 +133,19 @@ class MouldAssemblyBuffer(QueuePreemptive):
# if the length is zero then no componentType or entity.type can be read
# if the length is zero then no componentType or entity.type can be read
if
len
(
activeObjectQueue
)
==
0
:
if
len
(
activeObjectQueue
)
==
0
:
return
False
return
False
activeEntity
=
activeObjectQueue
[
0
]
# read the entity to be disposed
# read the entity to be disposed
index
=
0
activeEntity
=
None
for
index
in
range
(
len
(
activeObjectQueue
)):
if
activeObjectQueue
[
index
].
order
.
componentsReadyForAssembly
:
activeEntity
=
activeObjectQueue
[
index
]
break
index
+=
1
# if there is no entity in the activeQ that its parentOrder has the flag componentsReadyForAssembly set
if
not
activeEntity
:
# return false
return
False
# activeEntity = activeObjectQueue[0]
if
(
len
(
activeObject
.
next
)
==
1
):
#if we have only one possible receiver
if
(
len
(
activeObject
.
next
)
==
1
):
#if we have only one possible receiver
activeObject
.
receiver
=
activeObject
.
next
[
0
]
activeObject
.
receiver
=
activeObject
.
next
[
0
]
else
:
# otherwise,
else
:
# otherwise,
...
@@ -151,6 +163,7 @@ class MouldAssemblyBuffer(QueuePreemptive):
...
@@ -151,6 +163,7 @@ class MouldAssemblyBuffer(QueuePreemptive):
return
False
return
False
# if the successors (MouldAssembly) internal queue is empty then proceed with checking weather
# if the successors (MouldAssembly) internal queue is empty then proceed with checking weather
# the caller is the receiver
# the caller is the receiver
# TODO the activeEntity is already checked for the flag componentsReadyForAssembly
if
len
(
receiverQueue
)
==
0
:
if
len
(
receiverQueue
)
==
0
:
if
activeEntity
.
type
==
'Mould'
:
if
activeEntity
.
type
==
'Mould'
:
return
thecaller
is
activeObject
.
receiver
return
thecaller
is
activeObject
.
receiver
...
...
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