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
0fb94fd1
Commit
0fb94fd1
authored
Jan 22, 2014
by
Ioannis Papagiannopoulos
Committed by
Jérome Perrin
Feb 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update sortEntities() method of ConditionalBuffer and MouldAssemlyBuffer
parent
41f8415a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
29 deletions
+34
-29
dream/simulation/ConditionalBuffer.py
dream/simulation/ConditionalBuffer.py
+18
-8
dream/simulation/MouldAssemblyBuffer.py
dream/simulation/MouldAssemblyBuffer.py
+16
-7
dream/simulation/Queue.py
dream/simulation/Queue.py
+0
-14
No files found.
dream/simulation/ConditionalBuffer.py
View file @
0fb94fd1
...
...
@@ -22,7 +22,7 @@ Created on 15 Jan 2014
@author: Ioannis
'''
'''
Inherits from QueuePreemptive. Checks the condition of (a) component(s) before i
n can dispose of
them/it
Inherits from QueuePreemptive. Checks the condition of (a) component(s) before i
t can dispose
them/it
'''
from
QueuePreemptive
import
QueuePreemptive
...
...
@@ -39,13 +39,6 @@ class NoCallerError(Exception):
# the QueuePreemptive object
# ===========================================================================
class
ConditionalBuffer
(
QueuePreemptive
):
# ===========================================================================
# the __init__ function
# ===========================================================================
def
__init__
(
self
,
id
,
name
,
capacity
=-
1
,
dummy
=
False
,
schedulingRule
=
"CB"
):
# run the default method, change the schedulingRule to CB
# for description, check activeQSorter function of Queue coreObject
QueuePreemptive
.
__init__
(
self
,
id
,
name
,
capacity
,
dummy
,
schedulingRule
)
# =======================================================================
# checks if the Buffer can dispose an entity.
...
...
@@ -108,4 +101,21 @@ class ConditionalBuffer(QueuePreemptive):
return
activeEntity
.
componentType
==
'Secondary'
\
and
(
activeEntity
.
order
.
basicsEnded
)
# =======================================================================
# sort the entities of the activeQ
# bring to the front the entities of componentType Basic
# and the entities of componentType Secondary that
# have the flag basicsEnded set
# =======================================================================
def
sortEntities
(
self
):
activeObject
=
self
.
getActiveObject
()
# run the default sorting of the Queue first
QueuePreemptive
.
sortEntities
(
self
)
# and in the end sort according to the ConditionalBuffer sorting rule
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
# if the componentType of the entities in the activeQueue is Basic then don't move it to the end of the activeQ
# else if the componentType is Secondary and it's basics are not ended then move it to the back
activeObjectQueue
.
sort
(
key
=
lambda
x
:
not
((
x
.
componentType
==
'Basic'
)
\
or
((
x
.
order
.
basicsEnded
)
\
and
(
x
.
componentType
==
'Secondary'
))))
\ No newline at end of file
dream/simulation/MouldAssemblyBuffer.py
View file @
0fb94fd1
...
...
@@ -40,14 +40,23 @@ class NoCallerError(Exception):
# the MouldAssemblyBuffer object
# ===========================================================================
class
MouldAssemblyBuffer
(
QueuePreemptive
):
# =======================================================================
# Sort the entities of the activeQ
# bring the entities that are ready for assembly to the front
# =======================================================================
# the __init__ function
# =======================================================================
def
__init__
(
self
,
id
,
name
,
capacity
=-
1
,
dummy
=
False
,
schedulingRule
=
"MAB"
):
# run the default method, change the schedulingRule to 'MAB'
# for description, check activeQSorter function of Queue coreObject
QueuePreemptive
.
__init__
(
self
,
id
,
name
,
capacity
,
dummy
,
schedulingRule
)
def
sortEntities
(
self
):
activeObject
=
self
.
getActiveObject
()
# run the default sorting of the Queue first
QueuePreemptive
.
sortEntities
(
self
)
# and in the end sort according to the ConditionalBuffer sorting rule
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
# if all the components of the same mould are present then move them to the front of the activeQ
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
.
order
.
componentsReadyForAssembly
,
reverse
=
True
)
# keep the first entity of the activeQ
activeEntity
=
activeObjectQueue
[
0
]
# bring the entities that have the same parentOrder as the first entity to the front
activeObjectQueue
.
sort
(
key
=
lambda
x
:
not
x
.
order
.
name
==
activeEntity
.
order
.
name
)
# =======================================================================
# extend he default so that it sets order.basicsEnded to 1
...
...
dream/simulation/Queue.py
View file @
0fb94fd1
...
...
@@ -288,20 +288,6 @@ class Queue(CoreObject):
nextObject
=
obj
entity
.
nextQueueLength
=
len
(
nextObject
.
getActiveObjectQueue
())
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
nextQueueLength
)
#if the schedulingRule is set to ConditionalBuffer scheduling rule "CB" where orderComponents of type "Secondary"
#are moved to the end of the queue if their parent order.basicsEnded property is set to False
elif
criterion
==
'CB'
:
# if the componentType is Basic then don't move it to the end of the activeQ
# else if the componentType is Secondary and it's basics are not ended then move it to the back
activeObjectQ
.
sort
(
key
=
lambda
x
:
not
((
x
.
componentType
==
'Basic'
)
\
or
((
x
.
order
.
basicsEnded
)
\
and
(
x
.
componentType
==
'Secondary'
))))
#if the schedulingRule is set to MouldAssemblyBuffer scheduling rule "MAB" where orderComponents of the same order,
#whose components are all present in the activeQ of the activeObject or its successor,
#are moved to the beginning of the queue
elif
criterion
==
'MAB'
:
# if all the components of the same mould are present then move them to the front of the activeQ
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
order
.
componentsReadyForAssembly
)
else
:
assert
False
,
"Unknown scheduling criterion %r"
%
(
criterion
,
)
...
...
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