Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-02-20 04:32:09 -0500
committerHenrik Rentz-Reichert2012-02-20 04:32:09 -0500
commitc4a795f431f8ee844b48a56016a0a9ab02ad4dd3 (patch)
treec823dbf412cca7e9b207bb27078225df11c5d1a9 /tests
parent90088f94927e0583d8d00bc824e92addd72184bf (diff)
downloadorg.eclipse.etrice-c4a795f431f8ee844b48a56016a0a9ab02ad4dd3.tar.gz
org.eclipse.etrice-c4a795f431f8ee844b48a56016a0a9ab02ad4dd3.tar.xz
org.eclipse.etrice-c4a795f431f8ee844b48a56016a0a9ab02ad4dd3.zip
[generator, generator.c, generator.java, runtime.c, runtime.java] unified code generation for Java and C including state machine generation
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java131
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java439
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java881
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java157
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java203
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java121
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java133
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java197
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java121
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java588
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java147
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java9
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java603
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java315
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java2
-rw-r--r--tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java9
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java1
-rw-r--r--tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java5
28 files changed, 1990 insertions, 2120 deletions
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java
index f3b1e6372..d58277e17 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTest_Top.java
@@ -20,7 +20,7 @@ public class CPTest_Top extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java
index 6d53af0bc..d0f1564b3 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPTester.java
@@ -22,8 +22,8 @@ public class CPTester extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_TestPort1 = 1;
-
+ public static final int IFITEM_TestPort1 = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,66 +58,51 @@ public class CPTester 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() {
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
+
+ TestPort1.msg1();
+ System.out.println("msg1 sent ");
}
/**
@@ -131,12 +116,13 @@ public class CPTester 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
@@ -154,6 +140,7 @@ public class CPTester 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
@@ -167,7 +154,7 @@ public class CPTester 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;
@@ -175,27 +162,33 @@ public class CPTester 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() {
- TestPort1.msg1();
- System.out.println("msg1 sent ");
-
- TestPort1.msg1();
- System.out.println("msg1 sent ");
-
- TestPort1.msg1();
- System.out.println("msg1 sent ");
-
- TestPort1.msg1();
- System.out.println("msg1 sent ");
-
- TestPort1.msg1();
- System.out.println("msg1 sent ");
+ /* 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;
- TestPort1.msg1();
- System.out.println("msg1 sent ");
+ 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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java
index 1172d9aca..9258c5c2a 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/CPUser.java
@@ -29,8 +29,8 @@ public class CPUser extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_TestPort1 = 1;
-
+ public static final int IFITEM_TestPort1 = 1;
+
//--------------------- attributes
protected int counter;
//--------------------- operations
@@ -67,138 +67,141 @@ public class CPUser extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_state0 = 2;
- protected static final int STATE_state1 = 3;
- protected static final int STATE_state1_state0 = 4;
- protected static final int STATE_testOk = 5;
- protected static final int STATE_testFalse = 6;
- protected static final String stateStrings[] = {"<no state>","<top>","state0",
- "state1",
- "state1_state0",
- "testOk",
- "testFalse"
- };
+ /* state IDs */
+ public static final int STATE_state0 = 2;
+ public static final int STATE_state1_state0 = 3;
+ public static final int STATE_testOk = 4;
+ public static final int STATE_testFalse = 5;
+ public static final int STATE_state1 = 6;
- // 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};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__cp0 = 1;
+ public static final int CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1 = 2;
+ public static final int CHAIN_TRANS_state1_TO_cp2_BY_msg1TestPort1 = 3;
+ public static final int CHAIN_TRANS_state1_TO_state0_BY_msg1TestPort1 = 4;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8 = 5;
+ public static final int CHAIN_state1_TRANS_INITIAL_TO__state0 = 6;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__cp0 = 1;
- protected static final int CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1 = 2;
- protected static final int CHAIN_TRANS_state1_TO_cp2_BY_msg1TestPort1 = 3;
- protected static final int CHAIN_TRANS_state1_TO_state0_BY_msg1TestPort1 = 4;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8 = 5;
- protected static final int CHAIN_state1_TRANS_INITIAL_TO__state0 = 6;
+ /* triggers */
+ public static final int TRIG_TestPort1__msg1 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg1;
- // triggers for FSM
- protected static final int TRIG_TestPort1__msg1 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg1;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","state0",
+ "state1_state0",
+ "testOk",
+ "testFalse",
+ "state1"
+ };
- // 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:
- switch(trigger) {
- case TRIG_TestPort1__msg1:
- {
- chain = CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_state1_state0:
- switch(trigger) {
- case TRIG_TestPort1__msg1:
- {
- if (counter==2
- )
- {
- chain = CHAIN_TRANS_state1_TO_cp2_BY_msg1TestPort1;
- catching_state = STATE_TOP;
- } else
- if (counter==1
- )
- {
- chain = CHAIN_TRANS_state1_TO_state0_BY_msg1TestPort1;
- catching_state = STATE_TOP;
- } else
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
- catching_state = STATE_TOP;
- is_handler = true;
- skip_entry = true;
- }
- }
- break;
- }
- break;
- case STATE_testOk:
- switch(trigger) {
- case TRIG_TestPort1__msg1:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
- catching_state = STATE_TOP;
- is_handler = true;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_testFalse:
- switch(trigger) {
- case TRIG_TestPort1__msg1:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
- catching_state = STATE_TOP;
- is_handler = true;
- skip_entry = true;
- }
- 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};
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__cp0;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+ protected void entry_state0() {
+ System.out.println("state0: entry code");
+ crcGen.update(12);
+ }
+ protected void exit_state0() {
+ System.out.println("state0: exit code");
+ crcGen.update(13);
+ }
+ protected void entry_state1() {
+ System.out.println("state1: entry code");
+ crcGen.update(20);
+ }
+ protected void exit_state1() {
+ System.out.println("state1: exit code");
+ crcGen.update(21);
+ }
+ protected void entry_state1_state0() {
+ System.out.println("state1\\0: entry code");
+ System.out.printf("counter => %d\n",counter);
+ crcGen.update(22);
+ }
+ protected void exit_state1_state0() {
+ System.out.println("state1\\0: exit code");
+ crcGen.update(23);
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__cp0() {
+ System.out.println("Top Level init transition");
+ crcGen.update(10);
+ counter = 0;
+ }
+ protected void action_TRANS_cp0_TO_state0(InterfaceItemBase ifitem) {
+ System.out.println("choice0: else code");
+ crcGen.update(17);
+ }
+ protected void action_TRANS_cp0_TO_state0_COND_LastCheck(InterfaceItemBase ifitem) {
+ System.out.println("choice0: true code");
+ crcGen.update(15);
+ }
+ protected void action_TRANS_state0_TO_cp1_BY_msg1TestPort1(InterfaceItemBase ifitem) {
+ System.out.println("state0: msg1: transition code");
+ crcGen.update(18);
+ }
+ protected void action_TRANS_cp1_TO_state0(InterfaceItemBase ifitem) {
+ System.out.println("choice1: else code");
+ crcGen.update(10);
+ counter=3;
+ }
+ protected void action_TRANS_cp1_TO_state1_tp0_COND_tr3(InterfaceItemBase ifitem) {
+ System.out.println("choice1: to entry state1 code");
+ crcGen.update(30);
+ }
+ protected void action_TRANS_state1_TO_cp2_BY_msg1TestPort1(InterfaceItemBase ifitem) {
+ System.out.println("state1: msg1: transition code");
+ crcGen.update(30);
+ System.out.printf("CRC: %d \n", crcGen.getCrc());
+ }
+ protected void action_TRANS_cp2_TO_testFalse(InterfaceItemBase ifitem) {
+ System.out.println("Test false");
+ RTServices.getInstance().getSubSystem().testFinished(1);
+ }
+ protected void action_TRANS_cp2_TO_testOk_COND_tr6(InterfaceItemBase ifitem) {
+ System.out.println("Test ok");
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ }
+ protected void action_TRANS_cp1_TO_state1_COND_tr11(InterfaceItemBase ifitem) {
+ System.out.println("choice1: history to State1 transition code");
+ crcGen.update(25);
+ counter = 1;
+ }
+ protected void action_TRANS_state1_TO_state0_BY_msg1TestPort1(InterfaceItemBase ifitem) {
+ System.out.println("state1: msg1: transition code to state0");
+ crcGen.update(51);
+ counter=4;
+ }
+ protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8(InterfaceItemBase ifitem) {
+ System.out.println("Handler: msg1 received ");
+ crcGen.update(115);
+ counter = 2;
+ }
+ protected void action_state1_TRANS_tp0_TO_cp0(InterfaceItemBase ifitem) {
+ System.out.println("state1: tp0: transition code");
+ crcGen.update(25);
+ }
+ protected void action_state1_TRANS_cp0_TO_state0(InterfaceItemBase ifitem) {
+ System.out.println("state1: choice false code");
+ crcGen.update(57);
+ }
+ protected void action_state1_TRANS_cp0_TO_state0_COND_tr0(InterfaceItemBase ifitem) {
+ System.out.println("state1 choice: true code");
+ crcGen.update(56);
+ }
+ protected void action_state1_TRANS_INITIAL_TO__state0() {
+ System.out.println("state1 initial transition code");
+ crcGen.update(53);
}
/**
@@ -213,30 +216,31 @@ public class CPUser extends ActorClassBase {
switch (current) {
case STATE_state0:
if (!handler) exit_state0();
- history[STATE_TOP] = STATE_state0;
+ this.history[STATE_TOP] = STATE_state0;
current = STATE_TOP;
break;
case STATE_state1:
if (!handler) exit_state1();
- history[STATE_TOP] = STATE_state1;
+ this.history[STATE_TOP] = STATE_state1;
current = STATE_TOP;
break;
case STATE_state1_state0:
if (!handler) exit_state1_state0();
- history[STATE_state1] = STATE_state1_state0;
+ this.history[STATE_state1] = STATE_state1_state0;
current = STATE_state1;
break;
case STATE_testOk:
- history[STATE_TOP] = STATE_testOk;
+ this.history[STATE_TOP] = STATE_testOk;
current = STATE_TOP;
break;
case STATE_testFalse:
- history[STATE_TOP] = STATE_testFalse;
+ this.history[STATE_TOP] = STATE_testFalse;
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
@@ -310,6 +314,7 @@ public class CPUser 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
@@ -327,11 +332,11 @@ public class CPUser extends ActorClassBase {
if (!(skip_entry || handler)) entry_state1();
// state has a sub graph
// with init transition
- if (history[STATE_state1]==NO_STATE) {
+ if (this.history[STATE_state1]==NO_STATE) {
state = executeTransitionChain(CHAIN_state1_TRANS_INITIAL_TO__state0, null, null);
}
else {
- state = history[STATE_state1];
+ state = this.history[STATE_state1];
}
break;
case STATE_state1_state0:
@@ -345,7 +350,7 @@ public class CPUser extends ActorClassBase {
// in leaf state: return state id
return STATE_testFalse;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -353,103 +358,91 @@ public class CPUser 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_state0() {
- System.out.println("state0: entry code");
- crcGen.update(12);
- }
- protected void exit_state0() {
- System.out.println("state0: exit code");
- crcGen.update(13);
- }
- protected void entry_state1() {
- System.out.println("state1: entry code");
- crcGen.update(20);
- }
- protected void exit_state1() {
- System.out.println("state1: exit code");
- crcGen.update(21);
- }
- protected void entry_state1_state0() {
- System.out.println("state1\\0: entry code");
- System.out.printf("counter => %d\n",counter);
- crcGen.update(22);
- }
- protected void exit_state1_state0() {
- System.out.println("state1\\0: exit code");
- crcGen.update(23);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__cp0;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__cp0() {
- System.out.println("Top Level init transition");
- crcGen.update(10);
- counter = 0;
- }
- protected void action_TRANS_cp0_TO_state0(InterfaceItemBase ifitem) {
- System.out.println("choice0: else code");
- crcGen.update(17);
- }
- protected void action_TRANS_cp0_TO_state0_COND_LastCheck(InterfaceItemBase ifitem) {
- System.out.println("choice0: true code");
- crcGen.update(15);
- }
- protected void action_TRANS_state0_TO_cp1_BY_msg1TestPort1(InterfaceItemBase ifitem) {
- System.out.println("state0: msg1: transition code");
- crcGen.update(18);
- }
- protected void action_TRANS_cp1_TO_state0(InterfaceItemBase ifitem) {
- System.out.println("choice1: else code");
- crcGen.update(10);
- counter=3;
- }
- protected void action_TRANS_cp1_TO_state1_tp0_COND_tr3(InterfaceItemBase ifitem) {
- System.out.println("choice1: to entry state1 code");
- crcGen.update(30);
- }
- protected void action_TRANS_state1_TO_cp2_BY_msg1TestPort1(InterfaceItemBase ifitem) {
- System.out.println("state1: msg1: transition code");
- crcGen.update(30);
- System.out.printf("CRC: %d \n", crcGen.getCrc());
- }
- protected void action_TRANS_cp2_TO_testFalse(InterfaceItemBase ifitem) {
- System.out.println("Test false");
- RTServices.getInstance().getSubSystem().testFinished(1);
- }
- protected void action_TRANS_cp2_TO_testOk_COND_tr6(InterfaceItemBase ifitem) {
- System.out.println("Test ok");
- RTServices.getInstance().getSubSystem().testFinished(0);
- }
- protected void action_TRANS_cp1_TO_state1_COND_tr11(InterfaceItemBase ifitem) {
- System.out.println("choice1: history to State1 transition code");
- crcGen.update(25);
- counter = 1;
- }
- protected void action_TRANS_state1_TO_state0_BY_msg1TestPort1(InterfaceItemBase ifitem) {
- System.out.println("state1: msg1: transition code to state0");
- crcGen.update(51);
- counter=4;
- }
- protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8(InterfaceItemBase ifitem) {
- System.out.println("Handler: msg1 received ");
- crcGen.update(115);
- counter = 2;
- }
- protected void action_state1_TRANS_tp0_TO_cp0(InterfaceItemBase ifitem) {
- System.out.println("state1: tp0: transition code");
- crcGen.update(25);
- }
- protected void action_state1_TRANS_cp0_TO_state0(InterfaceItemBase ifitem) {
- System.out.println("state1: choice false code");
- crcGen.update(57);
- }
- protected void action_state1_TRANS_cp0_TO_state0_COND_tr0(InterfaceItemBase ifitem) {
- System.out.println("state1 choice: true code");
- crcGen.update(56);
- }
- protected void action_state1_TRANS_INITIAL_TO__state0() {
- System.out.println("state1 initial transition code");
- crcGen.update(53);
+ /* 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:
+ switch(trigger) {
+ case TRIG_TestPort1__msg1:
+ {
+ chain = CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_state1_state0:
+ switch(trigger) {
+ case TRIG_TestPort1__msg1:
+ {
+ if (counter==2
+ )
+ {
+ chain = CHAIN_TRANS_state1_TO_cp2_BY_msg1TestPort1;
+ catching_state = STATE_TOP;
+ } else
+ if (counter==1
+ )
+ {
+ chain = CHAIN_TRANS_state1_TO_state0_BY_msg1TestPort1;
+ catching_state = STATE_TOP;
+ } else
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
+ catching_state = STATE_TOP;
+ is_handler = true;
+ skip_entry = true;
+ }
+ }
+ break;
+ }
+ break;
+ case STATE_testOk:
+ switch(trigger) {
+ case TRIG_TestPort1__msg1:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
+ catching_state = STATE_TOP;
+ is_handler = true;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_testFalse:
+ switch(trigger) {
+ case TRIG_TestPort1__msg1:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr8;
+ catching_state = STATE_TOP;
+ is_handler = true;
+ skip_entry = true;
+ }
+ 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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java
index 91279a2c3..af6cd90ec 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/ChoicePointTest/TestProtocol.java
@@ -11,18 +11,13 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class TestProtocol {
// 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_msg1 = 1;
public static final int IN_msg2 = 2;
public static final int IN_msg3 = 3;
public static final int IN_msg4 = 4;
public static final int IN_msg5 = 5;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 6;
+ public static final int MSG_MAX = 6;
private static String messageStrings[] = {"MIN", "msg1","msg2","msg3","msg4","msg5","MAX"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java
index 400196a6f..6db277e1f 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerTest_Top.java
@@ -20,7 +20,7 @@ public class HandlerTest_Top extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java
index a43945dd1..cad856bf7 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/HandlerUser.java
@@ -29,8 +29,8 @@ public class HandlerUser extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_TestPort1 = 1;
-
+ public static final int IFITEM_TestPort1 = 1;
+
//--------------------- attributes
protected int counter;
//--------------------- operations
@@ -67,65 +67,446 @@ public class HandlerUser extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_state0 = 2;
- protected static final int STATE_state0_state1 = 3;
- protected static final int STATE_state0_state1_state7 = 4;
- protected static final int STATE_state0_state2 = 5;
- protected static final int STATE_testOk = 6;
- protected static final int STATE_testFalse = 7;
- protected static final int STATE_state1 = 8;
- protected static final String stateStrings[] = {"<no state>","<top>","state0",
- "state0_state1",
- "state0_state1_state7",
- "state0_state2",
- "testOk",
- "testFalse",
- "state1"
- };
+ /* state IDs */
+ public static final int STATE_state0_state1_state7 = 2;
+ public static final int STATE_state0_state2 = 3;
+ public static final int STATE_testOk = 4;
+ public static final int STATE_testFalse = 5;
+ public static final int STATE_state1 = 6;
+ public static final int STATE_state0 = 7;
+ public static final int STATE_state0_state1 = 8;
+
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__state0_tp2 = 1;
+ public static final int CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1 = 2;
+ public static final int CHAIN_TRANS_tp0_TO_state0_BY_msg1TestPort1 = 3;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0 = 4;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6 = 5;
+ public static final int CHAIN_TRANS_tp1_TO_cp0_BY_msg6TestPort1 = 6;
+ public static final int CHAIN_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1 = 7;
+ public static final int CHAIN_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5 = 8;
+ public static final int CHAIN_state0_TRANS_INITIAL_TO__state2 = 9;
+ public static final int CHAIN_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6 = 10;
+ public static final int CHAIN_state0_TRANS_state1_TO_state2_BY_msg5TestPort1 = 11;
+ public static final int CHAIN_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3 = 12;
+ public static final int CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5 = 13;
+ public static final int CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1 = 14;
+ public static final int CHAIN_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1 = 15;
+ public static final int CHAIN_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1 = 16;
+ public static final int CHAIN_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2 = 17;
+ public static final int CHAIN_state0_state1_TRANS_INITIAL_TO__state7 = 18;
+
+ /* triggers */
+ public static final int TRIG_TestPort1__msg1 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg1;
+ public static final int TRIG_TestPort1__msg2 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg2;
+ public static final int TRIG_TestPort1__msg3 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg3;
+ public static final int TRIG_TestPort1__msg4 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg4;
+ public static final int TRIG_TestPort1__msg5 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg5;
+ public static final int TRIG_TestPort1__msg6 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg6;
+
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","state0_state1_state7",
+ "state0_state2",
+ "testOk",
+ "testFalse",
+ "state1",
+ "state0",
+ "state0_state1"
+ };
// 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,NO_STATE};
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__state0_tp2 = 1;
- protected static final int CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1 = 2;
- protected static final int CHAIN_TRANS_tp0_TO_state0_BY_msg1TestPort1 = 3;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0 = 4;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6 = 5;
- protected static final int CHAIN_TRANS_tp1_TO_cp0_BY_msg6TestPort1 = 6;
- protected static final int CHAIN_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1 = 7;
- protected static final int CHAIN_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5 = 8;
- protected static final int CHAIN_state0_TRANS_INITIAL_TO__state2 = 9;
- protected static final int CHAIN_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6 = 10;
- protected static final int CHAIN_state0_TRANS_state1_TO_state2_BY_msg5TestPort1 = 11;
- protected static final int CHAIN_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3 = 12;
- protected static final int CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5 = 13;
- protected static final int CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1 = 14;
- protected static final int CHAIN_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1 = 15;
- protected static final int CHAIN_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1 = 16;
- protected static final int CHAIN_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2 = 17;
- protected static final int CHAIN_state0_state1_TRANS_INITIAL_TO__state7 = 18;
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ //*** Entry and Exit Codes
+ protected void entry_state0() {
+ System.out.println("state 0 entry action");
+ crcGen.update(13);
+ }
+ protected void exit_state0() {
+ System.out.println("state 0 exit action");
+ crcGen.update(14);
+ }
+ protected void entry_state0_state1() {
+ System.out.println("state 0/1 entry action");
+ crcGen.update(16);
+ }
+ protected void exit_state0_state1() {
+ System.out.println("state 0/1 exit action");
+ crcGen.update(17);
+ }
+ protected void entry_state0_state1_state7() {
+ System.out.println("state 0/1/7 entry action");
+ crcGen.update(23);
+ }
+ protected void exit_state0_state1_state7() {
+ System.out.println("state 0/1/7 exit action");
+ crcGen.update(24);
+ }
+ protected void entry_state0_state2() {
+ System.out.println("state 0/2 entry action");
+ crcGen.update(18);
+ }
+ protected void exit_state0_state2() {
+ System.out.println("state 0/2 exit action");
+ crcGen.update(19);
+ }
+ protected void entry_state1() {
+ System.out.println("state 1 entry action");
+ crcGen.update(111);
+ }
+ protected void exit_state1() {
+ System.out.println("state 1 exit action");
+ crcGen.update(112);
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level handler action no guard ");
+ crcGen.update(11);
+ }
+ protected void action_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level self transition action P1=>3");
+ crcGen.update(12);
+ }
+ protected void action_TRANS_INITIAL_TO__state0_tp2() {
+ System.out.println("top level initial transition");
+ crcGen.update(10);
+ }
+ protected void action_TRANS_cp0_TO_testFalse(InterfaceItemBase ifitem, int p1) {
+ System.out.println("Test false");
+ RTServices.getInstance().getSubSystem().testFinished(1);
+ }
+ protected void action_TRANS_cp0_TO_testOk_COND_tr3(InterfaceItemBase ifitem, int p1) {
+ System.out.println("Test ok");
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ }
+ protected void action_TRANS_state0_TO_cp1_BY_msg1TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("tr9 transition action");
+ crcGen.update(114);
+ }
+ protected void action_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level self transition action P1=>4");
+ crcGen.update(50);
+ }
+ protected void action_TRANS_tp0_TO_state0_BY_msg1TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level handler action p1=>7 ");
+ crcGen.update(70);
+ }
+ protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6(InterfaceItemBase ifitem, int p1) {
+ System.out.println("top level handler action p1=>12 ");
+ crcGen.update(110);
+ }
+ protected void action_TRANS_cp1_TO_state1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("tr8 transition action");
+ crcGen.update(113);
+ }
+ protected void action_TRANS_cp1_TO_state0_COND_tr10(InterfaceItemBase ifitem, int p1) {
+ System.out.println("tr4 transition action");
+ crcGen.update(115);
+ }
+ protected void action_TRANS_tp1_TO_cp0_BY_msg6TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("tp1 transition to choice action");
+ crcGen.update(117);
+ System.out.printf("CRC: %d \n", crcGen.getCrc());
+ }
+ protected void action_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1(InterfaceItemBase ifitem) {
+ System.out.println("state 0 handler action no guard");
+ crcGen.update(20);
+ }
+ protected void action_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2(InterfaceItemBase ifitem) {
+ System.out.println("state 0 tp1 self transition action");
+ crcGen.update(21);
+ }
+ protected void action_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0/2 self transition action");
+ crcGen.update(25);
+ }
+ protected void action_state0_TRANS_tp2_TO_state0_state1_tp0(InterfaceItemBase ifitem) {
+ System.out.println("state 0 tp2 transition action");
+ crcGen.update(15);
+ }
+ protected void action_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0 handler action P1 => 5");
+ crcGen.update(52);
+ }
+ protected void action_state0_TRANS_INITIAL_TO__state2() {
+ System.out.println("state 0 initial transition");
+ crcGen.update(53);
+ }
+ protected void action_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0/1 self transition");
+ crcGen.update(54);
+ }
+ protected void action_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0 tp1 p1=>5");
+ crcGen.update(120);
+ }
+ protected void action_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1(InterfaceItemBase ifitem, int p1) {
+ System.out.println("state 0 tp1 action P1 => 6");
+ crcGen.update(121);
+ }
+ protected void action_state0_state1_TRANS_tp0_TO_state7(InterfaceItemBase ifitem) {
+ System.out.println("state 0/1 transition entry action");
+ crcGen.update(22);
+ }
+ protected void action_state0_state1_TRANS_INITIAL_TO__state7() {
+ System.out.println("state 0/1 initial transition");
+ crcGen.update(121);
+ }
+
+ /**
+ * 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_state0:
+ if (!handler) exit_state0();
+ this.history[STATE_TOP] = STATE_state0;
+ current = STATE_TOP;
+ break;
+ case STATE_state0_state1:
+ if (!handler) exit_state0_state1();
+ this.history[STATE_state0] = STATE_state0_state1;
+ current = STATE_state0;
+ break;
+ case STATE_state0_state1_state7:
+ if (!handler) exit_state0_state1_state7();
+ this.history[STATE_state0_state1] = STATE_state0_state1_state7;
+ current = STATE_state0_state1;
+ break;
+ case STATE_state0_state2:
+ if (!handler) exit_state0_state2();
+ this.history[STATE_state0] = STATE_state0_state2;
+ current = STATE_state0;
+ break;
+ case STATE_testOk:
+ this.history[STATE_TOP] = STATE_testOk;
+ current = STATE_TOP;
+ break;
+ case STATE_testFalse:
+ this.history[STATE_TOP] = STATE_testFalse;
+ current = STATE_TOP;
+ break;
+ case STATE_state1:
+ if (!handler) exit_state1();
+ this.history[STATE_TOP] = STATE_state1;
+ 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_tp0_TO_tp0_BY_msg1TestPort1_tr0:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0(ifitem, p1);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1(ifitem, p1);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_INITIAL_TO__state0_tp2:
+ {
+ action_TRANS_INITIAL_TO__state0_tp2();
+ entry_state0();
+ action_state0_TRANS_tp2_TO_state0_state1_tp0(ifitem);
+ entry_state0_state1();
+ action_state0_state1_TRANS_tp0_TO_state7(ifitem);
+ return STATE_state0_state1_state7;
+ }
+ case CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_state0_TO_cp1_BY_msg1TestPort1(ifitem, p1);
+ if (p1!=4
+ ) {
+ action_TRANS_cp1_TO_state0_COND_tr10(ifitem, p1);
+ return STATE_state0;}
+ else {
+ action_TRANS_cp1_TO_state1(ifitem, p1);
+ return STATE_state1;}
+ }
+ case CHAIN_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5(ifitem, p1);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_tp0_TO_state0_BY_msg1TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp0_TO_state0_BY_msg1TestPort1(ifitem, p1);
+ return STATE_state0;
+ }
+ case CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6(ifitem, p1);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_tp1_TO_cp0_BY_msg6TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_TRANS_tp1_TO_cp0_BY_msg6TestPort1(ifitem, p1);
+ if (crcGen.getCrc()==7268
+ ) {
+ action_TRANS_cp0_TO_testOk_COND_tr3(ifitem, p1);
+ return STATE_testOk;}
+ else {
+ action_TRANS_cp0_TO_testFalse(ifitem, p1);
+ return STATE_testFalse;}
+ }
+ case CHAIN_state0_TRANS_state1_TO_state2_BY_msg5TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ return STATE_state0_state2;
+ }
+ case CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1:
+ {
+ action_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1(ifitem);
+ return STATE_state0;
+ }
+ case CHAIN_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2:
+ {
+ action_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2(ifitem);
+ return STATE_state0;
+ }
+ case CHAIN_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3(ifitem, p1);
+ return STATE_state0_state2;
+ }
+ case CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5(ifitem, p1);
+ return STATE_state0;
+ }
+ case CHAIN_state0_TRANS_INITIAL_TO__state2:
+ {
+ action_state0_TRANS_INITIAL_TO__state2();
+ return STATE_state0_state2;
+ }
+ case CHAIN_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6(ifitem, p1);
+ return STATE_state0_state1;
+ }
+ case CHAIN_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1(ifitem, p1);
+ return STATE_state0_state1;
+ }
+ case CHAIN_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1:
+ {
+ int p1 = (Integer) generic_data;
+ action_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1(ifitem, p1);
+ return STATE_state0_state2;
+ }
+ case CHAIN_state0_state1_TRANS_INITIAL_TO__state7:
+ {
+ action_state0_state1_TRANS_INITIAL_TO__state7();
+ return STATE_state0_state1_state7;
+ }
+ }
+ 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_state0:
+ if (!(skip_entry || handler)) entry_state0();
+ // state has a sub graph
+ // with init transition
+ if (this.history[STATE_state0]==NO_STATE) {
+ state = executeTransitionChain(CHAIN_state0_TRANS_INITIAL_TO__state2, null, null);
+ }
+ else {
+ state = this.history[STATE_state0];
+ }
+ break;
+ case STATE_state0_state1:
+ if (!(skip_entry || handler)) entry_state0_state1();
+ // state has a sub graph
+ // with init transition
+ if (this.history[STATE_state0_state1]==NO_STATE) {
+ state = executeTransitionChain(CHAIN_state0_state1_TRANS_INITIAL_TO__state7, null, null);
+ }
+ else {
+ state = this.history[STATE_state0_state1];
+ }
+ break;
+ case STATE_state0_state1_state7:
+ if (!(skip_entry || handler)) entry_state0_state1_state7();
+ // in leaf state: return state id
+ return STATE_state0_state1_state7;
+ case STATE_state0_state2:
+ if (!(skip_entry || handler)) entry_state0_state2();
+ // in leaf state: return state id
+ return STATE_state0_state2;
+ case STATE_testOk:
+ // in leaf state: return state id
+ return STATE_testOk;
+ case STATE_testFalse:
+ // in leaf state: return state id
+ return STATE_testFalse;
+ case STATE_state1:
+ if (!(skip_entry || handler)) entry_state1();
+ // in leaf state: return state id
+ return STATE_state1;
+ case STATE_TOP:
+ state = this.history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
- // triggers for FSM
- protected static final int TRIG_TestPort1__msg1 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg1;
- protected static final int TRIG_TestPort1__msg2 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg2;
- protected static final int TRIG_TestPort1__msg3 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg3;
- protected static final int TRIG_TestPort1__msg4 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg4;
- protected static final int TRIG_TestPort1__msg5 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg5;
- protected static final int TRIG_TestPort1__msg6 = IFITEM_TestPort1 + EVT_SHIFT*TestProtocol.IN_msg6;
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__state0_tp2;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- // receiveEvent contains the main implementation of the FSM
- @Override
+ /* 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;
@@ -134,7 +515,7 @@ public class HandlerUser extends ActorClassBase {
boolean skip_entry = false;
if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
+ switch (this.state) {
case STATE_state0_state1_state7:
switch(trigger) {
case TRIG_TestPort1__msg5:
@@ -457,400 +838,12 @@ public class HandlerUser extends ActorClassBase {
}
}
if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
+ exitTo(this.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__state0_tp2;
- 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_state0:
- if (!handler) exit_state0();
- history[STATE_TOP] = STATE_state0;
- current = STATE_TOP;
- break;
- case STATE_state0_state1:
- if (!handler) exit_state0_state1();
- history[STATE_state0] = STATE_state0_state1;
- current = STATE_state0;
- break;
- case STATE_state0_state1_state7:
- if (!handler) exit_state0_state1_state7();
- history[STATE_state0_state1] = STATE_state0_state1_state7;
- current = STATE_state0_state1;
- break;
- case STATE_state0_state2:
- if (!handler) exit_state0_state2();
- history[STATE_state0] = STATE_state0_state2;
- current = STATE_state0;
- break;
- case STATE_testOk:
- history[STATE_TOP] = STATE_testOk;
- current = STATE_TOP;
- break;
- case STATE_testFalse:
- history[STATE_TOP] = STATE_testFalse;
- current = STATE_TOP;
- break;
- case STATE_state1:
- if (!handler) exit_state1();
- history[STATE_TOP] = STATE_state1;
- 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_tp0_TO_tp0_BY_msg1TestPort1_tr0:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0(ifitem, p1);
- return STATE_TOP;
- }
- case CHAIN_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1(ifitem, p1);
- return STATE_TOP;
- }
- case CHAIN_TRANS_INITIAL_TO__state0_tp2:
- {
- action_TRANS_INITIAL_TO__state0_tp2();
- entry_state0();
- action_state0_TRANS_tp2_TO_state0_state1_tp0(ifitem);
- entry_state0_state1();
- action_state0_state1_TRANS_tp0_TO_state7(ifitem);
- return STATE_state0_state1_state7;
- }
- case CHAIN_TRANS_state0_TO_cp1_BY_msg1TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_state0_TO_cp1_BY_msg1TestPort1(ifitem, p1);
- if (p1!=4
- ) {
- action_TRANS_cp1_TO_state0_COND_tr10(ifitem, p1);
- return STATE_state0;}
- else {
- action_TRANS_cp1_TO_state1(ifitem, p1);
- return STATE_state1;}
- }
- case CHAIN_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5(ifitem, p1);
- return STATE_TOP;
- }
- case CHAIN_TRANS_tp0_TO_state0_BY_msg1TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp0_TO_state0_BY_msg1TestPort1(ifitem, p1);
- return STATE_state0;
- }
- case CHAIN_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6(ifitem, p1);
- return STATE_TOP;
- }
- case CHAIN_TRANS_tp1_TO_cp0_BY_msg6TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_TRANS_tp1_TO_cp0_BY_msg6TestPort1(ifitem, p1);
- if (crcGen.getCrc()==7268
- ) {
- action_TRANS_cp0_TO_testOk_COND_tr3(ifitem, p1);
- return STATE_testOk;}
- else {
- action_TRANS_cp0_TO_testFalse(ifitem, p1);
- return STATE_testFalse;}
- }
- case CHAIN_state0_TRANS_state1_TO_state2_BY_msg5TestPort1:
- {
- int p1 = (Integer) generic_data;
- return STATE_state0_state2;
- }
- case CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1:
- {
- action_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1(ifitem);
- return STATE_state0;
- }
- case CHAIN_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2:
- {
- action_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2(ifitem);
- return STATE_state0;
- }
- case CHAIN_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3(ifitem, p1);
- return STATE_state0_state2;
- }
- case CHAIN_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5(ifitem, p1);
- return STATE_state0;
- }
- case CHAIN_state0_TRANS_INITIAL_TO__state2:
- {
- action_state0_TRANS_INITIAL_TO__state2();
- return STATE_state0_state2;
- }
- case CHAIN_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6(ifitem, p1);
- return STATE_state0_state1;
- }
- case CHAIN_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1(ifitem, p1);
- return STATE_state0_state1;
- }
- case CHAIN_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1:
- {
- int p1 = (Integer) generic_data;
- action_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1(ifitem, p1);
- return STATE_state0_state2;
- }
- case CHAIN_state0_state1_TRANS_INITIAL_TO__state7:
- {
- action_state0_state1_TRANS_INITIAL_TO__state7();
- return STATE_state0_state1_state7;
- }
- }
- 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_state0:
- if (!(skip_entry || handler)) entry_state0();
- // state has a sub graph
- // with init transition
- if (history[STATE_state0]==NO_STATE) {
- state = executeTransitionChain(CHAIN_state0_TRANS_INITIAL_TO__state2, null, null);
- }
- else {
- state = history[STATE_state0];
- }
- break;
- case STATE_state0_state1:
- if (!(skip_entry || handler)) entry_state0_state1();
- // state has a sub graph
- // with init transition
- if (history[STATE_state0_state1]==NO_STATE) {
- state = executeTransitionChain(CHAIN_state0_state1_TRANS_INITIAL_TO__state7, null, null);
- }
- else {
- state = history[STATE_state0_state1];
- }
- break;
- case STATE_state0_state1_state7:
- if (!(skip_entry || handler)) entry_state0_state1_state7();
- // in leaf state: return state id
- return STATE_state0_state1_state7;
- case STATE_state0_state2:
- if (!(skip_entry || handler)) entry_state0_state2();
- // in leaf state: return state id
- return STATE_state0_state2;
- case STATE_testOk:
- // in leaf state: return state id
- return STATE_testOk;
- case STATE_testFalse:
- // in leaf state: return state id
- return STATE_testFalse;
- case STATE_state1:
- if (!(skip_entry || handler)) entry_state1();
- // in leaf state: return state id
- return STATE_state1;
- 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
- protected void entry_state0() {
- System.out.println("state 0 entry action");
- crcGen.update(13);
- }
- protected void exit_state0() {
- System.out.println("state 0 exit action");
- crcGen.update(14);
- }
- protected void entry_state0_state1() {
- System.out.println("state 0/1 entry action");
- crcGen.update(16);
- }
- protected void exit_state0_state1() {
- System.out.println("state 0/1 exit action");
- crcGen.update(17);
- }
- protected void entry_state0_state1_state7() {
- System.out.println("state 0/1/7 entry action");
- crcGen.update(23);
- }
- protected void exit_state0_state1_state7() {
- System.out.println("state 0/1/7 exit action");
- crcGen.update(24);
- }
- protected void entry_state0_state2() {
- System.out.println("state 0/2 entry action");
- crcGen.update(18);
- }
- protected void exit_state0_state2() {
- System.out.println("state 0/2 exit action");
- crcGen.update(19);
- }
- protected void entry_state1() {
- System.out.println("state 1 entry action");
- crcGen.update(111);
- }
- protected void exit_state1() {
- System.out.println("state 1 exit action");
- crcGen.update(112);
- }
-
- //*** Action Codes
- protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr0(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level handler action no guard ");
- crcGen.update(11);
- }
- protected void action_TRANS_tp1_TO_tp1_BY_msg1TestPort1_tr1(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level self transition action P1=>3");
- crcGen.update(12);
- }
- protected void action_TRANS_INITIAL_TO__state0_tp2() {
- System.out.println("top level initial transition");
- crcGen.update(10);
- }
- protected void action_TRANS_cp0_TO_testFalse(InterfaceItemBase ifitem, int p1) {
- System.out.println("Test false");
- RTServices.getInstance().getSubSystem().testFinished(1);
- }
- protected void action_TRANS_cp0_TO_testOk_COND_tr3(InterfaceItemBase ifitem, int p1) {
- System.out.println("Test ok");
- RTServices.getInstance().getSubSystem().testFinished(0);
- }
- protected void action_TRANS_state0_TO_cp1_BY_msg1TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("tr9 transition action");
- crcGen.update(114);
- }
- protected void action_TRANS_tp1_TO_tp1_BY_msg2TestPort1_tr5(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level self transition action P1=>4");
- crcGen.update(50);
- }
- protected void action_TRANS_tp0_TO_state0_BY_msg1TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level handler action p1=>7 ");
- crcGen.update(70);
- }
- protected void action_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr6(InterfaceItemBase ifitem, int p1) {
- System.out.println("top level handler action p1=>12 ");
- crcGen.update(110);
- }
- protected void action_TRANS_cp1_TO_state1(InterfaceItemBase ifitem, int p1) {
- System.out.println("tr8 transition action");
- crcGen.update(113);
- }
- protected void action_TRANS_cp1_TO_state0_COND_tr10(InterfaceItemBase ifitem, int p1) {
- System.out.println("tr4 transition action");
- crcGen.update(115);
- }
- protected void action_TRANS_tp1_TO_cp0_BY_msg6TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("tp1 transition to choice action");
- crcGen.update(117);
- System.out.printf("CRC: %d \n", crcGen.getCrc());
- }
- protected void action_state0_TRANS_tp0_TO_tp0_BY_msg3TestPort1_tr1(InterfaceItemBase ifitem) {
- System.out.println("state 0 handler action no guard");
- crcGen.update(20);
- }
- protected void action_state0_TRANS_tp1_TO_tp1_BY_msg4TestPort1_tr2(InterfaceItemBase ifitem) {
- System.out.println("state 0 tp1 self transition action");
- crcGen.update(21);
- }
- protected void action_state0_TRANS_state2_TO_state2_BY_msg1TestPort1_tr3(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0/2 self transition action");
- crcGen.update(25);
- }
- protected void action_state0_TRANS_tp2_TO_state0_state1_tp0(InterfaceItemBase ifitem) {
- System.out.println("state 0 tp2 transition action");
- crcGen.update(15);
- }
- protected void action_state0_TRANS_tp0_TO_tp0_BY_msg1TestPort1_tr5(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0 handler action P1 => 5");
- crcGen.update(52);
- }
- protected void action_state0_TRANS_INITIAL_TO__state2() {
- System.out.println("state 0 initial transition");
- crcGen.update(53);
- }
- protected void action_state0_TRANS_state1_TO_state1_BY_msg1TestPort1_tr6(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0/1 self transition");
- crcGen.update(54);
- }
- protected void action_state0_TRANS_tp1_TO_state1_BY_msg2TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0 tp1 p1=>5");
- crcGen.update(120);
- }
- protected void action_state0_TRANS_tp1_TO_state2_BY_msg2TestPort1(InterfaceItemBase ifitem, int p1) {
- System.out.println("state 0 tp1 action P1 => 6");
- crcGen.update(121);
- }
- protected void action_state0_state1_TRANS_tp0_TO_state7(InterfaceItemBase ifitem) {
- System.out.println("state 0/1 transition entry action");
- crcGen.update(22);
- }
- protected void action_state0_state1_TRANS_INITIAL_TO__state7() {
- System.out.println("state 0/1 initial transition");
- crcGen.update(121);
- }
//******************************************
// END of generated code for FSM
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java
index 05ab66eae..3d0437aa7 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/TestProtocol.java
@@ -11,19 +11,14 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class TestProtocol {
// 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_msg1 = 1;
public static final int IN_msg2 = 2;
public static final int IN_msg3 = 3;
public static final int IN_msg4 = 4;
public static final int IN_msg5 = 5;
public static final int IN_msg6 = 6;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 7;
+ public static final int MSG_MAX = 7;
private static String messageStrings[] = {"MIN", "msg1","msg2","msg3","msg4","msg5","msg6","MAX"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java
index 3224bfaed..745fde1a6 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/HandlerTest/Tester.java
@@ -25,9 +25,9 @@ public class Tester extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_TestPort1 = 1;
- protected static final int IFITEM_timer = 2;
-
+ public static final int IFITEM_TestPort1 = 1;
+ public static final int IFITEM_timer = 2;
+
//--------------------- attributes
//--------------------- operations
@@ -63,66 +63,63 @@ public class Tester 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() {
+ TestPort1.msg1(2);
+ System.out.println("msg1(2) sent ");
+ TestPort1.msg1(3);
+ System.out.println("msg1(3) sent ");
+ TestPort1.msg1(7);
+ System.out.println("msg1(7) sent ");
+ TestPort1.msg1(4);
+ System.out.println("msg1(4) sent ");
+ TestPort1.msg1(5);
+ System.out.println("msg1(5) sent ");
+ TestPort1.msg1(7);
+ System.out.println("msg1(7) sent ");
+ TestPort1.msg2(5);
+ System.out.println("msg2(5) sent ");
+ TestPort1.msg2(6);
+ System.out.println("msg2(6) sent ");
+
+
+
+ TestPort1.msg1(5);
+ System.out.println("msg1(5) sent ");
+ TestPort1.msg3();
+ System.out.println("msg3() sent ");
+ TestPort1.msg4();
+ System.out.println("msg4() sent ");
+ TestPort1.msg1(8);
+ System.out.println("msg1(8) sent ");
+ TestPort1.msg6(12);
+ System.out.println("msg6(12) sent ");
}
/**
@@ -136,12 +133,13 @@ public class Tester 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
@@ -159,6 +157,7 @@ public class Tester 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
@@ -172,7 +171,7 @@ public class Tester 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;
@@ -180,39 +179,33 @@ public class Tester 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() {
- TestPort1.msg1(2);
- System.out.println("msg1(2) sent ");
- TestPort1.msg1(3);
- System.out.println("msg1(3) sent ");
- TestPort1.msg1(7);
- System.out.println("msg1(7) sent ");
- TestPort1.msg1(4);
- System.out.println("msg1(4) sent ");
- TestPort1.msg1(5);
- System.out.println("msg1(5) sent ");
- TestPort1.msg1(7);
- System.out.println("msg1(7) sent ");
- TestPort1.msg2(5);
- System.out.println("msg2(5) sent ");
- TestPort1.msg2(6);
- System.out.println("msg2(6) sent ");
-
-
+ /* 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;
- TestPort1.msg1(5);
- System.out.println("msg1(5) sent ");
- TestPort1.msg3();
- System.out.println("msg3() sent ");
- TestPort1.msg4();
- System.out.println("msg4() sent ");
- TestPort1.msg1(8);
- System.out.println("msg1(8) sent ");
- TestPort1.msg6(12);
- System.out.println("msg6(12) sent ");
+ 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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
index e6d4384c4..5cea29de5 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPingActor.java
@@ -30,11 +30,11 @@ public class MrPingActor extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
- protected static final int IFITEM_PingPongPort2 = 2;
- protected static final int IFITEM_PingPongPort3 = 3;
- protected static final int IFITEM_timer = 4;
-
+ public static final int IFITEM_PingPongPort = 1;
+ public static final int IFITEM_PingPongPort2 = 2;
+ public static final int IFITEM_PingPongPort3 = 3;
+ public static final int IFITEM_timer = 4;
+
//--------------------- attributes
protected int count;
protected int pongCount;
@@ -76,97 +76,58 @@ public class MrPingActor extends ActorClassBase {
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"
- };
+ /* state IDs */
+ public static final int STATE_waitForTimer = 2;
+ public static final int STATE_waitForPong = 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__waitForTimer = 1;
+ public static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort = 2;
+ public static final int CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer = 3;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForTimer = 1;
- protected static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort = 2;
- protected static final int CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer = 3;
+ /* triggers */
+ public static final int TRIG_PingPongPort2__pong = IFITEM_PingPongPort2 + EVT_SHIFT*PingPongProtocol.OUT_pong;
+ public static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
+ public static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
- // triggers for FSM
- protected static final int TRIG_PingPongPort2__pong = IFITEM_PingPongPort2 + EVT_SHIFT*PingPongProtocol.OUT_pong;
- 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;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForTimer",
+ "waitForPong"
+ };
- // 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_PingPongPort2__pong:
- {
- chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort;
- 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__waitForTimer;
- 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__waitForTimer() {
+ count = 0;
+ timer.Start(10);
+ }
+ protected void action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ PingPongPort.ping();
+ PingPongPort2.ping();
+ pongCount = 0;
+ }
+ protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort(InterfaceItemBase ifitem) {
+ pongCount++;
+ }
+ protected void action_TRANS_cp0_TO_waitForTimer(InterfaceItemBase ifitem) {
+ if (count++ > 100) {
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ } else {
+ System.out.println(count);
+ timer.Start(5);}
}
/**
@@ -180,16 +141,17 @@ public class MrPingActor extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForTimer:
- history[STATE_TOP] = STATE_waitForTimer;
+ this.history[STATE_TOP] = STATE_waitForTimer;
current = STATE_TOP;
break;
case STATE_waitForPong:
- history[STATE_TOP] = STATE_waitForPong;
+ this.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
@@ -222,6 +184,7 @@ public class MrPingActor 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
@@ -238,7 +201,7 @@ public class MrPingActor extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPong;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -246,27 +209,57 @@ public class MrPingActor 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__waitForTimer() {
- count = 0;
- timer.Start(10);
- }
- protected void action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- PingPongPort.ping();
- PingPongPort2.ping();
- pongCount = 0;
- }
- protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort(InterfaceItemBase ifitem) {
- pongCount++;
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForTimer;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_cp0_TO_waitForTimer(InterfaceItemBase ifitem) {
- if (count++ > 100) {
- RTServices.getInstance().getSubSystem().testFinished(0);
- } else {
- System.out.println(count);
- timer.Start(5);}
+
+ /* 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_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_PingPongPort2__pong:
+ {
+ chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort2pongPingPongPort;
+ 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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java
index 5a532b646..1df1c9646 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor1.java
@@ -22,8 +22,8 @@ public class MrPongActor1 extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,76 +58,37 @@ public class MrPongActor1 extends ActorClassBase {
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"
- };
+ /* state IDs */
+ public static final int STATE_waitForPing = 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__waitForPing = 1;
+ public static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
- // 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 */
+ public static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
+ };
- // 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);
- }
- }
+ // 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__waitForPing;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
+ PingPongPort.pong();
}
/**
@@ -141,12 +102,13 @@ public class MrPongActor1 extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForPing:
- history[STATE_TOP] = STATE_waitForPing;
+ this.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
@@ -168,6 +130,7 @@ public class MrPongActor1 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
@@ -181,7 +144,7 @@ public class MrPongActor1 extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPing;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -189,11 +152,41 @@ public class MrPongActor1 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__waitForPing;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- //*** Action Codes
- protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
- PingPongPort.pong();
+ /* 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_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(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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java
index bbd1adb1c..82fdf30ed 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/MrPongActor2.java
@@ -22,8 +22,8 @@ public class MrPongActor2 extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,76 +58,43 @@ public class MrPongActor2 extends ActorClassBase {
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"
- };
+ /* state IDs */
+ public static final int STATE_waitForPing = 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__waitForPing = 1;
+ public static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
- // 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 */
+ public static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
+ };
- // 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);
- }
- }
+ // 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__waitForPing;
- 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__waitForPing() {
+ // simulate blocking call e.g. Queue
+ try{
+ Thread.sleep(5000);
+ }catch (InterruptedException e){}
+ }
+ protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
+ PingPongPort.pong();
}
/**
@@ -141,12 +108,13 @@ public class MrPongActor2 extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForPing:
- history[STATE_TOP] = STATE_waitForPing;
+ this.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
@@ -169,6 +137,7 @@ public class MrPongActor2 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
@@ -182,7 +151,7 @@ public class MrPongActor2 extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPing;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -190,17 +159,41 @@ public class MrPongActor2 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__waitForPing() {
- // simulate blocking call e.g. Queue
- try{
- Thread.sleep(5000);
- }catch (InterruptedException e){}
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForPing;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
- PingPongPort.pong();
+
+ /* 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_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(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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java
index 0fbce52c7..19fba6c6c 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongProtocol.java
@@ -11,15 +11,10 @@ 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;
- //IDs for incoming messages
public static final int IN_ping = 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", "pong", "ping","MAX"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java
index a2a19212a..16d6cbe55 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTest/PingPongTop.java
@@ -20,7 +20,7 @@ public class PingPongTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
index cd19c4098..1b479af2e 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPingActor.java
@@ -28,9 +28,9 @@ public class MrPingActor extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
- protected static final int IFITEM_timer = 2;
-
+ public static final int IFITEM_PingPongPort = 1;
+ public static final int IFITEM_timer = 2;
+
//--------------------- attributes
protected int count;
protected int pongCount;
@@ -70,90 +70,64 @@ public class MrPingActor extends ActorClassBase {
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"
- };
+ /* state IDs */
+ public static final int STATE_waitForTimer = 2;
+ public static final int STATE_waitForPong = 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__waitForTimer = 1;
+ public static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort = 2;
+ public static final int CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer = 3;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForTimer = 1;
- protected static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort = 2;
- protected static final int CHAIN_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer = 3;
+ /* triggers */
+ public static final int TRIG_PingPongPort__pong = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.OUT_pong;
+ public static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
- // 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;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForTimer",
+ "waitForPong"
+ };
- // 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_cp0_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);
- }
- }
+ // 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__waitForTimer;
- 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__waitForTimer() {
+ count = 0;
+ timer.Start(1000);
+ }
+ protected void action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ PingPongPort.get(0).ping();
+ PingPongPort.get(1).ping();
+ PingPongPort.get(2).ping();
+ pongCount = 0;
+ }
+ protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort(InterfaceItemBase ifitem) {
+ pongCount++;
+ }
+ protected void action_TRANS_cp0_TO_waitForTimer(InterfaceItemBase ifitem) {
+ if (count++ > 1000) {
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ } else {
+ //PingPongPort.get(0).ping();
+ //PingPongPort.get(1).ping();
+ //PingPongPort.get(2).ping();
+ System.out.println(pongCount);
+ System.out.println(count);
+ pongCount = 0;
+ timer.Start(10);
+ }
}
/**
@@ -167,16 +141,17 @@ public class MrPingActor extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForTimer:
- history[STATE_TOP] = STATE_waitForTimer;
+ this.history[STATE_TOP] = STATE_waitForTimer;
current = STATE_TOP;
break;
case STATE_waitForPong:
- history[STATE_TOP] = STATE_waitForPong;
+ this.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
@@ -209,6 +184,7 @@ public class MrPingActor 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
@@ -225,7 +201,7 @@ public class MrPingActor extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPong;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -233,33 +209,50 @@ public class MrPingActor 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__waitForTimer() {
- count = 0;
- timer.Start(1000);
- }
- protected void action_TRANS_waitForTimer_TO_waitForPong_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
- PingPongPort.get(0).ping();
- PingPongPort.get(1).ping();
- PingPongPort.get(2).ping();
- pongCount = 0;
- }
- protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort(InterfaceItemBase ifitem) {
- pongCount++;
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForTimer;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_cp0_TO_waitForTimer(InterfaceItemBase ifitem) {
- if (count++ > 1000) {
- RTServices.getInstance().getSubSystem().testFinished(0);
- } else {
- //PingPongPort.get(0).ping();
- //PingPongPort.get(1).ping();
- //PingPongPort.get(2).ping();
- System.out.println(pongCount);
- System.out.println(count);
- pongCount = 0;
- timer.Start(10);
+
+ /* 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_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_cp0_BY_pongPingPongPort;
+ 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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java
index 873548bb4..f89cd5ec0 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/MrPongActor1.java
@@ -22,8 +22,8 @@ public class MrPongActor1 extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,76 +58,37 @@ public class MrPongActor1 extends ActorClassBase {
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"
- };
+ /* state IDs */
+ public static final int STATE_waitForPing = 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__waitForPing = 1;
+ public static final int CHAIN_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger = 2;
- // 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 */
+ public static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
- // triggers for FSM
- protected static final int TRIG_PingPongPort__ping = IFITEM_PingPongPort + EVT_SHIFT*PingPongProtocol.IN_ping;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForPing"
+ };
- // 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);
- }
- }
+ // 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__waitForPing;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
+ PingPongPort.pong();
}
/**
@@ -141,12 +102,13 @@ public class MrPongActor1 extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_waitForPing:
- history[STATE_TOP] = STATE_waitForPing;
+ this.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
@@ -168,6 +130,7 @@ public class MrPongActor1 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
@@ -181,7 +144,7 @@ public class MrPongActor1 extends ActorClassBase {
// in leaf state: return state id
return STATE_waitForPing;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -189,11 +152,41 @@ public class MrPongActor1 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__waitForPing;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- //*** Action Codes
- protected void action_TRANS_waitForPing_TO_waitForPing_BY_pingPingPongPort_myTrigger(InterfaceItemBase ifitem) {
- PingPongPort.pong();
+ /* 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_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(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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java
index 373a12637..1e8b223b2 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongProtocol.java
@@ -11,15 +11,10 @@ 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;
- //IDs for incoming messages
public static final int IN_ping = 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", "pong", "ping","MAX"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java
index 9dc2141f2..23368aad6 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/PingPongThreadTestReplPort/PingPongTop.java
@@ -20,7 +20,7 @@ public class PingPongTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
index 5cefa4b1f..8b1c3ad3f 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPing.java
@@ -29,8 +29,8 @@ public class MrPing extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_PingPongPort = 1;
-
+ public static final int IFITEM_PingPongPort = 1;
+
//--------------------- attributes
protected int[] i32Array;
protected PingPongData data;
@@ -84,195 +84,161 @@ 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_state0 = 3;
- protected static final int STATE_state1 = 4;
- protected static final int STATE_state2 = 5;
- protected static final int STATE_TestFalse = 6;
- protected static final int STATE_TestOk = 7;
- protected static final String stateStrings[] = {"<no state>","<top>","waitForPong",
- "state0",
- "state1",
- "state2",
- "TestFalse",
- "TestOk"
- };
+ /* state IDs */
+ public static final int STATE_waitForPong = 2;
+ public static final int STATE_state0 = 3;
+ public static final int STATE_state1 = 4;
+ public static final int STATE_state2 = 5;
+ public static final int STATE_TestFalse = 6;
+ public static final int STATE_TestOk = 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__waitForPong = 1;
+ public static final int CHAIN_TRANS_state0_TO_state1_BY_pongPingPongPort = 2;
+ public static final int CHAIN_TRANS_state1_TO_state2_BY_pongSimplePingPongPort = 3;
+ public static final int CHAIN_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort = 4;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0 = 5;
+ public static final int CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1 = 6;
+ public static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort = 7;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__waitForPong = 1;
- protected static final int CHAIN_TRANS_state0_TO_state1_BY_pongPingPongPort = 2;
- protected static final int CHAIN_TRANS_state1_TO_state2_BY_pongSimplePingPongPort = 3;
- protected static final int CHAIN_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort = 4;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0 = 5;
- protected static final int CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1 = 6;
- protected static final int CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort = 7;
+ /* 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",
+ "state0",
+ "state1",
+ "state2",
+ "TestFalse",
+ "TestOk"
+ };
- // 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_cp0_BY_pongPingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_state0:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- { PingPongData p = (PingPongData) generic_data;
- if (p.getI32Val()==3
- )
- {
- chain = CHAIN_TRANS_state0_TO_state1_BY_pongPingPongPort;
- catching_state = STATE_TOP;
- } else
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- }
- break;
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_state1:
- switch(trigger) {
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_state1_TO_state2_BY_pongSimplePingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_state2:
- switch(trigger) {
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_TestFalse:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- }
- break;
- case STATE_TestOk:
- switch(trigger) {
- case TRIG_PingPongPort__pong:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- break;
- case TRIG_PingPongPort__pongSimple:
- {
- chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
- catching_state = STATE_TOP;
- skip_entry = true;
- }
- 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__waitForPong;
- 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__waitForPong() {
+ int i;
+ int[] intArray;
+ this.data=new PingPongData();
+
+ // send default data
+ PingPongData d = new PingPongData();
+ PingPongPort.ping(d);
+
+ d.setI8Val((byte) 45);
+ d.setI16Val((short) 34);
+ d.setI32Val(2);
+ d.setF32Val((float)3.14);
+ d.setF64Val(7.12345);
+ d.setStringVal("Hase !");
+
+ d.getOwnType().setI8Val((byte)10);
+ d.getOwnType().setI16Val((short)17);
+ d.getOwnType().setI32Val(4711);
+ d.getOwnType().setF32Val((float)3.0815);
+ d.getOwnType().setF64Val(123.45678);
+ d.getOwnType().setStringVal("Deep Hase !");
+ intArray = d.getOwnType().getArrayFromInt32();
+ for (i=0;i<intArray.length;i++) {intArray[i] = 10+i;}
+ d.getOwnType().setArrayFromInt32(intArray);
+
+ PingPongPort.ping(d);
+
+ d.setI8Val((byte) 55);
+ d.setI16Val((short) 44);
+ d.setI32Val(3);
+ d.setF32Val((float)24.4563458);
+ d.setF64Val(2347.2342312345);
+ d.setStringVal("Mein Hase !");
+
+ d.getOwnType().setI8Val((byte)15);
+ d.getOwnType().setI16Val((short)23);
+ d.getOwnType().setI32Val(4812);
+ d.getOwnType().setF32Val((float)2453.30815);
+ d.getOwnType().setF64Val(125332.42342);
+ d.getOwnType().setStringVal("Mein Deep Hase !");
+ intArray = d.getOwnType().getArrayFromInt32();
+ for (i=0;i<intArray.length;i++) {intArray[i] = 30+i;}
+ d.getOwnType().setArrayFromInt32(intArray);
+
+ PingPongPort.ping(d);
+ PingPongPort.ping(data);
+
+ data.setI8Val((byte) 67);
+ data.setI16Val((short) 97);
+ data.setI32Val(70);
+ data.setF32Val((float)233.14);
+ data.setF64Val(723434.12345);
+ data.setStringVal("Falscher Hase !");
+
+ crcGen.update(10);
+ }
+ protected void action_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0(InterfaceItemBase ifitem, PingPongData p) {
+ System.out.printf("Top Level : \n");
+ printData(p);
+ crcGen.update(20);
+ }
+ protected void action_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1(InterfaceItemBase ifitem, int p) {
+ System.out.printf("Top Level Simple: \n");
+ crcGen.update(35);
+ }
+ protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort(InterfaceItemBase ifitem, PingPongData p) {
+ printData(p);
+ crcGen.update(11);
+ }
+ protected void action_TRANS_cp0_TO_waitForPong(InterfaceItemBase ifitem, PingPongData p) {
+ crcGen.update(12);
+ }
+ protected void action_TRANS_cp0_TO_state0_COND_tr3(InterfaceItemBase ifitem, PingPongData p) {
+ // send default values
+ PingPongPort.ping(data);
+
+ data.getOwnType().setI8Val((byte)10);
+ data.getOwnType().setI16Val((short)17);
+ data.getOwnType().setI32Val(4711);
+ data.getOwnType().setF32Val((float)3.0815);
+ data.getOwnType().setF64Val(123.45678);
+ data.getOwnType().setStringVal("Deep Hase !");
+ int[] intArray = data.getOwnType().getArrayFromInt32();
+ for (int i=0;i<intArray.length;i++) {intArray[i] = 10+i;}
+ data.getOwnType().setArrayFromInt32(intArray);
+
+ // use convenient function
+ PingPongPort.ping((byte)45,(short)34,80,'c',(float)3.14,7.12345,"Hase !",intArray,data.getOwnType());
+
+ crcGen.update(13);
+ }
+ protected void action_TRANS_state0_TO_state1_BY_pongPingPongPort(InterfaceItemBase ifitem, PingPongData p) {
+ printData(p);
+ PingPongPort.pingSimple(12);
+ PingPongPort.pingSimple(27);
+ crcGen.update(14);
+ }
+ protected void action_TRANS_state1_TO_state2_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int p) {
+ crcGen.update(15);
+ }
+ protected void action_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int p) {
+ crcGen.update(16);
+ System.out.printf("CRC: %d \n", crcGen.getCrc());
+ }
+ protected void action_TRANS_cp1_TO_TestFalse(InterfaceItemBase ifitem, int p) {
+ RTServices.getInstance().getSubSystem().testFinished(1);
+ }
+ protected void action_TRANS_cp1_TO_TestOk_COND_tr9(InterfaceItemBase ifitem, int p) {
+ RTServices.getInstance().getSubSystem().testFinished(0);
}
/**
@@ -286,32 +252,33 @@ 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_state0:
- history[STATE_TOP] = STATE_state0;
+ this.history[STATE_TOP] = STATE_state0;
current = STATE_TOP;
break;
case STATE_state1:
- history[STATE_TOP] = STATE_state1;
+ this.history[STATE_TOP] = STATE_state1;
current = STATE_TOP;
break;
case STATE_state2:
- history[STATE_TOP] = STATE_state2;
+ this.history[STATE_TOP] = STATE_state2;
current = STATE_TOP;
break;
case STATE_TestFalse:
- history[STATE_TOP] = STATE_TestFalse;
+ this.history[STATE_TOP] = STATE_TestFalse;
current = STATE_TOP;
break;
case STATE_TestOk:
- history[STATE_TOP] = STATE_TestOk;
+ this.history[STATE_TOP] = STATE_TestOk;
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
@@ -377,6 +344,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
@@ -405,7 +373,7 @@ public class MrPing extends ActorClassBase {
// in leaf state: return state id
return STATE_TestOk;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -413,124 +381,144 @@ 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_INITIAL_TO__waitForPong() {
- int i;
- int[] intArray;
- this.data=new PingPongData();
-
- // send default data
- PingPongData d = new PingPongData();
- PingPongPort.ping(d);
-
- d.setI8Val((byte) 45);
- d.setI16Val((short) 34);
- d.setI32Val(2);
- d.setF32Val((float)3.14);
- d.setF64Val(7.12345);
- d.setStringVal("Hase !");
-
- d.getOwnType().setI8Val((byte)10);
- d.getOwnType().setI16Val((short)17);
- d.getOwnType().setI32Val(4711);
- d.getOwnType().setF32Val((float)3.0815);
- d.getOwnType().setF64Val(123.45678);
- d.getOwnType().setStringVal("Deep Hase !");
- intArray = d.getOwnType().getArrayFromInt32();
- for (i=0;i<intArray.length;i++) {intArray[i] = 10+i;}
- d.getOwnType().setArrayFromInt32(intArray);
-
- PingPongPort.ping(d);
-
- d.setI8Val((byte) 55);
- d.setI16Val((short) 44);
- d.setI32Val(3);
- d.setF32Val((float)24.4563458);
- d.setF64Val(2347.2342312345);
- d.setStringVal("Mein Hase !");
-
- d.getOwnType().setI8Val((byte)15);
- d.getOwnType().setI16Val((short)23);
- d.getOwnType().setI32Val(4812);
- d.getOwnType().setF32Val((float)2453.30815);
- d.getOwnType().setF64Val(125332.42342);
- d.getOwnType().setStringVal("Mein Deep Hase !");
- intArray = d.getOwnType().getArrayFromInt32();
- for (i=0;i<intArray.length;i++) {intArray[i] = 30+i;}
- d.getOwnType().setArrayFromInt32(intArray);
-
- PingPongPort.ping(d);
- PingPongPort.ping(data);
-
- data.setI8Val((byte) 67);
- data.setI16Val((short) 97);
- data.setI32Val(70);
- data.setF32Val((float)233.14);
- data.setF64Val(723434.12345);
- data.setStringVal("Falscher Hase !");
-
- crcGen.update(10);
- }
- protected void action_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0(InterfaceItemBase ifitem, PingPongData p) {
- System.out.printf("Top Level : \n");
- printData(p);
- crcGen.update(20);
- }
- protected void action_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1(InterfaceItemBase ifitem, int p) {
- System.out.printf("Top Level Simple: \n");
- crcGen.update(35);
- }
- protected void action_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort(InterfaceItemBase ifitem, PingPongData p) {
- printData(p);
- crcGen.update(11);
- }
- protected void action_TRANS_cp0_TO_waitForPong(InterfaceItemBase ifitem, PingPongData p) {
- crcGen.update(12);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForPong;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- protected void action_TRANS_cp0_TO_state0_COND_tr3(InterfaceItemBase ifitem, PingPongData p) {
- // send default values
- PingPongPort.ping(data);
-
- data.setI8Val((byte) 45);
- data.setI16Val((short) 34);
- data.setI32Val(80);
- data.setF32Val((float)3.14);
- data.setF64Val(7.12345);
- data.setStringVal("Hase !");
-
- data.getOwnType().setI8Val((byte)10);
- data.getOwnType().setI16Val((short)17);
- data.getOwnType().setI32Val(4711);
- data.getOwnType().setF32Val((float)3.0815);
- data.getOwnType().setF64Val(123.45678);
- data.getOwnType().setStringVal("Deep Hase !");
- int[] intArray = data.getOwnType().getArrayFromInt32();
- for (int i=0;i<intArray.length;i++) {intArray[i] = 10+i;}
- data.getOwnType().setArrayFromInt32(intArray);
+
+ /* 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;
- PingPongPort.ping(data);
- crcGen.update(13);
- }
- protected void action_TRANS_state0_TO_state1_BY_pongPingPongPort(InterfaceItemBase ifitem, PingPongData p) {
- printData(p);
- PingPongPort.pingSimple(12);
- PingPongPort.pingSimple(27);
- crcGen.update(14);
- }
- protected void action_TRANS_state1_TO_state2_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int p) {
- crcGen.update(15);
- }
- protected void action_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int p) {
- crcGen.update(16);
- System.out.printf("CRC: %d \n", crcGen.getCrc());
- }
- protected void action_TRANS_cp1_TO_TestFalse(InterfaceItemBase ifitem, int p) {
- RTServices.getInstance().getSubSystem().testFinished(1);
- }
- protected void action_TRANS_cp1_TO_TestOk_COND_tr9(InterfaceItemBase ifitem, int p) {
- RTServices.getInstance().getSubSystem().testFinished(0);
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_waitForPong:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_waitForPong_TO_cp0_BY_pongPingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_state0:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ { PingPongData p = (PingPongData) generic_data;
+ if (p.getI32Val()==3
+ )
+ {
+ chain = CHAIN_TRANS_state0_TO_state1_BY_pongPingPongPort;
+ catching_state = STATE_TOP;
+ } else
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ }
+ break;
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_state1:
+ switch(trigger) {
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_state1_TO_state2_BY_pongSimplePingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_state2:
+ switch(trigger) {
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_state2_TO_cp1_BY_pongSimplePingPongPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_TestFalse:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ }
+ break;
+ case STATE_TestOk:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ break;
+ case TRIG_PingPongPort__pongSimple:
+ {
+ chain = CHAIN_TRANS_tp0_TO_tp0_BY_pongSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ skip_entry = true;
+ }
+ 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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
index eb010beb2..b43af07da 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/MrPong.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/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
public void printData(PingPongData d) {
@@ -70,84 +70,45 @@ public class MrPong extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_reply = 2;
- protected static final String stateStrings[] = {"<no state>","<top>","reply"
- };
+ /* state IDs */
+ public static final int STATE_reply = 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__reply = 1;
+ public static final int CHAIN_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0 = 2;
+ public static final int CHAIN_TRANS_reply_TO_reply_BY_pingSimplePingPongPort_tr1 = 3;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__reply = 1;
- protected static final int CHAIN_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0 = 2;
- protected static final int CHAIN_TRANS_reply_TO_reply_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>","reply"
+ };
- // 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_reply:
- switch(trigger) {
- case TRIG_PingPongPort__ping:
- {
- chain = CHAIN_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PingPongPort__pingSimple:
- {
- chain = CHAIN_TRANS_reply_TO_reply_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__reply;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0(InterfaceItemBase ifitem, PingPongData p) {
+ p.setI8Val((byte)(p.getI8Val()+1));
+
+
+ PingPongPort.pong(p);
+ }
+ protected void action_TRANS_reply_TO_reply_BY_pingSimplePingPongPort_tr1(InterfaceItemBase ifitem, int p) {
+ PingPongPort.pongSimple(++p);
}
/**
@@ -161,12 +122,13 @@ public class MrPong extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_reply:
- history[STATE_TOP] = STATE_reply;
+ this.history[STATE_TOP] = STATE_reply;
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 +157,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
@@ -208,7 +171,7 @@ public class MrPong extends ActorClassBase {
// in leaf state: return state id
return STATE_reply;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -216,17 +179,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
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__reply;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- //*** Action Codes
- protected void action_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0(InterfaceItemBase ifitem, PingPongData p) {
- p.setI8Val((byte)(p.getI8Val()+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;
- PingPongPort.pong(p);
- }
- protected void action_TRANS_reply_TO_reply_BY_pingSimplePingPongPort_tr1(InterfaceItemBase ifitem, int p) {
- PingPongPort.pongSimple(++p);
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_reply:
+ switch(trigger) {
+ case TRIG_PingPongPort__ping:
+ {
+ chain = CHAIN_TRANS_reply_TO_reply_BY_pingPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pingSimple:
+ {
+ chain = CHAIN_TRANS_reply_TO_reply_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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java
index 8afe13cdf..150e4c74c 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/PingPongProtocol.java
@@ -11,17 +11,12 @@ 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"};
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java
index e11a120d9..f6b63e592 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/SendingDataByValueTest/SendingDataTop.java
@@ -20,7 +20,7 @@ public class SendingDataTop extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java
index b21d3c4d5..1385ab5ff 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/App_SubSystemHFSMTest.java
@@ -20,7 +20,7 @@ public class App_SubSystemHFSMTest extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java
index 1fd781be3..b6f3a4ca2 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM.java
@@ -22,8 +22,8 @@ public class a_HFSM extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_fct = 1;
-
+ public static final int IFITEM_fct = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -58,60 +58,307 @@ public class a_HFSM extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_State1 = 2;
- protected static final int STATE_State2 = 3;
- protected static final int STATE_State2_State1 = 4;
- protected static final int STATE_State2_State2 = 5;
- protected static final int STATE_State3 = 6;
- protected static final int STATE_State4 = 7;
- protected static final String stateStrings[] = {"<no state>","<top>","State1",
- "State2",
- "State2_State1",
- "State2_State2",
- "State3",
- "State4"
- };
+ /* state IDs */
+ public static final int STATE_State1 = 2;
+ public static final int STATE_State2_State1 = 3;
+ public static final int STATE_State2_State2 = 4;
+ public static final int STATE_State3 = 5;
+ public static final int STATE_State4 = 6;
+ public static final int STATE_State2 = 7;
+
+ /* transition chains */
+ public static final int CHAIN_State2_TRANS_State1_TO_State2_BY_m2fct = 1;
+ public static final int CHAIN_State2_TRANS_State2_TO_tp1_BY_m3fct = 2;
+ public static final int CHAIN_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3 = 3;
+ public static final int CHAIN_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4 = 4;
+ public static final int CHAIN_TRANS_INITIAL_TO__State1 = 5;
+ public static final int CHAIN_TRANS_State1_TO_State2_tp0_BY_m1fct = 6;
+ public static final int CHAIN_TRANS_State2_TO_State2_BY_m7fct_tr5 = 7;
+ public static final int CHAIN_TRANS_State2_TO_State4_BY_m4fct = 8;
+ public static final int CHAIN_TRANS_tp0_TO_State1_BY_resetfct = 9;
+ public static final int CHAIN_TRANS_tp1_TO_tp1_BY_m8fct_tr6 = 10;
+ public static final int CHAIN_TRANS_tp2_TO_tp2_BY_m9fct_tr7 = 11;
+
+ /* triggers */
+ public static final int TRIG_fct__m1 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m1;
+ public static final int TRIG_fct__m2 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m2;
+ public static final int TRIG_fct__m3 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m3;
+ public static final int TRIG_fct__m4 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m4;
+ public static final int TRIG_fct__m5 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m5;
+ public static final int TRIG_fct__m6 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m6;
+ public static final int TRIG_fct__m7 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m7;
+ public static final int TRIG_fct__m8 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m8;
+ public static final int TRIG_fct__m9 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m9;
+ public static final int TRIG_fct__reset = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_reset;
+
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","State1",
+ "State2_State1",
+ "State2_State2",
+ "State3",
+ "State4",
+ "State2"
+ };
// 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
- protected static final int CHAIN_State2_TRANS_State1_TO_State2_BY_m2fct = 1;
- protected static final int CHAIN_State2_TRANS_State2_TO_tp1_BY_m3fct = 2;
- protected static final int CHAIN_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3 = 3;
- protected static final int CHAIN_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4 = 4;
- protected static final int CHAIN_TRANS_INITIAL_TO__State1 = 5;
- protected static final int CHAIN_TRANS_State1_TO_State2_tp0_BY_m1fct = 6;
- protected static final int CHAIN_TRANS_State2_TO_State2_BY_m7fct_tr5 = 7;
- protected static final int CHAIN_TRANS_State2_TO_State4_BY_m4fct = 8;
- protected static final int CHAIN_TRANS_tp0_TO_State1_BY_resetfct = 9;
- protected static final int CHAIN_TRANS_tp1_TO_tp1_BY_m8fct_tr6 = 10;
- protected static final int CHAIN_TRANS_tp2_TO_tp2_BY_m9fct_tr7 = 11;
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ //*** Entry and Exit Codes
+ protected void entry_State1() {
+ fct.s1_entry();
+ }
+ protected void exit_State1() {
+ fct.s1_exit();
+ }
+ protected void entry_State2() {
+ fct.s2_entry();
+ }
+ protected void exit_State2() {
+ fct.s2_exit();
+ }
+ protected void entry_State2_State1() {
+ fct.s2s1_entry();
+ }
+ protected void exit_State2_State1() {
+ fct.s2s1_exit();
+ }
+ protected void entry_State2_State2() {
+ fct.s2s2_entry();
+ }
+ protected void exit_State2_State2() {
+ fct.s2s2_exit();
+ }
+ protected void entry_State3() {
+ fct.s3_entry();
+ }
+ protected void exit_State3() {
+ fct.s3_exit();
+ }
+ protected void entry_State4() {
+ fct.s4_entry();
+ }
+ protected void exit_State4() {
+ fct.s4_exit();
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__State1() {
+ fct.init_action();
+ }
+ protected void action_TRANS_State1_TO_State2_tp0_BY_m1fct(InterfaceItemBase ifitem) {
+ fct.s1_m1_s2_action();
+ }
+ protected void action_TRANS_State2_tp1_TO_State3(InterfaceItemBase ifitem) {
+ fct.s2__s3_action();
+ }
+ protected void action_TRANS_State2_TO_State4_BY_m4fct(InterfaceItemBase ifitem) {
+ fct.s2_m4_s4_action();
+ }
+ protected void action_TRANS_tp0_TO_State1_BY_resetfct(InterfaceItemBase ifitem) {
+ fct.top_reset_s2_action();
+ }
+ protected void action_TRANS_State2_TO_State2_BY_m7fct_tr5(InterfaceItemBase ifitem) {
+ fct.s2_m7_s2_action();
+ }
+ protected void action_TRANS_tp1_TO_tp1_BY_m8fct_tr6(InterfaceItemBase ifitem) {
+ fct.top_s8_top_action();
+ }
+ protected void action_TRANS_tp2_TO_tp2_BY_m9fct_tr7(InterfaceItemBase ifitem) {
+ fct.top_s9_top_action();
+ }
+ protected void action_State2_TRANS_tp0_TO_State1(InterfaceItemBase ifitem) {
+ fct.s2_m1_s2s1_action();
+ }
+ protected void action_State2_TRANS_State1_TO_State2_BY_m2fct(InterfaceItemBase ifitem) {
+ fct.s2s1_m2_s2s2_action();
+ }
+ protected void action_State2_TRANS_State2_TO_tp1_BY_m3fct(InterfaceItemBase ifitem) {
+ fct.s2s2_m3_action();
+ }
+ protected void action_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3(InterfaceItemBase ifitem) {
+ fct.s2_m5_s2_action();
+ }
+ protected void action_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4(InterfaceItemBase ifitem) {
+ fct.s2_m6_s2_action();
+ }
+
+ /**
+ * 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_State1:
+ if (!handler) exit_State1();
+ this.history[STATE_TOP] = STATE_State1;
+ current = STATE_TOP;
+ break;
+ case STATE_State2:
+ if (!handler) exit_State2();
+ this.history[STATE_TOP] = STATE_State2;
+ current = STATE_TOP;
+ break;
+ case STATE_State2_State1:
+ if (!handler) exit_State2_State1();
+ this.history[STATE_State2] = STATE_State2_State1;
+ current = STATE_State2;
+ break;
+ case STATE_State2_State2:
+ if (!handler) exit_State2_State2();
+ this.history[STATE_State2] = STATE_State2_State2;
+ current = STATE_State2;
+ break;
+ case STATE_State3:
+ if (!handler) exit_State3();
+ this.history[STATE_TOP] = STATE_State3;
+ current = STATE_TOP;
+ break;
+ case STATE_State4:
+ if (!handler) exit_State4();
+ this.history[STATE_TOP] = STATE_State4;
+ 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__State1:
+ {
+ action_TRANS_INITIAL_TO__State1();
+ return STATE_State1;
+ }
+ case CHAIN_TRANS_State1_TO_State2_tp0_BY_m1fct:
+ {
+ action_TRANS_State1_TO_State2_tp0_BY_m1fct(ifitem);
+ entry_State2();
+ action_State2_TRANS_tp0_TO_State1(ifitem);
+ return STATE_State2_State1;
+ }
+ case CHAIN_TRANS_State2_TO_State4_BY_m4fct:
+ {
+ action_TRANS_State2_TO_State4_BY_m4fct(ifitem);
+ return STATE_State4;
+ }
+ case CHAIN_TRANS_tp0_TO_State1_BY_resetfct:
+ {
+ action_TRANS_tp0_TO_State1_BY_resetfct(ifitem);
+ return STATE_State1;
+ }
+ case CHAIN_TRANS_State2_TO_State2_BY_m7fct_tr5:
+ {
+ action_TRANS_State2_TO_State2_BY_m7fct_tr5(ifitem);
+ return STATE_State2;
+ }
+ case CHAIN_TRANS_tp1_TO_tp1_BY_m8fct_tr6:
+ {
+ action_TRANS_tp1_TO_tp1_BY_m8fct_tr6(ifitem);
+ return STATE_TOP;
+ }
+ case CHAIN_TRANS_tp2_TO_tp2_BY_m9fct_tr7:
+ {
+ action_TRANS_tp2_TO_tp2_BY_m9fct_tr7(ifitem);
+ return STATE_TOP;
+ }
+ case CHAIN_State2_TRANS_State1_TO_State2_BY_m2fct:
+ {
+ action_State2_TRANS_State1_TO_State2_BY_m2fct(ifitem);
+ return STATE_State2_State2;
+ }
+ case CHAIN_State2_TRANS_State2_TO_tp1_BY_m3fct:
+ {
+ action_State2_TRANS_State2_TO_tp1_BY_m3fct(ifitem);
+ exit_State2();
+ action_TRANS_State2_tp1_TO_State3(ifitem);
+ return STATE_State3;
+ }
+ case CHAIN_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3:
+ {
+ action_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3(ifitem);
+ return STATE_State2;
+ }
+ case CHAIN_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4:
+ {
+ action_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4(ifitem);
+ return STATE_State2;
+ }
+ }
+ 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_State1:
+ if (!(skip_entry || handler)) entry_State1();
+ // in leaf state: return state id
+ return STATE_State1;
+ case STATE_State2:
+ if (!(skip_entry || handler)) entry_State2();
+ // state has a sub graph
+ // without init transition
+ state = this.history[STATE_State2];
+ break;
+ case STATE_State2_State1:
+ if (!(skip_entry || handler)) entry_State2_State1();
+ // in leaf state: return state id
+ return STATE_State2_State1;
+ case STATE_State2_State2:
+ if (!(skip_entry || handler)) entry_State2_State2();
+ // in leaf state: return state id
+ return STATE_State2_State2;
+ case STATE_State3:
+ if (!(skip_entry || handler)) entry_State3();
+ // in leaf state: return state id
+ return STATE_State3;
+ case STATE_State4:
+ if (!(skip_entry || handler)) entry_State4();
+ // in leaf state: return state id
+ return STATE_State4;
+ case STATE_TOP:
+ state = this.history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
- // triggers for FSM
- protected static final int TRIG_fct__m1 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m1;
- protected static final int TRIG_fct__m2 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m2;
- protected static final int TRIG_fct__m3 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m3;
- protected static final int TRIG_fct__m4 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m4;
- protected static final int TRIG_fct__m5 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m5;
- protected static final int TRIG_fct__m6 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m6;
- protected static final int TRIG_fct__m7 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m7;
- protected static final int TRIG_fct__m8 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m8;
- protected static final int TRIG_fct__m9 = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_m9;
- protected static final int TRIG_fct__reset = IFITEM_fct + EVT_SHIFT*p_HFSM.IN_reset;
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__State1;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
- // receiveEvent contains the main implementation of the FSM
- @Override
+ /* 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;
@@ -120,7 +367,7 @@ public class a_HFSM extends ActorClassBase {
boolean skip_entry = false;
if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
+ switch (this.state) {
case STATE_State1:
switch(trigger) {
case TRIG_fct__m1:
@@ -321,266 +568,12 @@ public class a_HFSM extends ActorClassBase {
}
}
if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
+ exitTo(this.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__State1;
- 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_State1:
- if (!handler) exit_State1();
- history[STATE_TOP] = STATE_State1;
- current = STATE_TOP;
- break;
- case STATE_State2:
- if (!handler) exit_State2();
- history[STATE_TOP] = STATE_State2;
- current = STATE_TOP;
- break;
- case STATE_State2_State1:
- if (!handler) exit_State2_State1();
- history[STATE_State2] = STATE_State2_State1;
- current = STATE_State2;
- break;
- case STATE_State2_State2:
- if (!handler) exit_State2_State2();
- history[STATE_State2] = STATE_State2_State2;
- current = STATE_State2;
- break;
- case STATE_State3:
- if (!handler) exit_State3();
- history[STATE_TOP] = STATE_State3;
- current = STATE_TOP;
- break;
- case STATE_State4:
- if (!handler) exit_State4();
- history[STATE_TOP] = STATE_State4;
- 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__State1:
- {
- action_TRANS_INITIAL_TO__State1();
- return STATE_State1;
- }
- case CHAIN_TRANS_State1_TO_State2_tp0_BY_m1fct:
- {
- action_TRANS_State1_TO_State2_tp0_BY_m1fct(ifitem);
- entry_State2();
- action_State2_TRANS_tp0_TO_State1(ifitem);
- return STATE_State2_State1;
- }
- case CHAIN_TRANS_State2_TO_State4_BY_m4fct:
- {
- action_TRANS_State2_TO_State4_BY_m4fct(ifitem);
- return STATE_State4;
- }
- case CHAIN_TRANS_tp0_TO_State1_BY_resetfct:
- {
- action_TRANS_tp0_TO_State1_BY_resetfct(ifitem);
- return STATE_State1;
- }
- case CHAIN_TRANS_State2_TO_State2_BY_m7fct_tr5:
- {
- action_TRANS_State2_TO_State2_BY_m7fct_tr5(ifitem);
- return STATE_State2;
- }
- case CHAIN_TRANS_tp1_TO_tp1_BY_m8fct_tr6:
- {
- action_TRANS_tp1_TO_tp1_BY_m8fct_tr6(ifitem);
- return STATE_TOP;
- }
- case CHAIN_TRANS_tp2_TO_tp2_BY_m9fct_tr7:
- {
- action_TRANS_tp2_TO_tp2_BY_m9fct_tr7(ifitem);
- return STATE_TOP;
- }
- case CHAIN_State2_TRANS_State1_TO_State2_BY_m2fct:
- {
- action_State2_TRANS_State1_TO_State2_BY_m2fct(ifitem);
- return STATE_State2_State2;
- }
- case CHAIN_State2_TRANS_State2_TO_tp1_BY_m3fct:
- {
- action_State2_TRANS_State2_TO_tp1_BY_m3fct(ifitem);
- exit_State2();
- action_TRANS_State2_tp1_TO_State3(ifitem);
- return STATE_State3;
- }
- case CHAIN_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3:
- {
- action_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3(ifitem);
- return STATE_State2;
- }
- case CHAIN_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4:
- {
- action_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4(ifitem);
- return STATE_State2;
- }
- }
- 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_State1:
- if (!(skip_entry || handler)) entry_State1();
- // in leaf state: return state id
- return STATE_State1;
- case STATE_State2:
- if (!(skip_entry || handler)) entry_State2();
- // state has a sub graph
- // without init transition
- state = history[STATE_State2];
- break;
- case STATE_State2_State1:
- if (!(skip_entry || handler)) entry_State2_State1();
- // in leaf state: return state id
- return STATE_State2_State1;
- case STATE_State2_State2:
- if (!(skip_entry || handler)) entry_State2_State2();
- // in leaf state: return state id
- return STATE_State2_State2;
- case STATE_State3:
- if (!(skip_entry || handler)) entry_State3();
- // in leaf state: return state id
- return STATE_State3;
- case STATE_State4:
- if (!(skip_entry || handler)) entry_State4();
- // in leaf state: return state id
- return STATE_State4;
- 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
- protected void entry_State1() {
- fct.s1_entry();
- }
- protected void exit_State1() {
- fct.s1_exit();
- }
- protected void entry_State2() {
- fct.s2_entry();
- }
- protected void exit_State2() {
- fct.s2_exit();
- }
- protected void entry_State2_State1() {
- fct.s2s1_entry();
- }
- protected void exit_State2_State1() {
- fct.s2s1_exit();
- }
- protected void entry_State2_State2() {
- fct.s2s2_entry();
- }
- protected void exit_State2_State2() {
- fct.s2s2_exit();
- }
- protected void entry_State3() {
- fct.s3_entry();
- }
- protected void exit_State3() {
- fct.s3_exit();
- }
- protected void entry_State4() {
- fct.s4_entry();
- }
- protected void exit_State4() {
- fct.s4_exit();
- }
-
- //*** Action Codes
- protected void action_TRANS_INITIAL_TO__State1() {
- fct.init_action();
- }
- protected void action_TRANS_State1_TO_State2_tp0_BY_m1fct(InterfaceItemBase ifitem) {
- fct.s1_m1_s2_action();
- }
- protected void action_TRANS_State2_tp1_TO_State3(InterfaceItemBase ifitem) {
- fct.s2__s3_action();
- }
- protected void action_TRANS_State2_TO_State4_BY_m4fct(InterfaceItemBase ifitem) {
- fct.s2_m4_s4_action();
- }
- protected void action_TRANS_tp0_TO_State1_BY_resetfct(InterfaceItemBase ifitem) {
- fct.top_reset_s2_action();
- }
- protected void action_TRANS_State2_TO_State2_BY_m7fct_tr5(InterfaceItemBase ifitem) {
- fct.s2_m7_s2_action();
- }
- protected void action_TRANS_tp1_TO_tp1_BY_m8fct_tr6(InterfaceItemBase ifitem) {
- fct.top_s8_top_action();
- }
- protected void action_TRANS_tp2_TO_tp2_BY_m9fct_tr7(InterfaceItemBase ifitem) {
- fct.top_s9_top_action();
- }
- protected void action_State2_TRANS_tp0_TO_State1(InterfaceItemBase ifitem) {
- fct.s2_m1_s2s1_action();
- }
- protected void action_State2_TRANS_State1_TO_State2_BY_m2fct(InterfaceItemBase ifitem) {
- fct.s2s1_m2_s2s2_action();
- }
- protected void action_State2_TRANS_State2_TO_tp1_BY_m3fct(InterfaceItemBase ifitem) {
- fct.s2s2_m3_action();
- }
- protected void action_State2_TRANS_tp3_TO_tp3_BY_m5fct_tr3(InterfaceItemBase ifitem) {
- fct.s2_m5_s2_action();
- }
- protected void action_State2_TRANS_tp4_TO_tp4_BY_m6fct_tr4(InterfaceItemBase ifitem) {
- fct.s2_m6_s2_action();
- }
//******************************************
// END of generated code for FSM
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java
index ff1b43a98..4b2fc9419 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tester.java
@@ -25,8 +25,8 @@ public class a_HFSM_Tester extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
- protected static final int IFITEM_testee = 1;
-
+ public static final int IFITEM_testee = 1;
+
//--------------------- attributes
//--------------------- operations
@@ -61,164 +61,66 @@ public class a_HFSM_Tester extends ActorClassBase {
destroyUser();
}
- //******************************************
- // START of generated code for FSM
- //******************************************
- // State IDs for FSM
- protected static final int STATE_State1 = 2;
- protected static final int STATE_State2 = 3;
- protected static final int STATE_State3 = 4;
- protected static final int STATE_State4 = 5;
- protected static final int STATE_State5 = 6;
- protected static final int STATE_State6 = 7;
- protected static final int STATE_State7 = 8;
- protected static final int STATE_TestPass = 9;
- protected static final String stateStrings[] = {"<no state>","<top>","State1",
- "State2",
- "State3",
- "State4",
- "State5",
- "State6",
- "State7",
- "TestPass"
- };
+ /* state IDs */
+ public static final int STATE_State1 = 2;
+ public static final int STATE_State2 = 3;
+ public static final int STATE_State3 = 4;
+ public static final int STATE_State4 = 5;
+ public static final int STATE_State5 = 6;
+ public static final int STATE_State6 = 7;
+ public static final int STATE_State7 = 8;
+ public static final int STATE_TestPass = 9;
- // 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,NO_STATE,NO_STATE};
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__State1 = 1;
+ public static final int CHAIN_TRANS_State1_TO_State2_BY_init_actiontestee = 2;
+ public static final int CHAIN_TRANS_State2_TO_State3_BY_s1_entrytestee = 3;
+ public static final int CHAIN_TRANS_State3_TO_State4_BY_s1_exittestee = 4;
+ public static final int CHAIN_TRANS_State4_TO_State5_BY_s1_m1_s2_actiontestee = 5;
+ public static final int CHAIN_TRANS_State5_TO_State6_BY_s2_entrytestee = 6;
+ public static final int CHAIN_TRANS_State6_TO_State7_BY_s2_m1_s2s1_actiontestee = 7;
+ public static final int CHAIN_TRANS_State7_TO_TestPass_BY_s2s1_entrytestee = 8;
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__State1 = 1;
- protected static final int CHAIN_TRANS_State1_TO_State2_BY_init_actiontestee = 2;
- protected static final int CHAIN_TRANS_State2_TO_State3_BY_s1_entrytestee = 3;
- protected static final int CHAIN_TRANS_State3_TO_State4_BY_s1_exittestee = 4;
- protected static final int CHAIN_TRANS_State4_TO_State5_BY_s1_m1_s2_actiontestee = 5;
- protected static final int CHAIN_TRANS_State5_TO_State6_BY_s2_entrytestee = 6;
- protected static final int CHAIN_TRANS_State6_TO_State7_BY_s2_m1_s2s1_actiontestee = 7;
- protected static final int CHAIN_TRANS_State7_TO_TestPass_BY_s2s1_entrytestee = 8;
+ /* triggers */
+ public static final int TRIG_testee__init_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_init_action;
+ public static final int TRIG_testee__s1_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_entry;
+ public static final int TRIG_testee__s1_exit = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_exit;
+ public static final int TRIG_testee__s1_m1_s2_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_m1_s2_action;
+ public static final int TRIG_testee__s2_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2_entry;
+ public static final int TRIG_testee__s2_m1_s2s1_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2_m1_s2s1_action;
+ public static final int TRIG_testee__s2s1_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2s1_entry;
- // triggers for FSM
- protected static final int TRIG_testee__init_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_init_action;
- protected static final int TRIG_testee__s1_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_entry;
- protected static final int TRIG_testee__s1_exit = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_exit;
- protected static final int TRIG_testee__s1_m1_s2_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s1_m1_s2_action;
- protected static final int TRIG_testee__s2_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2_entry;
- protected static final int TRIG_testee__s2_m1_s2s1_action = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2_m1_s2s1_action;
- protected static final int TRIG_testee__s2s1_entry = IFITEM_testee + EVT_SHIFT*p_HFSM.OUT_s2s1_entry;
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","State1",
+ "State2",
+ "State3",
+ "State4",
+ "State5",
+ "State6",
+ "State7",
+ "TestPass"
+ };
- // 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_State1:
- switch(trigger) {
- case TRIG_testee__init_action:
- {
- chain = CHAIN_TRANS_State1_TO_State2_BY_init_actiontestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State2:
- switch(trigger) {
- case TRIG_testee__s1_entry:
- {
- chain = CHAIN_TRANS_State2_TO_State3_BY_s1_entrytestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State3:
- switch(trigger) {
- case TRIG_testee__s1_exit:
- {
- chain = CHAIN_TRANS_State3_TO_State4_BY_s1_exittestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State4:
- switch(trigger) {
- case TRIG_testee__s1_m1_s2_action:
- {
- chain = CHAIN_TRANS_State4_TO_State5_BY_s1_m1_s2_actiontestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State5:
- switch(trigger) {
- case TRIG_testee__s2_entry:
- {
- chain = CHAIN_TRANS_State5_TO_State6_BY_s2_entrytestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State6:
- switch(trigger) {
- case TRIG_testee__s2_m1_s2s1_action:
- {
- chain = CHAIN_TRANS_State6_TO_State7_BY_s2_m1_s2s1_actiontestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_State7:
- switch(trigger) {
- case TRIG_testee__s2s1_entry:
- {
- chain = CHAIN_TRANS_State7_TO_TestPass_BY_s2s1_entrytestee;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_TestPass:
- 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,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__State1;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
+ //*** Entry and Exit Codes
+ protected void entry_TestPass() {
+ RTServices.getInstance().getSubSystem().testFinished(0);
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_State2_TO_State3_BY_s1_entrytestee(InterfaceItemBase ifitem) {
+ testee.m1();
}
/**
@@ -232,40 +134,41 @@ public class a_HFSM_Tester extends ActorClassBase {
while (current!=to) {
switch (current) {
case STATE_State1:
- history[STATE_TOP] = STATE_State1;
+ this.history[STATE_TOP] = STATE_State1;
current = STATE_TOP;
break;
case STATE_State2:
- history[STATE_TOP] = STATE_State2;
+ this.history[STATE_TOP] = STATE_State2;
current = STATE_TOP;
break;
case STATE_State3:
- history[STATE_TOP] = STATE_State3;
+ this.history[STATE_TOP] = STATE_State3;
current = STATE_TOP;
break;
case STATE_State4:
- history[STATE_TOP] = STATE_State4;
+ this.history[STATE_TOP] = STATE_State4;
current = STATE_TOP;
break;
case STATE_State5:
- history[STATE_TOP] = STATE_State5;
+ this.history[STATE_TOP] = STATE_State5;
current = STATE_TOP;
break;
case STATE_State6:
- history[STATE_TOP] = STATE_State6;
+ this.history[STATE_TOP] = STATE_State6;
current = STATE_TOP;
break;
case STATE_State7:
- history[STATE_TOP] = STATE_State7;
+ this.history[STATE_TOP] = STATE_State7;
current = STATE_TOP;
break;
case STATE_TestPass:
- history[STATE_TOP] = STATE_TestPass;
+ this.history[STATE_TOP] = STATE_TestPass;
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
@@ -311,6 +214,7 @@ public class a_HFSM_Tester 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
@@ -346,7 +250,7 @@ public class a_HFSM_Tester extends ActorClassBase {
// in leaf state: return state id
return STATE_TestPass;
case STATE_TOP:
- state = history[STATE_TOP];
+ state = this.history[STATE_TOP];
break;
}
skip_entry = false;
@@ -354,14 +258,103 @@ public class a_HFSM_Tester 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_TestPass() {
- RTServices.getInstance().getSubSystem().testFinished(0);
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__State1;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
}
- //*** Action Codes
- protected void action_TRANS_State2_TO_State3_BY_s1_entrytestee(InterfaceItemBase ifitem) {
- testee.m1();
+ /* 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_State1:
+ switch(trigger) {
+ case TRIG_testee__init_action:
+ {
+ chain = CHAIN_TRANS_State1_TO_State2_BY_init_actiontestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State2:
+ switch(trigger) {
+ case TRIG_testee__s1_entry:
+ {
+ chain = CHAIN_TRANS_State2_TO_State3_BY_s1_entrytestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State3:
+ switch(trigger) {
+ case TRIG_testee__s1_exit:
+ {
+ chain = CHAIN_TRANS_State3_TO_State4_BY_s1_exittestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State4:
+ switch(trigger) {
+ case TRIG_testee__s1_m1_s2_action:
+ {
+ chain = CHAIN_TRANS_State4_TO_State5_BY_s1_m1_s2_actiontestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State5:
+ switch(trigger) {
+ case TRIG_testee__s2_entry:
+ {
+ chain = CHAIN_TRANS_State5_TO_State6_BY_s2_entrytestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State6:
+ switch(trigger) {
+ case TRIG_testee__s2_m1_s2s1_action:
+ {
+ chain = CHAIN_TRANS_State6_TO_State7_BY_s2_m1_s2s1_actiontestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_State7:
+ switch(trigger) {
+ case TRIG_testee__s2s1_entry:
+ {
+ chain = CHAIN_TRANS_State7_TO_TestPass_BY_s2s1_entrytestee;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_TestPass:
+ 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/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java
index 5d51299dc..518f21e34 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/a_HFSM_Tests.java
@@ -20,7 +20,7 @@ public class a_HFSM_Tests extends ActorClassBase {
//--------------------- services
//--------------------- interface item IDs
-
+
//--------------------- attributes
//--------------------- operations
diff --git a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java
index 6358a0aa9..17ddad4c2 100644
--- a/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java
+++ b/tests/org.eclipse.etrice.integration.tests/src-gen/org/eclipse/etrice/integration/tests/p_HFSM.java
@@ -11,10 +11,7 @@ import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
public class p_HFSM {
// 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_init_action = 1;
public static final int OUT_s1_entry = 2;
public static final int OUT_s1_exit = 3;
@@ -40,7 +37,6 @@ public class p_HFSM {
public static final int OUT_top_s8_top_action = 23;
public static final int OUT_top_s9_top_action = 24;
public static final int OUT_top_reset_s2_action = 25;
- //IDs for incoming messages
public static final int IN_m1 = 26;
public static final int IN_m2 = 27;
public static final int IN_m3 = 28;
@@ -51,8 +47,7 @@ public class p_HFSM {
public static final int IN_m7 = 33;
public static final int IN_m8 = 34;
public static final int IN_m9 = 35;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 36;
+ public static final int MSG_MAX = 36;
private static String messageStrings[] = {"MIN", "init_action","s1_entry","s1_exit","s2_entry","s2_exit","s3_entry","s3_exit","s4_entry","s4_exit","s2s1_entry","s2s1_exit","s2s2_entry","s2s2_exit","s1_m1_s2_action","s2_m1_s2s1_action","s2s1_m2_s2s2_action","s2s2_m3_action","s2_m4_s4_action","s2_m5_s2_action","s2_m6_s2_action","s2__s3_action","s2_m7_s2_action","top_s8_top_action","top_s9_top_action","top_reset_s2_action", "m1","m2","m3","m4","m5","m6","reset","m7","m8","m9","MAX"};
diff --git a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java
index 14f478bf0..6bec2d712 100644
--- a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java
+++ b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassBaseTest.java
@@ -14,7 +14,6 @@ import org.eclipse.etrice.runtime.java.messaging.Message;
import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTServices;
import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
-import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
import junit.framework.TestCase;
diff --git a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java
index 0c4993802..da792e661 100644
--- a/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java
+++ b/tests/org.eclipse.etrice.runtime.java.tests/src/org/eclipse/etrice/runtime/java/modelbase/PortBaseTest.java
@@ -31,10 +31,7 @@ public class PortBaseTest extends TestCase {
}
@Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt,
- Object data) {
- // TODO Auto-generated method stub
-
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
}
}

Back to the top