Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-02-20 12:27:58 +0000
committerHenrik Rentz-Reichert2012-02-20 12:27:58 +0000
commit0e65f36df8f6230800ab0792f5adcf2350d63c1e (patch)
tree1cab7e5d8abdf02d05bbeba4f972ee4c91049c8d /examples
parentd82e1feb93f21c82cf720da990a44619eb6222e2 (diff)
downloadorg.eclipse.etrice-0e65f36df8f6230800ab0792f5adcf2350d63c1e.tar.gz
org.eclipse.etrice-0e65f36df8f6230800ab0792f5adcf2350d63c1e.tar.xz
org.eclipse.etrice-0e65f36df8f6230800ab0792f5adcf2350d63c1e.zip
[tutorials] re-generated
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/Blinky.java265
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyControlProtocoll.java53
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyController.java169
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyTop.java2
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/HelloWorldTop.java99
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/Controller.java321
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/GuiAdapter.java173
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedControlProtocol.java65
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedLightsTop.java2
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PingPong/MrPingActor.java240
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PingPong/MrPongActor1.java202
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PingPong/PingPongProtocol.java213
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PingPong/PingPongTop.java66
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PingPong/SubSystem_PingPong.java155
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PingPong/SubSystem_PingPongRunner.java36
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/DemoData.java46
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPing.java213
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPong.java143
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/PingPongProtocol.java83
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingDataTop.java2
20 files changed, 760 insertions, 1788 deletions
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/Blinky.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/Blinky.java
index 7e27cd585..8e8b32723 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/Blinky.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/Blinky.java
@@ -14,17 +14,17 @@ import Blinky.BlinkyControlProtocoll.*;
import room.basic.service.timing.PTimeout.*;
//--------------------- begin user code
- import org.eclipse.etrice.tutorials.PedLightGUI.*;
- //--------------------- end user code
+ import org.eclipse.etrice.tutorials.PedLightGUI.*;
+//--------------------- end user code
public class Blinky extends ActorClassBase {
//--------------------- begin user code
- private PedestrianLightWndNoTcp light = new PedestrianLightWndNoTcp();
- private TrafficLight3 carLights;
- private TrafficLight2 pedLights;
- //--------------------- end user code
+ private PedestrianLightWndNoTcp light = new PedestrianLightWndNoTcp();
+ private TrafficLight3 carLights;
+ private TrafficLight2 pedLights;
+ //--------------------- end user code
//--------------------- ports
protected BlinkyControlProtocollPort ControlPort = null;
@@ -33,13 +33,13 @@ public class Blinky extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_ControlPort = 1;
- protected static final int IFITEM_timer = 2;
-
+ public static final int IFITEM_ControlPort = 1;
+ public static final int IFITEM_timer = 2;
+
//--------------------- attributes
//--------------------- operations
- public void destroyUser (){
- light.closeWindow();
+ public void destroyUser() {
+ light.closeWindow();
}
//--------------------- construction
@@ -74,120 +74,64 @@ public class Blinky extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_off = 2;
- protected static final int STATE_blinking = 3;
- protected static final int STATE_blinking_on = 4;
- protected static final int STATE_blinking_off = 5;
- protected static final String stateStrings[] = {"<no state>","<top>","off",
- "blinking",
- "blinking_on",
- "blinking_off"
- };
+ /* state IDs */
+ public static final int STATE_off = 2;
+ public static final int STATE_blinking_on = 3;
+ public static final int STATE_blinking_off = 4;
+ public static final int STATE_blinking = 5;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__off = 1;
+ public static final int CHAIN_TRANS_blinking_TO_off_BY_stopControlPort = 2;
+ public static final int CHAIN_TRANS_off_TO_blinking_tp0_BY_startControlPort = 3;
+ public static final int CHAIN_blinking_TRANS_INITIAL_TO__on = 4;
+ public static final int CHAIN_blinking_TRANS_off_TO_on_BY_timeoutTicktimer = 5;
+ public static final int CHAIN_blinking_TRANS_on_TO_off_BY_timeoutTicktimer = 6;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__off = 1;
- protected static final int CHAIN_TRANS_blinking_TO_off_BY_stopControlPort = 2;
- protected static final int CHAIN_TRANS_off_TO_blinking_tp0_BY_startControlPort = 3;
- protected static final int CHAIN_blinking_TRANS_INITIAL_TO__on = 4;
- protected static final int CHAIN_blinking_TRANS_off_TO_on_BY_timeoutTicktimer = 5;
- protected static final int CHAIN_blinking_TRANS_on_TO_off_BY_timeoutTicktimer = 6;
+ /* triggers */
+ public static final int TRIG_ControlPort__start = IFITEM_ControlPort + EVT_SHIFT*BlinkyControlProtocoll.IN_start;
+ public static final int TRIG_ControlPort__stop = IFITEM_ControlPort + EVT_SHIFT*BlinkyControlProtocoll.IN_stop;
+ public static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
- // triggers for FSM
- protected static final int TRIG_ControlPort__start = IFITEM_ControlPort + EVT_SHIFT*BlinkyControlProtocoll.IN_start;
- protected static final int TRIG_ControlPort__stop = IFITEM_ControlPort + EVT_SHIFT*BlinkyControlProtocoll.IN_stop;
- protected static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","off",
+ "blinking_on",
+ "blinking_off",
+ "blinking"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_off:
- switch(trigger) {
- case TRIG_ControlPort__start:
- {
- chain = CHAIN_TRANS_off_TO_blinking_tp0_BY_startControlPort;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_blinking_on:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_blinking_TRANS_on_TO_off_BY_timeoutTicktimer;
- catching_state = STATE_blinking;
- }
- break;
- case TRIG_ControlPort__stop:
- {
- chain = CHAIN_TRANS_blinking_TO_off_BY_stopControlPort;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_blinking_off:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_blinking_TRANS_off_TO_on_BY_timeoutTicktimer;
- catching_state = STATE_blinking;
- }
- break;
- case TRIG_ControlPort__stop:
- {
- chain = CHAIN_TRANS_blinking_TO_off_BY_stopControlPort;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__off;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+ protected void entry_blinking_on() {
+ timer.Start(1000);
+ carLights.setState(TrafficLight3.YELLOW);
+ }
+ protected void entry_blinking_off() {
+ timer.Start(1000);
+ carLights.setState(TrafficLight3.OFF);
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__off() {
+ carLights = light.getCarLights();
+ pedLights = light.getPedLights();
+ carLights.setState(TrafficLight3.OFF);
+ pedLights.setState(TrafficLight2.OFF);
+ }
+ protected void action_TRANS_blinking_TO_off_BY_stopControlPort(InterfaceItemBase ifitem) {
+ timer.Kill();
+ carLights.setState(TrafficLight3.OFF);
}
/**
@@ -201,24 +145,25 @@ public class Blinky extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_off:
- history[STATE_TOP] = STATE_off;
+ this.history[STATE_TOP] = STATE_off;
current = STATE_TOP;
break;
case STATE_blinking:
- history[STATE_TOP] = STATE_blinking;
+ this.history[STATE_TOP] = STATE_blinking;
current = STATE_TOP;
break;
case STATE_blinking_on:
- history[STATE_blinking] = STATE_blinking_on;
+ this.history[STATE_blinking] = STATE_blinking_on;
current = STATE_blinking;
break;
case STATE_blinking_off:
- history[STATE_blinking] = STATE_blinking_off;
+ this.history[STATE_blinking] = STATE_blinking_off;
current = STATE_blinking;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -257,6 +202,7 @@ public class Blinky extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -272,11 +218,11 @@ public class Blinky extends ActorClassBase {
case STATE_blinking:
// state has a sub graph
// with init transition
- if (history[STATE_blinking]==NO_STATE) {
+ if (this.history[STATE_blinking]==NO_STATE) {
state = executeTransitionChain(CHAIN_blinking_TRANS_INITIAL_TO__on, null, null);
}
else {
- state = history[STATE_blinking];
+ state = this.history[STATE_blinking];
}
break;
case STATE_blinking_on:
@@ -288,7 +234,7 @@ public class Blinky extends ActorClassBase {
// in leaf state: return state id
return STATE_blinking_off;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -296,26 +242,73 @@ public class Blinky extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
- protected void entry_blinking_on() {
- timer.Start(1000);
- carLights.setState(TrafficLight3.YELLOW);
- }
- protected void entry_blinking_off() {
- timer.Start(1000);
- carLights.setState(TrafficLight3.OFF);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__off;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__off() {
- carLights = light.getCarLights();
- pedLights = light.getPedLights();
- carLights.setState(TrafficLight3.OFF);
- pedLights.setState(TrafficLight2.OFF);
- }
- protected void action_TRANS_blinking_TO_off_BY_stopControlPort(InterfaceItemBase ifitem) {
- timer.Kill();
- carLights.setState(TrafficLight3.OFF);
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_off:
+ switch(trigger) {
+ case TRIG_ControlPort__start:
+ {
+ chain = CHAIN_TRANS_off_TO_blinking_tp0_BY_startControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_blinking_on:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_blinking_TRANS_on_TO_off_BY_timeoutTicktimer;
+ catching_state = STATE_blinking;
+ }
+ break;
+ case TRIG_ControlPort__stop:
+ {
+ chain = CHAIN_TRANS_blinking_TO_off_BY_stopControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_blinking_off:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_blinking_TRANS_off_TO_on_BY_timeoutTicktimer;
+ catching_state = STATE_blinking;
+ }
+ break;
+ case TRIG_ControlPort__stop:
+ {
+ chain = CHAIN_TRANS_blinking_TO_off_BY_stopControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyControlProtocoll.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyControlProtocoll.java
index 8696ffde7..9b02e033b 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyControlProtocoll.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyControlProtocoll.java
@@ -11,21 +11,16 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class BlinkyControlProtocoll {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
- //IDs for incoming messages
+ public static final int MSG_MIN = 0;
public static final int IN_start = 1;
public static final int IN_stop = 2;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 3;
+ public static final int MSG_MAX = 3;
private static String messageStrings[] = {"MIN", "start","stop","MAX"};
public String getMessageString(int msg_id) {
- if (msg_id<0 || msg_id>MSG_MAX+1){
+ if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){
// id out of range
return "Message ID out of range";
}
@@ -56,7 +51,6 @@ public class BlinkyControlProtocoll {
System.out.println("unknown");
else {
if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
}
if (msg instanceof EventWithDataMessage)
@@ -100,14 +94,6 @@ public class BlinkyControlProtocoll {
// outgoing messages
}
- // interface for port class
- public interface IBlinkyControlProtocollPort{
- // incoming messages
- public void start ()
- ;
- public void stop ()
- ;
- }
// port class
static public class BlinkyControlProtocollConjPort extends PortBase {
@@ -130,7 +116,6 @@ public class BlinkyControlProtocoll {
System.out.println("unknown");
else {
if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
}
if (msg instanceof EventWithDataMessage)
@@ -142,24 +127,20 @@ public class BlinkyControlProtocoll {
// sent messages
- public void start ()
- {
+ public void start() {
if (messageStrings[ IN_start] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_start]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_start));
- }
- public void stop ()
- {
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_start));
+ }
+ public void stop() {
if (messageStrings[ IN_stop] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_stop]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_stop));
- }
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_stop));
+ }
}
// replicated port class
@@ -190,24 +171,16 @@ public class BlinkyControlProtocoll {
}
// incoming messages
- public void start ()
- {
+ public void start(){
for (int i=0; i<replication; ++i) {
- ports.get(i).start()
- ;
+ ports.get(i).start();
}
}
- public void stop ()
- {
+ public void stop(){
for (int i=0; i<replication; ++i) {
- ports.get(i).stop()
- ;
+ ports.get(i).stop();
}
}
}
- // interface for port class
- public interface IBlinkyControlProtocollConjPort{
- // outgoing messages
- }
}
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyController.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyController.java
index dffe3c354..6feeda89b 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyController.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyController.java
@@ -25,9 +25,9 @@ public class BlinkyController extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_ControlPort = 1;
- protected static final int IFITEM_timer = 2;
-
+ public static final int IFITEM_ControlPort = 1;
+ public static final int IFITEM_timer = 2;
+
//--------------------- attributes
//--------------------- operations
@@ -63,89 +63,49 @@ public class BlinkyController extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_on = 2;
- protected static final int STATE_off = 3;
- protected static final String stateStrings[] = {"<no state>","<top>","on",
- "off"
- };
+ /* state IDs */
+ public static final int STATE_on = 2;
+ public static final int STATE_off = 3;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__on = 1;
+ public static final int CHAIN_TRANS_off_TO_on_BY_timeoutTicktimer = 2;
+ public static final int CHAIN_TRANS_on_TO_off_BY_timeoutTicktimer = 3;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__on = 1;
- protected static final int CHAIN_TRANS_off_TO_on_BY_timeoutTicktimer = 2;
- protected static final int CHAIN_TRANS_on_TO_off_BY_timeoutTicktimer = 3;
+ /* triggers */
+ public static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
- // triggers for FSM
- protected static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","on",
+ "off"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_on:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_on_TO_off_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_off:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_off_TO_on_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__on;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__on() {
+ timer.Start(5000);
+ ControlPort.start();
+ }
+ protected void action_TRANS_on_TO_off_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ ControlPort.stop();
+ timer.Start(5000);
+ }
+ protected void action_TRANS_off_TO_on_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ ControlPort.start();
+ timer.Start(5000);
}
/**
@@ -159,16 +119,17 @@ public class BlinkyController extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_on:
- history[STATE_TOP] = STATE_on;
+ this.history[STATE_TOP] = STATE_on;
current = STATE_TOP;
break;
case STATE_off:
- history[STATE_TOP] = STATE_off;
+ this.history[STATE_TOP] = STATE_off;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -196,6 +157,7 @@ public class BlinkyController extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -212,7 +174,7 @@ public class BlinkyController extends ActorClassBase {
// in leaf state: return state id
return STATE_off;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -220,20 +182,51 @@ public class BlinkyController extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__on() {
- timer.Start(5000);
- ControlPort.start();
- }
- protected void action_TRANS_on_TO_off_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- ControlPort.stop();
- timer.Start(5000);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__on;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_off_TO_on_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- ControlPort.start();
- timer.Start(5000);
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_on:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_on_TO_off_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_off:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_off_TO_on_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyTop.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyTop.java
index 387367025..79fe1a02c 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyTop.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyTop.java
@@ -20,7 +20,7 @@ public class BlinkyTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/HelloWorldTop.java b/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/HelloWorldTop.java
index 51cc093ce..5e4f6bee6 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/HelloWorldTop.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/HelloWorldTop.java
@@ -20,7 +20,7 @@ public class HelloWorldTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
@@ -54,66 +54,35 @@ public class HelloWorldTop extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_state0 = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","state0"
- };
+ /* state IDs */
+ public static final int STATE_state0 = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__state0 = 1;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__state0 = 1;
+ /* triggers */
- // triggers for FSM
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","state0"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_state0:
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__state0;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__state0() {
+ System.out.println("HelloWorld !");
}
/**
@@ -127,12 +96,13 @@ public class HelloWorldTop extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_state0:
- history[STATE_TOP] = STATE_state0;
+ this.history[STATE_TOP] = STATE_state0;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -150,6 +120,7 @@ public class HelloWorldTop extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -163,7 +134,7 @@ public class HelloWorldTop extends ActorClassBase {
// in leaf state: return state id
return STATE_state0;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -171,11 +142,33 @@ public class HelloWorldTop extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__state0;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__state0() {
- System.out.println("HelloWorld !");
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_state0:
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/Controller.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/Controller.java
index 3037c7a26..558634e59 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/Controller.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/Controller.java
@@ -14,8 +14,8 @@ import room.basic.service.timing.PTimeout.*;
import PedLightsController.PedControlProtocol.*;
//--------------------- begin user code
- import org.eclipse.etrice.tutorials.PedLightGUI.*;
- //--------------------- end user code
+ import org.eclipse.etrice.tutorials.PedLightGUI.*;
+//--------------------- end user code
public class Controller extends ActorClassBase {
@@ -28,9 +28,9 @@ public class Controller extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_ControlPort = 1;
- protected static final int IFITEM_timer = 2;
-
+ public static final int IFITEM_ControlPort = 1;
+ public static final int IFITEM_timer = 2;
+
//--------------------- attributes
//--------------------- operations
@@ -66,142 +66,79 @@ public class Controller extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_off = 2;
- protected static final int STATE_carsGreen = 3;
- protected static final int STATE_carsYellow = 4;
- protected static final int STATE_carsRed = 5;
- protected static final int STATE_carsYellowRed = 6;
- protected static final int STATE_carsGreen2 = 7;
- protected static final String stateStrings[] = {"<no state>","<top>","off",
- "carsGreen",
- "carsYellow",
- "carsRed",
- "carsYellowRed",
- "carsGreen2"
- };
+ /* state IDs */
+ public static final int STATE_off = 2;
+ public static final int STATE_carsGreen = 3;
+ public static final int STATE_carsYellow = 4;
+ public static final int STATE_carsRed = 5;
+ public static final int STATE_carsYellowRed = 6;
+ public static final int STATE_carsGreen2 = 7;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__off = 1;
+ public static final int CHAIN_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer = 2;
+ public static final int CHAIN_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer = 3;
+ public static final int CHAIN_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer = 4;
+ public static final int CHAIN_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer = 5;
+ public static final int CHAIN_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer = 6;
+ public static final int CHAIN_TRANS_off_TO_carsGreen_BY_startControlPort = 7;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__off = 1;
- protected static final int CHAIN_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer = 2;
- protected static final int CHAIN_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer = 3;
- protected static final int CHAIN_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer = 4;
- protected static final int CHAIN_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer = 5;
- protected static final int CHAIN_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer = 6;
- protected static final int CHAIN_TRANS_off_TO_carsGreen_BY_startControlPort = 7;
+ /* triggers */
+ public static final int TRIG_ControlPort__start = IFITEM_ControlPort + EVT_SHIFT*PedControlProtocol.IN_start;
+ public static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
- // triggers for FSM
- protected static final int TRIG_ControlPort__start = IFITEM_ControlPort + EVT_SHIFT*PedControlProtocol.IN_start;
- protected static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","off",
+ "carsGreen",
+ "carsYellow",
+ "carsRed",
+ "carsYellowRed",
+ "carsGreen2"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_off:
- switch(trigger) {
- case TRIG_ControlPort__start:
- {
- chain = CHAIN_TRANS_off_TO_carsGreen_BY_startControlPort;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_carsGreen:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_carsYellow:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_carsRed:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_carsYellowRed:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_carsGreen2:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__off;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_off_TO_carsGreen_BY_startControlPort(InterfaceItemBase ifitem) {
+ timer.Start(700);
+ ControlPort.setCarLights(TrafficLight3.GREEN);
+ ControlPort.setPedLights(TrafficLight2.RED);
+ }
+ protected void action_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ timer.Start(700);
+ ControlPort.setCarLights(TrafficLight3.YELLOW);
+ ControlPort.setPedLights(TrafficLight2.RED);
+ }
+ protected void action_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ timer.Start(1500);
+ ControlPort.setCarLights(TrafficLight3.RED);
+ ControlPort.setPedLights(TrafficLight2.GREEN);
+ }
+ protected void action_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ timer.Start(700);
+ ControlPort.setCarLights(TrafficLight3.YELLOW_RED);
+ ControlPort.setPedLights(TrafficLight2.RED);
+ }
+ protected void action_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ timer.Start(700);
+ ControlPort.setCarLights(TrafficLight3.GREEN);
+ ControlPort.setPedLights(TrafficLight2.RED);
+ }
+ protected void action_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ ControlPort.setCarLights(TrafficLight3.OFF);
+ ControlPort.setPedLights(TrafficLight2.OFF);
}
/**
@@ -215,32 +152,33 @@ public class Controller extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_off:
- history[STATE_TOP] = STATE_off;
+ this.history[STATE_TOP] = STATE_off;
current = STATE_TOP;
break;
case STATE_carsGreen:
- history[STATE_TOP] = STATE_carsGreen;
+ this.history[STATE_TOP] = STATE_carsGreen;
current = STATE_TOP;
break;
case STATE_carsYellow:
- history[STATE_TOP] = STATE_carsYellow;
+ this.history[STATE_TOP] = STATE_carsYellow;
current = STATE_TOP;
break;
case STATE_carsRed:
- history[STATE_TOP] = STATE_carsRed;
+ this.history[STATE_TOP] = STATE_carsRed;
current = STATE_TOP;
break;
case STATE_carsYellowRed:
- history[STATE_TOP] = STATE_carsYellowRed;
+ this.history[STATE_TOP] = STATE_carsYellowRed;
current = STATE_TOP;
break;
case STATE_carsGreen2:
- history[STATE_TOP] = STATE_carsGreen2;
+ this.history[STATE_TOP] = STATE_carsGreen2;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -287,6 +225,7 @@ public class Controller extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -315,7 +254,7 @@ public class Controller extends ActorClassBase {
// in leaf state: return state id
return STATE_carsGreen2;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -323,37 +262,91 @@ public class Controller extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_off_TO_carsGreen_BY_startControlPort(InterfaceItemBase ifitem) {
- timer.Start(700);
- ControlPort.setCarLights(TrafficLight3.GREEN);
- ControlPort.setPedLights(TrafficLight2.RED);
- }
- protected void action_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- timer.Start(700);
- ControlPort.setCarLights(TrafficLight3.YELLOW);
- ControlPort.setPedLights(TrafficLight2.RED);
- }
- protected void action_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- timer.Start(1500);
- ControlPort.setCarLights(TrafficLight3.RED);
- ControlPort.setPedLights(TrafficLight2.GREEN);
- }
- protected void action_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- timer.Start(700);
- ControlPort.setCarLights(TrafficLight3.YELLOW_RED);
- ControlPort.setPedLights(TrafficLight2.RED);
- }
- protected void action_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- timer.Start(700);
- ControlPort.setCarLights(TrafficLight3.GREEN);
- ControlPort.setPedLights(TrafficLight2.RED);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__off;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- ControlPort.setCarLights(TrafficLight3.OFF);
- ControlPort.setPedLights(TrafficLight2.OFF);
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_off:
+ switch(trigger) {
+ case TRIG_ControlPort__start:
+ {
+ chain = CHAIN_TRANS_off_TO_carsGreen_BY_startControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsGreen:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsYellow:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsRed:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsYellowRed:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsGreen2:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/GuiAdapter.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/GuiAdapter.java
index 013f10642..dbff0f9fc 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/GuiAdapter.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/GuiAdapter.java
@@ -12,17 +12,17 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
import PedLightsController.PedControlProtocol.*;
//--------------------- begin user code
- import org.eclipse.etrice.tutorials.PedLightGUI.*;
- //--------------------- end user code
+ import org.eclipse.etrice.tutorials.PedLightGUI.*;
+//--------------------- end user code
public class GuiAdapter extends ActorClassBase {
//--------------------- begin user code
- private PedestrianLightWndNoTcp lights = new PedestrianLightWndNoTcp("Pedestrian Lights"," external port connection ");
- private TrafficLight3 carLights;
- private TrafficLight2 pedLights;
- //--------------------- end user code
+ private PedestrianLightWndNoTcp lights = new PedestrianLightWndNoTcp("Pedestrian Lights"," external port connection ");
+ private TrafficLight3 carLights;
+ private TrafficLight2 pedLights;
+ //--------------------- end user code
//--------------------- ports
protected PedControlProtocolConjPort ControlPort = null;
@@ -30,12 +30,12 @@ public class GuiAdapter extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_ControlPort = 1;
-
+ public static final int IFITEM_ControlPort = 1;
+
//--------------------- attributes
//--------------------- operations
- public void destroyUser (){
- lights.closeWindow();
+ public void destroyUser() {
+ lights.closeWindow();
}
//--------------------- construction
@@ -69,84 +69,49 @@ public class GuiAdapter extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_running = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","running"
- };
+ /* state IDs */
+ public static final int STATE_running = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__running = 1;
+ public static final int CHAIN_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0 = 2;
+ public static final int CHAIN_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1 = 3;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__running = 1;
- protected static final int CHAIN_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0 = 2;
- protected static final int CHAIN_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1 = 3;
+ /* triggers */
+ public static final int TRIG_ControlPort__setCarLights = IFITEM_ControlPort + EVT_SHIFT*PedControlProtocol.OUT_setCarLights;
+ public static final int TRIG_ControlPort__setPedLights = IFITEM_ControlPort + EVT_SHIFT*PedControlProtocol.OUT_setPedLights;
- // triggers for FSM
- protected static final int TRIG_ControlPort__setCarLights = IFITEM_ControlPort + EVT_SHIFT*PedControlProtocol.OUT_setCarLights;
- protected static final int TRIG_ControlPort__setPedLights = IFITEM_ControlPort + EVT_SHIFT*PedControlProtocol.OUT_setPedLights;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","running"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_running:
- switch(trigger) {
- case TRIG_ControlPort__setCarLights:
- {
- chain = CHAIN_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_ControlPort__setPedLights:
- {
- chain = CHAIN_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__running;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__running() {
+ carLights=lights.getCarLights();
+ pedLights=lights.getPedLights();
+ carLights.setState(TrafficLight3.OFF);
+ pedLights.setState(TrafficLight2.OFF);
+ lights.setPort(ControlPort);
+ }
+ protected void action_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0(InterfaceItemBase ifitem, int state) {
+ carLights.setState(state);
+ }
+ protected void action_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1(InterfaceItemBase ifitem, int state) {
+ pedLights.setState(state);
}
/**
@@ -160,12 +125,13 @@ public class GuiAdapter extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_running:
- history[STATE_TOP] = STATE_running;
+ this.history[STATE_TOP] = STATE_running;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -195,6 +161,7 @@ public class GuiAdapter extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -208,7 +175,7 @@ public class GuiAdapter extends ActorClassBase {
// in leaf state: return state id
return STATE_running;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -216,21 +183,47 @@ public class GuiAdapter extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__running() {
- carLights=lights.getCarLights();
- pedLights=lights.getPedLights();
- carLights.setState(TrafficLight3.OFF);
- pedLights.setState(TrafficLight2.OFF);
- lights.setPort(ControlPort);
- }
- protected void action_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0(InterfaceItemBase ifitem, int state) {
- carLights.setState(state);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__running;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1(InterfaceItemBase ifitem, int state) {
- pedLights.setState(state);
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_running:
+ switch(trigger) {
+ case TRIG_ControlPort__setCarLights:
+ {
+ chain = CHAIN_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_ControlPort__setPedLights:
+ {
+ chain = CHAIN_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedControlProtocol.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedControlProtocol.java
index 4b4ef56a6..4602341e3 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedControlProtocol.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedControlProtocol.java
@@ -11,22 +11,17 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class PedControlProtocol {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
+ public static final int MSG_MIN = 0;
public static final int OUT_setCarLights = 1;
public static final int OUT_setPedLights = 2;
- //IDs for incoming messages
public static final int IN_start = 3;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 4;
+ public static final int MSG_MAX = 4;
private static String messageStrings[] = {"MIN", "setCarLights","setPedLights", "start","MAX"};
public String getMessageString(int msg_id) {
- if (msg_id<0 || msg_id>MSG_MAX+1){
+ if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){
// id out of range
return "Message ID out of range";
}
@@ -57,7 +52,6 @@ public class PedControlProtocol {
System.out.println("unknown");
else {
if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
}
if (msg instanceof EventWithDataMessage)
@@ -69,23 +63,19 @@ public class PedControlProtocol {
// sent messages
- public void setCarLights (int state)
- {
+ public void setCarLights(int state) {
if (messageStrings[ OUT_setCarLights] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_setCarLights]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_setCarLights, state));
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_setCarLights, state));
}
- public void setPedLights (int state)
- {
+ public void setPedLights(int state) {
if (messageStrings[ OUT_setPedLights] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_setPedLights]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_setPedLights, state));
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_setPedLights, state));
}
}
@@ -117,28 +107,18 @@ public class PedControlProtocol {
}
// outgoing messages
- public void setCarLights (int state)
- {
+ public void setCarLights(int state){
for (int i=0; i<replication; ++i) {
- ports.get(i).setCarLights( state)
- ;
+ ports.get(i).setCarLights( state);
}
}
- public void setPedLights (int state)
- {
+ public void setPedLights(int state){
for (int i=0; i<replication; ++i) {
- ports.get(i).setPedLights( state)
- ;
+ ports.get(i).setPedLights( state);
}
}
}
- // interface for port class
- public interface IPedControlProtocolPort{
- // incoming messages
- public void start ()
- ;
- }
// port class
static public class PedControlProtocolConjPort extends PortBase {
@@ -161,7 +141,6 @@ public class PedControlProtocol {
System.out.println("unknown");
else {
if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
}
if (msg instanceof EventWithDataMessage)
@@ -173,15 +152,13 @@ public class PedControlProtocol {
// sent messages
- public void start ()
- {
+ public void start() {
if (messageStrings[ IN_start] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_start]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_start));
- }
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_start));
+ }
}
// replicated port class
@@ -212,21 +189,11 @@ public class PedControlProtocol {
}
// incoming messages
- public void start ()
- {
+ public void start(){
for (int i=0; i<replication; ++i) {
- ports.get(i).start()
- ;
+ ports.get(i).start();
}
}
}
- // interface for port class
- public interface IPedControlProtocolConjPort{
- // outgoing messages
- public void setCarLights (int state)
- ;
- public void setPedLights (int state)
- ;
- }
}
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedLightsTop.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedLightsTop.java
index d006790ed..2544472bd 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedLightsTop.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedLightsTop.java
@@ -20,7 +20,7 @@ public class PedLightsTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/MrPingActor.java b/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/MrPingActor.java
deleted file mode 100644
index 492750d3c..000000000
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/MrPingActor.java
+++ /dev/null
@@ -1,240 +0,0 @@
-package PingPong;
-
-import org.eclipse.etrice.runtime.java.messaging.Address;
-import org.eclipse.etrice.runtime.java.messaging.IRTObject;
-import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
-import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
-import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
-
-import room.basic.service.timing.*;
-
-import room.basic.service.timing.PTimeout.*;
-import PingPong.PingPongProtocol.*;
-
-
-
-public class MrPingActor extends ActorClassBase {
-
-
- //--------------------- ports
- protected PingPongProtocolConjPortRepl PingPongPort = null;
- //--------------------- saps
- protected PTimeoutConjPort timer = null;
- //--------------------- services
-
- //--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
- protected static final int IFITEM_timer = 2;
-
- //--------------------- attributes
- //--------------------- operations
-
- //--------------------- construction
- public MrPingActor(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
- super(parent, name, port_addr[0][0], peer_addr[0][0]);
- setClassName("MrPingActor");
-
- // initialize attributes
-
- // own ports
- PingPongPort = new PingPongProtocolConjPortRepl(this, "PingPongPort", IFITEM_PingPongPort, port_addr[IFITEM_PingPongPort], peer_addr[IFITEM_PingPongPort]);
- // own saps
- timer = new PTimeoutConjPort(this, "timer", IFITEM_timer, 0, port_addr[IFITEM_timer][0], peer_addr[IFITEM_timer][0]);
- // own service implementations
- }
-
-
- //--------------------- lifecycle functions
- public void init(){
- initUser();
- }
-
- public void start(){
- startUser();
- }
-
- public void stop(){
- stopUser();
- }
-
- public void destroy(){
- destroyUser();
- }
-
- //******************************************
- // START of generated code for FSM
- //******************************************
-
- // State IDs for FSM
- protected static final int STATE_waitForTimer = 2;
- protected static final int STATE_waitForPong = 3;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForTimer",
- "waitForPong"
- };
-
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
-
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForTimer = 1;
- protected static final int CHAIN_TRANS_waitForPong_TO_waitForTimer_BY_pongPingPongPort = 2;
- protected static final int CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer = 3;
-
- // triggers for FSM
- protected static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
- protected static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
-
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_waitForTimer:
- switch(trigger) {
- case TRIG_timer__timeoutTick:
- {
- chain = CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_waitForPong:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_waitForPong_TO_waitForTimer_BY_pongPingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
-
- private void setState(int new_state) {
- DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
- if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
- System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
- }
- this.state = new_state;
- }
-
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__waitForTimer;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
- }
-
- /**
- * calls exit codes while exiting from the current state to one of its
- * parent states while remembering the history
- * @param current - the current state
- * @param to - the final parent state
- * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
- */
- private void exitTo(int current, int to, boolean handler) {
- while (current!=to) {
- switch (current) {
- case STATE_waitForTimer:
- history[STATE_TOP] = STATE_waitForTimer;
- current = STATE_TOP;
- break;
- case STATE_waitForPong:
- history[STATE_TOP] = STATE_waitForPong;
- current = STATE_TOP;
- break;
- }
- }
- }
- /**
- * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
- * matching the trigger of this chain. The ID of the final state is returned
- * @param chain - the chain ID
- * @param generic_data - the generic data pointer
- * @return the ID of the final state
- */
- private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {
- switch (chain) {
- case CHAIN_TRANS_INITIAL_TO__waitForTimer:
- {
- action_TRANS_INITIAL_TO__waitForTimer();
- return STATE_waitForTimer;
- }
- case CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer:
- {
- action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(ifitem);
- return STATE_waitForPong;
- }
- case CHAIN_TRANS_waitForPong_TO_waitForTimer_BY_pongPingPongPort:
- {
- action_TRANS_waitForPong_TO_waitForTimer_BY_pongPingPongPort(ifitem);
- return STATE_waitForTimer;
- }
- }
- return NO_STATE;
- }
- /**
- * calls entry codes while entering a state's history. The ID of the final leaf state is returned
- * @param state - the state which is entered
- * @param handler - entry code is executed if not handler
- * @return - the ID of the final leaf state
- */
- private int enterHistory(int state, boolean handler, boolean skip_entry) {
- while (true) {
- switch (state) {
- case STATE_waitForTimer:
- // in leaf state: return state id
- return STATE_waitForTimer;
- case STATE_waitForPong:
- // in leaf state: return state id
- return STATE_waitForPong;
- case STATE_TOP:
- state = history[STATE_TOP];
- break;
- }
- skip_entry = false;
- }
- //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
- }
-
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__waitForTimer() {
- timer.Start(1000);
- }
- protected void action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- PingPongPort.ping();
- }
- protected void action_TRANS_waitForPong_TO_waitForTimer_BY_pongPingPongPort(InterfaceItemBase ifitem) {
- timer.Start(1000);
- }
-
- //******************************************
- // END of generated code for FSM
- //******************************************
-};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/MrPongActor1.java b/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/MrPongActor1.java
deleted file mode 100644
index f41be7ee6..000000000
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/MrPongActor1.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package PingPong;
-
-import org.eclipse.etrice.runtime.java.messaging.Address;
-import org.eclipse.etrice.runtime.java.messaging.IRTObject;
-import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
-import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
-import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
-
-
-import PingPong.PingPongProtocol.*;
-
-
-
-public class MrPongActor1 extends ActorClassBase {
-
-
- //--------------------- ports
- protected PingPongProtocolPort PingPongPort = null;
- //--------------------- saps
- //--------------------- services
-
- //--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
- //--------------------- attributes
- //--------------------- operations
-
- //--------------------- construction
- public MrPongActor1(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
- super(parent, name, port_addr[0][0], peer_addr[0][0]);
- setClassName("MrPongActor1");
-
- // initialize attributes
-
- // own ports
- PingPongPort = new PingPongProtocolPort(this, "PingPongPort", IFITEM_PingPongPort, 0, port_addr[IFITEM_PingPongPort][0], peer_addr[IFITEM_PingPongPort][0]);
- // own saps
- // own service implementations
- }
-
-
- //--------------------- lifecycle functions
- public void init(){
- initUser();
- }
-
- public void start(){
- startUser();
- }
-
- public void stop(){
- stopUser();
- }
-
- public void destroy(){
- destroyUser();
- }
-
- //******************************************
- // START of generated code for FSM
- //******************************************
-
- // State IDs for FSM
- protected static final int STATE_waitForPing = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
- };
-
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
-
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForPing = 1;
- protected static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
-
- // triggers for FSM
- protected static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
-
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_waitForPing:
- switch(trigger) {
- case TRIG_PingPongPort__ping:
- {
- chain = CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
-
- private void setState(int new_state) {
- DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
- if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
- System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
- }
- this.state = new_state;
- }
-
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__waitForPing;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
- }
-
- /**
- * calls exit codes while exiting from the current state to one of its
- * parent states while remembering the history
- * @param current - the current state
- * @param to - the final parent state
- * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
- */
- private void exitTo(int current, int to, boolean handler) {
- while (current!=to) {
- switch (current) {
- case STATE_waitForPing:
- history[STATE_TOP] = STATE_waitForPing;
- current = STATE_TOP;
- break;
- }
- }
- }
- /**
- * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
- * matching the trigger of this chain. The ID of the final state is returned
- * @param chain - the chain ID
- * @param generic_data - the generic data pointer
- * @return the ID of the final state
- */
- private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {
- switch (chain) {
- case CHAIN_TRANS_INITIAL_TO__waitForPing:
- {
- return STATE_waitForPing;
- }
- case CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger:
- {
- action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(ifitem);
- return STATE_waitForPing;
- }
- }
- return NO_STATE;
- }
- /**
- * calls entry codes while entering a state's history. The ID of the final leaf state is returned
- * @param state - the state which is entered
- * @param handler - entry code is executed if not handler
- * @return - the ID of the final leaf state
- */
- private int enterHistory(int state, boolean handler, boolean skip_entry) {
- while (true) {
- switch (state) {
- case STATE_waitForPing:
- // in leaf state: return state id
- return STATE_waitForPing;
- case STATE_TOP:
- state = history[STATE_TOP];
- break;
- }
- skip_entry = false;
- }
- //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
- }
-
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
- PingPongPort.pong();
- }
-
- //******************************************
- // END of generated code for FSM
- //******************************************
-};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/PingPongProtocol.java b/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/PingPongProtocol.java
deleted file mode 100644
index 403e0cf11..000000000
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/PingPongProtocol.java
+++ /dev/null
@@ -1,213 +0,0 @@
-package PingPong;
-
-import java.util.ArrayList;
-
-import org.eclipse.etrice.runtime.java.messaging.Address;
-import org.eclipse.etrice.runtime.java.messaging.Message;
-import org.eclipse.etrice.runtime.java.modelbase.*;
-import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
-
-
-
-public class PingPongProtocol {
- // message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
- public static final int OUT_pong = 1;
- //IDs for incoming messages
- public static final int IN_ping = 2;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 3;
-
-
- private static String messageStrings[] = {"MIN", "pong", "ping","MAX"};
-
- public String getMessageString(int msg_id) {
- if (msg_id<0 || msg_id>MSG_MAX+1){
- // id out of range
- return "Message ID out of range";
- }
- else{
- return messageStrings[msg_id];
- }
- }
-
-
- // port class
- static public class PingPongProtocolPort extends PortBase {
- // constructors
- public PingPongProtocolPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
- super(actor, name, localId, 0, addr, peerAddress);
- DebuggingService.getInstance().addPortInstance(this);
- }
- public PingPongProtocolPort(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
- super(actor, name, localId, idx, addr, peerAddress);
- DebuggingService.getInstance().addPortInstance(this);
- }
-
- @Override
- public void receive(Message m) {
- if (!(m instanceof EventMessage))
- return;
- EventMessage msg = (EventMessage) m;
- if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
- System.out.println("unknown");
- else {
- if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
- DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
- }
- if (msg instanceof EventWithDataMessage)
- getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
- else
- getActor().receiveEvent(this, msg.getEvtId(), null);
- }
- }
-
-
- // sent messages
- public void pong ()
- {
- if (messageStrings[ OUT_pong] != "timerTick"){
- // TODOTS: model switch for activation
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_pong]);
- }
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_pong));
- }
- }
-
- // replicated port class
- static public class PingPongProtocolPortRepl {
- private ArrayList<PingPongProtocolPort> ports;
- private int replication;
-
- public PingPongProtocolPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = addr.length;
- ports = new ArrayList<PingPongProtocol.PingPongProtocolPort>(replication);
- for (int i=0; i<replication; ++i) {
- ports.add(new PingPongProtocolPort(
- actor, name+i, localId, i, addr[i], peerAddress[i]));
- }
- }
-
- public int getReplication() {
- return replication;
- }
-
- public int getIndexOf(InterfaceItemBase ifitem){
- return ifitem.getIdx();
- }
-
- public PingPongProtocolPort get(int i) {
- return ports.get(i);
- }
-
- // outgoing messages
- public void pong ()
- {
- for (int i=0; i<replication; ++i) {
- ports.get(i).pong()
- ;
- }
- }
- }
-
- // interface for port class
- public interface IPingPongProtocolPort{
- // incoming messages
- public void ping ()
- ;
- }
-
- // port class
- static public class PingPongProtocolConjPort extends PortBase {
- // constructors
- public PingPongProtocolConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
- super(actor, name, localId, 0, addr, peerAddress);
- DebuggingService.getInstance().addPortInstance(this);
- }
- public PingPongProtocolConjPort(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
- super(actor, name, localId, idx, addr, peerAddress);
- DebuggingService.getInstance().addPortInstance(this);
- }
-
- @Override
- public void receive(Message m) {
- if (!(m instanceof EventMessage))
- return;
- EventMessage msg = (EventMessage) m;
- if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
- System.out.println("unknown");
- else {
- if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
- DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
- }
- if (msg instanceof EventWithDataMessage)
- getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
- else
- getActor().receiveEvent(this, msg.getEvtId(), null);
- }
- }
-
-
- // sent messages
- public void ping ()
- {
- if (messageStrings[ IN_ping] != "timerTick"){
- // TODOTS: model switch for activation
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_ping]);
- }
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_ping));
- }
- }
-
- // replicated port class
- static public class PingPongProtocolConjPortRepl {
- private ArrayList<PingPongProtocolConjPort> ports;
- private int replication;
-
- public PingPongProtocolConjPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = addr.length;
- ports = new ArrayList<PingPongProtocol.PingPongProtocolConjPort>(replication);
- for (int i=0; i<replication; ++i) {
- ports.add(new PingPongProtocolConjPort(
- actor, name+i, localId, i, addr[i], peerAddress[i]));
- }
- }
-
- public int getReplication() {
- return replication;
- }
-
- public int getIndexOf(InterfaceItemBase ifitem){
- return ifitem.getIdx();
- }
-
- public PingPongProtocolConjPort get(int i) {
- return ports.get(i);
- }
-
- // incoming messages
- public void ping ()
- {
- for (int i=0; i<replication; ++i) {
- ports.get(i).ping()
- ;
- }
- }
- }
-
- // interface for port class
- public interface IPingPongProtocolConjPort{
- // outgoing messages
- public void pong ()
- ;
- }
-}
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/PingPongTop.java b/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/PingPongTop.java
deleted file mode 100644
index d1a7ff9d7..000000000
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/PingPongTop.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package PingPong;
-
-import org.eclipse.etrice.runtime.java.messaging.Address;
-import org.eclipse.etrice.runtime.java.messaging.IRTObject;
-import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
-import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
-import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
-
-
-
-
-
-public class PingPongTop extends ActorClassBase {
-
-
- //--------------------- ports
- //--------------------- saps
- //--------------------- services
-
- //--------------------- interface item IDs
-
- //--------------------- attributes
- //--------------------- operations
-
- //--------------------- construction
- public PingPongTop(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
- super(parent, name, port_addr[0][0], peer_addr[0][0]);
- setClassName("PingPongTop");
-
- // initialize attributes
-
- // own ports
- // own saps
- // own service implementations
- }
-
-
- //--------------------- lifecycle functions
- public void init(){
- initUser();
- }
-
- public void start(){
- startUser();
- }
-
- public void stop(){
- stopUser();
- }
-
- public void destroy(){
- destroyUser();
- }
-
- //--------------------- no state machine
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
- handleSystemEvent(ifitem, evt, data);
- }
-
- @Override
- public void executeInitTransition(){
- }
-};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/SubSystem_PingPong.java b/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/SubSystem_PingPong.java
deleted file mode 100644
index 90b53990c..000000000
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/SubSystem_PingPong.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package PingPong;
-
-import org.eclipse.etrice.runtime.java.messaging.MessageService;
-import org.eclipse.etrice.runtime.java.messaging.RTServices;
-import org.eclipse.etrice.runtime.java.messaging.Address;
-import org.eclipse.etrice.runtime.java.messaging.IRTObject;
-import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;
-import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
-
-import room.basic.service.timing.*;
-
-
-
-public class SubSystem_PingPong extends SubSystemClassBase{
-
-
- public SubSystem_PingPong(IRTObject parent, String name) {
- super(parent, name);
- }
-
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){
- }
-
- @Override
- public void instantiateMessageServices(){
-
- RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main"));
- RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 1, 0),"MessageService_mrPingThread", 5));
- RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 2, 0),"MessageService_mrPong1Thread", 5));
- }
-
- @Override
- public void instantiateActors(){
- // all addresses
- // Addresses for the Subsystem Systemport
- Address addr_item_SystemPort_0 = new Address(0,0,110);
- Address addr_item_SystemPort_1 = new Address(0,0,111);
- Address addr_item_SystemPort_2 = new Address(0,0,112);
- Address addr_item_SystemPort_3 = new Address(0,0,113);
-
- // actor instance /SubSystem_PingPong/application itself => Systemport Address
- // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
- Address addr_item__SubSystem_PingPong_application = new Address(0,0,101);
- // interface items of /SubSystem_PingPong/application
- // actor instance /SubSystem_PingPong/application/MrPing itself => Systemport Address
- // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
- Address addr_item__SubSystem_PingPong_application_MrPing = new Address(0,1,102);
- // interface items of /SubSystem_PingPong/application/MrPing
- Address addr_item__SubSystem_PingPong_application_MrPing_PingPongPort = new Address(0,1,103);
- Address addr_item__SubSystem_PingPong_application_MrPing_timer = new Address(0,1,105);
- // actor instance /SubSystem_PingPong/application/MrPong1 itself => Systemport Address
- // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
- Address addr_item__SubSystem_PingPong_application_MrPong1 = new Address(0,2,106);
- // interface items of /SubSystem_PingPong/application/MrPong1
- Address addr_item__SubSystem_PingPong_application_MrPong1_PingPongPort = new Address(0,2,107);
- // actor instance /SubSystem_PingPong/services itself => Systemport Address
- // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
- Address addr_item__SubSystem_PingPong_services = new Address(0,0,108);
- // interface items of /SubSystem_PingPong/services
- Address addr_item__SubSystem_PingPong_services_timeout_0 = new Address(0,0,109);
-
- // instantiate all actor instances
- instances = new ActorClassBase[4];
- instances[0] = new PingPongTop(
- this,
- "application",
- // own interface item addresses
- new Address[][] {{addr_item__SubSystem_PingPong_application}
- },
- // peer interface item addresses
- new Address[][] {{addr_item_SystemPort_0}
- }
- );
- instances[1] = new MrPingActor(
- instances[0],
- "MrPing",
- // own interface item addresses
- new Address[][] {{addr_item__SubSystem_PingPong_application_MrPing},
- {
- addr_item__SubSystem_PingPong_application_MrPing_PingPongPort
- },
- {
- addr_item__SubSystem_PingPong_application_MrPing_timer
- }
- },
- // peer interface item addresses
- new Address[][] {{addr_item_SystemPort_1},
- {
- addr_item__SubSystem_PingPong_application_MrPong1_PingPongPort
- },
- {
- addr_item__SubSystem_PingPong_services_timeout_0
- }
- }
- );
- instances[2] = new MrPongActor1(
- instances[0],
- "MrPong1",
- // own interface item addresses
- new Address[][] {{addr_item__SubSystem_PingPong_application_MrPong1},
- {
- addr_item__SubSystem_PingPong_application_MrPong1_PingPongPort
- }
- },
- // peer interface item addresses
- new Address[][] {{addr_item_SystemPort_2},
- {
- addr_item__SubSystem_PingPong_application_MrPing_PingPongPort
- }
- }
- );
- instances[3] = new ATimingService(
- this,
- "services",
- // own interface item addresses
- new Address[][] {{addr_item__SubSystem_PingPong_services},
- {
- },
- {
- addr_item__SubSystem_PingPong_services_timeout_0
- }
- },
- // peer interface item addresses
- new Address[][] {{addr_item_SystemPort_3},
- {
- },
- {
- addr_item__SubSystem_PingPong_application_MrPing_timer
- }
- }
- );
-
- // create the subsystem system port
- RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort",
- 0, //local ID
- // own addresses
- new Address[]{
- addr_item_SystemPort_0,
- addr_item_SystemPort_1,
- addr_item_SystemPort_2,
- addr_item_SystemPort_3
- },
- // peer addresses
- new Address[]{
- addr_item__SubSystem_PingPong_application,
- addr_item__SubSystem_PingPong_application_MrPing,
- addr_item__SubSystem_PingPong_application_MrPong1,
- addr_item__SubSystem_PingPong_services
- });
-
- }
-};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/SubSystem_PingPongRunner.java b/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/SubSystem_PingPongRunner.java
deleted file mode 100644
index d840fd674..000000000
--- a/examples/org.eclipse.etrice.tutorials/src-gen/PingPong/SubSystem_PingPongRunner.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * @author generated by eTrice
- *
- * this class contains the main function running component SubSystem_PingPong
- * it instantiates SubSystem_PingPong and starts and ends the lifecycle
- */
-
-package PingPong;
-
-import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;
-
-class SubSystem_PingPongRunner extends SubSystemRunnerBase {
-
- static SubSystem_PingPong main_component = new SubSystem_PingPong(null, "SubSystem_PingPong");
-
- /**
- * main function
- * creates component and starts and stops the lifecycle
- */
- public static void main(String[] args) {
-
- System.out.println("*** T H E B E G I N ***");
-
- main_component.init(); // lifecycle init
- main_component.start(); // lifecycle start
-
- // application runs until quit
- waitForQuit();
-
- // end the lifecycle
- main_component.stop(); // lifecycle stop
- main_component.destroy(); // lifecycle destroy
-
- System.out.println("*** T H E E N D ***");
- }
-};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/DemoData.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/DemoData.java
index 89f235d7a..840bdb67e 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/DemoData.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/DemoData.java
@@ -2,46 +2,72 @@ package SendingData;
+
public class DemoData {
+
+
//--------------------- attributes
- protected int int32Val;protected byte[] int8Array = {1,2,3,4,5,6,7,8,9,10};
- protected double float64Val;protected String stringVal;
+ protected int int32Val;
+ protected byte[] int8Array;
+ protected double float64Val;
+ protected String stringVal;
+
//--------------------- attribute setters and getters
public void setInt32Val (int int32Val) {
this.int32Val = int32Val;
}
public int getInt32Val () {
- return int32Val;
- }public void setInt8Array (byte[] int8Array) {
+ return this.int32Val;
+ }
+ public void setInt8Array (byte[] int8Array) {
this.int8Array = int8Array;
}
public byte[] getInt8Array () {
- return int8Array;
- }public void setFloat64Val (double float64Val) {
+ return this.int8Array;
+ }
+ public void setFloat64Val (double float64Val) {
this.float64Val = float64Val;
}
public double getFloat64Val () {
- return float64Val;
- }public void setStringVal (String stringVal) {
+ return this.float64Val;
+ }
+ public void setStringVal (String stringVal) {
this.stringVal = stringVal;
}
public String getStringVal () {
- return stringVal;
+ return this.stringVal;
}
+
//--------------------- operations
// default constructor
public DemoData() {
+ super();
+
+ // initialize attributes
int32Val = 4711;
+ int8Array = new byte[] {1,2,3,4,5,6,7,8,9,10};
float64Val = 0.0;
stringVal = "empty";
}
+ // constructor using fields
+ public DemoData(int int32Val, byte[] int8Array, double float64Val, String stringVal) {
+ super();
+
+ this.int32Val = int32Val;
+ this.int8Array = int8Array;
+ this.float64Val = float64Val;
+ this.stringVal = stringVal;
+ }
+
// deep copy
public DemoData deepCopy() {
DemoData copy = new DemoData();
copy.int32Val = int32Val;
- for (int i=0;i<10;i++){copy.int8Array[i]=int8Array[i];}
+ for (int i=0;i<10;i++){
+ copy.int8Array[i] = int8Array[i];
+ }
copy.float64Val = float64Val;
copy.stringVal = stringVal;
return copy;
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPing.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPing.java
index 0eefcb416..ae333d4f5 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPing.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPing.java
@@ -22,12 +22,12 @@ public class MrPing extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
//--------------------- operations
- public void printData (DemoData d){
- System.out.printf("d.int32Val: %d\n",d.int32Val);
+ public void printData(DemoData d) {
+ System.out.printf("d.int32Val: %d\n",d.int32Val);
System.out.printf("d.float64Val: %f\n",d.float64Val);
System.out.printf("d.int8Array: ");
for(int i = 0; i<d.int8Array.length; i++) {
@@ -66,99 +66,64 @@ public class MrPing extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_waitForPong = 2;
- protected static final int STATE_waitForPongSimple = 3;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForPong",
- "waitForPongSimple"
- };
+ /* state IDs */
+ public static final int STATE_waitForPong = 2;
+ public static final int STATE_waitForPongSimple = 3;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__waitForPongSimple = 1;
+ public static final int CHAIN_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1 = 2;
+ public static final int CHAIN_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort = 3;
+ public static final int CHAIN_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2 = 4;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForPongSimple = 1;
- protected static final int CHAIN_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1 = 2;
- protected static final int CHAIN_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort = 3;
- protected static final int CHAIN_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2 = 4;
+ /* triggers */
+ public static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
+ public static final int TRIG_PingPongPort__pongSimple = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pongSimple;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
- protected static final int TRIG_PingPongPort__pongSimple = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pongSimple;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForPong",
+ "waitForPongSimple"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_waitForPong:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_waitForPongSimple:
- switch(trigger) {
- case TRIG_PingPongPort__pongSimple:
- { int data = (Integer) generic_data;
- if (data < 10
- )
- {
- chain = CHAIN_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1;
- catching_state = STATE_TOP;
- } else
- {
- chain = CHAIN_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort;
- catching_state = STATE_TOP;
- }
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__waitForPongSimple;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2(InterfaceItemBase ifitem, DemoData data) {
+ printData(data);
+ }
+ protected void action_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1(InterfaceItemBase ifitem, int data) {
+ // keep in mind that MrPong increments
+ PingPongPort.pingSimple(data);
+ System.out.printf("data: %d\n",data);
+ }
+ protected void action_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int data) {
+ System.out.printf("data: %d\n",data);
+
+ DemoData d = new DemoData();
+ // send the default values
+ PingPongPort.ping(d);
+ d.int32Val=815;
+ for (int i = 0; i<d.int8Array.length;i++){
+ d.int8Array[i]=(byte)(i+100);
+ }
+ d.stringVal="some contents";
+ d.float64Val=3.141234;
+ PingPongPort.ping(d);
+ }
+ protected void action_TRANS_INITIAL_TO__waitForPongSimple() {
+ PingPongPort.pingSimple(0);
}
/**
@@ -172,16 +137,17 @@ public class MrPing extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForPong:
- history[STATE_TOP] = STATE_waitForPong;
+ this.history[STATE_TOP] = STATE_waitForPong;
current = STATE_TOP;
break;
case STATE_waitForPongSimple:
- history[STATE_TOP] = STATE_waitForPongSimple;
+ this.history[STATE_TOP] = STATE_waitForPongSimple;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -217,6 +183,7 @@ public class MrPing extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -233,7 +200,7 @@ public class MrPing extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPongSimple;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -241,33 +208,59 @@ public class MrPing extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2(InterfaceItemBase ifitem, DemoData data) {
- printData(data);
- }
- protected void action_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1(InterfaceItemBase ifitem, int data) {
- // keep in mind that MrPong increments
- PingPongPort.pingSimple(data);
- System.out.printf("data: %d\n",data);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForPongSimple;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int data) {
- System.out.printf("data: %d\n",data);
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
- DemoData d = new DemoData();
- // send the default values
- PingPongPort.ping(d);
- d.int32Val=815;
- for (int i = 0; i<d.int8Array.length;i++){
- d.int8Array[i]=(byte)(i+100);
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_waitForPong:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_waitForPongSimple:
+ switch(trigger) {
+ case TRIG_PingPongPort__pongSimple:
+ { int data = (Integer) generic_data;
+ if (data < 10
+ )
+ {
+ chain = CHAIN_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1;
+ catching_state = STATE_TOP;
+ } else
+ {
+ chain = CHAIN_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort;
+ catching_state = STATE_TOP;
+ }
+ }
+ break;
+ }
+ break;
}
- d.stringVal="some contents";
- d.float64Val=3.141234;
- PingPongPort.ping(d);
- }
- protected void action_TRANS_INITIAL_TO__waitForPongSimple() {
- PingPongPort.pingSimple(0);
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPong.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPong.java
index f389e72bc..86372deb1 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPong.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPong.java
@@ -22,8 +22,8 @@ public class MrPong extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,84 +58,42 @@ public class MrPong extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_looping = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","looping"
- };
+ /* state IDs */
+ public static final int STATE_looping = 2;
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__looping = 1;
+ public static final int CHAIN_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0 = 2;
+ public static final int CHAIN_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1 = 3;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__looping = 1;
- protected static final int CHAIN_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0 = 2;
- protected static final int CHAIN_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1 = 3;
+ /* triggers */
+ public static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
+ public static final int TRIG_PingPongPort__pingSimple = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_pingSimple;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
- protected static final int TRIG_PingPongPort__pingSimple = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_pingSimple;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","looping"
+ };
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_looping:
- switch(trigger) {
- case TRIG_PingPongPort__ping:
- {
- chain = CHAIN_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pingSimple:
- {
- chain = CHAIN_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
private void setState(int new_state) {
DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
}
this.state = new_state;
}
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__looping;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0(InterfaceItemBase ifitem, DemoData data) {
+ PingPongPort.pong(data);
+ }
+ protected void action_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1(InterfaceItemBase ifitem, int data) {
+ PingPongPort.pongSimple(data+1);
}
/**
@@ -149,12 +107,13 @@ public class MrPong extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_looping:
- history[STATE_TOP] = STATE_looping;
+ this.history[STATE_TOP] = STATE_looping;
current = STATE_TOP;
break;
}
}
}
+
/**
* calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
* matching the trigger of this chain. The ID of the final state is returned
@@ -183,6 +142,7 @@ public class MrPong extends ActorClassBase {
}
return NO_STATE;
}
+
/**
* calls entry codes while entering a state's history. The ID of the final leaf state is returned
* @param state - the state which is entered
@@ -196,7 +156,7 @@ public class MrPong extends ActorClassBase {
// in leaf state: return state id
return STATE_looping;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -204,14 +164,47 @@ public class MrPong extends ActorClassBase {
//return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
}
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0(InterfaceItemBase ifitem, DemoData data) {
- PingPongPort.pong(data);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__looping;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1(InterfaceItemBase ifitem, int data) {
- PingPongPort.pongSimple(data+1);
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_looping:
+ switch(trigger) {
+ case TRIG_PingPongPort__ping:
+ {
+ chain = CHAIN_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pingSimple:
+ {
+ chain = CHAIN_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
}
//******************************************
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/PingPongProtocol.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/PingPongProtocol.java
index cd00ff067..eaa0e80ae 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/PingPongProtocol.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/PingPongProtocol.java
@@ -11,23 +11,18 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class PingPongProtocol {
// message IDs
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
+ public static final int MSG_MIN = 0;
public static final int OUT_pong = 1;
public static final int OUT_pongSimple = 2;
- //IDs for incoming messages
public static final int IN_ping = 3;
public static final int IN_pingSimple = 4;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 5;
+ public static final int MSG_MAX = 5;
private static String messageStrings[] = {"MIN", "pong","pongSimple", "ping","pingSimple","MAX"};
public String getMessageString(int msg_id) {
- if (msg_id<0 || msg_id>MSG_MAX+1){
+ if (msg_id<MSG_MIN || msg_id>MSG_MAX+1){
// id out of range
return "Message ID out of range";
}
@@ -58,7 +53,6 @@ public class PingPongProtocol {
System.out.println("unknown");
else {
if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
}
if (msg instanceof EventWithDataMessage)
@@ -70,23 +64,22 @@ public class PingPongProtocol {
// sent messages
- public void pong (DemoData data)
- {
+ public void pong(DemoData data) {
if (messageStrings[ OUT_pong] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_pong]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_pong, data.deepCopy()));
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_pong, data.deepCopy()));
}
- public void pongSimple (int data)
- {
+ public void pong(int int32Val, byte[] int8Array, double float64Val, String stringVal) {
+ pong(new DemoData(int32Val, int8Array, float64Val, stringVal));
+ }
+ public void pongSimple(int data) {
if (messageStrings[ OUT_pongSimple] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_pongSimple]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_pongSimple, data));
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_pongSimple, data));
}
}
@@ -118,30 +111,18 @@ public class PingPongProtocol {
}
// outgoing messages
- public void pong (DemoData data)
- {
+ public void pong(DemoData data){
for (int i=0; i<replication; ++i) {
- ports.get(i).pong( data)
- ;
+ ports.get(i).pong( data);
}
}
- public void pongSimple (int data)
- {
+ public void pongSimple(int data){
for (int i=0; i<replication; ++i) {
- ports.get(i).pongSimple( data)
- ;
+ ports.get(i).pongSimple( data);
}
}
}
- // interface for port class
- public interface IPingPongProtocolPort{
- // incoming messages
- public void ping (DemoData data)
- ;
- public void pingSimple (int data)
- ;
- }
// port class
static public class PingPongProtocolConjPort extends PortBase {
@@ -164,7 +145,6 @@ public class PingPongProtocol {
System.out.println("unknown");
else {
if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
}
if (msg instanceof EventWithDataMessage)
@@ -176,23 +156,22 @@ public class PingPongProtocol {
// sent messages
- public void ping (DemoData data)
- {
+ public void ping(DemoData data) {
if (messageStrings[ IN_ping] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_ping]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_ping, data.deepCopy()));
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_ping, data.deepCopy()));
}
- public void pingSimple (int data)
- {
+ public void ping(int int32Val, byte[] int8Array, double float64Val, String stringVal) {
+ ping(new DemoData(int32Val, int8Array, float64Val, stringVal));
+ }
+ public void pingSimple(int data) {
if (messageStrings[ IN_pingSimple] != "timerTick"){
- // TODOTS: model switch for activation
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_pingSimple]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_pingSimple, data));
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_pingSimple, data));
}
}
@@ -224,28 +203,16 @@ public class PingPongProtocol {
}
// incoming messages
- public void ping (DemoData data)
- {
+ public void ping(DemoData data){
for (int i=0; i<replication; ++i) {
- ports.get(i).ping( data)
- ;
+ ports.get(i).ping( data);
}
}
- public void pingSimple (int data)
- {
+ public void pingSimple(int data){
for (int i=0; i<replication; ++i) {
- ports.get(i).pingSimple( data)
- ;
+ ports.get(i).pingSimple( data);
}
}
}
- // interface for port class
- public interface IPingPongProtocolConjPort{
- // outgoing messages
- public void pong (DemoData data)
- ;
- public void pongSimple (int data)
- ;
- }
}
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingDataTop.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingDataTop.java
index 91d716d07..be016b167 100644
--- a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingDataTop.java
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingDataTop.java
@@ -20,7 +20,7 @@ public class SendingDataTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations

Back to the top