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
8b91f25b
Commit
8b91f25b
authored
Jan 16, 2014
by
Ioannis Papagiannopoulos
Committed by
Jérome Perrin
Jan 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new object MouldAssembly added (not tested)
parent
e15a8531
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
164 additions
and
2 deletions
+164
-2
dream/simulation/MouldAssembly.py
dream/simulation/MouldAssembly.py
+162
-0
dream/simulation/Order.py
dream/simulation/Order.py
+1
-1
dream/simulation/Queue.py
dream/simulation/Queue.py
+1
-1
No files found.
dream/simulation/MouldAssembly.py
0 → 100644
View file @
8b91f25b
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 16 Jan 2014
@author: Ioannis
'''
'''
inherits from MachinePreemptive. It takes the components of an order and reassembles them as mould
'''
from
MachinePreemptive
import
MachinePreemptive
from
SimPy.Simulation
import
reactivate
,
now
# ===========================================================================
# the MachineJobShop object
# ===========================================================================
class
MouldAssemble
(
MachinePreemptive
):
# =======================================================================
# method that updates the capacity according to the componentsList of the
# activeEntity's parent order
# =======================================================================
def
updateCapacity
(
self
,
capacity
):
activeObject
=
self
.
getActiveObject
()
self
.
capacity
=
capacity
self
.
Res
=
Resource
(
self
.
capacity
)
# =======================================================================
# assemble method that assembles the components together to a mould (order
# and returns the product of the assembly. Furthermore, it resets the capacity
# of the internal queue to 1
# =======================================================================
def
assemble
(
self
):
activeObject
=
self
.
getActiveObject
()
# get the internal queue of the active core object
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
# assert that all the components are of the same parent order
for
entity
in
activeObjectQueue
:
assert
entity
.
order
==
activeObjectQueue
[
0
].
order
,
\
'The components residing in the MouldAssembly internal queue
\
are not of the same parent order!'
# if we have to create a new Entity (mould) this should be modified
# we need the new entity's route, priority, isCritical flag, etc.
mouldToBeAssembled
=
activeObjectQueue
[
0
].
order
del
activeObjectQueue
[:]
activeObjectQueue
.
append
(
mouldToBeAssembled
)
mouldToBeAssembled
.
currentStation
=
self
self
.
timeLastEntityEnded
=
now
()
# after assembling reset the capacity
activeObject
.
updateCapacity
(
1
)
# =======================================================================
# getEntity method that gets the entity from the giver
# it should run in a loop till it get's all the entities from the same order
# (with the flag componentsReadyForAssembly set)
# =======================================================================
def
getEntity
(
self
):
activeObject
=
self
.
getActiveObject
()
giverObejct
=
activeObject
.
getGiverObject
()
giverObjectQueue
=
giverObject
.
getActiveObjectQueue
()
# read the number of basic and secondary components of the moulds
capacity
=
len
(
giverObjectQueue
[
0
].
order
.
basicComponentsList
\
+
giverObjectQueue
[
0
].
order
.
secondaryComponentsList
)
# and set the capacity of the internal queue of the assembler
activeObject
.
updateCapacity
(
capacity
)
# dummy variable to inform when the sum of needed components is received
# before the assembly-processing
orderGroupReceived
=
False
# the current activeEntity of the assembler
activeEntity
=
None
# loop till all the requested components are gathered
# all the components are received at the same time
while
not
orderGroupReceived
:
if
not
(
activeEntity
is
None
):
assert
activeEntity
.
order
==
giverObjectQueue
[
0
].
order
,
\
'the next Entity to be received by the MouldAssembly
\
must have the same parent order as the activeEntity of the assembler'
# get the following component
activeEntity
=
MachinePreemptive
.
getEntity
(
self
)
# if the length of the internal queue is equal to the updated capacity
if
len
(
activeObject
.
getActiveObjectQueue
())
==
self
.
capacity
:
# then exit the while loop
orderGroupReceived
=
True
# perform the assembly-action and return the assembled mould
activeEntity
=
activeObject
.
assemble
()
return
activeEntity
# =======================================================================
# check if the assemble can accept an entity
# returns true if it is empty
# =======================================================================
def
canAccept
(
self
,
callerObject
=
None
):
if
callerObject
!=
None
:
#check it the caller object holds an Entity that requests for current object
if
len
(
callerObject
.
getActiveObjectQueue
())
>
0
:
activeEntity
=
callerObject
.
getActiveObjectQueue
()[
0
]
# if the machine's Id is in the list of the entity's next stations
if
self
.
id
in
activeEntity
.
remainingRoute
[
0
].
get
(
'stationIdsList'
,[]):
#return according to the state of the Queue
return
len
(
self
.
getActiveObjectQueue
())
==
0
return
False
# =======================================================================
# checks if the Machine can accept an entity and there is an entity in
# some predecessor waiting for it and updates the giver to the one that is to be taken
# The internal queue of the assembler must be empty
# and the parent order of the entities to be received must have
# the flag componentsReadyForAssembly set to True
# =======================================================================
def
canAcceptAndIsRequested
(
self
):
# get active and giver objects
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
giverObject
=
self
.
getGiverObject
()
# if we have only one possible giver just check if the internal queue is empty
# and if the giver has to dispose something
if
(
len
(
activeObject
.
previous
)
==
1
):
return
giverObject
.
haveToDispose
(
activeObject
)
\
and
len
(
activeObjectQueue
)
==
0
\
# dummy variables that help prioritise the objects requesting to give objects to the Machine (activeObject)
isRequested
=
False
# isRequested is dummyVariable checking if it is requested to accept an item
maxTimeWaiting
=
0
# dummy variable counting the time a predecessor is blocked
# loop through the possible givers to see which have to dispose and which is the one blocked for longer
for
object
in
activeObject
.
previous
:
# if the predecessor objects have entities to dispose of
if
(
object
.
haveToDispose
(
activeObject
)
and
object
.
receiver
==
self
):
isRequested
=
True
# and if the predecessor has been down while trying to give away the Entity
if
(
object
.
downTimeInTryingToReleaseCurrentEntity
>
0
):
# the timeWaiting dummy variable counts the time end of the last failure of the giver object
timeWaiting
=
now
()
-
object
.
timeLastFailureEnded
# in any other case, it holds the time since the end of the Entity processing
else
:
timeWaiting
=
now
()
-
object
.
timeLastEntityEnded
#if more than one predecessor have to dispose, take the part from the one that is blocked longer
if
(
timeWaiting
>=
maxTimeWaiting
):
activeObject
.
giver
=
object
maxTimeWaiting
=
timeWaiting
return
len
(
activeObjectQueue
)
==
0
and
isRequested
dream/simulation/Order.py
View file @
8b91f25b
...
...
@@ -46,7 +46,7 @@ class Order(Job):
self
.
manager
=
manager
# the manager responsible to handle the order
self
.
basicsEnded
=
basicsEnded
# flag that informs that the basic components of the order are finished
# flag that informs weather the components needed for the assembly are present in the Assembly Buffer
self
.
componentsReadForAssembly
=
componentsReadyForAssembly
self
.
componentsRead
y
ForAssembly
=
componentsReadyForAssembly
dream/simulation/Queue.py
View file @
8b91f25b
...
...
@@ -290,4 +290,4 @@ class Queue(CoreObject):
#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
.
componentsReadForAssembly
)
\ No newline at end of file
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
order
.
componentsReadyForAssembly
)
\ 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