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
c0abf540
Commit
c0abf540
authored
May 28, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assembly and Dismantle updated. Source and CoreObject minor fixes
parent
b242d7a5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
64 deletions
+71
-64
dream/simulation/Assembly.py
dream/simulation/Assembly.py
+31
-30
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+3
-3
dream/simulation/Dismantle.py
dream/simulation/Dismantle.py
+31
-26
dream/simulation/Failure.py
dream/simulation/Failure.py
+2
-0
dream/simulation/Source.py
dream/simulation/Source.py
+4
-5
No files found.
dream/simulation/Assembly.py
View file @
c0abf540
...
@@ -26,8 +26,9 @@ Models an assembly object
...
@@ -26,8 +26,9 @@ Models an assembly object
it gathers frames and parts which are loaded to the frames
it gathers frames and parts which are loaded to the frames
'''
'''
from
SimPy.Simulation
import
Process
,
Resource
# from SimPy.Simulation import Process, Resource
from
SimPy.Simulation
import
waitevent
,
now
,
hold
# from SimPy.Simulation import waitevent, now, hold
import
simpy
import
xlwt
import
xlwt
from
RandomNumberGenerator
import
RandomNumberGenerator
from
RandomNumberGenerator
import
RandomNumberGenerator
from
CoreObject
import
CoreObject
from
CoreObject
import
CoreObject
...
@@ -41,6 +42,8 @@ class Assembly(CoreObject):
...
@@ -41,6 +42,8 @@ class Assembly(CoreObject):
# initialize the object
# initialize the object
#===========================================================================
#===========================================================================
def
__init__
(
self
,
id
,
name
,
processingTime
=
None
):
def
__init__
(
self
,
id
,
name
,
processingTime
=
None
):
from
Globals
import
G
self
.
env
=
G
.
env
if
not
processingTime
:
if
not
processingTime
:
processingTime
=
{
'distributionType'
:
'Fixed'
,
processingTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
0
,
'mean'
:
0
,
...
@@ -80,7 +83,7 @@ class Assembly(CoreObject):
...
@@ -80,7 +83,7 @@ class Assembly(CoreObject):
# initialize method
# initialize method
#===========================================================================
#===========================================================================
def
initialize
(
self
):
def
initialize
(
self
):
Process
.
__init__
(
self
)
#
Process.__init__(self)
CoreObject
.
initialize
(
self
)
CoreObject
.
initialize
(
self
)
self
.
waitToDispose
=
False
#flag that shows if the object waits to dispose an entity
self
.
waitToDispose
=
False
#flag that shows if the object waits to dispose an entity
...
@@ -97,8 +100,6 @@ class Assembly(CoreObject):
...
@@ -97,8 +100,6 @@ class Assembly(CoreObject):
self
.
timeLastEntityLeft
=
0
#holds the last time that an entity left the object
self
.
timeLastEntityLeft
=
0
#holds the last time that an entity left the object
self
.
processingTimeOfCurrentEntity
=
0
#holds the total processing time that the current entity required
self
.
processingTimeOfCurrentEntity
=
0
#holds the total processing time that the current entity required
self
.
totalBlockageTime
=
0
#holds the total blockage time
self
.
totalBlockageTime
=
0
#holds the total blockage time
self
.
totalWaitingTime
=
0
#holds the total waiting time
self
.
totalWaitingTime
=
0
#holds the total waiting time
...
@@ -111,9 +112,9 @@ class Assembly(CoreObject):
...
@@ -111,9 +112,9 @@ class Assembly(CoreObject):
self
.
nameLastFrameWasFull
=
""
#holds the name of the last frame that was full, ie that assembly process started
self
.
nameLastFrameWasFull
=
""
#holds the name of the last frame that was full, ie that assembly process started
self
.
nameLastEntityEntered
=
""
#holds the name of the last frame that entered processing in the object
self
.
nameLastEntityEntered
=
""
#holds the name of the last frame that entered processing in the object
self
.
nameLastEntityEnded
=
""
#holds the name of the last frame that ended processing in the object
self
.
nameLastEntityEnded
=
""
#holds the name of the last frame that ended processing in the object
self
.
Res
=
Resource
(
1
)
self
.
Res
=
simpy
.
Resource
(
self
.
env
,
1
)
self
.
Res
.
activeQ
=
[]
self
.
Res
.
users
=
[]
self
.
Res
.
waitQ
=
[]
# self.Res.waitQ=[]
#===========================================================================
#===========================================================================
# class generator
# class generator
...
@@ -125,50 +126,50 @@ class Assembly(CoreObject):
...
@@ -125,50 +126,50 @@ class Assembly(CoreObject):
while
1
:
while
1
:
self
.
printTrace
(
self
.
id
,
waitEvent
=
''
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
''
)
# wait until the Queue can accept an entity and one predecessor requests it
# wait until the Queue can accept an entity and one predecessor requests it
yield
waitevent
,
self
,
self
.
isRequested
#[self.isRequested,self.canDispose, self.loadOperatorAvailable]
yield
self
.
isRequested
#[self.isRequested,self.canDispose, self.loadOperatorAvailable]
if
self
.
isRequested
.
value
:
if
self
.
isRequested
.
signalparam
:
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
value
.
id
)
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
# reset the isRequested signal parameter
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
self
.
isRequested
=
self
.
env
.
event
()
self
.
getEntity
(
"Frame"
)
#get the Frame
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
for
i
in
range
(
self
.
getActiveObjectQueue
()[
0
].
capacity
):
#this loop will be carried until the Frame is full with the parts
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(to load parts)'
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(to load parts)'
)
yield
waitevent
,
self
,
self
.
isRequested
yield
self
.
isRequested
if
self
.
isRequested
.
signalparam
:
if
self
.
isRequested
.
value
:
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
value
.
id
)
# reset the isRequested signal parameter
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
self
.
isRequested
=
self
.
env
.
event
()
# TODO: fix the getEntity 'Part' case
# TODO: fix the getEntity 'Part' case
self
.
getEntity
(
"Part"
)
self
.
getEntity
(
"Part"
)
self
.
outputTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
"is now full in "
+
self
.
objName
)
self
.
outputTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
"is now full in "
+
self
.
objName
)
self
.
timeLastFrameWasFull
=
now
()
self
.
timeLastFrameWasFull
=
self
.
env
.
now
self
.
nameLastFrameWasFull
=
self
.
getActiveObjectQueue
()[
0
].
name
self
.
nameLastFrameWasFull
=
self
.
getActiveObjectQueue
()[
0
].
name
startWorkingTime
=
now
()
startWorkingTime
=
self
.
env
.
now
self
.
totalProcessingTimeInCurrentEntity
=
self
.
calculateProcessingTime
()
self
.
totalProcessingTimeInCurrentEntity
=
self
.
calculateProcessingTime
()
yield
hold
,
self
,
self
.
totalProcessingTimeInCurrentEntity
#hold for the time the assembly operation is carried
yield
self
.
env
.
timeout
(
self
.
totalProcessingTimeInCurrentEntity
)
#hold for the time the assembly operation is carried
self
.
totalWorkingTime
+=
now
()
-
startWorkingTime
self
.
totalWorkingTime
+=
self
.
env
.
now
-
startWorkingTime
self
.
outputTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
"ended processing in "
+
self
.
objName
)
self
.
outputTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
"ended processing in "
+
self
.
objName
)
self
.
timeLastEntityEnded
=
now
()
self
.
timeLastEntityEnded
=
self
.
env
.
now
self
.
nameLastEntityEnded
=
self
.
getActiveObjectQueue
()[
0
].
name
self
.
nameLastEntityEnded
=
self
.
getActiveObjectQueue
()[
0
].
name
startBlockageTime
=
now
()
startBlockageTime
=
self
.
env
.
now
self
.
completedJobs
+=
1
#Assembly completed a job
self
.
completedJobs
+=
1
#Assembly completed a job
self
.
waitToDispose
=
True
#since all the frame is full
self
.
waitToDispose
=
True
#since all the frame is full
self
.
printTrace
(
self
.
id
,
attemptSignalReceiver
=
'(generator'
)
self
.
printTrace
(
self
.
id
,
attemptSignalReceiver
=
'(generator
)
'
)
# signal the receiver that the activeObject has something to dispose of
# signal the receiver that the activeObject has something to dispose of
if
not
self
.
signalReceiver
():
if
not
self
.
signalReceiver
():
# if there was no available receiver, get into blocking control
# if there was no available receiver, get into blocking control
while
1
:
while
1
:
# wait the event canDispose, this means that the station can deliver the item to successor
# wait the event canDispose, this means that the station can deliver the item to successor
event
=
yield
waitevent
,
self
,
self
.
canDispose
#[self.canDispose, self.interruptionStart]
receivedEvent
=
yield
self
.
canDispose
#[self.canDispose, self.interruptionStart]
self
.
canDispose
=
self
.
env
.
event
()
# try to signal a receiver, if successful then proceed to get an other entity
# try to signal a receiver, if successful then proceed to get an other entity
if
self
.
signalReceiver
():
if
self
.
signalReceiver
():
break
break
...
@@ -177,11 +178,11 @@ class Assembly(CoreObject):
...
@@ -177,11 +178,11 @@ class Assembly(CoreObject):
# signals the preceding station (e.g. self.machine) and immediately after that gets the entity.
# signals the preceding station (e.g. self.machine) and immediately after that gets the entity.
# the preceding machine gets the canDispose signal which is actually useless, is emptied by the following station
# the preceding machine gets the canDispose signal which is actually useless, is emptied by the following station
# and then cannot exit an infinite loop.
# and then cannot exit an infinite loop.
yield
hold
,
self
,
0
yield
self
.
env
.
timeout
(
0
)
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
# if while waiting (for a canDispose event) became free as the machines that follows emptied it, then proceed
if
not
self
.
haveToDispose
():
if
not
self
.
haveToDispose
():
break
break
#self.totalBlockageTime+=
now()
-startBlockageTime #add the blockage time
#self.totalBlockageTime+=
self.env.now
-startBlockageTime #add the blockage time
#===========================================================================
#===========================================================================
...
@@ -275,7 +276,7 @@ class Assembly(CoreObject):
...
@@ -275,7 +276,7 @@ class Assembly(CoreObject):
# if the type is Frame
# if the type is Frame
if
(
activeEntity
.
type
==
"Frame"
):
if
(
activeEntity
.
type
==
"Frame"
):
self
.
nameLastEntityEntered
=
activeEntity
.
name
self
.
nameLastEntityEntered
=
activeEntity
.
name
self
.
timeLastEntityEntered
=
now
()
self
.
timeLastEntityEntered
=
self
.
env
.
now
activeEntity
.
currentStation
=
self
activeEntity
.
currentStation
=
self
# if the frame is not fully loaded then signal a giver
# if the frame is not fully loaded then signal a giver
...
@@ -317,11 +318,11 @@ class Assembly(CoreObject):
...
@@ -317,11 +318,11 @@ class Assembly(CoreObject):
#the following Object
#the following Object
#till the end of simulation, we have to add this blockage to the percentage of blockage in Assembly
#till the end of simulation, we have to add this blockage to the percentage of blockage in Assembly
if
(
mightBeBlocked
)
and
((
self
.
nameLastEntityEntered
==
self
.
nameLastEntityEnded
)):
if
(
mightBeBlocked
)
and
((
self
.
nameLastEntityEntered
==
self
.
nameLastEntityEnded
)):
self
.
totalBlockageTime
+=
now
()
-
self
.
timeLastEntityEnded
self
.
totalBlockageTime
+=
self
.
env
.
now
-
self
.
timeLastEntityEnded
#if Assembly is currently processing an entity we should count this working time
#if Assembly is currently processing an entity we should count this working time
if
(
len
(
activeObjectQueue
)
>
0
)
and
(
not
(
self
.
nameLastEntityEnded
==
self
.
nameLastFrameWasFull
)):
if
(
len
(
activeObjectQueue
)
>
0
)
and
(
not
(
self
.
nameLastEntityEnded
==
self
.
nameLastFrameWasFull
)):
self
.
totalWorkingTime
+=
now
()
-
self
.
timeLastFrameWasFull
self
.
totalWorkingTime
+=
self
.
env
.
now
-
self
.
timeLastFrameWasFull
self
.
totalWaitingTime
=
MaxSimtime
-
self
.
totalWorkingTime
-
self
.
totalBlockageTime
self
.
totalWaitingTime
=
MaxSimtime
-
self
.
totalWorkingTime
-
self
.
totalBlockageTime
...
...
dream/simulation/CoreObject.py
View file @
c0abf540
...
@@ -262,7 +262,7 @@ class CoreObject(object):
...
@@ -262,7 +262,7 @@ class CoreObject(object):
# update the next list of the object
# update the next list of the object
self
.
updateNext
(
activeEntity
)
self
.
updateNext
(
activeEntity
)
self
.
outputTrace
(
activeEntity
.
name
,
"got into "
+
self
.
objName
)
self
.
outputTrace
(
activeEntity
.
name
,
"got into "
+
self
.
objName
)
#
self.printTrace(activeEntity.name, enter=self.id)
self
.
printTrace
(
activeEntity
.
name
,
enter
=
self
.
id
)
return
activeEntity
return
activeEntity
#===========================================================================
#===========================================================================
...
@@ -522,14 +522,14 @@ class CoreObject(object):
...
@@ -522,14 +522,14 @@ class CoreObject(object):
assert
len
(
kw
)
==
1
,
'only one phrase per printTrace supported for the moment'
assert
len
(
kw
)
==
1
,
'only one phrase per printTrace supported for the moment'
from
Globals
import
G
from
Globals
import
G
import
Globals
import
Globals
time
=
self
.
env
.
now
time
=
G
.
env
.
now
charLimit
=
60
charLimit
=
60
remainingChar
=
charLimit
-
len
(
entity
)
-
len
(
str
(
time
))
remainingChar
=
charLimit
-
len
(
entity
)
-
len
(
str
(
time
))
if
(
G
.
console
==
'Yes'
):
if
(
G
.
console
==
'Yes'
):
print
time
,
entity
,
print
time
,
entity
,
for
key
in
kw
:
for
key
in
kw
:
if
key
not
in
Globals
.
getSupportedPrintKwrds
():
if
key
not
in
Globals
.
getSupportedPrintKwrds
():
raise
ValueError
(
"Unsupported phrase %s for %s"
%
(
key
,
entity
.
name
))
raise
ValueError
(
"Unsupported phrase %s for %s"
%
(
key
,
entity
))
element
=
Globals
.
getPhrase
()[
key
]
element
=
Globals
.
getPhrase
()[
key
]
phrase
=
element
[
'phrase'
]
phrase
=
element
[
'phrase'
]
prefix
=
element
.
get
(
'prefix'
,
None
)
prefix
=
element
.
get
(
'prefix'
,
None
)
...
...
dream/simulation/Dismantle.py
View file @
c0abf540
...
@@ -27,8 +27,9 @@ Models a dicmantle object
...
@@ -27,8 +27,9 @@ Models a dicmantle object
it gathers frames that have parts loaded, unloads the parts and sends the frame to one destination and the parts to another
it gathers frames that have parts loaded, unloads the parts and sends the frame to one destination and the parts to another
'''
'''
from
SimPy.Simulation
import
Process
,
Resource
# from SimPy.Simulation import Process, Resource
from
SimPy.Simulation
import
waitevent
,
now
,
hold
,
infinity
# from SimPy.Simulation import waitevent, now, hold, infinity
import
simpy
import
xlwt
import
xlwt
from
RandomNumberGenerator
import
RandomNumberGenerator
from
RandomNumberGenerator
import
RandomNumberGenerator
from
CoreObject
import
CoreObject
from
CoreObject
import
CoreObject
...
@@ -43,6 +44,9 @@ class Dismantle(CoreObject):
...
@@ -43,6 +44,9 @@ class Dismantle(CoreObject):
#===========================================================================
#===========================================================================
def
__init__
(
self
,
id
,
name
,
distribution
=
'Fixed'
,
mean
=
1
,
stdev
=
0.1
,
min
=
0
,
max
=
5
):
def
__init__
(
self
,
id
,
name
,
distribution
=
'Fixed'
,
mean
=
1
,
stdev
=
0.1
,
min
=
0
,
max
=
5
):
CoreObject
.
__init__
(
self
,
id
,
name
)
CoreObject
.
__init__
(
self
,
id
,
name
)
from
Globals
import
G
self
.
env
=
G
.
env
self
.
type
=
"Dismantle"
#String that shows the type of object
self
.
type
=
"Dismantle"
#String that shows the type of object
self
.
distType
=
distribution
#the distribution that the procTime follows
self
.
distType
=
distribution
#the distribution that the procTime follows
self
.
rng
=
RandomNumberGenerator
(
self
,
self
.
distType
)
self
.
rng
=
RandomNumberGenerator
(
self
,
self
.
distType
)
...
@@ -74,7 +78,7 @@ class Dismantle(CoreObject):
...
@@ -74,7 +78,7 @@ class Dismantle(CoreObject):
# the initialize method
# the initialize method
#===========================================================================
#===========================================================================
def
initialize
(
self
):
def
initialize
(
self
):
Process
.
__init__
(
self
)
#
Process.__init__(self)
CoreObject
.
initialize
(
self
)
CoreObject
.
initialize
(
self
)
self
.
waitToDispose
=
False
#flag that shows if the object waits to dispose an entity
self
.
waitToDispose
=
False
#flag that shows if the object waits to dispose an entity
self
.
waitToDisposePart
=
False
#flag that shows if the object waits to dispose a part
self
.
waitToDisposePart
=
False
#flag that shows if the object waits to dispose a part
...
@@ -105,9 +109,9 @@ class Dismantle(CoreObject):
...
@@ -105,9 +109,9 @@ class Dismantle(CoreObject):
self
.
nameLastFrameWasFull
=
""
#holds the name of the last frame that was full, ie that assembly process started
self
.
nameLastFrameWasFull
=
""
#holds the name of the last frame that was full, ie that assembly process started
self
.
nameLastEntityEntered
=
""
#holds the name of the last frame that entered processing in the object
self
.
nameLastEntityEntered
=
""
#holds the name of the last frame that entered processing in the object
self
.
nameLastEntityEnded
=
""
#holds the name of the last frame that ended processing in the object
self
.
nameLastEntityEnded
=
""
#holds the name of the last frame that ended processing in the object
self
.
Res
=
Resource
(
capacity
=
infinity
)
self
.
Res
=
simpy
.
Resource
(
self
.
env
,
capacity
=
'inf'
)
self
.
Res
.
activeQ
=
[]
self
.
Res
.
users
=
[]
self
.
Res
.
waitQ
=
[]
# self.Res.waitQ=[]
#===========================================================================
#===========================================================================
# the run method
# the run method
...
@@ -119,23 +123,23 @@ class Dismantle(CoreObject):
...
@@ -119,23 +123,23 @@ class Dismantle(CoreObject):
while
1
:
while
1
:
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(frame)'
)
self
.
printTrace
(
self
.
id
,
waitEvent
=
'(frame)'
)
# wait until the Queue can accept an entity and one predecessor requests it
# wait until the Queue can accept an entity and one predecessor requests it
yield
waitevent
,
self
,
self
.
isRequested
#[self.isRequested,self.canDispose, self.loadOperatorAvailable]
yield
self
.
isRequested
#[self.isRequested,self.canDispose, self.loadOperatorAvailable]
if
self
.
isRequested
.
signalparam
:
if
self
.
isRequested
.
value
:
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
signalparam
.
id
)
self
.
printTrace
(
self
.
id
,
isRequested
=
self
.
isRequested
.
value
.
id
)
# reset the isRequested signal parameter
# reset the isRequested signal parameter
self
.
isRequested
.
signalparam
=
None
self
.
isRequested
=
self
.
env
.
event
()
self
.
getEntity
()
#get the Frame with the parts
self
.
getEntity
()
#get the Frame with the parts
self
.
timeLastEntityEntered
=
now
()
self
.
timeLastEntityEntered
=
self
.
env
.
now
startWorkingTime
=
now
()
startWorkingTime
=
self
.
env
.
now
self
.
totalProcessingTimeInCurrentEntity
=
self
.
calculateProcessingTime
()
self
.
totalProcessingTimeInCurrentEntity
=
self
.
calculateProcessingTime
()
#hold for the time the assembly operation is carried
#hold for the time the assembly operation is carried
yield
hold
,
self
,
self
.
totalProcessingTimeInCurrentEntity
yield
self
.
env
.
timeout
(
self
.
totalProcessingTimeInCurrentEntity
)
self
.
totalWorkingTime
+=
now
()
-
startWorkingTime
self
.
totalWorkingTime
+=
self
.
env
.
now
-
startWorkingTime
self
.
timeLastEntityEnded
=
now
()
self
.
timeLastEntityEnded
=
self
.
env
.
now
startBlockageTime
=
now
()
startBlockageTime
=
self
.
env
.
now
self
.
waitToDispose
=
True
self
.
waitToDispose
=
True
self
.
waitToDisposePart
=
True
#Dismantle is in state to dispose a part
self
.
waitToDisposePart
=
True
#Dismantle is in state to dispose a part
...
@@ -144,12 +148,13 @@ class Dismantle(CoreObject):
...
@@ -144,12 +148,13 @@ class Dismantle(CoreObject):
# try and signal the receiver
# try and signal the receiver
if
not
self
.
signalReceiver
():
if
not
self
.
signalReceiver
():
# if not possible, then wait till a receiver is available
# if not possible, then wait till a receiver is available
yield
waitevent
,
self
,
self
.
canDispose
yield
self
.
canDispose
self
.
canDispose
=
self
.
env
.
event
()
# and signal it again
# and signal it again
if
not
self
.
signalReceiver
():
if
not
self
.
signalReceiver
():
continue
continue
# if the receiver was not responsive, release the control to let him remove the entity
# if the receiver was not responsive, release the control to let him remove the entity
yield
hold
,
self
,
0
yield
self
.
env
.
timeout
(
0
)
# if all the parts are removed but not the frame, then set the flag waitToDisposeFrame
# if all the parts are removed but not the frame, then set the flag waitToDisposeFrame
if
self
.
frameIsEmpty
()
and
not
self
.
waitToDisposeFrame
:
if
self
.
frameIsEmpty
()
and
not
self
.
waitToDisposeFrame
:
self
.
waitToDisposePart
=
False
self
.
waitToDisposePart
=
False
...
@@ -275,7 +280,7 @@ class Dismantle(CoreObject):
...
@@ -275,7 +280,7 @@ class Dismantle(CoreObject):
activeObject
.
waitToDisposePart
=
False
activeObject
.
waitToDisposePart
=
False
# if the internal queue is empty then try to signal the giver that the object can now receive
# if the internal queue is empty then try to signal the giver that the object can now receive
if
activeObject
.
canAccept
():
if
activeObject
.
canAccept
():
activeObject
.
printTrace
(
self
.
id
,
attemptSi
ng
alGiver
=
'(removeEntity)'
)
activeObject
.
printTrace
(
self
.
id
,
attemptSi
gn
alGiver
=
'(removeEntity)'
)
activeObject
.
signalGiver
()
activeObject
.
signalGiver
()
return
activeEntity
return
activeEntity
...
@@ -284,9 +289,9 @@ class Dismantle(CoreObject):
...
@@ -284,9 +289,9 @@ class Dismantle(CoreObject):
#===========================================================================
#===========================================================================
def
addBlockage
(
self
):
def
addBlockage
(
self
):
if
len
(
self
.
getActiveObjectQueue
())
==
1
:
if
len
(
self
.
getActiveObjectQueue
())
==
1
:
self
.
totalTimeInCurrentEntity
=
now
()
-
self
.
timeLastEntityEntered
self
.
totalTimeInCurrentEntity
=
self
.
env
.
now
-
self
.
timeLastEntityEntered
self
.
totalTimeWaitingForOperator
+=
self
.
operatorWaitTimeCurrentEntity
self
.
totalTimeWaitingForOperator
+=
self
.
operatorWaitTimeCurrentEntity
blockage
=
now
()
-
(
self
.
timeLastEntityEnded
+
self
.
downTimeInTryingToReleaseCurrentEntity
)
blockage
=
self
.
env
.
now
-
(
self
.
timeLastEntityEnded
+
self
.
downTimeInTryingToReleaseCurrentEntity
)
self
.
totalBlockageTime
+=
blockage
self
.
totalBlockageTime
+=
blockage
#===========================================================================
#===========================================================================
...
@@ -300,12 +305,12 @@ class Dismantle(CoreObject):
...
@@ -300,12 +305,12 @@ class Dismantle(CoreObject):
#if there is an entity that finished processing in Dismantle but did not get to reach
#if there is an entity that finished processing in Dismantle but did not get to reach
#the following Object
#the following Object
#till the end of simulation, we have to add this blockage to the percentage of blockage in Dismantle
#till the end of simulation, we have to add this blockage to the percentage of blockage in Dismantle
if
(
len
(
self
.
Res
.
activeQ
)
>
0
)
and
(
self
.
waitToDisposeFrame
)
or
(
self
.
waitToDisposePart
):
if
(
len
(
self
.
Res
.
users
)
>
0
)
and
(
self
.
waitToDisposeFrame
)
or
(
self
.
waitToDisposePart
):
self
.
totalBlockageTime
+=
now
()
-
self
.
timeLastEntityEnded
self
.
totalBlockageTime
+=
self
.
env
.
now
-
self
.
timeLastEntityEnded
#if Dismantle is currently processing an entity we should count this working time
#if Dismantle is currently processing an entity we should count this working time
if
(
len
(
self
.
Res
.
activeQ
)
>
0
)
and
(
not
((
self
.
waitToDisposeFrame
)
or
(
self
.
waitToDisposePart
))):
if
(
len
(
self
.
Res
.
users
)
>
0
)
and
(
not
((
self
.
waitToDisposeFrame
)
or
(
self
.
waitToDisposePart
))):
self
.
totalWorkingTime
+=
now
()
-
self
.
timeLastEntityEntered
self
.
totalWorkingTime
+=
self
.
env
.
now
-
self
.
timeLastEntityEntered
self
.
totalWaitingTime
=
MaxSimtime
-
self
.
totalWorkingTime
-
self
.
totalBlockageTime
self
.
totalWaitingTime
=
MaxSimtime
-
self
.
totalWorkingTime
-
self
.
totalBlockageTime
...
@@ -322,7 +327,7 @@ class Dismantle(CoreObject):
...
@@ -322,7 +327,7 @@ class Dismantle(CoreObject):
from
Globals
import
G
from
Globals
import
G
if
(
G
.
trace
==
"Yes"
):
#output only if the user has selected to
if
(
G
.
trace
==
"Yes"
):
#output only if the user has selected to
#handle the 3 columns
#handle the 3 columns
G
.
traceSheet
.
write
(
G
.
traceIndex
,
0
,
str
(
now
()
))
G
.
traceSheet
.
write
(
G
.
traceIndex
,
0
,
str
(
self
.
env
.
now
))
G
.
traceSheet
.
write
(
G
.
traceIndex
,
1
,
name
)
G
.
traceSheet
.
write
(
G
.
traceIndex
,
1
,
name
)
G
.
traceSheet
.
write
(
G
.
traceIndex
,
2
,
message
)
G
.
traceSheet
.
write
(
G
.
traceIndex
,
2
,
message
)
G
.
traceIndex
+=
1
#increment the row
G
.
traceIndex
+=
1
#increment the row
...
...
dream/simulation/Failure.py
View file @
c0abf540
...
@@ -115,6 +115,7 @@ class Failure(ObjectInterruption):
...
@@ -115,6 +115,7 @@ class Failure(ObjectInterruption):
self
.
reactivateVictim
()
# since repairing is over, the Machine is reactivated
self
.
reactivateVictim
()
# since repairing is over, the Machine is reactivated
self
.
victim
.
Up
=
True
self
.
victim
.
Up
=
True
self
.
outputTrace
(
"is up"
)
self
.
outputTrace
(
"is up"
)
self
.
repairman
.
totalWorkingTime
+=
self
.
env
.
now
-
timeOperationStarted
self
.
repairman
.
totalWorkingTime
+=
self
.
env
.
now
-
timeOperationStarted
continue
continue
...
@@ -125,6 +126,7 @@ class Failure(ObjectInterruption):
...
@@ -125,6 +126,7 @@ class Failure(ObjectInterruption):
self
.
reactivateVictim
()
# since repairing is over, the Machine is reactivated
self
.
reactivateVictim
()
# since repairing is over, the Machine is reactivated
self
.
victim
.
Up
=
True
self
.
victim
.
Up
=
True
self
.
outputTrace
(
"is up"
)
self
.
outputTrace
(
"is up"
)
# if(self.repairman and self.repairman!="None"): #if a resource was used, it is now released
# if(self.repairman and self.repairman!="None"): #if a resource was used, it is now released
# print self.repairman.Res.users
# print self.repairman.Res.users
# print self.env.now, self.repairman.id, 'about to be release from', self.victim.id
# print self.env.now, self.repairman.id, 'about to be release from', self.victim.id
...
...
dream/simulation/Source.py
View file @
c0abf540
...
@@ -146,20 +146,19 @@ class Source(CoreObject):
...
@@ -146,20 +146,19 @@ class Source(CoreObject):
while
1
:
while
1
:
# wait for any event (entity creation or request for disposal of entity)
# wait for any event (entity creation or request for disposal of entity)
receivedEvent
=
yield
self
.
entityCreated
|
self
.
canDispose
|
self
.
loadOperatorAvailable
receivedEvent
=
yield
self
.
entityCreated
|
self
.
canDispose
|
self
.
loadOperatorAvailable
self
.
printTrace
(
self
.
id
,
received
=
''
)
# if an entity is created try to signal the receiver and continue
# if an entity is created try to signal the receiver and continue
if
self
.
entityCreated
in
receivedEvent
:
if
self
.
entityCreated
in
receivedEvent
:
self
.
entityCreated
=
self
.
env
.
event
()
self
.
entityCreated
=
self
.
env
.
event
()
if
self
.
signalReceiver
():
continue
# otherwise, if the receiver requests availability then try to signal him if there is anything to dispose of
# otherwise, if the receiver requests availability then try to signal him if there is anything to dispose of
if
self
.
canDispose
in
receivedEvent
or
self
.
loadOperatorAvailable
in
receivedEvent
:
if
self
.
canDispose
in
receivedEvent
or
self
.
loadOperatorAvailable
in
receivedEvent
:
# self.canDispose.signalparam=None
# self.canDispose.signalparam=None
self
.
canDispose
=
self
.
env
.
event
()
self
.
canDispose
=
self
.
env
.
event
()
# self.loadOperatorAvailable.signalparam=None
# self.loadOperatorAvailable.signalparam=None
self
.
loadOperatorAvailable
=
self
.
env
.
event
()
self
.
loadOperatorAvailable
=
self
.
env
.
event
()
if
self
.
haveToDispose
():
if
self
.
haveToDispose
():
if
self
.
signalReceiver
():
if
self
.
signalReceiver
():
continue
continue
#===========================================================================
#===========================================================================
# add newly created entity to pendingEntities
# add newly created entity to pendingEntities
...
...
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