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
85a340ff
Commit
85a340ff
authored
Sep 09, 2014
by
Ioannis Papagiannopoulos
Committed by
Georgios Dagkakis
Nov 03, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interruptions updated and make use of expectedSignals dict
parent
623ed13b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
30 deletions
+133
-30
dream/simulation/Failure.py
dream/simulation/Failure.py
+31
-2
dream/simulation/OperatedPoolBroker.py
dream/simulation/OperatedPoolBroker.py
+32
-8
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+14
-6
dream/simulation/OperatorRouterManaged.py
dream/simulation/OperatorRouterManaged.py
+12
-4
dream/simulation/ScheduledMaintenance.py
dream/simulation/ScheduledMaintenance.py
+12
-0
dream/simulation/ShiftScheduler.py
dream/simulation/ShiftScheduler.py
+12
-4
dream/simulation/SkilledOperatorRouter.py
dream/simulation/SkilledOperatorRouter.py
+20
-6
No files found.
dream/simulation/Failure.py
View file @
85a340ff
...
...
@@ -112,7 +112,10 @@ class Failure(ObjectInterruption):
elif
self
.
deteriorationType
==
'onShift'
:
while
failureNotTriggered
:
timeRestartedCounting
=
self
.
env
.
now
self
.
isWaitingForVictimOffShift
=
True
self
.
isWaitingForVictimOffShift
=
True
self
.
expectedSignals
[
'victimOffShift'
]
=
1
receivedEvent
=
yield
self
.
env
.
timeout
(
remainingTimeToFailure
)
|
self
.
victimOffShift
# the failure should receive a signal if there is a shift-off triggered
if
self
.
victimOffShift
in
receivedEvent
:
...
...
@@ -121,31 +124,57 @@ class Failure(ObjectInterruption):
remainingTimeToFailure
=
remainingTimeToFailure
-
(
self
.
env
.
now
-
timeRestartedCounting
)
# wait for the shift to start again
self
.
isWaitingForVictimOnShift
=
True
self
.
expectedSignals
[
'victimOnShift'
]
=
1
yield
self
.
victimOnShift
self
.
expectedSignals
[
'victimOnShift'
]
=
0
self
.
isWaitingForVictimOnShift
=
False
self
.
victimOnShift
=
self
.
env
.
event
()
assert
self
.
victim
.
onShift
==
True
,
'the victim of shiftFailure must be onShift to continue counting the TTF'
else
:
self
.
isWaitingForVictimOffShift
=
False
failureNotTriggered
=
False
self
.
expectedSignals
[
'victimOffShift'
]
=
0
# if time to failure counts only in working time
elif
self
.
deteriorationType
==
'working'
:
# wait for victim to start process
self
.
expectedSignals
[
'victimStartsProcess'
]
=
1
yield
self
.
victimStartsProcess
self
.
expectedSignals
[
'victimStartsProcess'
]
=
0
self
.
victimStartsProcess
=
self
.
env
.
event
()
while
failureNotTriggered
:
timeRestartedCounting
=
self
.
env
.
now
self
.
expectedSignals
[
'victimEndsProcess'
]
=
1
# wait either for the failure or end of process
receivedEvent
=
yield
self
.
env
.
timeout
(
remainingTimeToFailure
)
|
self
.
victimEndsProcess
if
self
.
victimEndsProcess
in
receivedEvent
:
self
.
victimEndsProcess
=
self
.
env
.
event
()
remainingTimeToFailure
=
remainingTimeToFailure
-
(
self
.
env
.
now
-
timeRestartedCounting
)
self
.
expectedSignals
[
'victimStartsProcess'
]
=
1
yield
self
.
victimStartsProcess
self
.
expectedSignals
[
'victimStartsProcess'
]
=
0
# wait for victim to start again processing
self
.
victimStartsProcess
=
self
.
env
.
event
()
else
:
failureNotTriggered
=
False
self
.
expectedSignals
[
'victimEndsProcess'
]
=
0
# interrupt the victim only if it was not previously interrupted
if
not
self
.
victim
.
interruptionStart
.
triggered
:
self
.
interruptVictim
()
# interrupt the victim
...
...
dream/simulation/OperatedPoolBroker.py
View file @
85a340ff
...
...
@@ -71,7 +71,13 @@ class Broker(ObjectInterruption):
def
run
(
self
):
while
1
:
# TODO: add new broker event - brokerIsCalled
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
assert
eventTime
==
self
.
env
.
now
,
'the broker should be granted control instantly'
self
.
isCalled
=
self
.
env
.
event
()
...
...
@@ -92,7 +98,7 @@ class Broker(ObjectInterruption):
# add the currentEntity to the pendingEntities
if
not
self
.
victim
.
currentEntity
in
G
.
pendingEntities
:
G
.
pendingEntities
.
append
(
self
.
victim
.
currentEntity
)
if
not
G
.
Router
.
invoked
:
if
not
G
.
Router
.
invoked
and
G
.
Router
.
expectedSignals
[
'isCalled'
]
:
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
G
.
Router
.
invoked
=
True
succeedTuple
=
(
self
,
self
.
env
.
now
)
...
...
@@ -100,7 +106,13 @@ class Broker(ObjectInterruption):
self
.
waitForOperator
=
True
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
self
.
expectedSignals
[
'resourceAvailable'
]
=
1
yield
self
.
resourceAvailable
self
.
expectedSignals
[
'resourceAvailable'
]
=
0
transmitter
,
eventTime
=
self
.
resourceAvailable
.
value
self
.
resourceAvailable
=
self
.
env
.
event
()
# remove the currentEntity from the pendingEntities
...
...
@@ -112,7 +124,13 @@ class Broker(ObjectInterruption):
elif
G
.
Router
.
invoked
and
G
.
Router
.
allocation
:
self
.
waitForOperator
=
True
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
self
.
expectedSignals
[
'resourceAvailable'
]
=
1
yield
self
.
resourceAvailable
self
.
expectedSignals
[
'resourceAvailable'
]
=
0
transmitter
,
eventTime
=
self
.
resourceAvailable
.
value
self
.
resourceAvailable
=
self
.
env
.
event
()
self
.
waitForOperator
=
False
...
...
@@ -136,13 +154,18 @@ class Broker(ObjectInterruption):
self
.
victim
.
outputTrace
(
self
.
victim
.
currentOperator
.
objName
,
"started work in "
+
self
.
victim
.
objName
)
self
.
victim
.
currentOperator
.
timeLastOperationStarted
=
self
.
env
.
now
#()
# signal the machine that an operator is reserved
succeedTuple
=
(
self
,
self
.
env
.
now
)
self
.
victim
.
brokerIsSet
.
succeed
(
succeedTuple
)
if
self
.
victim
.
expectedSignals
[
'brokerIsSet'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
self
.
victim
.
brokerIsSet
.
succeed
(
succeedTuple
)
# update the schedule of the operator
self
.
victim
.
currentOperator
.
schedule
.
append
([
self
.
victim
,
self
.
env
.
now
])
# wait till the processing is over
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
assert
eventTime
==
self
.
env
.
now
,
'the broker should be granted control instantly'
self
.
isCalled
=
self
.
env
.
event
()
...
...
@@ -156,11 +179,11 @@ 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
:
if
not
G
.
Router
.
invoked
and
G
.
Router
.
expectedSignals
[
'isCalled'
]
:
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
self
.
victim
.
r
outer
.
invoked
=
True
G
.
R
outer
.
invoked
=
True
succeedTuple
=
(
self
,
self
.
env
.
now
)
self
.
victim
.
r
outer
.
isCalled
.
succeed
(
succeedTuple
)
G
.
R
outer
.
isCalled
.
succeed
(
succeedTuple
)
# 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.
...
...
@@ -175,6 +198,7 @@ class Broker(ObjectInterruption):
else
:
pass
# return the control to the victim
succeedTuple
=
(
self
,
self
.
env
.
now
)
self
.
victim
.
brokerIsSet
.
succeed
(
succeedTuple
)
if
self
.
victim
.
expectedSignals
[
'brokerIsSet'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
self
.
victim
.
brokerIsSet
.
succeed
(
succeedTuple
)
dream/simulation/OperatorRouter.py
View file @
85a340ff
...
...
@@ -106,7 +106,13 @@ class Router(ObjectInterruption):
def
run
(
self
):
while
1
:
# wait until the router is called
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
self
.
isCalled
=
self
.
env
.
event
()
self
.
printTrace
(
''
,
'=-'
*
15
)
...
...
@@ -238,16 +244,18 @@ class Router(ObjectInterruption):
station
.
timeLastEntityEnded
=
self
.
env
.
now
#required to count blockage correctly in the preemptied station
elif
station
.
broker
.
waitForOperator
:
# signal this station's broker that the resource is available
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
if
station
.
broker
.
expectedSignals
[
'resourceAvailable'
]:
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
else
:
# signal the queue proceeding the station
if
station
.
canAccept
()
\
and
any
(
type
==
'Load'
for
type
in
station
.
multOperationTypeList
):
self
.
printTrace
(
'router'
,
'signalling'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
if
station
.
expectedSignals
[
'loadOperatorAvailable'
]:
self
.
printTrace
(
'router'
,
'signalling'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
#===========================================================================
# clear the pending lists of the router
...
...
dream/simulation/OperatorRouterManaged.py
View file @
85a340ff
...
...
@@ -78,7 +78,13 @@ class RouterManaged(Router):
def
run
(
self
):
while
1
:
# wait until the router is called
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
self
.
isCalled
=
self
.
env
.
event
()
self
.
printTrace
(
''
,
'=-'
*
15
)
...
...
@@ -193,8 +199,9 @@ class RouterManaged(Router):
if
station
in
self
.
pendingMachines
and
station
in
self
.
toBeSignalled
:
# signal this station's broker that the resource is available
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
operator
.
isAssignedTo
().
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
if
operator
.
isAssignedTo
().
broker
.
expectedSignals
[
'resourceAvailable'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
operator
.
isAssignedTo
().
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
elif
(
not
station
in
self
.
pendingMachines
)
or
(
not
station
in
self
.
toBeSignalled
):
# signal the queue proceeding the station
assert
operator
.
candidateEntity
.
currentStation
in
self
.
toBeSignalled
,
'the candidateEntity currentStation is not picked by the Router'
...
...
@@ -204,8 +211,9 @@ class RouterManaged(Router):
# if the station is already is already signalled then do not send event
if
not
operator
.
candidateEntity
.
currentStation
.
loadOperatorAvailable
.
triggered
:
self
.
printTrace
(
'router'
,
'signalling queue'
+
' '
*
50
+
operator
.
candidateEntity
.
currentStation
.
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
operator
.
candidateEntity
.
currentStation
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
if
operator
.
candidateEntity
.
currentStation
.
expectedSignals
[
'loadOperatorAvailable'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
operator
.
candidateEntity
.
currentStation
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
#===========================================================================
# clear the pending lists of the router
...
...
dream/simulation/ScheduledMaintenance.py
View file @
85a340ff
...
...
@@ -82,7 +82,13 @@ class ScheduledMaintenance(ObjectInterruption):
self
.
victim
.
isWorkingOnTheLast
=
True
self
.
waitingSignal
=
True
# TODO: signal to be triggered by postProcessingActions of Machines
self
.
expectedSignals
[
'endedLastProcessing'
]
=
1
yield
self
.
victim
.
endedLastProcessing
# there is no signal yet that signals the change of such state (an object getting empty)
self
.
expectedSignals
[
'endedLastProcessing'
]
=
0
transmitter
,
eventTime
=
self
.
victim
.
endedLastProcessing
.
value
assert
eventTime
==
self
.
env
.
now
,
'the processing end signal is not received by maintenance on time'
self
.
victim
.
endedLastProcessing
=
self
.
env
.
event
()
...
...
@@ -93,7 +99,13 @@ class ScheduledMaintenance(ObjectInterruption):
waitStartTime
=
self
.
env
.
now
self
.
waitingSignal
=
True
# TODO: signal to be triggered by removeEntity of Machines
self
.
expectedSignals
[
'victimIsEmptyBeforeMaintenance'
]
=
1
yield
self
.
victimIsEmptyBeforeMaintenance
# there is no signal yet that signals the change of such state (an object getting empty)
self
.
expectedSignals
[
'victimIsEmptyBeforeMaintenance'
]
=
0
transmitter
,
eventTime
=
self
.
victimIsEmptyBeforeMaintenance
.
value
assert
eventTime
==
self
.
env
.
now
,
'the processing end signal is not received by maintenance on time'
self
.
victimIsEmptyBeforeMaintenance
=
self
.
env
.
event
()
...
...
dream/simulation/ShiftScheduler.py
View file @
85a340ff
...
...
@@ -78,8 +78,9 @@ class ShiftScheduler(ObjectInterruption):
# if the victim has interruptions that measure only the on-shift time, they have to be notified
for
oi
in
self
.
victim
.
objectInterruptions
:
if
oi
.
isWaitingForVictimOnShift
:
succeedTuple
=
(
self
,
self
.
env
.
now
)
oi
.
victimOnShift
.
succeed
(
succeedTuple
)
if
oi
.
expectedSignals
[
'victimOnShift'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
oi
.
victimOnShift
.
succeed
(
succeedTuple
)
self
.
victim
.
totalOffShiftTime
+=
self
.
env
.
now
-
self
.
victim
.
timeLastShiftEnded
self
.
victim
.
onShift
=
True
...
...
@@ -97,15 +98,22 @@ class ShiftScheduler(ObjectInterruption):
if
self
.
endUnfinished
and
len
(
self
.
victim
.
getActiveObjectQueue
())
==
1
and
(
not
self
.
victim
.
waitToDispose
):
self
.
victim
.
isWorkingOnTheLast
=
True
self
.
waitingSignal
=
True
self
.
expectedSignals
[
'endedLastProcessing'
]
=
1
yield
self
.
victim
.
endedLastProcessing
self
.
expectedSignals
[
'endedLastProcessing'
]
=
0
transmitter
,
eventTime
=
self
.
victim
.
endedLastProcessing
.
value
self
.
victim
.
endedLastProcessing
=
self
.
env
.
event
()
# if the victim has interruptions that measure only the on-shift time, they have to be notified
for
oi
in
self
.
victim
.
objectInterruptions
:
if
oi
.
isWaitingForVictimOffShift
:
succeedTuple
=
(
self
,
self
.
env
.
now
)
oi
.
victimOffShift
.
succeed
(
succeedTuple
)
if
oi
.
expectedSignals
[
'victimOffShift'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
oi
.
victimOffShift
.
succeed
(
succeedTuple
)
# interrupt the victim only if it was not previously interrupted
if
not
self
.
victim
.
interruptionStart
.
triggered
:
...
...
dream/simulation/SkilledOperatorRouter.py
View file @
85a340ff
...
...
@@ -70,7 +70,13 @@ class SkilledRouter(Router):
def
run
(
self
):
while
1
:
# wait until the router is called
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
self
.
isCalled
=
self
.
env
.
event
()
self
.
printTrace
(
''
,
'=-'
*
15
)
...
...
@@ -126,7 +132,13 @@ class SkilledRouter(Router):
# # XXX wait till all the stations have finished their current WIP
#===================================================================
# TODO: fix that, add flags, reset the signals
self
.
expectedSignals
[
'endedLastProcessing'
]
=
1
receivedEvent
=
yield
self
.
env
.
all_of
(
self
.
endProcessingSignals
)
self
.
expectedSignals
[
'endedLastProcessing'
]
=
0
for
station
in
self
.
busyStations
:
if
station
.
endedLastProcessing
in
receivedEvent
:
transmitter
,
eventTime
=
station
.
endedLastProcessing
.
value
...
...
@@ -241,16 +253,18 @@ class SkilledRouter(Router):
for
station
in
self
.
toBeSignalled
:
if
station
.
broker
.
waitForOperator
:
# signal this station's broker that the resource is available
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
station
.
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
if
station
.
broker
.
expectedSignals
[
'resourceAvailable'
]:
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
station
.
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
else
:
# signal the queue proceeding the station
if
station
.
canAccept
()
\
and
any
(
type
==
'Load'
for
type
in
station
.
multOperationTypeList
):
self
.
printTrace
(
'router'
,
'signalling'
+
' '
*
50
+
station
.
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
if
station
.
expectedSignals
[
'loadOperatorAvailable'
]:
self
.
printTrace
(
'router'
,
'signalling'
+
' '
*
50
+
station
.
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
#===================================================================
# default behaviour
...
...
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