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
ea7fa32a
Commit
ea7fa32a
authored
Apr 15, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BatchReasssembly updated to signalGiver/Receiver and cleanup
parent
e5759f22
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
70 deletions
+33
-70
dream/simulation/BatchReassembly.py
dream/simulation/BatchReassembly.py
+33
-70
No files found.
dream/simulation/BatchReassembly.py
View file @
ea7fa32a
...
...
@@ -45,10 +45,7 @@ class BatchReassembly(CoreObject):
#initialize the id, the capacity of the object and the distribution
# =======================================================================
def
__init__
(
self
,
id
,
name
,
numberOfSubBatches
=
1
,
processingTime
=
None
,
operator
=
'None'
):
CoreObject
.
__init__
(
self
,
id
,
name
)
# hold the id, name, and type of the Machine instance
self
.
id
=
id
self
.
objName
=
name
CoreObject
.
__init__
(
self
,
id
,
name
)
self
.
type
=
"BatchRassembly"
#String that shows the type of object
if
not
processingTime
:
processingTime
=
{
'distributionType'
:
'Fixed'
,
...
...
@@ -63,11 +60,6 @@ class BatchReassembly(CoreObject):
self
.
operator
=
operator
# Sets the attributes of the processing (and failure) time(s)
self
.
rng
=
RandomNumberGenerator
(
self
,
**
processingTime
)
# for routing purposes
self
.
next
=
[]
#list with the next objects in the flow
self
.
previous
=
[]
#list with the previous objects in the flow
# self.nextIds=[] #list with the ids of the next objects in the flow
# self.previousIds=[] #list with the ids of the previous objects in the flow
# =======================================================================
# initialize the internal resource of the object
...
...
@@ -116,15 +108,25 @@ class BatchReassembly(CoreObject):
if
len
(
self
.
getActiveObjectQueue
())
==
self
.
numberOfSubBatches
and
self
.
currentEntity
.
type
!=
'Batch'
:
yield
hold
,
self
,
self
.
calculateProcessingTime
()
self
.
reassemble
()
if
not
self
.
signalReceiver
():
while
1
:
event
=
yield
waitevent
,
self
,
[
self
.
canDispose
,
self
.
interruptiontStart
]
if
self
.
interruptionStart
.
signalparam
==
now
():
yield
waitevent
,
self
,
self
.
interruptionEnd
assert
self
==
self
.
interruptionEnd
.
signalparam
if
self
.
signalReceiver
():
break
if
not
self
.
signalReceiver
():
while
1
:
event
=
yield
waitevent
,
self
,
[
self
.
canDispose
,
self
.
interruptionStart
]
if
self
.
interruptionStart
.
signalparam
==
now
():
yield
waitevent
,
self
,
self
.
interruptionEnd
assert
self
==
self
.
interruptionEnd
.
signalparam
if
self
.
signalReceiver
():
break
# =======================================================================
# removes an entity from the Machine
# =======================================================================
def
removeEntity
(
self
,
entity
=
None
):
activeObject
=
self
.
getActiveObject
()
activeEntity
=
CoreObject
.
removeEntity
(
self
,
entity
)
# run the default method
activeObject
.
waitToDispose
=
False
# update the waitToDispose flag
if
activeObject
.
canAccept
():
activeObject
.
signalGiver
()
return
activeEntity
# =======================================================================
# reassemble method that assembles the subBatches back together to a Batch
...
...
@@ -171,21 +173,22 @@ class BatchReassembly(CoreObject):
def
canAccept
(
self
,
callerObject
=
None
):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
# giverObject=self.getGiverObject()
# giverObjectQueue = self.getGiverObjectQueue()
if
len
(
activeObject
.
previous
)
!=
1
:
assert
callerObject
!=
None
,
'the callerObject cannot be None for canAccept of BatchReassembly'
# if there is only one predecessor
if
(
len
(
activeObject
.
previous
)
==
1
):
# find the predecessor object and its queue
predecessor
=
activeObject
.
previous
[
0
]
predecessorQueue
=
predecessor
.
getActiveObjectQueue
()
if
len
(
activeObjectQueue
)
==
0
:
return
activeObject
.
Up
elif
len
(
activeObject
.
previous
[
0
].
getActiveObjectQueue
()
)
==
0
:
elif
len
(
predecessorQueue
)
==
0
:
return
False
else
:
return
activeObject
.
Up
\
and
activeObjectQueue
[
0
].
type
!=
'Batch'
\
and
len
(
activeObjectQueue
)
<
self
.
numberOfSubBatches
\
and
activeObject
.
previous
[
0
].
getActiveObjectQueue
()
[
0
].
batchId
==
activeObjectQueue
[
0
].
batchId
and
predecessorQueue
[
0
].
batchId
==
activeObjectQueue
[
0
].
batchId
thecaller
=
callerObject
# return True ONLY if the length of the activeOjbectQueue is smaller than
...
...
@@ -202,7 +205,6 @@ class BatchReassembly(CoreObject):
# get active and the receiver object
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
# receiverObject=activeObject.getReceiverObject()
#if we have only one successor just check if object waits to dispose and also is up
# this is done to achieve better (cpu) processing time
if
(
len
(
activeObject
.
next
)
==
1
or
callerObject
==
None
):
...
...
@@ -210,18 +212,6 @@ class BatchReassembly(CoreObject):
and
activeObjectQueue
[
0
].
type
==
"Batch"
# the control of the length of the queue is not needed
thecaller
=
callerObject
# #give the entity to the receiver that is waiting for the most time.
# #plant does not do this in every occasion!
# maxTimeWaiting=0
# 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.receiver=object # and update the successorIndex to the index of this object
#
# #return true only to the predecessor from which the queue will take
# receiverObject=activeObject.getReceiverObject()
return
len
(
activeObjectQueue
)
==
1
\
and
(
thecaller
in
activeObject
.
next
)
\
and
activeObjectQueue
[
0
].
type
!=
"Batch"
# the control of the length of the queue is not needed
...
...
@@ -237,39 +227,12 @@ class BatchReassembly(CoreObject):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
giverObject
=
self
.
getGiverObject
()
giverObjectQueue
=
self
.
getGiverObjectQueue
()
# #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):
# if len(activeObjectQueue)==0:
# return activeObject.Up and giverObject.haveToDispose(activeObject)
# else:
# return activeObject.Up and giverObject.haveToDispose(activeObject)\
# and activeObjectQueue[0].type!='Batch'\
# and len(activeObjectQueue)<self.numberOfSubBatches\
# and giverObjectQueue[0].batchId==activeObjectQueue[0].batchId
#
# 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 # 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
# if(object.downTimeInTryingToReleaseCurrentEntity>0):# if the predecessor has failed wile waiting
# timeWaiting=now()-object.timeLastFailureEnded # then update according the timeWaiting to be compared with the ones
# else: # of the other machines
# 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 isRequested\
# and activeObject.Up\
# and len(activeObjectQueue)<self.numberOfSubBatches\
# and (len(activeObjectQueue)==0 or activeObjectQueue[0].type!='Batch')\
# and activeObject.getGiverObjectQueue()[0].batchId==activeObjectQueue[0].batchId
# return true when the Queue is not fully occupied and a predecessor is requesting it
return
activeObject
.
Up
and
giverObject
.
haveToDispose
(
activeObject
)
\
if
(
len
(
activeObjectQueue
)
==
0
):
return
activeObject
.
Up
and
giverObject
.
haveToDispose
(
activeObject
)
else
:
return
activeObject
.
Up
and
giverObject
.
haveToDispose
(
activeObject
)
\
and
len
(
activeObjectQueue
)
<
activeObject
.
numberOfSubBatches
\
and
(
len
(
activeObjectQueue
)
==
0
or
activeObjectQueue
[
0
].
type
!=
'Batch'
)
\
and
activeObjectQueue
[
0
].
type
!=
'Batch'
\
and
giverObjectQueue
[
0
].
batchId
==
activeObjectQueue
[
0
].
batchId
\ 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