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
59ec575e
Commit
59ec575e
authored
Mar 20, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Break to start counting time from the start of the shift
parent
aeb2af24
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
dream/simulation/Break.py
dream/simulation/Break.py
+21
-4
No files found.
dream/simulation/Break.py
View file @
59ec575e
...
...
@@ -55,13 +55,30 @@ class Break(ObjectInterruption):
from
ObjectResource
import
ObjectResource
while
1
:
# if the time that the victim is off-shift should not be counted
# if the victim is off-shift wait for the victim to become on-shift
if
not
self
.
victim
.
onShift
:
self
.
isWaitingForVictimOnShift
=
True
self
.
expectedSignals
[
'victimOnShift'
]
=
1
yield
self
.
victimOnShift
self
.
victimOnShift
=
self
.
env
.
event
()
timeToBreak
=
self
.
rngTTB
.
generateNumber
()
remainingTimeToBreak
=
timeToBreak
yield
self
.
env
.
timeout
(
remainingTimeToBreak
)
self
.
expectedSignals
[
'victimOffShift'
]
=
1
self
.
isWaitingForVictimOffShift
=
True
# wait for the break or the end off shift of the victim
receivedEvent
=
yield
self
.
env
.
any_of
([
self
.
env
.
timeout
(
remainingTimeToBreak
),
self
.
victimOffShift
])
# if the victim became off shift the loop should start again (to wait on-shift etc)
if
self
.
victimOffShift
in
receivedEvent
:
transmitter
,
eventTime
=
self
.
victimOffShift
.
value
assert
eventTime
==
self
.
env
.
now
,
'victimOffShift was triggered earlier, not now'
# reset the signalparam of the victimOffShift event
self
.
victimOffShift
=
self
.
env
.
event
()
continue
# interrupt the victim
# if the victim is station
if
issubclass
(
self
.
victim
.
__class__
,
CoreObject
):
...
...
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