Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-02-23 17:10:45 -0500
committerHenrik Rentz-Reichert2011-02-23 17:10:45 -0500
commitc5e939ebca6576a089a4d3c8101f61fd7553371c (patch)
tree0eb9c803244e79b691eb351ad4d828bab6e0e34f /modellib/org.eclipse.etrice.modellib/models/TimingService.room
parentf2c3d8e1319515d3ab14323a15cb75df7af28c16 (diff)
downloadorg.eclipse.etrice-c5e939ebca6576a089a4d3c8101f61fd7553371c.tar.gz
org.eclipse.etrice-c5e939ebca6576a089a4d3c8101f61fd7553371c.tar.xz
org.eclipse.etrice-c5e939ebca6576a089a4d3c8101f61fd7553371c.zip
applied patch 2 of
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337075 Thanks for the contribution!
Diffstat (limited to 'modellib/org.eclipse.etrice.modellib/models/TimingService.room')
-rw-r--r--modellib/org.eclipse.etrice.modellib/models/TimingService.room158
1 files changed, 75 insertions, 83 deletions
diff --git a/modellib/org.eclipse.etrice.modellib/models/TimingService.room b/modellib/org.eclipse.etrice.modellib/models/TimingService.room
index 2de1bf0d3..a7f4d5b4b 100644
--- a/modellib/org.eclipse.etrice.modellib/models/TimingService.room
+++ b/modellib/org.eclipse.etrice.modellib/models/TimingService.room
@@ -1,6 +1,71 @@
-RoomModel room.basic.service.timing {
-
- ProtocolClass PTimer {
+RoomModel room.basic.service.timing { ActorClass ATimingService {
+ Interface {
+ SPP timer: PTimer
+ SPP timeout: PTimeout
+ }
+ Structure {
+ usercode1 {
+ "import java.util.Timer;"
+ }
+ usercode2 {
+ "private Timer timerService = null;"
+ "private int taskCount = 0;"
+ "private static final int PURGE_LIMIT = 1000;"
+ }
+ ServiceImplementation of timer
+ ServiceImplementation of timeout
+ }
+ Behavior {
+ Operation stop() {
+ "System.out.println(toString() + \"::stop()\");"
+ "timerService.cancel();"
+ "timerService = null;"
+ }
+ StateMachine { Transition tr0: initial -> Operational {
+ action {
+ "timerService = new Timer();"
+ }
+ }
+ Transition tr1: Operational -> Operational {
+ triggers {
+ <Start:timeout>
+ }
+ action {
+ "// start timeout"
+ "taskCount++;"
+ "if (taskCount>PURGE_LIMIT) timerService.purge();"
+ "timerService.schedule(((PTimeoutPort)ifitem).getTask(), time_ms);"
+ }
+ }
+ Transition tr2: Operational -> Operational {
+ triggers {
+ <Kill:timeout>
+ }
+ // nothing to do to kill timeout (handled by timerService)
+ }
+ Transition tr3: Operational -> Operational {
+ triggers {
+ <Start:timer>
+ }
+ action {
+ "// start timer"
+ "taskCount++;"
+ "if (taskCount>PURGE_LIMIT) timerService.purge();"
+ "timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(), time_ms, time_ms);"
+ }
+ }
+ Transition tr4: Operational -> Operational {
+ triggers {
+ <Kill:timer>
+ }
+ // nothing to do to kill timer (handled by timer)
+ } State Operational {
+ entry {
+ "// prepare"
+ }
+ }}
+ }
+ }ProtocolClass PTimer {
usercode1 {
"import java.util.TimerTask;"
}
@@ -73,7 +138,7 @@ RoomModel room.basic.service.timing {
DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
getPeerAddress(), messageStrings[OUT_timerTick]);
- getMsgReceiver().receive(
+ getPeerMsgReceiver().receive(
new EventWithDataMessage(getPeerAddress(), OUT_timerTick, id));"
}
}
@@ -100,7 +165,7 @@ RoomModel room.basic.service.timing {
DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
getPeerAddress(), messageStrings[IN_Start]);
- getMsgReceiver()
+ getPeerMsgReceiver()
.receive(
new EventWithDataMessage(getPeerAddress(),
IN_Start, new TimerData(time_ms, ++currentId)));"
@@ -112,7 +177,7 @@ RoomModel room.basic.service.timing {
if (active) {
active = false;
- getMsgReceiver().receive(
+ getPeerMsgReceiver().receive(
new EventWithDataMessage(getPeerAddress(), IN_Kill, currentId));
}"
}
@@ -192,7 +257,7 @@ RoomModel room.basic.service.timing {
DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
getPeerAddress(), messageStrings[OUT_timeoutTick]);
- getMsgReceiver().receive(
+ getPeerMsgReceiver().receive(
new EventWithDataMessage(getPeerAddress(), OUT_timeoutTick, id));"
}
}
@@ -220,7 +285,7 @@ RoomModel room.basic.service.timing {
DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
getPeerAddress(), messageStrings[IN_Start]);
- getMsgReceiver()
+ getPeerMsgReceiver()
.receive(
new EventWithDataMessage(getPeerAddress(),
IN_Start, new TimeoutData(time_ms, ++currentId)));"
@@ -232,82 +297,9 @@ RoomModel room.basic.service.timing {
if (active) {
active = false;
- getMsgReceiver().receive(
+ getPeerMsgReceiver().receive(
new EventWithDataMessage(getPeerAddress(), IN_Kill, new Integer(currentId)));
}"
}
}
- }
-
- ActorClass ATimingService {
- Interface {
- SPP timer: PTimer
- SPP timeout: PTimeout
- }
- Structure {
- usercode1 {
- "import java.util.Timer;"
- }
- usercode2 {
- "private Timer timerService = null;"
- "private int taskCount = 0;"
- "private static final int PURGE_LIMIT = 1000;"
- }
- ServiceImplementation of timer
- ServiceImplementation of timeout
- }
- Behavior {
- Operation stop() {
- "System.out.println(toString() + \"::stop()\");"
- "timerService.cancel();"
- "timerService = null;"
- }
- StateMachine {
- State Operational {
- entry {
- "// prepare"
- }
- }
- Transition tr0: initial -> Operational {
- action {
- "timerService = new Timer();"
- }
- }
- Transition tr1: Operational -> Operational {
- triggers {
- <Start:timeout>
- }
- action {
- "// start timeout"
- "taskCount++;"
- "if (taskCount>PURGE_LIMIT) timerService.purge();"
- "timerService.schedule(((PTimeoutPort)ifitem).getTask(), time_ms);"
- }
- }
- Transition tr2: Operational -> Operational {
- triggers {
- <Kill:timeout>
- }
- // nothing to do to kill timeout (handled by timerService)
- }
- Transition tr3: Operational -> Operational {
- triggers {
- <Start:timer>
- }
- action {
- "// start timer"
- "taskCount++;"
- "if (taskCount>PURGE_LIMIT) timerService.purge();"
- "timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(), time_ms, time_ms);"
- }
- }
- Transition tr4: Operational -> Operational {
- triggers {
- <Kill:timer>
- }
- // nothing to do to kill timer (handled by timer)
- }
- }
- }
- }
-}
+ }} \ No newline at end of file

Back to the top