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
c2cba721
Commit
c2cba721
authored
Jan 06, 2014
by
Georgios Dagkakis
Committed by
Jérome Perrin
Jan 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Order (Entity) and OrderDecomposition (CoreObject) added. No testing yet
parent
1819e6a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
0 deletions
+166
-0
dream/simulation/Order.py
dream/simulation/Order.py
+45
-0
dream/simulation/OrderDecomposition.py
dream/simulation/OrderDecomposition.py
+121
-0
No files found.
dream/simulation/Order.py
0 → 100644
View file @
c2cba721
# ===========================================================================
# 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 06 Jan 2013
@author: George
'''
'''
Order is an Entity that can have its design, get broken to sub-components
'''
from
Globals
import
G
from
Entity
import
Entity
# ============================ The Order object ==============================
class
Order
(
Entity
):
type
=
"Order"
def
__init__
(
self
,
id
=
None
,
name
=
None
,
priority
=
0
,
dueDate
=
None
,
orderDate
=
None
,
isCritical
=
False
,
componentsList
=
[],
designTime
=
0
,
manager
=
None
,
basicsEnded
=
False
):
Entity
.
__init__
(
self
,
id
=
id
,
name
=
name
,
priority
=
priority
,
dueDate
=
dueDate
,
orderDate
=
orderDate
)
self
.
isCritical
=
isCritical
self
.
componentsList
=
componentsList
self
.
designTime
=
designTime
self
.
manager
=
manager
self
.
basicsEnded
=
basicsEnded
dream/simulation/OrderDecomposition.py
0 → 100644
View file @
c2cba721
# ===========================================================================
# 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 06 Jan 2013
@author: George
'''
'''
OrderDecomposition is a Core Object that takes an order after design and decomposes to order components
dummy object: infinite capacity no processing time
'''
from
SimPy.Simulation
import
Process
,
Resource
from
SimPy.Simulation
import
waituntil
,
now
,
hold
,
infinity
from
Globals
import
G
from
CoreObject
import
CoreObject
from
RandomNumberGenerator
import
RandomNumberGenerator
from
Entity
import
Entity
from
Order
import
Order
from
OrderComponent
import
OrderComponent
# ===========================================================================
# the Order-Decomposition Object
# ===========================================================================
class
OrderDecomposition
(
CoreObject
):
def
__init__
(
self
,
id
,
name
):
CoreObject
.
__init__
(
self
)
self
.
type
=
'OrderDecomposition'
def
initialize
(
self
):
CoreObject
.
initialize
(
self
)
# using the default CoreObject Functionality
self
.
Res
=
Resource
(
infinity
)
# initialize the Internal resource (Queue) functionality. This is a dummy object so
# infinite capacity is assumed
#run just waits until there is something to get and gets it
def
run
(
self
):
while
1
:
yield
waituntil
,
self
,
self
.
canAcceptAndIsRequested
#wait until the Queue can accept an entity
#and one predecessor requests it
self
.
getEntity
()
self
.
decompose
()
def
canAccept
(
self
,
callerObject
=
None
):
return
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 there is a place,
# the machine is up and the predecessor has an entity to dispose
# this is done to achieve better (cpu) processing time
if
(
len
(
activeObject
.
previous
)
==
1
):
return
activeObject
.
Up
and
giverObject
.
haveToDispose
(
activeObject
)
# dummy variables that help prioritize the objects requesting to give objects to the Machine (activeObject)
isRequested
=
False
# is requested 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
(
object
.
haveToDispose
(
activeObject
)
and
object
.
receiver
==
self
):
isRequested
=
True
# if the predecessor objects have entities to dispose of
if
(
object
.
downTimeInTryingToReleaseCurrentEntity
>
0
):
# and the predecessor has been down while trying to give away the Entity
timeWaiting
=
now
()
-
object
.
timeLastFailureEnded
# the timeWaiting dummy variable counts the time end of the last failure of the giver object
else
:
timeWaiting
=
now
()
-
object
.
timeLastEntityEnded
# in any other case, it holds the time since the end of the Entity processing
#if more than one predecessor have to dispose take the part from the one that is blocked longer
if
(
timeWaiting
>=
maxTimeWaiting
):
activeObject
.
giver
=
object
# the object to deliver the Entity to the activeObject is set to the ith member of the previous list
maxTimeWaiting
=
timeWaiting
# in the next loops, check the other predecessors in the previous list
return
activeObject
.
Up
and
isRequested
# =======================================================================
# checks if the OrderDecomposition can dispose an entity to the following object
# =======================================================================
def
haveToDispose
(
self
,
callerObject
=
None
):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
#if there is no Entity return False
if
len
(
activeObjectQueue
)
==
0
:
return
False
activeEntity
=
activeObjectQueue
[
0
]
import
Globals
self
.
receiver
=
Globals
.
findObjectById
(
activeEntity
.
remainingRoute
[
1
][
0
])
#read the next station
#return True if the OrderDecomposition in the state of disposing and the caller is the receiver
return
activeObject
.
Up
and
(
callerObject
is
self
.
receiver
)
#decomposes the order to its components
def
decompose
(
self
):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
#loop in the internal Queue. Decompose only if an Entity is of type order
for
entity
in
activeObjectQueue
:
if
entity
.
type
==
'Order'
:
activeObjectQueue
.
remove
(
entity
)
#remove the order from the internal Queue
#append the components in the internal queue
for
component
in
entity
.
componentsList
:
activeObjectQueue
.
append
(
component
)
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