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
8e5f31b4
Commit
8e5f31b4
authored
May 26, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
printTrace method changed. Clean-up
parent
6ddc3dae
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
195 additions
and
210 deletions
+195
-210
dream/simulation/Assembly.py
dream/simulation/Assembly.py
+8
-16
dream/simulation/Conveyer.py
dream/simulation/Conveyer.py
+13
-29
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+47
-88
dream/simulation/Dismantle.py
dream/simulation/Dismantle.py
+3
-6
dream/simulation/Globals.py
dream/simulation/Globals.py
+75
-0
dream/simulation/Machine.py
dream/simulation/Machine.py
+8
-34
dream/simulation/MachineJobShop.py
dream/simulation/MachineJobShop.py
+2
-4
dream/simulation/OperatedPoolBroker.py
dream/simulation/OperatedPoolBroker.py
+7
-13
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+21
-2
dream/simulation/Queue.py
dream/simulation/Queue.py
+7
-14
dream/simulation/QueueManagedJob.py
dream/simulation/QueueManagedJob.py
+3
-3
dream/simulation/Source.py
dream/simulation/Source.py
+1
-1
No files found.
dream/simulation/Assembly.py
View file @
8e5f31b4
...
...
@@ -123,26 +123,22 @@ class Assembly(CoreObject):
# check if there is WIP and signal receiver
self
.
initialSignalReceiver
()
while
1
:
# self.printTrace(self.id, 'will wait for frame event')
self
.
printTrace1
(
self
.
id
,
waitEvent
=
''
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
''
)
# wait until the Queue can accept an entity and one predecessor requests it
yield
waitevent
,
self
,
self
.
isRequested
#[self.isRequested,self.canDispose, self.loadOperatorAvailable]
if
self
.
isRequested
.
signalparam
:
# self.printTrace(self.id, 'received a isRequested event from '+self.isRequested.signalparam.id)
self
.
printTrace1
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
self
.
getEntity
(
"Frame"
)
#get the Frame
for
i
in
range
(
self
.
getActiveObjectQueue
()[
0
].
capacity
):
#this loop will be carried until the Frame is full with the parts
self
.
printTrace1
(
self
.
id
,
waitEvent
=
'(to load parts)'
)
# self.printTrace(self.id, 'will wait for part event')
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(to load parts)'
)
yield
waitevent
,
self
,
self
.
isRequested
if
self
.
isRequested
.
signalparam
:
# self.printTrace(self.id, 'received a isRequested event from '+self.isRequested.signalparam.id)
self
.
printTrace1
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
# TODO: fix the getEntity 'Part' case
...
...
@@ -166,8 +162,7 @@ class Assembly(CoreObject):
self
.
completedJobs
+=
1
#Assembly completed a job
self
.
waitToDispose
=
True
#since all the frame is full
# self.printTrace(self.id, 'will try to signal a receiver from generator')
self
.
printTrace1
(
self
.
id
,
attemptSignalReceiver
=
'(generator'
)
self
.
printTrace
(
self
.
id
,
attemptSignalReceiver
=
'(generator'
)
# signal the receiver that the activeObject has something to dispose of
if
not
self
.
signalReceiver
():
# if there was no available receiver, get into blocking control
...
...
@@ -250,8 +245,7 @@ class Assembly(CoreObject):
activeEntity
=
CoreObject
.
removeEntity
(
self
,
entity
)
#run the default method
self
.
waitToDispose
=
False
if
self
.
canAccept
():
# self.printTrace(self.id, 'will try signalling a giver from removeEntity')
self
.
printTrace1
(
self
.
id
,
attemptSignalGiver
=
'(removeEntity)'
)
self
.
printTrace
(
self
.
id
,
attemptSignalGiver
=
'(removeEntity)'
)
self
.
signalGiver
()
return
activeEntity
...
...
@@ -276,8 +270,7 @@ class Assembly(CoreObject):
assert
activeEntity
.
type
==
type
,
'the type of the entity to get must be of type '
+
type
+
' while it is '
+
activeEntity
.
type
#remove the entity from the previews object
giverObject
.
removeEntity
(
activeEntity
)
# self.printTrace(activeEntity.name, "got into "+self.id)
self
.
printTrace1
(
activeEntity
.
name
,
enter
=
self
.
id
)
self
.
printTrace
(
activeEntity
.
name
,
enter
=
self
.
id
)
self
.
outputTrace
(
activeEntity
.
name
,
"got into "
+
self
.
objName
)
# if the type is Frame
if
(
activeEntity
.
type
==
"Frame"
):
...
...
@@ -287,8 +280,7 @@ class Assembly(CoreObject):
# if the frame is not fully loaded then signal a giver
if
len
(
activeObjectQueue
[
0
].
getFrameQueue
())
<
activeObjectQueue
[
0
].
capacity
:
# self.printTrace(self.id, 'will try signalling a giver from getEntity')
self
.
printTrace1
(
self
.
id
,
attemptSignalGiver
=
'(getEntity)'
)
self
.
printTrace
(
self
.
id
,
attemptSignalGiver
=
'(getEntity)'
)
self
.
signalGiver
()
return
activeEntity
...
...
dream/simulation/Conveyer.py
View file @
8e5f31b4
...
...
@@ -100,13 +100,11 @@ class Conveyer(CoreObject):
# print self.id, 'time to move', self.conveyerMover.timeToWait
self
.
conveyerMover
.
canMove
.
signal
(
now
())
# self.printTrace(self.id, 'will wait for event')
self
.
printTrace1
(
self
.
id
,
waitEvent
=
''
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
''
)
yield
waitevent
,
self
,
[
self
.
isRequested
,
self
.
canDispose
,
self
.
moveEnd
]
# , self.loadOperatorAvailable]
# if the event that activated the thread is isRequested then getEntity
if
self
.
isRequested
.
signalparam
:
# self.printTrace(self.id, 'received an is requested event')
self
.
printTrace1
(
self
.
id
,
isRequested
=
''
)
self
.
printTrace
(
self
.
id
,
isRequested
=
''
)
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
# get the entity
...
...
@@ -119,32 +117,26 @@ class Conveyer(CoreObject):
# self.loadOperatorAvailable.signalparam=None
# if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer
if
self
.
canDispose
.
signalparam
:
# self.printTrace(self.id, 'received a canDispose event')
self
.
printTrace1
(
self
.
id
,
canDispose
=
''
)
self
.
printTrace
(
self
.
id
,
canDispose
=
''
)
self
.
canDispose
.
signalparam
=
None
# if the object received a moveEnd signal from the ConveyerMover
if
self
.
moveEnd
.
signalparam
:
# self.printTrace(self.id, 'received a moveEnd event')
self
.
printTrace1
(
self
.
id
,
moveEnd
=
''
)
self
.
printTrace
(
self
.
id
,
moveEnd
=
''
)
self
.
moveEnd
.
signalparam
=
None
# check if there is a possibility to accept and signal a giver
if
self
.
canAccept
():
# self.printTrace(self.id, 'will try to signal Giver from removeEntity')
self
.
printTrace1
(
self
.
id
,
attemptSignalGiver
=
'(removeEntity)'
)
self
.
printTrace
(
self
.
id
,
attemptSignalGiver
=
'(removeEntity)'
)
self
.
signalGiver
()
# if the event that activated the thread is canDispose then signalReceiver
if
self
.
haveToDispose
():
# self.printTrace(self.id, 'will try to signal a receiver from generator')
self
.
printTrace1
(
self
.
id
,
attemptSignalReceiver
=
'(generator)'
)
self
.
printTrace
(
self
.
id
,
attemptSignalReceiver
=
'(generator)'
)
if
self
.
receiver
:
if
not
self
.
receiver
.
entryIsAssignedTo
():
# self.printTrace(self.id, 'will try to signal receiver from generator1')
self
.
printTrace1
(
self
.
id
,
attemptSignalReceiver
=
'(generator1)'
)
self
.
printTrace
(
self
.
id
,
attemptSignalReceiver
=
'(generator1)'
)
self
.
signalReceiver
()
continue
# self.printTrace(self.id, 'will try to signal receiver from generator2')
self
.
printTrace1
(
self
.
id
,
attemptSignalReceiver
=
'(generator2)'
)
self
.
printTrace
(
self
.
id
,
attemptSignalReceiver
=
'(generator2)'
)
self
.
signalReceiver
()
#===========================================================================
...
...
@@ -203,8 +195,7 @@ class Conveyer(CoreObject):
if
(
self
.
length
-
self
.
position
[
0
]
<
0.000001
)
and
(
not
self
.
entityLastReachedEnd
==
self
.
getActiveObjectQueue
()[
0
]):
self
.
waitToDispose
=
True
self
.
entityLastReachedEnd
=
self
.
getActiveObjectQueue
()[
0
]
# self.printTrace(self.getActiveObjectQueue()[0].name, 'has reached the end'+' !! . !! .'*7)
self
.
printTrace1
(
self
.
getActiveObjectQueue
()[
0
].
name
,
conveyerEnd
=
''
)
self
.
printTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
conveyerEnd
=
''
)
return
True
return
False
...
...
@@ -343,8 +334,7 @@ class Conveyer(CoreObject):
if
self
.
isFull
():
self
.
timeBlockageStarted
=
now
()
self
.
wasFull
=
True
# self.printTrace(self.id, 'is now Full '+str(len(self.getActiveObjectQueue()))+' (*) '*20)
self
.
printTrace1
(
self
.
id
,
conveyerFull
=
str
(
len
(
self
.
getActiveObjectQueue
())))
self
.
printTrace
(
self
.
id
,
conveyerFull
=
str
(
len
(
self
.
getActiveObjectQueue
())))
return
activeEntity
#===========================================================================
...
...
@@ -367,8 +357,7 @@ class Conveyer(CoreObject):
self
.
conveyerMover
.
canMove
.
signal
(
now
())
# if there is anything to dispose of then signal a receiver
if
self
.
haveToDispose
():
# self.printTrace(self.id, 'will try to signal a receiver from removeEntity')
self
.
printTrace1
(
self
.
id
,
attemptSingalReceiver
=
'(removeEntity)'
)
self
.
printTrace
(
self
.
id
,
attemptSingalReceiver
=
'(removeEntity)'
)
self
.
signalReceiver
()
return
activeEntity
...
...
@@ -521,18 +510,13 @@ class ConveyerMover(Process):
#===========================================================================
def
run
(
self
):
while
1
:
# self.conveyer.printTrace(self.conveyer.id, 'mover will wait for canMove event')
self
.
conveyer
.
printTrace1
(
self
.
conveyer
.
id
,
waitEvent
=
'(canMove)'
)
self
.
conveyer
.
printTrace
(
self
.
conveyer
.
id
,
waitEvent
=
'(canMove)'
)
yield
waitevent
,
self
,
self
.
canMove
#wait until the conveyer triggers the mover
# self.conveyer.printTrace(self.conveyer.id, 'mover received canMove event')
self
.
conveyer
.
printTrace1
(
self
.
conveyer
.
id
,
received
=
'(canMove)'
)
self
.
conveyer
.
printTrace
(
self
.
conveyer
.
id
,
received
=
'(canMove)'
)
yield
hold
,
self
,
self
.
timeToWait
#wait for the time that the conveyer calculated
# print '. .'*40
# print 'conveyer moving entities'
# continue if interrupted
self
.
conveyer
.
moveEntities
()
#move the entities of the conveyer
# self.conveyer.call=False #reset call so it will be triggered only when it is needed again
self
.
conveyer
.
moveEnd
.
signal
(
now
())
...
...
dream/simulation/CoreObject.py
View file @
8e5f31b4
This diff is collapsed.
Click to expand it.
dream/simulation/Dismantle.py
View file @
8e5f31b4
...
...
@@ -117,14 +117,12 @@ class Dismantle(CoreObject):
# check if there is WIP and signal receiver
self
.
initialSignalReceiver
()
while
1
:
# self.printTrace(self.id, 'will wait for frame event')
self
.
printTrace1
(
self
.
id
,
waitEvent
=
'(frame)'
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(frame)'
)
# wait until the Queue can accept an entity and one predecessor requests it
yield
waitevent
,
self
,
self
.
isRequested
#[self.isRequested,self.canDispose, self.loadOperatorAvailable]
if
self
.
isRequested
.
signalparam
:
# self.printTrace(self.id, 'received a isRequested event from '+self.isRequested.signalparam.id)
self
.
printTrace1
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
...
...
@@ -277,8 +275,7 @@ class Dismantle(CoreObject):
activeObject
.
waitToDisposePart
=
False
# if the internal queue is empty then try to signal the giver that the object can now receive
if
activeObject
.
canAccept
():
# activeObject.printTrace(self.id, 'will try signalling a giver from removeEntity')
activeObject
.
printTrace1
(
self
.
id
,
attemptSingalGiver
=
'(removeEntity)'
)
activeObject
.
printTrace
(
self
.
id
,
attemptSingalGiver
=
'(removeEntity)'
)
activeObject
.
signalGiver
()
return
activeEntity
...
...
dream/simulation/Globals.py
View file @
8e5f31b4
...
...
@@ -279,3 +279,78 @@ def getConfidenceIntervals(value_list):
'ub'
:
ub
,
'avg'
:
numpy
.
mean
(
value_list
)
}
# #===========================================================================
# # printTrace
# #===========================================================================
# def printTrace(entity='',station='', **kw):
# assert len(kw)==1, 'only one phrase per printTrace supported for the moment'
# from Globals import G
# time=now()
# charLimit=60
# remainingChar=charLimit-len(entity)-len(str(time))
# if(G.console=='Yes'):
# print time,entity,
# for key in kw:
# if key not in getSupportedPrintKwrds():
# raise ValueError("Unsupported phrase %s for %s" % (key, station.id))
# element=getPhrase()[key]
# phrase=element['phrase']
# prefix=element.get('prefix',None)
# suffix=element.get('suffix',None)
# arg=kw[key]
# if prefix:
# print prefix*remainingChar,phrase,arg
# elif suffix:
# remainingChar-=len(phrase)+len(arg)
# suffix*=remainingChar
# if key=='enter':
# suffix=suffix+'>'
# print phrase,arg,suffix
# else:
# print phrase,arg
#===========================================================================
# get the supported print Keywords
#===========================================================================
def
getSupportedPrintKwrds
():
return
(
"create"
,
"signal"
,
"signalReceiver"
,
"signalGiver"
,
"attemptSignal"
,
"attemptSignalGiver"
,
"attemptSignalReceiver"
,
"preempt"
,
"preempted"
,
"startWork"
,
"finishWork"
,
"processEnd"
,
"interrupted"
,
"enter"
,
"waitEvent"
,
"received"
,
"isRequested"
,
"canDispose"
,
"interruptionEnd"
,
"loadOperatorAvailable"
,
'resourceAvailable'
,
'conveyerEnd'
,
'conveyerFull'
,
'moveEnd'
)
#===========================================================================
# get the phrase to print from the keyword
#===========================================================================
def
getPhrase
():
printKwrds
=
{
'create'
:{
'phrase'
:
'created an entity'
},
'signal'
:{
'phrase'
:
'signalling'
},
'signalGiver'
:{
'phrase'
:
'signalling giver'
,
'prefix'
:
'_'
},
'signalReceiver'
:{
'phrase'
:
'signalling receiver'
,
'prefix'
:
'_'
},
'attemptSignal'
:{
'phrase'
:
'will try to signal'
},
'attemptSignalGiver'
:{
'phrase'
:
'will try to signal a giver'
},
'attemptSignalReceiver'
:{
'phrase'
:
'will try to signal a receiver'
},
'preempt'
:
{
'phrase'
:
'preempts'
,
'suffix'
:
' .'
},
'preempted'
:
{
'phrase'
:
'is being preempted'
,
'suffix'
:
'. '
},
'startWork'
:{
'phrase'
:
'started working in'
},
'finishWork'
:{
'phrase'
:
'finished working in'
},
'processEnd'
:{
'phrase'
:
'ended processing in'
},
'interrupted'
:{
'phrase'
:
'interrupted at'
,
'suffix'
:
' .'
},
'enter'
:{
'phrase'
:
'got into'
,
'suffix'
:
'='
},
'waitEvent'
:{
'phrase'
:
'will wait for event'
},
'received'
:{
'phrase'
:
'received event'
},
'isRequested'
:{
'phrase'
:
'received an isRequested event from'
},
'canDispose'
:{
'phrase'
:
'received an canDispose event'
},
'interruptionEnd'
:{
'phrase'
:
'received an interruptionEnd event at'
},
"loadOperatorAvailable"
:{
'phrase'
:
'received a loadOperatorAvailable event at'
},
"resourceAvailable"
:{
'phrase'
:
'received a resourceAvailable event'
},
'moveEnd'
:{
'phrase'
:
'received a moveEnd event'
},
"conveyerEnd"
:{
'phrase'
:
'has reached conveyer End'
,
'suffix'
:
'.!'
},
'conveyerFull'
:{
'phrase'
:
'is now Full, No of units:'
,
'suffix'
:
'(*)'
}}
return
printKwrds
dream/simulation/Machine.py
View file @
8e5f31b4
...
...
@@ -228,15 +228,12 @@ class Machine(CoreObject):
while
1
:
# waitEvent isRequested /interruptionEnd/loadOperatorAvailable
while
1
:
# self.printTrace(self.id, 'will wait for event')
self
.
printTrace1
(
self
.
id
,
waitEvent
=
''
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
''
)
yield
waitevent
,
self
,
[
self
.
isRequested
,
self
.
interruptionEnd
,
self
.
loadOperatorAvailable
]
# self.printTrace(self.id, 'received an event')
self
.
printTrace1
(
self
.
id
,
received
=
''
)
self
.
printTrace
(
self
.
id
,
received
=
''
)
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity
if
self
.
isRequested
.
signalparam
:
# self.printTrace(self.id, 'received an isRequested event from'+self.isRequested.signalparam.id)
self
.
printTrace1
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
assert
self
.
isRequested
.
signalparam
==
self
.
giver
,
'the giver is not the requestingObject'
assert
self
.
giver
.
receiver
==
self
,
'the receiver of the signalling object in not the station'
# reset the signalparam of the isRequested event
...
...
@@ -246,11 +243,9 @@ class Machine(CoreObject):
# if an operator was rendered available while it was needed by the machine to proceed with getEntity
if
self
.
interruptionEnd
.
signalparam
==
now
()
or
self
.
loadOperatorAvailable
.
signalparam
==
now
():
if
self
.
interruptionEnd
.
signalparam
==
now
():
# self.printTrace(self.id, 'received an interruptionEnd event sent at '+str(self.interruptionEnd.signalparam))
self
.
printTrace1
(
self
.
id
,
interruptionEnd
=
str
(
self
.
interruptionEnd
.
signalparam
))
self
.
printTrace
(
self
.
id
,
interruptionEnd
=
str
(
self
.
interruptionEnd
.
signalparam
))
elif
self
.
loadOperatorAvailable
.
signalparam
==
now
():
# self.printTrace(self.id, 'received an loadOperatorAvailable event sent at '+str(self.loadOperatorAvailable.signalparam))
self
.
printTrace1
(
self
.
id
,
loadOperatorAvailable
=
str
(
self
.
loadOperatorAvailable
.
signalparam
))
self
.
printTrace
(
self
.
id
,
loadOperatorAvailable
=
str
(
self
.
loadOperatorAvailable
.
signalparam
))
# try to signal the Giver, otherwise wait until it is requested
if
self
.
signalGiver
():
break
...
...
@@ -475,8 +470,7 @@ class Machine(CoreObject):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
activeEntity
=
activeObjectQueue
[
0
]
# self.printTrace(activeObject.getActiveObjectQueue()[0].name,"ended processing in "+activeObject.objName)
self
.
printTrace1
(
activeObject
.
getActiveObjectQueue
()[
0
].
name
,
processEnd
=
activeObject
.
objName
)
self
.
printTrace
(
activeObject
.
getActiveObjectQueue
()[
0
].
name
,
processEnd
=
activeObject
.
objName
)
# reset the variables used to handle the interruptions timing
self
.
timeRestartingProcessing
=
0
self
.
breakTime
=
0
...
...
@@ -526,8 +520,7 @@ class Machine(CoreObject):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
activeEntity
=
activeObjectQueue
[
0
]
# self.printTrace(self.getActiveObjectQueue()[0].name, "Interrupted at "+self.objName+'. '*5)
self
.
printTrace1
(
self
.
getActiveObjectQueue
()[
0
].
name
,
interrupted
=
self
.
objName
)
self
.
printTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
interrupted
=
self
.
objName
)
# if the interrupt occured while processing an entity
if
not
activeObject
.
waitToDispose
:
# output to trace that the Machine (self.objName) got interrupted
...
...
@@ -712,8 +705,7 @@ class Machine(CoreObject):
activeObject
.
waitToDispose
=
False
# update the waitToDispose flag
# if the Machine canAccept then signal a giver
if
activeObject
.
canAccept
():
# self.printTrace(self.id, 'will try signalling a giver from removeEntity')
self
.
printTrace1
(
self
.
id
,
attemptSignalGiver
=
'(removeEntity)'
)
self
.
printTrace
(
self
.
id
,
attemptSignalGiver
=
'(removeEntity)'
)
activeObject
.
signalGiver
()
return
activeEntity
...
...
@@ -744,12 +736,6 @@ class Machine(CoreObject):
def
calculateLoadTime
(
self
):
return
self
.
loadRng
.
generateNumber
()
# =======================================================================
# prepare the machine to be operated
# =======================================================================
def
requestRouter
(
self
):
if
not
self
.
router
.
isCalled
():
self
.
router
.
invoke
()
#===========================================================================
# find candidate operators within the free operators
...
...
@@ -803,18 +789,6 @@ class Machine(CoreObject):
def
isOperated
(
self
):
return
self
.
toBeOperated
# =======================================================================
# check if the machine is already set-up
# =======================================================================
def
isSetUp
(
self
):
return
self
.
setUp
# =======================================================================
# request that the machine is set-up by an operator
# =======================================================================
def
requestSetup
(
self
):
self
.
setUp
=
False
# =======================================================================
# actions to be taken after the simulation ends
# =======================================================================
...
...
dream/simulation/MachineJobShop.py
View file @
8e5f31b4
...
...
@@ -49,8 +49,7 @@ class MachineJobShop(Machine):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
activeEntity
=
activeObjectQueue
[
0
]
# self.printTrace(activeObject.getActiveObjectQueue()[0].name,"ended processing in "+activeObject.objName)
self
.
printTrace1
(
activeObject
.
getActiveObjectQueue
()[
0
].
name
,
processEnd
=
activeObject
.
objName
)
self
.
printTrace
(
activeObject
.
getActiveObjectQueue
()[
0
].
name
,
processEnd
=
activeObject
.
objName
)
# reset the variables used to handle the interruptions timing
self
.
timeRestartingProcessing
=
0
self
.
breakTime
=
0
...
...
@@ -231,8 +230,7 @@ class MachineJobShop(Machine):
# method to execute preemption
# =======================================================================
def
preempt
(
self
):
# self.printTrace(self.id,'preempting'+' .'*7)
self
.
printTrace1
(
self
.
id
,
preempted
=
''
)
self
.
printTrace
(
self
.
id
,
preempted
=
''
)
activeObject
=
self
.
getActiveObject
()
activeEntity
=
self
.
getActiveObjectQueue
()[
0
]
#get the active Entity
#calculate the remaining processing time
...
...
dream/simulation/OperatedPoolBroker.py
View file @
8e5f31b4
...
...
@@ -71,7 +71,7 @@ class Broker(ObjectInterruption):
# TODO: add new broker event - brokerIsCalled
yield
waitevent
,
self
,
self
.
isCalled
assert
self
.
isCalled
.
signalparam
==
now
(),
'the broker should be granted control instantly'
self
.
victim
.
printTrace
1
(
self
.
victim
.
id
,
received
=
'(broker)'
)
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
received
=
'(broker)'
)
# ======= request a resource
if
self
.
victim
.
isOperated
()
\
and
any
(
type
==
'Load'
or
type
==
'Setup'
or
type
==
'Processing'
\
...
...
@@ -87,28 +87,24 @@ class Broker(ObjectInterruption):
if
not
self
.
victim
.
currentEntity
in
G
.
pendingEntities
:
G
.
pendingEntities
.
append
(
self
.
victim
.
currentEntity
)
if
not
G
.
Router
.
invoked
:
# self.printTrace(self.victim.id, 'broker'+' '*50+'signalling router')
self
.
victim
.
printTrace1
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
signal
(
now
())
self
.
waitForOperator
=
True
# self.printTrace(self.victim.id, 'broker waits till resource is available1')
self
.
victim
.
printTrace1
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
yield
waitevent
,
self
,
self
.
resourceAvailable
# remove the currentEntity from the pendingEntities
if
self
.
victim
.
currentEntity
in
G
.
pendingEntities
:
G
.
pendingEntities
.
remove
(
self
.
victim
.
currentEntity
)
self
.
waitForOperator
=
False
# self.printTrace(self.victim.id, 'received resourceAvailable event')
self
.
victim
.
printTrace1
(
self
.
victim
.
id
,
resourceAvailable
=
'(broker)'
)
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
resourceAvailable
=
'(broker)'
)
#===============================================================
assert
self
.
victim
.
operatorPool
.
checkIfResourceIsAvailable
(),
'there is no available operator to request'
# set the available resource as the currentOperator
self
.
victim
.
currentOperator
=
self
.
victim
.
operatorPool
.
findAvailableOperator
()
yield
request
,
self
,
self
.
victim
.
operatorPool
.
getResource
(
self
.
victim
.
currentOperator
)
# self.printTrace(self.victim.currentOperator.objName, 'started work in '+self.victim.id)
self
.
victim
.
printTrace1
(
self
.
victim
.
currentOperator
.
objName
,
startWork
=
self
.
victim
.
id
)
self
.
victim
.
printTrace
(
self
.
victim
.
currentOperator
.
objName
,
startWork
=
self
.
victim
.
id
)
# clear the timeWaitForOperatorStarted variable
self
.
timeWaitForOperatorStarted
=
0
# update the time that the operation started
...
...
@@ -125,16 +121,14 @@ class Broker(ObjectInterruption):
# TODO: signalling the router must be done more elegantly, router must be set as global variable
# if the router is already invoked then do not signal it again
if
not
self
.
victim
.
router
.
invoked
:
# self.printTrace(self.victim.id, 'broker'+' '*50+'signalling ROUTER')
self
.
victim
.
printTrace1
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
self
.
victim
.
router
.
invoked
=
True
self
.
victim
.
router
.
isCalled
.
signal
(
now
())
# TODO: signalling the router will give the chance to it to take the control, but when will it eventually receive it.
# after signalling the broker will signal it's victim that it has finished it's processes
# TODO: this wont work for the moment. The actions that follow must be performed by all operated brokers.
self
.
printTrace
(
self
.
victim
.
currentOperator
.
objName
,
'released '
+
self
.
victim
.
id
)
self
.
victim
.
printTrace1
(
self
.
victim
.
currentOperator
.
objName
,
finishWork
=
self
.
victim
.
id
)
self
.
victim
.
printTrace
(
self
.
victim
.
currentOperator
.
objName
,
finishWork
=
self
.
victim
.
id
)
# the victim current operator must be cleared after the operator is released
self
.
timeLastOperationEnded
=
now
()
self
.
victim
.
currentOperator
=
None
...
...
dream/simulation/OperatorRouter.py
View file @
8e5f31b4
...
...
@@ -386,13 +386,13 @@ class Router(ObjectInterruption):
# for each pendingQueue
for
object
in
self
.
pendingQueues
:
# find available operator for then machines that follow
for
nextobject
in
object
.
findReceivers
(
):
for
nextobject
in
object
.
findReceivers
For
(
object
):
candidateOperator
=
nextobject
.
findCandidateOperator
()
if
not
candidateOperator
in
self
.
candidateOperators
:
self
.
candidateOperators
.
append
(
candidateOperator
)
# check the option of preemption if there are critical entities and no available operators
#------------------------------------------------------------------------------
if
not
object
.
findReceivers
(
)
and
\
if
not
object
.
findReceivers
For
(
object
)
and
\
any
(
entity
for
entity
in
object
.
getActiveObjectQueue
()
if
entity
.
isCritical
):
# for each of the following objects
for
nextObject
in
object
.
next
:
...
...
@@ -533,6 +533,25 @@ class Router(ObjectInterruption):
candidateList
=
self
.
candidateOperators
self
.
activeQSorter
(
criterion
=
self
.
schedulingRule
,
candList
=
candidateList
)
def
findCandidateReceiverFor
(
self
,
entity
):
# initiate the local list variable available receivers
availableReceivers
=
[
x
for
x
in
entity
.
candidateReceivers
\
if
not
x
in
self
.
occupiedReceivers
]
# and pick the object that is waiting for the most time
if
availableReceivers
:
# find the receiver that waits the most
availableReceiver
=
entity
.
currentStation
.
selectReceiver
(
availableReceivers
)
self
.
occupiedReceivers
.
append
(
availableReceiver
)
# if there is no available receiver add the entity to the entitiesWithOccupiedReceivers list
else
:
self
.
entitiesWithOccupiedReceivers
.
append
(
entity
)
availableReceiver
=
None
# if the sorting flag is not set then the sorting of each queue must prevail in case of operators conflict
if
not
self
.
sorting
and
not
availableReceiver
and
bool
(
availableReceivers
):
availableReceiver
=
entity
.
currentStation
.
selectReceiver
(
self
.
candidateReceivers
)
if
not
entity
in
self
.
conflictingEntities
:
self
.
conflictingEntities
.
append
(
entity
)
return
availableReceiver
#=======================================================================
# Find candidate entities and their receivers
...
...
dream/simulation/Queue.py
View file @
8e5f31b4
...
...
@@ -96,16 +96,13 @@ class Queue(CoreObject):
# check if there is WIP and signal receiver
self
.
initialSignalReceiver
()
while
1
:
# self.printTrace(self.id, 'will wait for event')
self
.
printTrace1
(
self
.
id
,
waitEvent
=
''
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
''
)
# wait until the Queue can accept an entity and one predecessor requests it
yield
waitevent
,
self
,
[
self
.
isRequested
,
self
.
canDispose
,
self
.
loadOperatorAvailable
]
# self.printTrace(self.id, 'just received an event')
self
.
printTrace1
(
self
.
id
,
received
=
''
)
self
.
printTrace
(
self
.
id
,
received
=
''
)
# if the event that activated the thread is isRequested then getEntity
if
self
.
isRequested
.
signalparam
:
# self.printTrace(self.id, 'received a isRequested event from'+self.isRequested.signalparam.id)
self
.
printTrace1
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
self
.
getEntity
()
...
...
@@ -114,18 +111,15 @@ class Queue(CoreObject):
activeObjectQueue
[
0
].
startTime
=
now
()
# if the queue received an loadOperatorIsAvailable (from Router) with signalparam time
if
self
.
loadOperatorAvailable
.
signalparam
:
# self.printTrace(self.id, 'received a loadOperatorAvailable event')
# self.printTrace1(self.id, loadOperatorAvailable=str(self.loadOperatorAvailable.signalparam))
# self.printTrace(self.id, loadOperatorAvailable=str(self.loadOperatorAvailable.signalparam))
self
.
loadOperatorAvailable
.
signalparam
=
None
# if the queue received an canDispose with signalparam time, this means that the signals was sent from a MouldAssemblyBuffer
if
self
.
canDispose
.
signalparam
:
# self.printTrace(self.id, 'received a canDispose event')
self
.
printTrace1
(
self
.
id
,
canDispose
=
''
)
self
.
printTrace
(
self
.
id
,
canDispose
=
''
)
self
.
canDispose
.
signalparam
=
None
# if the event that activated the thread is canDispose then signalReceiver
if
self
.
haveToDispose
():
# self.printTrace(self.id, 'will try to signal a receiver from generator')
self
.
printTrace1
(
self
.
id
,
attemptSignalReceiver
=
'(generator)'
)
self
.
printTrace
(
self
.
id
,
attemptSignalReceiver
=
'(generator)'
)
if
self
.
receiver
:
if
not
self
.
receiver
.
entryIsAssignedTo
():
self
.
signalReceiver
()
...
...
@@ -178,8 +172,7 @@ class Queue(CoreObject):
# TODO: disable that for the mouldAssemblyBuffer
if
not
self
.
__class__
.
__name__
==
'MouldAssemblyBuffer'
:
if
self
.
haveToDispose
():
self
.
printTrace
(
self
.
id
,
'will try to signal a receiver from removeEntity'
)
self
.
printTrace1
(
self
.
id
,
attemptSignalReceiver
=
'(removeEntity)'
)
self
.
printTrace
(
self
.
id
,
attemptSignalReceiver
=
'(removeEntity)'
)
self
.
signalReceiver
()
return
activeEntity
...
...
dream/simulation/QueueManagedJob.py
View file @
8e5f31b4
...
...
@@ -104,7 +104,8 @@ class QueueManagedJob(QueueJobShop):
#===========================================================================
# signalRouter method
#===========================================================================
def
signalRouter
(
self
,
receiver
=
None
):
@
staticmethod
def
signalRouter
(
receiver
=
None
):
# if an operator is not assigned to the receiver then do not signal the receiver but the Router
# TODO: identifyEntityToGet needs giver defined but here is not yet defined for Machines and machineJobShops
try
:
...
...
@@ -113,8 +114,7 @@ class QueueManagedJob(QueueJobShop):
if
receiver
.
identifyEntityToGet
().
manager
.
isAssignedTo
()
!=
receiver
:
from
Globals
import
G
if
not
G
.
Router
.
invoked
:
# self.printTrace(self.id,' '*50+'signalling router')
self
.
printTrace1
(
self
.
id
,
signal
=
'router'
)
# self.printTrace(self.id, signal='router')
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
signal
(
now
())
return
True
...
...
dream/simulation/Source.py
View file @
8e5f31b4
...
...
@@ -171,7 +171,7 @@ class Source(CoreObject):
# creates an Entity
#============================================================================
def
createEntity
(
self
):
self
.
printTrace
(
self
.
id
,
'created an entity
'
)
# self.printTrace(self.id, create='
')
return
self
.
item
(
id
=
self
.
item
.
type
+
str
(
G
.
numberOfEntities
),
name
=
self
.
item
.
type
+
str
(
self
.
numberOfArrivals
))
#return the newly created Entity
#============================================================================
# calculates the processing time
...
...
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