summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortjung2012-03-18 15:02:51 (EDT)
committertjung2012-03-18 15:02:51 (EDT)
commitd1aec1df1dfe79183966336a6ea247af25bc93bb (patch)
tree79b6677549b13cd45ce918b3603fd49405e9faf0
parentd94dd3bdf845f1f842e3bfc10b74cfef0717e346 (diff)
downloadorg.eclipse.etrice-d1aec1df1dfe79183966336a6ea247af25bc93bb.zip
org.eclipse.etrice-d1aec1df1dfe79183966336a6ea247af25bc93bb.tar.gz
org.eclipse.etrice-d1aec1df1dfe79183966336a6ea247af25bc93bb.tar.bz2
[modellib.models.ATimingService] cast exception fixed
-rw-r--r--runtime/org.eclipse.etrice.modellib/models/TimingService.room582
1 files changed, 277 insertions, 305 deletions
diff --git a/runtime/org.eclipse.etrice.modellib/models/TimingService.room b/runtime/org.eclipse.etrice.modellib/models/TimingService.room
index 8fccf01..403d8ec 100644
--- a/runtime/org.eclipse.etrice.modellib/models/TimingService.room
+++ b/runtime/org.eclipse.etrice.modellib/models/TimingService.room
@@ -2,317 +2,289 @@ RoomModel room.basic.service.timing {
import room.basic.types.java.* from "JavaTypes.room"
- ExternalType Integer -> Integer
-
- 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;"
- }
+ ActorClass ATimingService {
+ Interface {
+ SPP timeout: PTimeout
+ SPP timer: PTimer
+ }
+ Structure {
+ usercode1 {
+ "import java.util.Timer;"
+ }
+ usercode2 {
+ "private Timer timerService = null;"
+ "private int taskCount = 0;"
+ "private static final int PURGE_LIMIT = 1000;"
+ } ServiceImplementation of timeout ServiceImplementation of timer
+ }
+ 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++;"
+ Transition tr0: initial -> Operational {
+ action {
+ "timerService = new Timer();"
+ }
+ }
+ Transition tr1: Operational -> Operational {
+ triggers {
+ <internalStart: timeout>
+ }
+ action {
+ "// start timeout"
+ "taskCount++;"
+ "if (taskCount>PURGE_LIMIT) timerService.purge();"
+ "timerService.schedule(((PTimeoutPort)ifitem).getTask(), ((TimerData)td).getTime());"
+ }
+ }
+ Transition tr2: Operational -> Operational {
+ triggers {
+ <Kill: timeout>
+ }
+
+ // nothing to do to kill timeout (handled by timerService)
+
+ action {
+ "// nothing to do to kill timer (handled by timer)"
+ }
+ }
+ Transition tr3: Operational -> Operational {
+ triggers {
+ <internalStart: timer>
+ }
+ action {
+ "// start timer"
+ "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)
+ "int t = td.getTime();"
+ "timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(),t,t);"
+ }
+ }
+ Transition tr4: Operational -> Operational {
+ triggers {
+ <Kill: timer>
+ }
+ action {
+ "// nothing to do to kill timer (handled by timer)"
+ }
}
- State Operational {
- entry {
- "// prepare"
- }
+ State Operational {
+ entry {
+ "// prepare"
+ }
}
- }
- }
+ }
+ }
}
- ProtocolClass PTimer {
- usercode1 {
- "import java.util.TimerTask;"
- }
- usercode2 {
- "static protected class FireTimerTask extends TimerTask {
-
- private int time;
- private int id;
- private PTimerPort port;
-
- public FireTimerTask(int time, int id, PTimerPort port) {
- this.time = time;
- this.id = id;
- this.port = port;
- }
-
- @Override
- public void run() {
- port.timer(id);
- }
-
- public int getTime() {
- return time;
- }
-
- public int getId() {
- return id;
- }
- }
-
- static protected class TimerData {
- int time;
- int id;
- public TimerData(int time, int id) {
- this.time = time;
- this.id = id;
- }
- }"
- }
- incoming {
- Message Start (time_ms : int32)
- Message Kill ()
- }
- outgoing {
- Message timerTick ()
- }
- regular PortClass {
- usercode {
- "private FireTimerTask task = null;
-
- public TimerTask getTask() { return task; }"
- }
- handle Start {
- "//regular PortClass handle start
- EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
- TimerData td = (TimerData)dataMsg.getData();
- task = new FireTimerTask(td.time, td.id, this);
- getActor().receiveEvent(this, IN_Start, td.time);"
- }
- handle Kill {
- "//regular PortClass handle kill
- EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
- int id = (Integer)dataMsg.getData();
- if (task!=null && task.getId()==id) {
- task.cancel();
- }"
- }
- Operation timer(id: Integer) {
- "//regular PortClass Operation timer
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[OUT_timerTick]);
-
- getPeerMsgReceiver().receive(
- new EventWithDataMessage(getPeerAddress(), OUT_timerTick, id));"
- }
- }
-
- conjugate PortClass {
- usercode {
- "private int currentId = 0;
- private boolean active = false;"
- }
- handle timerTick {
- "//conjugate PortClass handle timer
- EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
- int id = (Integer)dataMsg.getData();
- if (active && id==currentId) {
- getActor().receiveEvent(this, msg.getEvtId(), null);
- }"
- }
- handle Start {
- "//conjugate PortClass handle start
- if (active)
- return;
-
- active = true;
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[IN_Start]);
-
- getPeerMsgReceiver()
- .receive(
- new EventWithDataMessage(getPeerAddress(),
- IN_Start, new TimerData(time_ms, ++currentId)));"
- }
- handle Kill {
- "//conjugate PortClass kill
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[IN_Kill]);
-
- if (active) {
- active = false;
- getPeerMsgReceiver().receive(
- new EventWithDataMessage(getPeerAddress(), IN_Kill, currentId));
- }"
- }
- }
- }
-
- ProtocolClass PTimeout {
- usercode1 {
- "import java.util.TimerTask;"
- }
- usercode2 {
- "static protected class FireTimeoutTask extends TimerTask {
-
- private int time;
- private int id;
- private PTimeoutPort port;
-
- public FireTimeoutTask(int time, int id, PTimeoutPort port) {
- this.time = time;
- this.id = id;
- this.port = port;
- }
-
- @Override
- public void run() {
- port.timeout(id);
- }
-
- public int getTime() {
- return time;
- }
-
- public int getId() {
- return id;
- }
- }
-
- static protected class TimeoutData {
- int time;
- int id;
- public TimeoutData(int time, int id) {
- this.time = time;
- this.id = id;
- }
- }"
- }
- incoming {
- Message Start (time_ms : int32)
- Message Kill ()
- }
- outgoing {
- Message timeoutTick ()
- }
- regular PortClass {
- usercode {
- "private FireTimeoutTask task = null;
-
- public TimerTask getTask() { return task; }"
- }
- handle Start {
- "//regular PortClass handle start
- EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
- TimeoutData td = (TimeoutData)dataMsg.getData();
- task = new FireTimeoutTask(td.time, td.id, this);
- getActor().receiveEvent(this, IN_Start, td.time);"
- }
- handle Kill {
- "//regular PortClass handle kill
- EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
- int id = (Integer)dataMsg.getData();
- if (task!=null && task.getId()==id) {
- task.cancel();
- }"
- }
- Operation timeout(id: Integer) {
- "//regular PortClass Operation timeout
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[OUT_timeoutTick]);
-
- getPeerMsgReceiver().receive(
- new EventWithDataMessage(getPeerAddress(), OUT_timeoutTick, id));"
- }
- }
-
- conjugate PortClass {
- usercode {
- "private int currentId = 0;
- private boolean active = false;"
- }
- handle timeoutTick {
- "//conjugate PortClass handle timeout
- EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
- int id = (Integer)dataMsg.getData();
- if (active && id==currentId) {
- active = false;
- getActor().receiveEvent(this, msg.getEvtId(), null);
- }"
- }
- handle Start {
- "//conjugate PortClass handle start
- if (active)
- return;
-
- active = true;
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[IN_Start]);
-
- getPeerMsgReceiver()
- .receive(
- new EventWithDataMessage(getPeerAddress(),
- IN_Start, new TimeoutData(time_ms, ++currentId)));"
- }
- handle Kill {
- "//conjugate PortClass kill
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
- getPeerAddress(), messageStrings[IN_Kill]);
-
- if (active) {
- active = false;
- getPeerMsgReceiver().receive(
- new EventWithDataMessage(getPeerAddress(), IN_Kill, new Integer(currentId)));
- }"
- }
- }
+ ProtocolClass PTimer {
+ usercode1 {
+ "import java.util.TimerTask;"
+ }
+ usercode2 {
+ "static protected class FireTimeoutTask extends TimerTask {
+
+ private int time;
+ private int id;
+ private PTimerPort port;
+
+ public FireTimeoutTask(int time, int id, PTimerPort port) {
+ this.time = time;
+ this.id = id;
+ this.port = port;
+ }
+
+ @Override
+ public void run() {
+ TimerData td = new TimerData(0,id);
+ port.internalTimeout(td);
+ }
+
+ public int getTime() {
+ return time;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
+ "
+ }
+ incoming {
+ Message Kill()
+ private Message internalStart(td: TimerData)
+ }
+ outgoing {
+ Message timerTick()
+ private Message internalTimeout(td: TimerData)
+ }
+ regular PortClass
+ {
+ usercode {
+ "private FireTimeoutTask task = null;
+
+ public TimerTask getTask() { return task; }"
+ }
+ handle internalStart {
+ "
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimerData td = (TimerData)dataMsg.getData();
+ task = new FireTimeoutTask(td.time, td.id, this);
+ getActor().receiveEvent(this, IN_internalStart, td);"
+ }
+ handle Kill {
+ "//regular PortClass handle kill
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimerData td = (TimerData)dataMsg.getData();
+ if (task!=null && task.getId()==td.getId()) {
+ task.cancel();
+ }"
+ }
+ }
+ conjugate PortClass
+ {
+ usercode {
+ "private int currentId = 0;
+ private boolean active = false;"
+ }
+ handle internalTimeout {
+ "//conjugate PortClass handle timeout
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimerData td = (TimerData) dataMsg.getData();
+ if (active && td.getId()==currentId) {
+ getActor().receiveEvent(this, OUT_timerTick, null);
+ }"
+ }
+ handle Kill {
+ "//conjugate PortClass kill
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Kill]);
+
+ if (active) {
+ active = false;
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), IN_Kill, currentId));
+ }"
+ }
+ Operation Start(time_ms: int32) sends internalStart {
+ "
+ if (active) return;
+ active = true;
+
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStart]);
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStart, new TimerData(time_ms,++currentId)));
+ "
+ }
+ }
+ }
+
+ ProtocolClass PTimeout {
+ usercode1 {
+ "import java.util.TimerTask;"
+ }
+ usercode2 {
+ "static protected class FireTimeoutTask extends TimerTask {
+
+ private int time;
+ private int id;
+ private PTimeoutPort port;
+
+ public FireTimeoutTask(int time, int id, PTimeoutPort port) {
+ this.time = time;
+ this.id = id;
+ this.port = port;
+ }
+
+ @Override
+ public void run() {
+ TimerData td = new TimerData(0,id);
+ port.internalTimeout(td);
+ }
+
+ public int getTime() {
+ return time;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
+ "
+ }
+ incoming {
+ Message Kill()
+ private Message internalStart(td: TimerData)
+ }
+ outgoing {
+ Message timeoutTick()
+ private Message internalTimeout(td: TimerData)
+ }
+ regular PortClass
+ {
+ usercode {
+ "private FireTimeoutTask task = null;
+
+ public TimerTask getTask() { return task; }"
+ }
+ handle internalStart {
+ "
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimerData td = (TimerData)dataMsg.getData();
+ task = new FireTimeoutTask(td.time, td.id, this);
+ getActor().receiveEvent(this, IN_internalStart, td);"
+ }
+ handle Kill {
+ "//regular PortClass handle kill
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimerData td = (TimerData)dataMsg.getData();
+ if (task!=null && task.getId()==td.getId()) {
+ task.cancel();
+ }"
+ }
+ }
+ conjugate PortClass
+ {
+ usercode {
+ "private int currentId = 0;
+ private boolean active = false;"
+ }
+ handle internalTimeout {
+ "//conjugate PortClass handle timeout
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimerData td = (TimerData) dataMsg.getData();
+ if (active && td.getId()==currentId) {
+ active = false;
+ getActor().receiveEvent(this, OUT_timeoutTick, null);
+ }"
+ }
+ handle Kill {
+ "//conjugate PortClass kill
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Kill]);
+
+ if (active) {
+ active = false;
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), IN_Kill, currentId));
+ }"
+ }
+ Operation Start(time_ms: int32) sends internalStart {
+ "
+ if (active) return;
+ active = true;
+
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStart]);
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStart, new TimerData(time_ms,++currentId)));
+ "
+ }
+ }
}
+ DataClass TimerData {
+ Attribute time: int32
+ Attribute id: int32
+ }
} \ No newline at end of file