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
ac62132b
Commit
ac62132b
authored
Dec 12, 2013
by
Georgios Dagkakis
Committed by
Jérome Perrin
Jan 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Queue updated so that predessesor/successor Indexes get deprecated. Other objects to follow
parent
8574c94b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+8
-0
dream/simulation/Queue.py
dream/simulation/Queue.py
+10
-12
No files found.
dream/simulation/CoreObject.py
View file @
ac62132b
...
...
@@ -73,7 +73,11 @@ class CoreObject(Process):
# ============================== the below are currently used in Jobshop =======================
self
.
giver
=
None
#the CoreObject that the activeObject will take an Entity from
if
len
(
self
.
previous
)
>
0
:
self
.
giver
=
self
.
previous
[
0
]
self
.
receiver
=
None
#the CoreObject that the activeObject will give an Entity to
if
len
(
self
.
next
)
>
0
:
self
.
receiver
=
self
.
next
[
0
]
# ============================== variable that is used for the loading of machines =============
self
.
exitAssignedToReceiver
=
False
# by default the objects are not blocked
# when the entities have to be loaded to operatedMachines
...
...
@@ -203,6 +207,8 @@ class CoreObject(Process):
# =================== get the giver object in a getEntity transaction. =========================
def
getGiverObject
(
self
):
if
self
.
type
==
'Queue'
:
#
return
self
.
giver
return
self
.
previous
[
self
.
predecessorIndex
]
# ============== get the giver object queue in a getEntity transaction. ========================
...
...
@@ -211,6 +217,8 @@ class CoreObject(Process):
# ============== get the receiver object in a removeEntity transaction. =======================
def
getReceiverObject
(
self
):
if
self
.
type
==
'Queue'
:
return
self
.
receiver
return
self
.
next
[
self
.
successorIndex
]
# ========== get the receiver object queue in a removeEntity transaction. ======================
...
...
dream/simulation/Queue.py
View file @
ac62132b
...
...
@@ -116,7 +116,7 @@ class Queue(CoreObject):
# =======================================================================
# checks if the Queue can dispose an entity to the following object
# it checks also who called it and returns TRUE
# only to the
successo
r that will give the entity.
# only to the
receive
r that will give the entity.
# this is kind of slow I think got to check
# =======================================================================
def
haveToDispose
(
self
,
callerObject
=
None
):
...
...
@@ -124,7 +124,7 @@ class Queue(CoreObject):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
#if we have only one
successo
r just check if the Queue holds one or more entities
#if we have only one
possible receive
r just check if the Queue holds one or more entities
if
(
len
(
activeObject
.
next
)
==
1
or
callerObject
==
None
):
return
len
(
self
.
Res
.
activeQ
)
>
0
...
...
@@ -134,17 +134,16 @@ class Queue(CoreObject):
thecaller
=
callerObject
#give the entity to the
successo
r that is waiting for the most time.
#give the entity to the
possible receive
r that is waiting for the most time.
#plant does not do this in every occasion!
maxTimeWaiting
=
0
i
=
0
# loop through the object in the successor list
# loop through the object in the successor list
for
object
in
activeObject
.
next
:
if
(
object
.
canAccept
()):
# if the object can accept
timeWaiting
=
now
()
-
object
.
timeLastEntityLeft
# compare the time that it has been waiting
if
(
timeWaiting
>
maxTimeWaiting
or
maxTimeWaiting
==
0
):
# with the others'
maxTimeWaiting
=
timeWaiting
self
.
successorIndex
=
i
# and update the successorIndex to the index of this object
i
+=
1
self
.
receiver
=
object
# and update the receiver to the index of this object
#return true only to the predecessor from which the queue will take
receiverObject
=
activeObject
.
getReceiverObject
()
...
...
@@ -166,16 +165,16 @@ class Queue(CoreObject):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
giverObject
=
self
.
getGiverObject
()
#if we have only one predecessor just check if there is a place available and the predecessor has an entity to dispose
if
(
len
(
activeObject
.
previous
)
==
1
):
return
len
(
activeObjectQueue
)
<
self
.
capacity
and
giverObject
.
haveToDispose
(
activeObject
)
isRequested
=
False
# dummy boolean variable to check if any predecessor has something to hand in
maxTimeWaiting
=
0
# dummy timer to check which predecessor has been waiting the most
#loop through the predecessors to see which have to dispose and which is the one blocked for longer
i
=
0
# loop through all the predecessors
#loop through the predecessors to see which have to dispose and which is the one blocked for longer # loop through all the predecessors
for
object
in
activeObject
.
previous
:
if
(
object
.
haveToDispose
(
activeObject
)):
# if they have something to dispose off
isRequested
=
True
# then the Queue is requested to handle the entity
...
...
@@ -186,9 +185,8 @@ class Queue(CoreObject):
#if more than one predecessor have to dispose take the part from the one that is blocked longer
if
(
timeWaiting
>=
maxTimeWaiting
):
activeObject
.
predecessorIndex
=
i
maxTimeWaiting
=
timeWaiting
i
+=
1
# pick the predecessor waiting the more
activeObject
.
giver
=
object
maxTimeWaiting
=
timeWaiting
# pick the predecessor waiting the more
return
len
(
activeObjectQueue
)
<
self
.
capacity
and
isRequested
# return true when the Queue is not fully occupied and a predecessor is requesting it
# =======================================================================
# gets an entity from the predecessor that
...
...
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