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
e2e10cac
Commit
e2e10cac
authored
Apr 16, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JobShopObjects updated to handle events.
parent
087c5b76
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
183 additions
and
111 deletions
+183
-111
dream/simulation/ExitJobShop.py
dream/simulation/ExitJobShop.py
+21
-0
dream/simulation/MachineJobShop.py
dream/simulation/MachineJobShop.py
+110
-79
dream/simulation/OperatedPoolBroker.py
dream/simulation/OperatedPoolBroker.py
+1
-1
dream/simulation/Queue.py
dream/simulation/Queue.py
+1
-1
dream/simulation/QueueJobShop.py
dream/simulation/QueueJobShop.py
+50
-30
No files found.
dream/simulation/ExitJobShop.py
View file @
e2e10cac
...
@@ -41,4 +41,25 @@ class ExitJobShop(Exit):
...
@@ -41,4 +41,25 @@ class ExitJobShop(Exit):
from
Globals
import
G
from
Globals
import
G
self
.
previous
=
G
.
ObjList
self
.
previous
=
G
.
ObjList
Exit
.
initialize
(
self
)
#run default behaviour
Exit
.
initialize
(
self
)
#run default behaviour
#===========================================================================
# method used to check whether the station is in the entity-to-be-received route
# TODO: consider giving the activeEntity as attribute
#===========================================================================
def
isInRoute
(
self
,
callerObject
=
None
):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
thecaller
=
callerObject
# if the caller is not defined then return True. We are only interested in checking whether
# the station can accept whatever entity from whichever giver
if
not
thecaller
:
return
True
#check it the caller object holds an Entity that requests for current object
if
len
(
thecaller
.
getActiveObjectQueue
())
>
0
:
# TODO: make sure that the first entity of the callerObject is to be disposed
activeEntity
=
thecaller
.
getActiveObjectQueue
()[
0
]
# if the machine's Id is in the list of the entity's next stations
if
activeObject
.
id
in
activeEntity
.
remainingRoute
[
0
].
get
(
'stationIdsList'
,[]):
return
True
return
False
\ No newline at end of file
dream/simulation/MachineJobShop.py
View file @
e2e10cac
This diff is collapsed.
Click to expand it.
dream/simulation/OperatedPoolBroker.py
View file @
e2e10cac
...
@@ -135,7 +135,7 @@ class Broker(ObjectInterruption):
...
@@ -135,7 +135,7 @@ class Broker(ObjectInterruption):
if
candidateMachines
:
if
candidateMachines
:
maxTimeWaiting
=
0
maxTimeWaiting
=
0
receiver
=
None
receiver
=
None
# choose the one that waits the most time and
assign
give it the chance to grasp the resource
# choose the one that waits the most time and give it the chance to grasp the resource
for
machine
in
candidateMachines
:
for
machine
in
candidateMachines
:
timeWaiting
=
now
()
-
machine
.
broker
.
timeWaitForOperatorStarted
timeWaiting
=
now
()
-
machine
.
broker
.
timeWaitForOperatorStarted
if
(
timeWaiting
>
maxTimeWaiting
or
maxTimeWaiting
==
0
):
if
(
timeWaiting
>
maxTimeWaiting
or
maxTimeWaiting
==
0
):
...
...
dream/simulation/Queue.py
View file @
e2e10cac
...
@@ -160,7 +160,7 @@ class Queue(CoreObject):
...
@@ -160,7 +160,7 @@ class Queue(CoreObject):
activeObject
=
self
.
getActiveObject
()
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
giverObject
=
self
.
getGiverObject
()
giverObject
=
self
.
getGiverObject
()
return
len
(
activeObjectQueue
)
<
self
.
capacity
and
giverObject
.
haveToDispose
(
activeObject
)
return
len
(
activeObjectQueue
)
<
activeObject
.
capacity
and
giverObject
.
haveToDispose
(
activeObject
)
# =======================================================================
# =======================================================================
...
...
dream/simulation/QueueJobShop.py
View file @
e2e10cac
...
@@ -48,48 +48,67 @@ class QueueJobShop(Queue):
...
@@ -48,48 +48,67 @@ class QueueJobShop(Queue):
# it checks also the next station of the Entity
# it checks also the next station of the Entity
# and returns true only if the active object is the next station
# and returns true only if the active object is the next station
# =======================================================================
# =======================================================================
def
canAccept
(
self
,
callerObject
=
None
):
def
canAccept
(
self
,
callerObject
=
None
):
if
callerObject
!=
None
:
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
thecaller
=
callerObject
#return according to the state of the Queue
#check it the caller object holds an Entity that requests for current object
#check it the caller object holds an Entity that requests for current object
if
len
(
callerObject
.
getActiveObjectQueue
())
>
0
:
return
len
(
self
.
getActiveObjectQueue
())
<
activeObject
.
capacity
\
activeEntity
=
callerObject
.
getActiveObjectQueue
()[
0
]
and
activeObject
.
isInRoute
(
callerObject
)
# check if the object in the active entity's route next step
if
self
.
id
in
activeEntity
.
remainingRoute
[
0
].
get
(
'stationIdsList'
,[]):
#===========================================================================
# if activeEntity.remainingRoute[0][0]==self.id:
# method used to check whether the station is in the entity-to-be-received route
return
len
(
self
.
getActiveObjectQueue
())
<
self
.
capacity
#return according to the state of the Queue
# TODO: consider giving the activeEntity as attribute
return
False
#===========================================================================
def
isInRoute
(
self
,
callerObject
=
None
):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
thecaller
=
callerObject
# if the caller is not defined then return True. We are only interested in checking whether
# the station can accept whatever entity from whichever giver
if
not
thecaller
:
return
True
#check it the caller object holds an Entity that requests for current object
if
len
(
thecaller
.
getActiveObjectQueue
())
>
0
:
# TODO: make sure that the first entity of the callerObject is to be disposed
activeEntity
=
thecaller
.
getActiveObjectQueue
()[
0
]
# if the machine's Id is in the list of the entity's next stations
if
activeObject
.
id
in
activeEntity
.
remainingRoute
[
0
].
get
(
'stationIdsList'
,[]):
return
True
return
False
# =======================================================================
# =======================================================================
# checks if the Queue can dispose an entity.
# checks if the Queue can dispose an entity.
# Returns True only to the potential receiver
# Returns True only to the potential receiver
# =======================================================================
# =======================================================================
def
haveToDispose
(
self
,
callerObject
=
None
):
def
haveToDispose
(
self
,
callerObject
=
None
):
# print self.id, 'htd',
# if callerObject:
# print callerObject.id
# get active object and its queue
# get active object and its queue
activeObject
=
self
.
getActiveObject
()
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
thecaller
=
callerObject
thecaller
=
callerObject
#if we have only one possible receiver just check if the Queue holds one or more entities
#if we have only one possible receiver just check if the Queue holds one or more entities
if
(
len
(
activeObject
.
next
)
==
1
or
callerObject
==
None
):
if
(
callerObject
==
None
):
activeObject
.
receiver
=
activeObject
.
next
[
0
]
return
len
(
activeObjectQueue
)
>
0
return
len
(
activeObjectQueue
)
>
0
\
and
thecaller
==
activeObject
.
receiver
#give the entity to the possible receiver that is waiting for the most time.
#return True if the Queue has Entities and the caller is in the self.next list
#plant does not do this in every occasion!
return
len
(
activeObjectQueue
)
>
0
\
maxTimeWaiting
=
0
and
(
thecaller
in
activeObject
.
next
)
\
hasFreeReceiver
=
False
and
thecaller
.
isInRoute
(
activeObject
)
# loop through the object in the successor list
for
object
in
activeObject
.
next
:
#===========================================================================
if
(
object
.
canAccept
(
activeObject
)):
# if the object can accept
# extend the default behaviour to check if whether the station
hasFreeReceiver
=
True
# is in the route of the entity to be received
timeWaiting
=
now
()
-
object
.
timeLastEntityLeft
# compare the time that it has been waiting
#===========================================================================
if
(
timeWaiting
>
maxTimeWaiting
or
maxTimeWaiting
==
0
):
# with the others'
def
canAcceptAndIsRequested
(
self
):
maxTimeWaiting
=
timeWaiting
activeObject
=
self
.
getActiveObject
()
self
.
receiver
=
object
# and update the receiver to the index of this object
giverObject
=
activeObject
.
getGiverObject
()
if
activeObject
.
isInRoute
(
giverObject
):
#return True if the Queue has Entities and the caller is the receiver
return
Queue
.
canAcceptAndIsRequested
(
self
)
return
len
(
activeObjectQueue
)
>
0
and
(
thecaller
is
self
.
receiver
)
and
hasFreeReceiver
# =======================================================================
# =======================================================================
# gets an entity from the predecessor that the predecessor index points to
# gets an entity from the predecessor that the predecessor index points to
...
@@ -139,8 +158,9 @@ class QueueJobShop(Queue):
...
@@ -139,8 +158,9 @@ class QueueJobShop(Queue):
# =======================================================================
# =======================================================================
def
removeEntity
(
self
,
entity
=
None
):
def
removeEntity
(
self
,
entity
=
None
):
activeObject
=
self
.
getActiveObject
()
activeObject
=
self
.
getActiveObject
()
receiverObject
=
self
.
receiver
receiverObject
=
activeObject
.
getReceiverObject
()
activeEntity
=
Queue
.
removeEntity
(
self
,
entity
)
#run the default method
#run the default method
activeEntity
=
Queue
.
removeEntity
(
self
,
entity
)
removeReceiver
=
True
removeReceiver
=
True
# search in the internalQ. If an entity has the same receiver do not remove
# search in the internalQ. If an entity has the same receiver do not remove
for
ent
in
self
.
getActiveObjectQueue
():
for
ent
in
self
.
getActiveObjectQueue
():
...
...
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