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
23c117cb
Commit
23c117cb
authored
May 16, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new method prinTrace for printing on console
parent
b84a9fd4
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
143 deletions
+88
-143
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+19
-26
dream/simulation/Globals.py
dream/simulation/Globals.py
+4
-0
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+1
-0
dream/simulation/Machine.py
dream/simulation/Machine.py
+8
-14
dream/simulation/ObjectInterruption.py
dream/simulation/ObjectInterruption.py
+9
-1
dream/simulation/OperatedPoolBroker.py
dream/simulation/OperatedPoolBroker.py
+8
-20
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+32
-75
dream/simulation/Queue.py
dream/simulation/Queue.py
+7
-7
No files found.
dream/simulation/CoreObject.py
View file @
23c117cb
...
...
@@ -266,10 +266,7 @@ class CoreObject(Process):
#if the receiver does not hold an Entity that is also critical
if
not
self
.
receiver
.
getActiveObjectQueue
()[
0
].
isCritical
:
self
.
receiver
.
shouldPreempt
=
True
#=======================================================
# testing
# print now(), self.id, 'preempting receiver', self.receiver.id,'.. '*6
#=======================================================
self
.
printTrace
(
self
.
id
,
'preempting receiver'
+
self
.
receiver
.
id
+
'.. '
*
6
)
self
.
receiver
.
preempt
()
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
...
...
@@ -310,10 +307,7 @@ class CoreObject(Process):
# the hot flag should not be raised
if
successorsAreMachines
:
activeEntity
.
hot
=
True
#=======================================================================
# # TESTING
# print now(), activeEntity.name, "got into "+self.id
#=======================================================================
self
.
printTrace
(
activeEntity
.
name
,
"got into "
+
self
.
id
)
# update wipStatList
if
self
.
gatherWipStat
:
self
.
wipStatList
.
append
([
now
(),
len
(
activeObjectQueue
)])
...
...
@@ -333,7 +327,7 @@ class CoreObject(Process):
# signal the successor that the object can dispose an entity
# =======================================================================
def
signalReceiver
(
self
):
#
print now(), self.id, 'trying to signal receiver'
#
self.printTrace(self.id, 'trying to signal receiver')
activeObject
=
self
.
getActiveObject
()
possibleReceivers
=
activeObject
.
findReceivers
()
if
possibleReceivers
:
...
...
@@ -356,10 +350,7 @@ class CoreObject(Process):
activeObject
.
receiver
=
receiver
activeObject
.
receiver
.
giver
=
activeObject
#===================================================================
# # TESTING
# print now(), self.id,' '*50, 'signalling receiver', self.receiver.id
#===================================================================
self
.
printTrace
(
self
.
id
,
' '
*
50
+
'signalling receiver '
+
self
.
receiver
.
id
)
# assign the entry of the receiver
activeObject
.
receiver
.
assignEntryTo
()
activeObject
.
receiver
.
isRequested
.
signal
(
activeObject
)
...
...
@@ -392,10 +383,7 @@ class CoreObject(Process):
if
receiver
.
isLoadRequested
():
from
Globals
import
G
if
not
G
.
Router
.
invoked
:
#===================================================================
# # TESTING
# print now(), self.id,' '*50, 'signalling router'
#===================================================================
self
.
printTrace
(
self
.
id
,
' '
*
50
+
'signalling router'
)
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
signal
(
now
())
return
True
...
...
@@ -425,7 +413,7 @@ class CoreObject(Process):
# signal the giver that the entity is removed from its internalQueue
# =======================================================================
def
signalGiver
(
self
):
#
print now(), self.id, 'trying to signal giver'
#
self.printTrace(self.id, 'trying to signal giver')
activeObject
=
self
.
getActiveObject
()
possibleGivers
=
activeObject
.
findGivers
()
if
possibleGivers
:
...
...
@@ -440,10 +428,7 @@ class CoreObject(Process):
giversReceiver
=
activeObject
activeObject
.
giver
=
giver
activeObject
.
giver
.
receiver
=
activeObject
#===================================================================
# # TESTING
# print now(), self.id,' '*50, 'signalling giver', self.giver.id
#===================================================================
self
.
printTrace
(
self
.
id
,
' '
*
50
+
'signalling giver '
+
self
.
giver
.
id
)
activeObject
.
giver
.
canDispose
.
signal
(
activeObject
)
return
True
return
False
...
...
@@ -497,8 +482,17 @@ class CoreObject(Process):
if
(
G
.
traceIndex
==
65536
):
G
.
traceIndex
=
0
G
.
sheetIndex
+=
1
G
.
traceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
sheetIndex
),
cell_overwrite_ok
=
True
)
G
.
traceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
sheetIndex
),
cell_overwrite_ok
=
True
)
#===========================================================================
# prints message to the console
#===========================================================================
#print message in the console. Format is (Simulation Time | Entity or Frame Name | message)
def
printTrace
(
self
,
entityName
,
message
):
from
Globals
import
G
if
(
G
.
console
==
"Yes"
):
#output only if the user has selected to
print
now
(),
entityName
,
message
# =======================================================================
# outputs data to "output.xls"
# =======================================================================
...
...
@@ -604,15 +598,14 @@ class CoreObject(Process):
# assign Exit of the object
# =======================================================================
def
assignExitTo
(
self
,
callerObject
=
None
):
# print self.id, 'assignExit'
# self.exitAssignedToReceiver = self.receiver
# self.printTrace(self.id, 'assignExit')
self
.
exitAssignedToReceiver
=
callerObject
# =======================================================================
# unblock the object
# =======================================================================
def
unAssignExit
(
self
):
#
print now(),self.id, 'unassignExit'
#
self.printTrace(self.id, 'unassignExit')
self
.
exitAssignedToReceiver
=
None
# =======================================================================
...
...
dream/simulation/Globals.py
View file @
23c117cb
...
...
@@ -50,6 +50,10 @@ class G:
Base
=
1
#the Base time unit. Default =1 minute
maxSimTime
=
0
#the total simulation time
# flag for printing in console
# -----------------------------------------------------------------------
console
=
""
# data for the trace output in excel
# -----------------------------------------------------------------------
trace
=
""
#this is written from input. If it is "Yes" then you write to trace, else we do not
...
...
dream/simulation/LineGenerationJSON.py
View file @
23c117cb
...
...
@@ -103,6 +103,7 @@ def readGeneralInput():
G
.
numberOfReplications
=
int
(
general
.
get
(
'numberOfReplications'
,
'1'
))
# read the number of replications / default 1
G
.
maxSimTime
=
float
(
general
.
get
(
'maxSimTime'
,
'100'
))
# get the maxSimTime / default 100
G
.
trace
=
general
.
get
(
'trace'
,
'No'
)
# get trace in order to check if trace is requested
G
.
console
=
general
.
get
(
'console'
,
'No'
)
# get console flag in order to check if console print is requested
G
.
confidenceLevel
=
float
(
general
.
get
(
'confidenceLevel'
,
'0.95'
))
# get the confidence level
G
.
seed
=
general
.
get
(
'seed'
)
...
...
dream/simulation/Machine.py
View file @
23c117cb
...
...
@@ -226,12 +226,12 @@ class Machine(CoreObject):
while
1
:
# waitEvent isRequested /interruptionEnd/loadOperatorAvailable
while
1
:
#
print now(), self.id, 'will wait for event'
#
self.printTrace(self.id, 'will wait for event')
yield
waitevent
,
self
,
[
self
.
isRequested
,
self
.
interruptionEnd
,
self
.
loadOperatorAvailable
]
#
print now(), self.id, 'received an event'
#
self.printTrace(self.id, 'received an event')
# if the machine can accept an entity and one predecessor requests it continue with receiving the entity
if
self
.
isRequested
.
signalparam
:
#
print now(), self.id, 'received an isRequested event from', self.isRequested.signalparam.id
#
self.printTrace(self.id, 'received an isRequested event from'+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
...
...
@@ -241,9 +241,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():
#
print self.id, 'received an interruptionEnd event sent at ', self.interruptionEnd.signalparam
#
self.printTrace(self.id, 'received an interruptionEnd event sent at '+self.interruptionEnd.signalparam)
# elif self.loadOperatorAvailable.signalparam==now():
#
print now(), self.id, 'received an loadOperatorAvailable event sent at ', self.loadOperatorAvailable.signalparam
#
self.printTrace(self.id, 'received an loadOperatorAvailable event sent at '+self.loadOperatorAvailable.signalparam)
# try to signal the Giver, otherwise wait until it is requested
if
self
.
signalGiver
():
break
...
...
@@ -481,10 +481,7 @@ class Machine(CoreObject):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
activeEntity
=
activeObjectQueue
[
0
]
#=======================================================================
# # TESTING
# print activeObject.getActiveObjectQueue()[0].name,"ended processing in "+activeObject.objName
#=======================================================================
self
.
printTrace
(
activeObject
.
getActiveObjectQueue
()[
0
].
name
,
"ended processing in "
+
activeObject
.
objName
)
# reset the variables used to handle the interruptions timing
self
.
timeRestartingProcessing
=
0
self
.
breakTime
=
0
...
...
@@ -539,10 +536,7 @@ class Machine(CoreObject):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
activeEntity
=
activeObjectQueue
[
0
]
#=======================================================================
# testing
# print self.getActiveObjectQueue()[0].name, "Interrupted at ",self.objName, '. '*5
#=======================================================================
self
.
printTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
"Interrupted at "
+
self
.
objName
+
'. '
*
5
)
# if the interrupt occured while processing an entity
if
not
activeObject
.
waitToDispose
:
# output to trace that the Machine (self.objName) got interrupted
...
...
@@ -747,7 +741,7 @@ class Machine(CoreObject):
activeObject
.
waitToDispose
=
False
# update the waitToDispose flag
# if the Machine canAccept then signal a giver
if
activeObject
.
canAccept
():
#
print self.id, now(), 'will try signalling a giver from removeEntity'
#
self.printTrace(self.id, 'will try signalling a giver from removeEntity')
activeObject
.
signalGiver
()
return
activeEntity
...
...
dream/simulation/ObjectInterruption.py
View file @
23c117cb
...
...
@@ -137,4 +137,12 @@ class ObjectInterruption(Process):
G
.
traceIndex
=
0
G
.
sheetIndex
+=
1
G
.
traceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
sheetIndex
),
cell_overwrite_ok
=
True
)
\ No newline at end of file
#===========================================================================
# prints message to the console
#===========================================================================
#print message in the console. Format is (Simulation Time | Entity or Frame Name | message)
def
printTrace
(
self
,
entityName
,
message
):
from
Globals
import
G
if
(
G
.
console
==
"Yes"
):
#output only if the user has selected to
print
now
(),
entityName
,
message
\ No newline at end of file
dream/simulation/OperatedPoolBroker.py
View file @
23c117cb
...
...
@@ -49,7 +49,6 @@ class Broker(ObjectInterruption):
self
.
timeWaitForOperatorStarted
=
0
# Broker events
self
.
isCalled
=
SimEvent
(
'brokerIsCalled'
)
# self.victimQueueIsEmpty=SimEvent('victimQueueIsEmpty')
self
.
resourceAvailable
=
SimEvent
(
'resourceAvailable'
)
self
.
waitForOperator
=
False
...
...
@@ -76,7 +75,7 @@ class Broker(ObjectInterruption):
if
self
.
victim
.
isOperated
()
\
and
any
(
type
==
'Load'
or
type
==
'Setup'
or
type
==
'Processing'
\
for
type
in
self
.
victim
.
multOperationTypeList
):
#
print now(), self.victim.id, 'broker is invoked'
#
self.printTrace(self.victim.id, 'broker is invoked')
# update the time that the station is waiting for the operator
self
.
timeWaitForOperatorStarted
=
now
()
#===============================================================
...
...
@@ -88,30 +87,24 @@ class Broker(ObjectInterruption):
if
not
self
.
victim
.
currentEntity
in
G
.
pendingEntities
:
G
.
pendingEntities
.
append
(
self
.
victim
.
currentEntity
)
if
not
G
.
Router
.
invoked
:
#===========================================================
# testing
# print now(), self.victim.id, 'broker', ' '*50, 'signalling router'
#===========================================================
self
.
printTrace
(
self
.
victim
.
id
,
'broker'
+
' '
*
50
+
'signalling router'
)
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
signal
(
now
())
self
.
waitForOperator
=
True
#
print now(), self.victim.id, 'broker waits till resource is available1'
#
self.printTrace(self.victim.id, 'broker waits till resource is available1')
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
#
print self.victim.id, 'received resourceAvailable event'
#
self.printTrace(self.victim.id, 'received resourceAvailable event')
#===============================================================
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
)
#===============================================================
# # TESTING
# print now(), self.victim.currentOperator.objName, 'started work in ', self.victim.id
#===============================================================
self
.
printTrace
(
self
.
victim
.
currentOperator
.
objName
,
'started work in '
+
self
.
victim
.
id
)
# clear the timeWaitForOperatorStarted variable
self
.
timeWaitForOperatorStarted
=
0
# update the time that the operation started
...
...
@@ -125,13 +118,11 @@ class Broker(ObjectInterruption):
yield
release
,
self
,
self
.
victim
.
operatorPool
.
getResource
(
self
.
victim
.
currentOperator
)
# signal the other brokers waiting for the same operators that they are now free
# also signal the stations that were not requested to receive because the operator was occupied
#===============================================================
# TESTING
# print now(), self.victim.id, 'broker signalling ROUTER'
#===============================================================
# 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
.
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.
...
...
@@ -139,10 +130,7 @@ class Broker(ObjectInterruption):
# TODO: this wont work for the moment. The actions that follow must be performed by all operated brokers.
# self.signalLoadStations()
#===============================================================
# # TESTING
# print now(), self.victim.currentOperator.objName, 'released', self.victim.id
#===============================================================
self
.
printTrace
(
self
.
victim
.
currentOperator
.
objName
,
'released '
+
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 @
23c117cb
This diff is collapsed.
Click to expand it.
dream/simulation/Queue.py
View file @
23c117cb
...
...
@@ -95,13 +95,13 @@ class Queue(CoreObject):
# check if there is WIP and signal receiver
self
.
initialSignalReceiver
()
while
1
:
#
print self.id, 'will wait for event', now(
)
#
self.printTrace(self.id, 'will wait for event'
)
# wait until the Queue can accept an entity and one predecessor requests it
yield
waitevent
,
self
,
[
self
.
isRequested
,
self
.
canDispose
,
self
.
loadOperatorAvailable
]
#
print now(), self.id, 'just received an event'
#
self.printTrace(self.id, 'just received an event')
# if the event that activated the thread is isRequested then getEntity
if
self
.
isRequested
.
signalparam
:
#
print now(), self.id, 'received a isRequested event from', self.isRequested.signalparam.id
#
self.printTrace(self.id, 'received a isRequested event from'+self.isRequested.signalparam.id)
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
self
.
getEntity
()
...
...
@@ -110,15 +110,15 @@ class Queue(CoreObject):
activeObjectQueue
[
0
].
startTime
=
now
()
# if the queue received an loadOperatorIsAvailable (from Router) with signalparam time
if
self
.
loadOperatorAvailable
.
signalparam
:
#
print now(), self.id, 'received a loadOperatorAvailable event'
#
self.printTrace(self.id, 'received a loadOperatorAvailable event')
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
:
#
print now(), self.id, 'received a canDispose event'
#
self.printTrace(self.id, 'received a canDispose event')
self
.
canDispose
.
signalparam
=
None
# if the event that activated the thread is canDispose then signalReceiver
if
self
.
haveToDispose
():
#
print now(), self.id, 'will try to signal a receiver from generator'
#
self.printTrace(self.id, 'will try to signal a receiver from generator')
if
self
.
receiver
:
if
not
self
.
receiver
.
entryIsAssignedTo
():
self
.
signalReceiver
()
...
...
@@ -171,7 +171,7 @@ class Queue(CoreObject):
# TODO: disable that for the mouldAssemblyBuffer
if
not
self
.
__class__
.
__name__
==
'MouldAssemblyBuffer'
:
if
self
.
haveToDispose
():
#
print now(), self.id, 'will try to signal a receiver from removeEntity'
#
self.printTrace(self.id, 'will try to signal a receiver from removeEntity')
self
.
signalReceiver
()
return
activeEntity
...
...
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