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
Show 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
...
@@ -113,6 +113,9 @@ class Failure(ObjectInterruption):
...
@@ -113,6 +113,9 @@ class Failure(ObjectInterruption):
while
failureNotTriggered
:
while
failureNotTriggered
:
timeRestartedCounting
=
self
.
env
.
now
timeRestartedCounting
=
self
.
env
.
now
self
.
isWaitingForVictimOffShift
=
True
self
.
isWaitingForVictimOffShift
=
True
self
.
expectedSignals
[
'victimOffShift'
]
=
1
receivedEvent
=
yield
self
.
env
.
timeout
(
remainingTimeToFailure
)
|
self
.
victimOffShift
receivedEvent
=
yield
self
.
env
.
timeout
(
remainingTimeToFailure
)
|
self
.
victimOffShift
# the failure should receive a signal if there is a shift-off triggered
# the failure should receive a signal if there is a shift-off triggered
if
self
.
victimOffShift
in
receivedEvent
:
if
self
.
victimOffShift
in
receivedEvent
:
...
@@ -121,31 +124,57 @@ class Failure(ObjectInterruption):
...
@@ -121,31 +124,57 @@ class Failure(ObjectInterruption):
remainingTimeToFailure
=
remainingTimeToFailure
-
(
self
.
env
.
now
-
timeRestartedCounting
)
remainingTimeToFailure
=
remainingTimeToFailure
-
(
self
.
env
.
now
-
timeRestartedCounting
)
# wait for the shift to start again
# wait for the shift to start again
self
.
isWaitingForVictimOnShift
=
True
self
.
isWaitingForVictimOnShift
=
True
self
.
expectedSignals
[
'victimOnShift'
]
=
1
yield
self
.
victimOnShift
yield
self
.
victimOnShift
self
.
expectedSignals
[
'victimOnShift'
]
=
0
self
.
isWaitingForVictimOnShift
=
False
self
.
isWaitingForVictimOnShift
=
False
self
.
victimOnShift
=
self
.
env
.
event
()
self
.
victimOnShift
=
self
.
env
.
event
()
assert
self
.
victim
.
onShift
==
True
,
'the victim of shiftFailure must be onShift to continue counting the TTF'
assert
self
.
victim
.
onShift
==
True
,
'the victim of shiftFailure must be onShift to continue counting the TTF'
else
:
else
:
self
.
isWaitingForVictimOffShift
=
False
self
.
isWaitingForVictimOffShift
=
False
failureNotTriggered
=
False
failureNotTriggered
=
False
self
.
expectedSignals
[
'victimOffShift'
]
=
0
# if time to failure counts only in working time
# if time to failure counts only in working time
elif
self
.
deteriorationType
==
'working'
:
elif
self
.
deteriorationType
==
'working'
:
# wait for victim to start process
# wait for victim to start process
self
.
expectedSignals
[
'victimStartsProcess'
]
=
1
yield
self
.
victimStartsProcess
yield
self
.
victimStartsProcess
self
.
expectedSignals
[
'victimStartsProcess'
]
=
0
self
.
victimStartsProcess
=
self
.
env
.
event
()
self
.
victimStartsProcess
=
self
.
env
.
event
()
while
failureNotTriggered
:
while
failureNotTriggered
:
timeRestartedCounting
=
self
.
env
.
now
timeRestartedCounting
=
self
.
env
.
now
self
.
expectedSignals
[
'victimEndsProcess'
]
=
1
# wait either for the failure or end of process
# wait either for the failure or end of process
receivedEvent
=
yield
self
.
env
.
timeout
(
remainingTimeToFailure
)
|
self
.
victimEndsProcess
receivedEvent
=
yield
self
.
env
.
timeout
(
remainingTimeToFailure
)
|
self
.
victimEndsProcess
if
self
.
victimEndsProcess
in
receivedEvent
:
if
self
.
victimEndsProcess
in
receivedEvent
:
self
.
victimEndsProcess
=
self
.
env
.
event
()
self
.
victimEndsProcess
=
self
.
env
.
event
()
remainingTimeToFailure
=
remainingTimeToFailure
-
(
self
.
env
.
now
-
timeRestartedCounting
)
remainingTimeToFailure
=
remainingTimeToFailure
-
(
self
.
env
.
now
-
timeRestartedCounting
)
self
.
expectedSignals
[
'victimStartsProcess'
]
=
1
yield
self
.
victimStartsProcess
yield
self
.
victimStartsProcess
self
.
expectedSignals
[
'victimStartsProcess'
]
=
0
# wait for victim to start again processing
# wait for victim to start again processing
self
.
victimStartsProcess
=
self
.
env
.
event
()
self
.
victimStartsProcess
=
self
.
env
.
event
()
else
:
else
:
failureNotTriggered
=
False
failureNotTriggered
=
False
self
.
expectedSignals
[
'victimEndsProcess'
]
=
0
# interrupt the victim only if it was not previously interrupted
# interrupt the victim only if it was not previously interrupted
if
not
self
.
victim
.
interruptionStart
.
triggered
:
if
not
self
.
victim
.
interruptionStart
.
triggered
:
self
.
interruptVictim
()
# interrupt the victim
self
.
interruptVictim
()
# interrupt the victim
...
...
dream/simulation/OperatedPoolBroker.py
View file @
85a340ff
...
@@ -71,7 +71,13 @@ class Broker(ObjectInterruption):
...
@@ -71,7 +71,13 @@ class Broker(ObjectInterruption):
def
run
(
self
):
def
run
(
self
):
while
1
:
while
1
:
# TODO: add new broker event - brokerIsCalled
# TODO: add new broker event - brokerIsCalled
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
transmitter
,
eventTime
=
self
.
isCalled
.
value
assert
eventTime
==
self
.
env
.
now
,
'the broker should be granted control instantly'
assert
eventTime
==
self
.
env
.
now
,
'the broker should be granted control instantly'
self
.
isCalled
=
self
.
env
.
event
()
self
.
isCalled
=
self
.
env
.
event
()
...
@@ -92,7 +98,7 @@ class Broker(ObjectInterruption):
...
@@ -92,7 +98,7 @@ class Broker(ObjectInterruption):
# add the currentEntity to the pendingEntities
# add the currentEntity to the pendingEntities
if
not
self
.
victim
.
currentEntity
in
G
.
pendingEntities
:
if
not
self
.
victim
.
currentEntity
in
G
.
pendingEntities
:
G
.
pendingEntities
.
append
(
self
.
victim
.
currentEntity
)
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)'
)
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
G
.
Router
.
invoked
=
True
G
.
Router
.
invoked
=
True
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
...
@@ -100,7 +106,13 @@ class Broker(ObjectInterruption):
...
@@ -100,7 +106,13 @@ class Broker(ObjectInterruption):
self
.
waitForOperator
=
True
self
.
waitForOperator
=
True
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
self
.
expectedSignals
[
'resourceAvailable'
]
=
1
yield
self
.
resourceAvailable
yield
self
.
resourceAvailable
self
.
expectedSignals
[
'resourceAvailable'
]
=
0
transmitter
,
eventTime
=
self
.
resourceAvailable
.
value
transmitter
,
eventTime
=
self
.
resourceAvailable
.
value
self
.
resourceAvailable
=
self
.
env
.
event
()
self
.
resourceAvailable
=
self
.
env
.
event
()
# remove the currentEntity from the pendingEntities
# remove the currentEntity from the pendingEntities
...
@@ -112,7 +124,13 @@ class Broker(ObjectInterruption):
...
@@ -112,7 +124,13 @@ class Broker(ObjectInterruption):
elif
G
.
Router
.
invoked
and
G
.
Router
.
allocation
:
elif
G
.
Router
.
invoked
and
G
.
Router
.
allocation
:
self
.
waitForOperator
=
True
self
.
waitForOperator
=
True
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
self
.
victim
.
printTrace
(
self
.
victim
.
id
,
waitEvent
=
'(resourceIsAvailable broker)'
)
self
.
expectedSignals
[
'resourceAvailable'
]
=
1
yield
self
.
resourceAvailable
yield
self
.
resourceAvailable
self
.
expectedSignals
[
'resourceAvailable'
]
=
0
transmitter
,
eventTime
=
self
.
resourceAvailable
.
value
transmitter
,
eventTime
=
self
.
resourceAvailable
.
value
self
.
resourceAvailable
=
self
.
env
.
event
()
self
.
resourceAvailable
=
self
.
env
.
event
()
self
.
waitForOperator
=
False
self
.
waitForOperator
=
False
...
@@ -136,13 +154,18 @@ class Broker(ObjectInterruption):
...
@@ -136,13 +154,18 @@ class Broker(ObjectInterruption):
self
.
victim
.
outputTrace
(
self
.
victim
.
currentOperator
.
objName
,
"started work in "
+
self
.
victim
.
objName
)
self
.
victim
.
outputTrace
(
self
.
victim
.
currentOperator
.
objName
,
"started work in "
+
self
.
victim
.
objName
)
self
.
victim
.
currentOperator
.
timeLastOperationStarted
=
self
.
env
.
now
#()
self
.
victim
.
currentOperator
.
timeLastOperationStarted
=
self
.
env
.
now
#()
# signal the machine that an operator is reserved
# signal the machine that an operator is reserved
if
self
.
victim
.
expectedSignals
[
'brokerIsSet'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
self
.
victim
.
brokerIsSet
.
succeed
(
succeedTuple
)
self
.
victim
.
brokerIsSet
.
succeed
(
succeedTuple
)
# update the schedule of the operator
# update the schedule of the operator
self
.
victim
.
currentOperator
.
schedule
.
append
([
self
.
victim
,
self
.
env
.
now
])
self
.
victim
.
currentOperator
.
schedule
.
append
([
self
.
victim
,
self
.
env
.
now
])
# wait till the processing is over
# wait till the processing is over
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
transmitter
,
eventTime
=
self
.
isCalled
.
value
assert
eventTime
==
self
.
env
.
now
,
'the broker should be granted control instantly'
assert
eventTime
==
self
.
env
.
now
,
'the broker should be granted control instantly'
self
.
isCalled
=
self
.
env
.
event
()
self
.
isCalled
=
self
.
env
.
event
()
...
@@ -156,11 +179,11 @@ class Broker(ObjectInterruption):
...
@@ -156,11 +179,11 @@ class Broker(ObjectInterruption):
# TODO: signalling the router must be done more elegantly, router must be set as global variable
# 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 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
.
printTrace
(
self
.
victim
.
id
,
signal
=
'router (broker)'
)
self
.
victim
.
r
outer
.
invoked
=
True
G
.
R
outer
.
invoked
=
True
succeedTuple
=
(
self
,
self
.
env
.
now
)
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.
# 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
# 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.
# 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):
...
@@ -175,6 +198,7 @@ class Broker(ObjectInterruption):
else
:
else
:
pass
pass
# return the control to the victim
# return the control to the victim
if
self
.
victim
.
expectedSignals
[
'brokerIsSet'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
self
.
victim
.
brokerIsSet
.
succeed
(
succeedTuple
)
self
.
victim
.
brokerIsSet
.
succeed
(
succeedTuple
)
dream/simulation/OperatorRouter.py
View file @
85a340ff
...
@@ -106,7 +106,13 @@ class Router(ObjectInterruption):
...
@@ -106,7 +106,13 @@ class Router(ObjectInterruption):
def
run
(
self
):
def
run
(
self
):
while
1
:
while
1
:
# wait until the router is called
# wait until the router is called
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
transmitter
,
eventTime
=
self
.
isCalled
.
value
self
.
isCalled
=
self
.
env
.
event
()
self
.
isCalled
=
self
.
env
.
event
()
self
.
printTrace
(
''
,
'=-'
*
15
)
self
.
printTrace
(
''
,
'=-'
*
15
)
...
@@ -238,6 +244,7 @@ class Router(ObjectInterruption):
...
@@ -238,6 +244,7 @@ class Router(ObjectInterruption):
station
.
timeLastEntityEnded
=
self
.
env
.
now
#required to count blockage correctly in the preemptied station
station
.
timeLastEntityEnded
=
self
.
env
.
now
#required to count blockage correctly in the preemptied station
elif
station
.
broker
.
waitForOperator
:
elif
station
.
broker
.
waitForOperator
:
# signal this station's broker that the resource is available
# signal this station's broker that the resource is available
if
station
.
broker
.
expectedSignals
[
'resourceAvailable'
]:
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
station
.
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
...
@@ -245,6 +252,7 @@ class Router(ObjectInterruption):
...
@@ -245,6 +252,7 @@ class Router(ObjectInterruption):
# signal the queue proceeding the station
# signal the queue proceeding the station
if
station
.
canAccept
()
\
if
station
.
canAccept
()
\
and
any
(
type
==
'Load'
for
type
in
station
.
multOperationTypeList
):
and
any
(
type
==
'Load'
for
type
in
station
.
multOperationTypeList
):
if
station
.
expectedSignals
[
'loadOperatorAvailable'
]:
self
.
printTrace
(
'router'
,
'signalling'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
self
.
printTrace
(
'router'
,
'signalling'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
station
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
...
...
dream/simulation/OperatorRouterManaged.py
View file @
85a340ff
...
@@ -78,7 +78,13 @@ class RouterManaged(Router):
...
@@ -78,7 +78,13 @@ class RouterManaged(Router):
def
run
(
self
):
def
run
(
self
):
while
1
:
while
1
:
# wait until the router is called
# wait until the router is called
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
transmitter
,
eventTime
=
self
.
isCalled
.
value
self
.
isCalled
=
self
.
env
.
event
()
self
.
isCalled
=
self
.
env
.
event
()
self
.
printTrace
(
''
,
'=-'
*
15
)
self
.
printTrace
(
''
,
'=-'
*
15
)
...
@@ -193,6 +199,7 @@ class RouterManaged(Router):
...
@@ -193,6 +199,7 @@ class RouterManaged(Router):
if
station
in
self
.
pendingMachines
and
station
in
self
.
toBeSignalled
:
if
station
in
self
.
pendingMachines
and
station
in
self
.
toBeSignalled
:
# signal this station's broker that the resource is available
# signal this station's broker that the resource is available
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
operator
.
isAssignedTo
().
id
)
if
operator
.
isAssignedTo
().
broker
.
expectedSignals
[
'resourceAvailable'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
operator
.
isAssignedTo
().
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
operator
.
isAssignedTo
().
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
elif
(
not
station
in
self
.
pendingMachines
)
or
(
not
station
in
self
.
toBeSignalled
):
elif
(
not
station
in
self
.
pendingMachines
)
or
(
not
station
in
self
.
toBeSignalled
):
...
@@ -204,6 +211,7 @@ class RouterManaged(Router):
...
@@ -204,6 +211,7 @@ class RouterManaged(Router):
# if the station is already is already signalled then do not send event
# if the station is already is already signalled then do not send event
if
not
operator
.
candidateEntity
.
currentStation
.
loadOperatorAvailable
.
triggered
:
if
not
operator
.
candidateEntity
.
currentStation
.
loadOperatorAvailable
.
triggered
:
self
.
printTrace
(
'router'
,
'signalling queue'
+
' '
*
50
+
operator
.
candidateEntity
.
currentStation
.
id
)
self
.
printTrace
(
'router'
,
'signalling queue'
+
' '
*
50
+
operator
.
candidateEntity
.
currentStation
.
id
)
if
operator
.
candidateEntity
.
currentStation
.
expectedSignals
[
'loadOperatorAvailable'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
operator
.
candidateEntity
.
currentStation
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
operator
.
candidateEntity
.
currentStation
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
...
...
dream/simulation/ScheduledMaintenance.py
View file @
85a340ff
...
@@ -82,7 +82,13 @@ class ScheduledMaintenance(ObjectInterruption):
...
@@ -82,7 +82,13 @@ class ScheduledMaintenance(ObjectInterruption):
self
.
victim
.
isWorkingOnTheLast
=
True
self
.
victim
.
isWorkingOnTheLast
=
True
self
.
waitingSignal
=
True
self
.
waitingSignal
=
True
# TODO: signal to be triggered by postProcessingActions of Machines
# 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)
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
transmitter
,
eventTime
=
self
.
victim
.
endedLastProcessing
.
value
assert
eventTime
==
self
.
env
.
now
,
'the processing end signal is not received by maintenance on time'
assert
eventTime
==
self
.
env
.
now
,
'the processing end signal is not received by maintenance on time'
self
.
victim
.
endedLastProcessing
=
self
.
env
.
event
()
self
.
victim
.
endedLastProcessing
=
self
.
env
.
event
()
...
@@ -93,7 +99,13 @@ class ScheduledMaintenance(ObjectInterruption):
...
@@ -93,7 +99,13 @@ class ScheduledMaintenance(ObjectInterruption):
waitStartTime
=
self
.
env
.
now
waitStartTime
=
self
.
env
.
now
self
.
waitingSignal
=
True
self
.
waitingSignal
=
True
# TODO: signal to be triggered by removeEntity of Machines
# 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)
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
transmitter
,
eventTime
=
self
.
victimIsEmptyBeforeMaintenance
.
value
assert
eventTime
==
self
.
env
.
now
,
'the processing end signal is not received by maintenance on time'
assert
eventTime
==
self
.
env
.
now
,
'the processing end signal is not received by maintenance on time'
self
.
victimIsEmptyBeforeMaintenance
=
self
.
env
.
event
()
self
.
victimIsEmptyBeforeMaintenance
=
self
.
env
.
event
()
...
...
dream/simulation/ShiftScheduler.py
View file @
85a340ff
...
@@ -78,6 +78,7 @@ class ShiftScheduler(ObjectInterruption):
...
@@ -78,6 +78,7 @@ class ShiftScheduler(ObjectInterruption):
# if the victim has interruptions that measure only the on-shift time, they have to be notified
# if the victim has interruptions that measure only the on-shift time, they have to be notified
for
oi
in
self
.
victim
.
objectInterruptions
:
for
oi
in
self
.
victim
.
objectInterruptions
:
if
oi
.
isWaitingForVictimOnShift
:
if
oi
.
isWaitingForVictimOnShift
:
if
oi
.
expectedSignals
[
'victimOnShift'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
oi
.
victimOnShift
.
succeed
(
succeedTuple
)
oi
.
victimOnShift
.
succeed
(
succeedTuple
)
...
@@ -97,13 +98,20 @@ class ShiftScheduler(ObjectInterruption):
...
@@ -97,13 +98,20 @@ class ShiftScheduler(ObjectInterruption):
if
self
.
endUnfinished
and
len
(
self
.
victim
.
getActiveObjectQueue
())
==
1
and
(
not
self
.
victim
.
waitToDispose
):
if
self
.
endUnfinished
and
len
(
self
.
victim
.
getActiveObjectQueue
())
==
1
and
(
not
self
.
victim
.
waitToDispose
):
self
.
victim
.
isWorkingOnTheLast
=
True
self
.
victim
.
isWorkingOnTheLast
=
True
self
.
waitingSignal
=
True
self
.
waitingSignal
=
True
self
.
expectedSignals
[
'endedLastProcessing'
]
=
1
yield
self
.
victim
.
endedLastProcessing
yield
self
.
victim
.
endedLastProcessing
self
.
expectedSignals
[
'endedLastProcessing'
]
=
0
transmitter
,
eventTime
=
self
.
victim
.
endedLastProcessing
.
value
transmitter
,
eventTime
=
self
.
victim
.
endedLastProcessing
.
value
self
.
victim
.
endedLastProcessing
=
self
.
env
.
event
()
self
.
victim
.
endedLastProcessing
=
self
.
env
.
event
()
# if the victim has interruptions that measure only the on-shift time, they have to be notified
# if the victim has interruptions that measure only the on-shift time, they have to be notified
for
oi
in
self
.
victim
.
objectInterruptions
:
for
oi
in
self
.
victim
.
objectInterruptions
:
if
oi
.
isWaitingForVictimOffShift
:
if
oi
.
isWaitingForVictimOffShift
:
if
oi
.
expectedSignals
[
'victimOffShift'
]:
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
oi
.
victimOffShift
.
succeed
(
succeedTuple
)
oi
.
victimOffShift
.
succeed
(
succeedTuple
)
...
...
dream/simulation/SkilledOperatorRouter.py
View file @
85a340ff
...
@@ -70,7 +70,13 @@ class SkilledRouter(Router):
...
@@ -70,7 +70,13 @@ class SkilledRouter(Router):
def
run
(
self
):
def
run
(
self
):
while
1
:
while
1
:
# wait until the router is called
# wait until the router is called
self
.
expectedSignals
[
'isCalled'
]
=
1
yield
self
.
isCalled
yield
self
.
isCalled
self
.
expectedSignals
[
'isCalled'
]
=
0
transmitter
,
eventTime
=
self
.
isCalled
.
value
transmitter
,
eventTime
=
self
.
isCalled
.
value
self
.
isCalled
=
self
.
env
.
event
()
self
.
isCalled
=
self
.
env
.
event
()
self
.
printTrace
(
''
,
'=-'
*
15
)
self
.
printTrace
(
''
,
'=-'
*
15
)
...
@@ -126,7 +132,13 @@ class SkilledRouter(Router):
...
@@ -126,7 +132,13 @@ class SkilledRouter(Router):
# # XXX wait till all the stations have finished their current WIP
# # XXX wait till all the stations have finished their current WIP
#===================================================================
#===================================================================
# TODO: fix that, add flags, reset the signals
# TODO: fix that, add flags, reset the signals
self
.
expectedSignals
[
'endedLastProcessing'
]
=
1
receivedEvent
=
yield
self
.
env
.
all_of
(
self
.
endProcessingSignals
)
receivedEvent
=
yield
self
.
env
.
all_of
(
self
.
endProcessingSignals
)
self
.
expectedSignals
[
'endedLastProcessing'
]
=
0
for
station
in
self
.
busyStations
:
for
station
in
self
.
busyStations
:
if
station
.
endedLastProcessing
in
receivedEvent
:
if
station
.
endedLastProcessing
in
receivedEvent
:
transmitter
,
eventTime
=
station
.
endedLastProcessing
.
value
transmitter
,
eventTime
=
station
.
endedLastProcessing
.
value
...
@@ -241,6 +253,7 @@ class SkilledRouter(Router):
...
@@ -241,6 +253,7 @@ class SkilledRouter(Router):
for
station
in
self
.
toBeSignalled
:
for
station
in
self
.
toBeSignalled
:
if
station
.
broker
.
waitForOperator
:
if
station
.
broker
.
waitForOperator
:
# signal this station's broker that the resource is available
# signal this station's broker that the resource is available
if
station
.
broker
.
expectedSignals
[
'resourceAvailable'
]:
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
station
.
id
)
self
.
printTrace
(
'router'
,
'signalling broker of'
+
' '
*
50
+
station
.
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
station
.
broker
.
resourceAvailable
.
succeed
(
succeedTuple
)
...
@@ -248,6 +261,7 @@ class SkilledRouter(Router):
...
@@ -248,6 +261,7 @@ class SkilledRouter(Router):
# signal the queue proceeding the station
# signal the queue proceeding the station
if
station
.
canAccept
()
\
if
station
.
canAccept
()
\
and
any
(
type
==
'Load'
for
type
in
station
.
multOperationTypeList
):
and
any
(
type
==
'Load'
for
type
in
station
.
multOperationTypeList
):
if
station
.
expectedSignals
[
'loadOperatorAvailable'
]:
self
.
printTrace
(
'router'
,
'signalling'
+
' '
*
50
+
station
.
id
)
self
.
printTrace
(
'router'
,
'signalling'
+
' '
*
50
+
station
.
id
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
succeedTuple
=
(
self
,
self
.
env
.
now
)
station
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
station
.
loadOperatorAvailable
.
succeed
(
succeedTuple
)
...
...
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