Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-09-15 16:06:47 +0000
committerHenrik Rentz-Reichert2011-09-15 16:06:47 +0000
commit49a683cce734e84421fb1dd2ebf9dbadaf51994f (patch)
tree80e18a7ad0d919f3ac6c5846e7b9d070c35f5176 /examples
parentcd303d15477d33c120dae5e0f5d6314138d4bd50 (diff)
downloadorg.eclipse.etrice-49a683cce734e84421fb1dd2ebf9dbadaf51994f.tar.gz
org.eclipse.etrice-49a683cce734e84421fb1dd2ebf9dbadaf51994f.tar.xz
org.eclipse.etrice-49a683cce734e84421fb1dd2ebf9dbadaf51994f.zip
[tutorials, integration.tests, modellib] changed gitignore and added generated files
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.etrice.tutorials/.gitignore1
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/Blinky.java324
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyControlProtocoll.java213
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyController.java242
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyTop.java66
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/SubSystem_Blinky.java163
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/Blinky/SubSystem_BlinkyRunner.java36
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/HelloWorldTop.java184
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/SubSystem_HelloWorld.java69
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/SubSystem_HelloWorldRunner.java36
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/Controller.java362
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/GuiAdapter.java239
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedControlProtocol.java232
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedLightsTop.java66
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/SubSys_PedLights.java153
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/SubSys_PedLightsRunner.java36
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/DemoData.java49
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPing.java276
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPong.java220
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/PingPongProtocol.java251
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingDataTop.java66
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingData_SubSystem.java117
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingData_SubSystemRunner.java36
-rw-r--r--examples/org.eclipse.etrice.tutorials/src-gen/readme.txt4
24 files changed, 3440 insertions, 1 deletions
diff --git a/examples/org.eclipse.etrice.tutorials/.gitignore b/examples/org.eclipse.etrice.tutorials/.gitignore
index 4bd2f9ef0..092357e47 100644
--- a/examples/org.eclipse.etrice.tutorials/.gitignore
+++ b/examples/org.eclipse.etrice.tutorials/.gitignore
@@ -1,2 +1 @@
bin
-src-gen/*
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/Blinky.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/Blinky.java
new file mode 100644
index 000000000..513782f81
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/Blinky.java
@@ -0,0 +1,324 @@
+package Blinky;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+import room.basic.service.timing.*;
+
+import Blinky.BlinkyControlProtocoll.*;
+import room.basic.service.timing.PTimeout.*;
+
+//--------------------- begin user code
+ import org.eclipse.etrice.tutorials.PedLightGUI.*;
+ //--------------------- end user code
+
+
+public class Blinky extends ActorClassBase {
+
+ //--------------------- begin user code
+ private PedestrianLightWndNoTcp light = new PedestrianLightWndNoTcp();
+ private TrafficLight3 carLights;
+ private TrafficLight2 pedLights;
+ //--------------------- end user code
+
+ //--------------------- ports
+ protected BlinkyControlProtocollPort ControlPort = null;
+ //--------------------- saps
+ protected PTimeoutConjPort timer = null;
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_ControlPort = 1;
+ protected static final int IFITEM_timer = 2;
+
+ //--------------------- attributes
+ //--------------------- operations
+ public void destroyUser (){
+ light.closeWindow();
+ }
+
+ //--------------------- construction
+ public Blinky(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("Blinky");
+
+ // initialize attributes
+
+ // own ports
+ ControlPort = new BlinkyControlProtocollPort(this, "ControlPort", IFITEM_ControlPort, 0, port_addr[IFITEM_ControlPort][0], peer_addr[IFITEM_ControlPort][0]);
+ // own saps
+ timer = new PTimeoutConjPort(this, "timer", IFITEM_timer, 0, port_addr[IFITEM_timer][0], peer_addr[IFITEM_timer][0]);
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_off = 2;
+ protected static final int STATE_blinking = 3;
+ protected static final int STATE_blinking_on = 4;
+ protected static final int STATE_blinking_off = 5;
+ protected static final String stateStrings[] = {"<no state>","<top>","off",
+ "blinking",
+ "blinking_on",
+ "blinking_off"
+ };
+
+ // history
+ // TODOHRR: history defined in ActorClassBase, init in constructor
+ // history = new int[5];
+ // for (int i = 0; i < history.length; i++) {
+ // history[i] = NO_STATE;
+ // }
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+
+ // transition chains
+ protected static final int CHAIN_TRANS_INITIAL_TO__off = 1;
+ protected static final int CHAIN_TRANS_blinking_TO_off_BY_stopControlPort = 2;
+ protected static final int CHAIN_TRANS_off_TO_blinking_tp0_BY_startControlPort = 3;
+ protected static final int CHAIN_blinking_TRANS_INITIAL_TO__on = 4;
+ protected static final int CHAIN_blinking_TRANS_off_TO_on_BY_timeoutTicktimer = 5;
+ protected static final int CHAIN_blinking_TRANS_on_TO_off_BY_timeoutTicktimer = 6;
+
+ // triggers for FSM
+ protected static final int TRIG_ControlPort__start = IFITEM_ControlPort + EVT_SHIFT*BlinkyControlProtocoll.IN_start;
+ protected static final int TRIG_ControlPort__stop = IFITEM_ControlPort + EVT_SHIFT*BlinkyControlProtocoll.IN_stop;
+ protected static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
+
+ // receiveEvent contains the main implementation of the FSM
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (state) {
+ case STATE_off:
+ switch(trigger) {
+ case TRIG_ControlPort__start:
+ {
+ chain = CHAIN_TRANS_off_TO_blinking_tp0_BY_startControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_blinking_on:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_blinking_TRANS_on_TO_off_BY_timeoutTicktimer;
+ catching_state = STATE_blinking;
+ }
+ break;
+ case TRIG_ControlPort__stop:
+ {
+ chain = CHAIN_TRANS_blinking_TO_off_BY_stopControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_blinking_off:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_blinking_TRANS_off_TO_on_BY_timeoutTicktimer;
+ catching_state = STATE_blinking;
+ }
+ break;
+ case TRIG_ControlPort__stop:
+ {
+ chain = CHAIN_TRANS_blinking_TO_off_BY_stopControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ // TODOTS: model switch for activation
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ @Override
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__off;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /**
+ * 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_off:
+ history[STATE_TOP] = STATE_off;
+ current = STATE_TOP;
+ break;
+ case STATE_blinking:
+ history[STATE_TOP] = STATE_blinking;
+ current = STATE_TOP;
+ break;
+ case STATE_blinking_on:
+ history[STATE_blinking] = STATE_blinking_on;
+ current = STATE_blinking;
+ break;
+ case STATE_blinking_off:
+ history[STATE_blinking] = STATE_blinking_off;
+ current = STATE_blinking;
+ break;
+ }
+ }
+ }
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @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__off:
+ {
+ action_TRANS_INITIAL_TO__off();
+ return STATE_off;
+ }
+ case CHAIN_TRANS_off_TO_blinking_tp0_BY_startControlPort:
+ {
+ return STATE_blinking_on;
+ }
+ case CHAIN_TRANS_blinking_TO_off_BY_stopControlPort:
+ {
+ action_TRANS_blinking_TO_off_BY_stopControlPort(ifitem);
+ return STATE_off;
+ }
+ case CHAIN_blinking_TRANS_on_TO_off_BY_timeoutTicktimer:
+ {
+ return STATE_blinking_off;
+ }
+ case CHAIN_blinking_TRANS_off_TO_on_BY_timeoutTicktimer:
+ {
+ return STATE_blinking_on;
+ }
+ case CHAIN_blinking_TRANS_INITIAL_TO__on:
+ {
+ return STATE_blinking_on;
+ }
+ }
+ 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_off:
+ // in leaf state: return state id
+ return STATE_off;
+ case STATE_blinking:
+ // state has a sub graph
+ // with init transition
+ if (history[STATE_blinking]==NO_STATE) {
+ state = executeTransitionChain(CHAIN_TRANS_INITIAL_TO__off, null, null);
+ }
+ else {
+ state = history[STATE_blinking];
+ }
+ break;
+ case STATE_blinking_on:
+ if (!(skip_entry || handler)) entry_blinking_on();
+ // in leaf state: return state id
+ return STATE_blinking_on;
+ case STATE_blinking_off:
+ if (!(skip_entry || handler)) entry_blinking_off();
+ // in leaf state: return state id
+ return STATE_blinking_off;
+ 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_blinking_on() {
+ timer.Start(1000);
+ carLights.setState(TrafficLight3.YELLOW);
+ }
+ protected void entry_blinking_off() {
+ timer.Start(1000);
+ carLights.setState(TrafficLight3.OFF);
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__off() {
+ carLights = light.getCarLights();
+ pedLights = light.getPedLights();
+ carLights.setState(TrafficLight3.OFF);
+ pedLights.setState(TrafficLight2.OFF);
+ }
+ protected void action_TRANS_blinking_TO_off_BY_stopControlPort(InterfaceItemBase ifitem) {
+ timer.Kill();
+ carLights.setState(TrafficLight3.OFF);
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyControlProtocoll.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyControlProtocoll.java
new file mode 100644
index 000000000..8696ffde7
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyControlProtocoll.java
@@ -0,0 +1,213 @@
+package Blinky;
+
+import java.util.ArrayList;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.Message;
+import org.eclipse.etrice.runtime.java.modelbase.*;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+
+public class BlinkyControlProtocoll {
+ // message IDs
+ // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
+ // error if msgID <= MSG_MIN
+ public static final int MSG_MIN = 0;
+ //IDs for outgoing messages
+ //IDs for incoming messages
+ public static final int IN_start = 1;
+ public static final int IN_stop = 2;
+ //error if msgID >= MSG_MAX
+ public static final int MSG_MAX = 3;
+
+
+ private static String messageStrings[] = {"MIN", "start","stop","MAX"};
+
+ public String getMessageString(int msg_id) {
+ if (msg_id<0 || msg_id>MSG_MAX+1){
+ // id out of range
+ return "Message ID out of range";
+ }
+ else{
+ return messageStrings[msg_id];
+ }
+ }
+
+
+ // port class
+ static public class BlinkyControlProtocollPort extends PortBase {
+ // constructors
+ public BlinkyControlProtocollPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public BlinkyControlProtocollPort(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
+ super(actor, name, localId, idx, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+
+ @Override
+ public void receive(Message m) {
+ if (!(m instanceof EventMessage))
+ return;
+ EventMessage msg = (EventMessage) m;
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ System.out.println("unknown");
+ else {
+ if (messageStrings[msg.getEvtId()] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
+ }
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+
+
+ // sent messages
+ }
+
+ // replicated port class
+ static public class BlinkyControlProtocollPortRepl {
+ private ArrayList<BlinkyControlProtocollPort> ports;
+ private int replication;
+
+ public BlinkyControlProtocollPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<BlinkyControlProtocoll.BlinkyControlProtocollPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new BlinkyControlProtocollPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public BlinkyControlProtocollPort get(int i) {
+ return ports.get(i);
+ }
+
+ // outgoing messages
+ }
+
+ // interface for port class
+ public interface IBlinkyControlProtocollPort{
+ // incoming messages
+ public void start ()
+ ;
+ public void stop ()
+ ;
+ }
+
+ // port class
+ static public class BlinkyControlProtocollConjPort extends PortBase {
+ // constructors
+ public BlinkyControlProtocollConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public BlinkyControlProtocollConjPort(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
+ super(actor, name, localId, idx, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+
+ @Override
+ public void receive(Message m) {
+ if (!(m instanceof EventMessage))
+ return;
+ EventMessage msg = (EventMessage) m;
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ System.out.println("unknown");
+ else {
+ if (messageStrings[msg.getEvtId()] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
+ }
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+
+
+ // sent messages
+ public void start ()
+ {
+ if (messageStrings[ IN_start] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_start]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_start));
+ }
+ public void stop ()
+ {
+ if (messageStrings[ IN_stop] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_stop]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_stop));
+ }
+ }
+
+ // replicated port class
+ static public class BlinkyControlProtocollConjPortRepl {
+ private ArrayList<BlinkyControlProtocollConjPort> ports;
+ private int replication;
+
+ public BlinkyControlProtocollConjPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<BlinkyControlProtocoll.BlinkyControlProtocollConjPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new BlinkyControlProtocollConjPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public BlinkyControlProtocollConjPort get(int i) {
+ return ports.get(i);
+ }
+
+ // incoming messages
+ public void start ()
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).start()
+ ;
+ }
+ }
+ public void stop ()
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).stop()
+ ;
+ }
+ }
+ }
+
+ // interface for port class
+ public interface IBlinkyControlProtocollConjPort{
+ // outgoing messages
+ }
+}
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyController.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyController.java
new file mode 100644
index 000000000..24d32080e
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyController.java
@@ -0,0 +1,242 @@
+package Blinky;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+import room.basic.service.timing.*;
+
+import Blinky.BlinkyControlProtocoll.*;
+import room.basic.service.timing.PTimeout.*;
+
+
+
+public class BlinkyController extends ActorClassBase {
+
+
+ //--------------------- ports
+ protected BlinkyControlProtocollConjPort ControlPort = null;
+ //--------------------- saps
+ protected PTimeoutConjPort timer = null;
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_ControlPort = 1;
+ protected static final int IFITEM_timer = 2;
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ //--------------------- construction
+ public BlinkyController(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("BlinkyController");
+
+ // initialize attributes
+
+ // own ports
+ ControlPort = new BlinkyControlProtocollConjPort(this, "ControlPort", IFITEM_ControlPort, 0, port_addr[IFITEM_ControlPort][0], peer_addr[IFITEM_ControlPort][0]);
+ // own saps
+ timer = new PTimeoutConjPort(this, "timer", IFITEM_timer, 0, port_addr[IFITEM_timer][0], peer_addr[IFITEM_timer][0]);
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_on = 2;
+ protected static final int STATE_off = 3;
+ protected static final String stateStrings[] = {"<no state>","<top>","on",
+ "off"
+ };
+
+ // history
+ // TODOHRR: history defined in ActorClassBase, init in constructor
+ // history = new int[5];
+ // for (int i = 0; i < history.length; i++) {
+ // history[i] = NO_STATE;
+ // }
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+
+ // transition chains
+ protected static final int CHAIN_TRANS_INITIAL_TO__on = 1;
+ protected static final int CHAIN_TRANS_off_TO_on_BY_timeoutTicktimer = 2;
+ protected static final int CHAIN_TRANS_on_TO_off_BY_timeoutTicktimer = 3;
+
+ // triggers for FSM
+ protected static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
+
+ // receiveEvent contains the main implementation of the FSM
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (state) {
+ case STATE_on:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_on_TO_off_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_off:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_off_TO_on_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ // TODOTS: model switch for activation
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ @Override
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__on;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /**
+ * 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_on:
+ history[STATE_TOP] = STATE_on;
+ current = STATE_TOP;
+ break;
+ case STATE_off:
+ history[STATE_TOP] = STATE_off;
+ current = STATE_TOP;
+ break;
+ }
+ }
+ }
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @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__on:
+ {
+ action_TRANS_INITIAL_TO__on();
+ return STATE_on;
+ }
+ case CHAIN_TRANS_on_TO_off_BY_timeoutTicktimer:
+ {
+ action_TRANS_on_TO_off_BY_timeoutTicktimer(ifitem);
+ return STATE_off;
+ }
+ case CHAIN_TRANS_off_TO_on_BY_timeoutTicktimer:
+ {
+ action_TRANS_off_TO_on_BY_timeoutTicktimer(ifitem);
+ return STATE_on;
+ }
+ }
+ 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_on:
+ // in leaf state: return state id
+ return STATE_on;
+ case STATE_off:
+ // in leaf state: return state id
+ return STATE_off;
+ case STATE_TOP:
+ state = history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__on() {
+ timer.Start(5000);
+ ControlPort.start();
+ }
+ protected void action_TRANS_on_TO_off_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ ControlPort.stop();
+ timer.Start(5000);
+ }
+ protected void action_TRANS_off_TO_on_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ ControlPort.start();
+ timer.Start(5000);
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyTop.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyTop.java
new file mode 100644
index 000000000..387367025
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/BlinkyTop.java
@@ -0,0 +1,66 @@
+package Blinky;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+
+
+
+public class BlinkyTop extends ActorClassBase {
+
+
+ //--------------------- ports
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ //--------------------- construction
+ public BlinkyTop(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("BlinkyTop");
+
+ // initialize attributes
+
+ // own ports
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //--------------------- no state machine
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
+ handleSystemEvent(ifitem, evt, data);
+ }
+
+ @Override
+ public void executeInitTransition(){
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/SubSystem_Blinky.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/SubSystem_Blinky.java
new file mode 100644
index 000000000..0d045dae7
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/SubSystem_Blinky.java
@@ -0,0 +1,163 @@
+package Blinky;
+
+import org.eclipse.etrice.runtime.java.messaging.MessageService;
+import org.eclipse.etrice.runtime.java.messaging.RTServices;
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+
+import room.basic.service.timing.*;
+
+
+
+public class SubSystem_Blinky extends SubSystemClassBase{
+
+
+ public SubSystem_Blinky(IRTObject parent, String name) {
+ super(parent, name);
+ }
+
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){
+ }
+
+ @Override
+ public void instantiateMessageServices(){
+
+ RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main"));
+ }
+
+ @Override
+ public void instantiateActors(){
+ // all addresses
+ // Addresses for the Subsystem Systemport
+ Address addr_item_SystemPort_0 = new Address(0,0,111);
+ Address addr_item_SystemPort_1 = new Address(0,0,112);
+ Address addr_item_SystemPort_2 = new Address(0,0,113);
+ Address addr_item_SystemPort_3 = new Address(0,0,114);
+
+ // actor instance /SubSystem_Blinky/application itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SubSystem_Blinky_application = new Address(0,0,101);
+ // interface items of /SubSystem_Blinky/application
+ // actor instance /SubSystem_Blinky/application/blinky itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SubSystem_Blinky_application_blinky = new Address(0,0,102);
+ // interface items of /SubSystem_Blinky/application/blinky
+ Address addr_item__SubSystem_Blinky_application_blinky_ControlPort = new Address(0,0,103);
+ Address addr_item__SubSystem_Blinky_application_blinky_timer = new Address(0,0,104);
+ // actor instance /SubSystem_Blinky/application/controller itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SubSystem_Blinky_application_controller = new Address(0,0,105);
+ // interface items of /SubSystem_Blinky/application/controller
+ Address addr_item__SubSystem_Blinky_application_controller_ControlPort = new Address(0,0,106);
+ Address addr_item__SubSystem_Blinky_application_controller_timer = new Address(0,0,107);
+ // actor instance /SubSystem_Blinky/timingService itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SubSystem_Blinky_timingService = new Address(0,0,108);
+ // interface items of /SubSystem_Blinky/timingService
+ Address addr_item__SubSystem_Blinky_timingService_timeout_0 = new Address(0,0,109);
+ Address addr_item__SubSystem_Blinky_timingService_timeout_1 = new Address(0,0,110);
+
+ // instantiate all actor instances
+ instances = new ActorClassBase[4];
+ instances[0] = new BlinkyTop(
+ this,
+ "application",
+ // own interface item addresses
+ new Address[][] {{addr_item__SubSystem_Blinky_application}
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_0}
+ }
+ );
+ instances[1] = new Blinky(
+ instances[0],
+ "blinky",
+ // own interface item addresses
+ new Address[][] {{addr_item__SubSystem_Blinky_application_blinky},
+ {
+ addr_item__SubSystem_Blinky_application_blinky_ControlPort
+ },
+ {
+ addr_item__SubSystem_Blinky_application_blinky_timer
+ }
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_1},
+ {
+ addr_item__SubSystem_Blinky_application_controller_ControlPort
+ },
+ {
+ addr_item__SubSystem_Blinky_timingService_timeout_0
+ }
+ }
+ );
+ instances[2] = new BlinkyController(
+ instances[0],
+ "controller",
+ // own interface item addresses
+ new Address[][] {{addr_item__SubSystem_Blinky_application_controller},
+ {
+ addr_item__SubSystem_Blinky_application_controller_ControlPort
+ },
+ {
+ addr_item__SubSystem_Blinky_application_controller_timer
+ }
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_2},
+ {
+ addr_item__SubSystem_Blinky_application_blinky_ControlPort
+ },
+ {
+ addr_item__SubSystem_Blinky_timingService_timeout_1
+ }
+ }
+ );
+ instances[3] = new ATimingService(
+ this,
+ "timingService",
+ // own interface item addresses
+ new Address[][] {{addr_item__SubSystem_Blinky_timingService},
+ {
+ },
+ {
+ addr_item__SubSystem_Blinky_timingService_timeout_0,
+ addr_item__SubSystem_Blinky_timingService_timeout_1
+ }
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_3},
+ {
+ },
+ {
+ addr_item__SubSystem_Blinky_application_blinky_timer,
+ addr_item__SubSystem_Blinky_application_controller_timer
+ }
+ }
+ );
+
+ // create the subsystem system port
+ RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort",
+ 0, //local ID
+ // own addresses
+ new Address[]{
+ addr_item_SystemPort_0,
+ addr_item_SystemPort_1,
+ addr_item_SystemPort_2,
+ addr_item_SystemPort_3
+ },
+ // peer addresses
+ new Address[]{
+ addr_item__SubSystem_Blinky_application,
+ addr_item__SubSystem_Blinky_application_blinky,
+ addr_item__SubSystem_Blinky_application_controller,
+ addr_item__SubSystem_Blinky_timingService
+ });
+
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/SubSystem_BlinkyRunner.java b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/SubSystem_BlinkyRunner.java
new file mode 100644
index 000000000..c0a52d85c
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/Blinky/SubSystem_BlinkyRunner.java
@@ -0,0 +1,36 @@
+/**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component SubSystem_Blinky
+ * it instantiates SubSystem_Blinky and starts and ends the lifecycle
+ */
+
+package Blinky;
+
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;
+
+class SubSystem_BlinkyRunner extends SubSystemRunnerBase {
+
+ static SubSystem_Blinky main_component = new SubSystem_Blinky(null, "SubSystem_Blinky");
+
+ /**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+ public static void main(String[] args) {
+
+ System.out.println("*** T H E B E G I N ***");
+
+ main_component.init(); // lifecycle init
+ main_component.start(); // lifecycle start
+
+ // application runs until quit
+ waitForQuit();
+
+ // end the lifecycle
+ main_component.stop(); // lifecycle stop
+ main_component.destroy(); // lifecycle destroy
+
+ System.out.println("*** T H E E N D ***");
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/HelloWorldTop.java b/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/HelloWorldTop.java
new file mode 100644
index 000000000..4f54b1ca5
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/HelloWorldTop.java
@@ -0,0 +1,184 @@
+package HelloWorld;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+
+
+
+public class HelloWorldTop extends ActorClassBase {
+
+
+ //--------------------- ports
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ //--------------------- construction
+ public HelloWorldTop(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("HelloWorldTop");
+
+ // initialize attributes
+
+ // own ports
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // 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"
+ };
+
+ // history
+ // TODOHRR: history defined in ActorClassBase, init in constructor
+ // history = new int[5];
+ // for (int i = 0; i < history.length; i++) {
+ // history[i] = NO_STATE;
+ // }
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+
+ // transition chains
+ protected static final int CHAIN_TRANS_INITIAL_TO__state0 = 1;
+
+ // triggers for FSM
+
+ // 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);
+ }
+ }
+
+ 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);
+ }
+
+ /**
+ * 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:
+ 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
+ * @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__state0:
+ {
+ action_TRANS_INITIAL_TO__state0();
+ return STATE_state0;
+ }
+ }
+ 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:
+ // in leaf state: return state id
+ return STATE_state0;
+ case STATE_TOP:
+ state = history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__state0() {
+ System.out.println("HelloWorld !");
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/SubSystem_HelloWorld.java b/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/SubSystem_HelloWorld.java
new file mode 100644
index 000000000..590a822ea
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/SubSystem_HelloWorld.java
@@ -0,0 +1,69 @@
+package HelloWorld;
+
+import org.eclipse.etrice.runtime.java.messaging.MessageService;
+import org.eclipse.etrice.runtime.java.messaging.RTServices;
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+
+
+
+
+public class SubSystem_HelloWorld extends SubSystemClassBase{
+
+
+ public SubSystem_HelloWorld(IRTObject parent, String name) {
+ super(parent, name);
+ }
+
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){
+ }
+
+ @Override
+ public void instantiateMessageServices(){
+
+ RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main"));
+ }
+
+ @Override
+ public void instantiateActors(){
+ // all addresses
+ // Addresses for the Subsystem Systemport
+ Address addr_item_SystemPort_0 = new Address(0,0,102);
+
+ // actor instance /SubSystem_HelloWorld/application itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SubSystem_HelloWorld_application = new Address(0,0,101);
+ // interface items of /SubSystem_HelloWorld/application
+
+ // instantiate all actor instances
+ instances = new ActorClassBase[1];
+ instances[0] = new HelloWorldTop(
+ this,
+ "application",
+ // own interface item addresses
+ new Address[][] {{addr_item__SubSystem_HelloWorld_application}
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_0}
+ }
+ );
+
+ // create the subsystem system port
+ RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort",
+ 0, //local ID
+ // own addresses
+ new Address[]{
+ addr_item_SystemPort_0
+ },
+ // peer addresses
+ new Address[]{
+ addr_item__SubSystem_HelloWorld_application
+ });
+
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/SubSystem_HelloWorldRunner.java b/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/SubSystem_HelloWorldRunner.java
new file mode 100644
index 000000000..18c521c37
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/HelloWorld/SubSystem_HelloWorldRunner.java
@@ -0,0 +1,36 @@
+/**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component SubSystem_HelloWorld
+ * it instantiates SubSystem_HelloWorld and starts and ends the lifecycle
+ */
+
+package HelloWorld;
+
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;
+
+class SubSystem_HelloWorldRunner extends SubSystemRunnerBase {
+
+ static SubSystem_HelloWorld main_component = new SubSystem_HelloWorld(null, "SubSystem_HelloWorld");
+
+ /**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+ public static void main(String[] args) {
+
+ System.out.println("*** T H E B E G I N ***");
+
+ main_component.init(); // lifecycle init
+ main_component.start(); // lifecycle start
+
+ // application runs until quit
+ waitForQuit();
+
+ // end the lifecycle
+ main_component.stop(); // lifecycle stop
+ main_component.destroy(); // lifecycle destroy
+
+ System.out.println("*** T H E E N D ***");
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/Controller.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/Controller.java
new file mode 100644
index 000000000..8f038a523
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/Controller.java
@@ -0,0 +1,362 @@
+package PedLightsController;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+import room.basic.service.timing.*;
+
+import room.basic.service.timing.PTimeout.*;
+import PedLightsController.PedControlProtocol.*;
+
+//--------------------- begin user code
+ import org.eclipse.etrice.tutorials.PedLightGUI.*;
+ //--------------------- end user code
+
+
+public class Controller extends ActorClassBase {
+
+
+ //--------------------- ports
+ protected PedControlProtocolPort ControlPort = null;
+ //--------------------- saps
+ protected PTimeoutConjPort timer = null;
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_ControlPort = 1;
+ protected static final int IFITEM_timer = 2;
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ //--------------------- construction
+ public Controller(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("Controller");
+
+ // initialize attributes
+
+ // own ports
+ ControlPort = new PedControlProtocolPort(this, "ControlPort", IFITEM_ControlPort, 0, port_addr[IFITEM_ControlPort][0], peer_addr[IFITEM_ControlPort][0]);
+ // own saps
+ timer = new PTimeoutConjPort(this, "timer", IFITEM_timer, 0, port_addr[IFITEM_timer][0], peer_addr[IFITEM_timer][0]);
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_off = 2;
+ protected static final int STATE_carsGreen = 3;
+ protected static final int STATE_carsYellow = 4;
+ protected static final int STATE_carsRed = 5;
+ protected static final int STATE_carsYellowRed = 6;
+ protected static final int STATE_carsGreen2 = 7;
+ protected static final String stateStrings[] = {"<no state>","<top>","off",
+ "carsGreen",
+ "carsYellow",
+ "carsRed",
+ "carsYellowRed",
+ "carsGreen2"
+ };
+
+ // 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_TRANS_INITIAL_TO__off = 1;
+ protected static final int CHAIN_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer = 2;
+ protected static final int CHAIN_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer = 3;
+ protected static final int CHAIN_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer = 4;
+ protected static final int CHAIN_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer = 5;
+ protected static final int CHAIN_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer = 6;
+ protected static final int CHAIN_TRANS_off_TO_carsGreen_BY_startControlPort = 7;
+
+ // triggers for FSM
+ protected static final int TRIG_ControlPort__start = IFITEM_ControlPort + EVT_SHIFT*PedControlProtocol.IN_start;
+ protected static final int TRIG_timer__timeoutTick = IFITEM_timer + EVT_SHIFT*PTimeout.OUT_timeoutTick;
+
+ // receiveEvent contains the main implementation of the FSM
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (state) {
+ case STATE_off:
+ switch(trigger) {
+ case TRIG_ControlPort__start:
+ {
+ chain = CHAIN_TRANS_off_TO_carsGreen_BY_startControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsGreen:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsYellow:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsRed:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsYellowRed:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_carsGreen2:
+ switch(trigger) {
+ case TRIG_timer__timeoutTick:
+ {
+ chain = CHAIN_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ // TODOTS: model switch for activation
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ @Override
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__off;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /**
+ * 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_off:
+ history[STATE_TOP] = STATE_off;
+ current = STATE_TOP;
+ break;
+ case STATE_carsGreen:
+ history[STATE_TOP] = STATE_carsGreen;
+ current = STATE_TOP;
+ break;
+ case STATE_carsYellow:
+ history[STATE_TOP] = STATE_carsYellow;
+ current = STATE_TOP;
+ break;
+ case STATE_carsRed:
+ history[STATE_TOP] = STATE_carsRed;
+ current = STATE_TOP;
+ break;
+ case STATE_carsYellowRed:
+ history[STATE_TOP] = STATE_carsYellowRed;
+ current = STATE_TOP;
+ break;
+ case STATE_carsGreen2:
+ history[STATE_TOP] = STATE_carsGreen2;
+ current = STATE_TOP;
+ break;
+ }
+ }
+ }
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @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__off:
+ {
+ return STATE_off;
+ }
+ case CHAIN_TRANS_off_TO_carsGreen_BY_startControlPort:
+ {
+ action_TRANS_off_TO_carsGreen_BY_startControlPort(ifitem);
+ return STATE_carsGreen;
+ }
+ case CHAIN_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer:
+ {
+ action_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer(ifitem);
+ return STATE_carsYellow;
+ }
+ case CHAIN_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer:
+ {
+ action_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer(ifitem);
+ return STATE_carsRed;
+ }
+ case CHAIN_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer:
+ {
+ action_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer(ifitem);
+ return STATE_carsYellowRed;
+ }
+ case CHAIN_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer:
+ {
+ action_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer(ifitem);
+ return STATE_carsGreen2;
+ }
+ case CHAIN_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer:
+ {
+ action_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer(ifitem);
+ return STATE_off;
+ }
+ }
+ 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_off:
+ // in leaf state: return state id
+ return STATE_off;
+ case STATE_carsGreen:
+ // in leaf state: return state id
+ return STATE_carsGreen;
+ case STATE_carsYellow:
+ // in leaf state: return state id
+ return STATE_carsYellow;
+ case STATE_carsRed:
+ // in leaf state: return state id
+ return STATE_carsRed;
+ case STATE_carsYellowRed:
+ // in leaf state: return state id
+ return STATE_carsYellowRed;
+ case STATE_carsGreen2:
+ // in leaf state: return state id
+ return STATE_carsGreen2;
+ case STATE_TOP:
+ state = history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_off_TO_carsGreen_BY_startControlPort(InterfaceItemBase ifitem) {
+ timer.Start(700);
+ ControlPort.setCarLights(TrafficLight3.GREEN);
+ ControlPort.setPedLights(TrafficLight2.RED);
+ }
+ protected void action_TRANS_carsGreen_TO_carsYellow_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ timer.Start(700);
+ ControlPort.setCarLights(TrafficLight3.YELLOW);
+ ControlPort.setPedLights(TrafficLight2.RED);
+ }
+ protected void action_TRANS_carsYellow_TO_carsRed_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ timer.Start(1500);
+ ControlPort.setCarLights(TrafficLight3.RED);
+ ControlPort.setPedLights(TrafficLight2.GREEN);
+ }
+ protected void action_TRANS_carsRed_TO_carsYellowRed_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ timer.Start(700);
+ ControlPort.setCarLights(TrafficLight3.YELLOW_RED);
+ ControlPort.setPedLights(TrafficLight2.RED);
+ }
+ protected void action_TRANS_carsYellowRed_TO_carsGreen2_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ timer.Start(700);
+ ControlPort.setCarLights(TrafficLight3.GREEN);
+ ControlPort.setPedLights(TrafficLight2.RED);
+ }
+ protected void action_TRANS_carsGreen2_TO_off_BY_timeoutTicktimer(InterfaceItemBase ifitem) {
+ ControlPort.setCarLights(TrafficLight3.OFF);
+ ControlPort.setPedLights(TrafficLight2.OFF);
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/GuiAdapter.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/GuiAdapter.java
new file mode 100644
index 000000000..226447134
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/GuiAdapter.java
@@ -0,0 +1,239 @@
+package PedLightsController;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+import PedLightsController.PedControlProtocol.*;
+
+//--------------------- begin user code
+ import org.eclipse.etrice.tutorials.PedLightGUI.*;
+ //--------------------- end user code
+
+
+public class GuiAdapter extends ActorClassBase {
+
+ //--------------------- begin user code
+ private PedestrianLightWndNoTcp lights = new PedestrianLightWndNoTcp("Pedestrian Lights"," external port connection ");
+ private TrafficLight3 carLights;
+ private TrafficLight2 pedLights;
+ //--------------------- end user code
+
+ //--------------------- ports
+ protected PedControlProtocolConjPort ControlPort = null;
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_ControlPort = 1;
+
+ //--------------------- attributes
+ //--------------------- operations
+ public void destroyUser (){
+ lights.closeWindow();
+ }
+
+ //--------------------- construction
+ public GuiAdapter(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("GuiAdapter");
+
+ // initialize attributes
+
+ // own ports
+ ControlPort = new PedControlProtocolConjPort(this, "ControlPort", IFITEM_ControlPort, 0, port_addr[IFITEM_ControlPort][0], peer_addr[IFITEM_ControlPort][0]);
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_running = 2;
+ protected static final String stateStrings[] = {"<no state>","<top>","running"
+ };
+
+ // history
+ // TODOHRR: history defined in ActorClassBase, init in constructor
+ // history = new int[5];
+ // for (int i = 0; i < history.length; i++) {
+ // history[i] = NO_STATE;
+ // }
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+
+ // transition chains
+ protected static final int CHAIN_TRANS_INITIAL_TO__running = 1;
+ protected static final int CHAIN_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0 = 2;
+ protected static final int CHAIN_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1 = 3;
+
+ // triggers for FSM
+ protected static final int TRIG_ControlPort__setCarLights = IFITEM_ControlPort + EVT_SHIFT*PedControlProtocol.OUT_setCarLights;
+ protected static final int TRIG_ControlPort__setPedLights = IFITEM_ControlPort + EVT_SHIFT*PedControlProtocol.OUT_setPedLights;
+
+ // receiveEvent contains the main implementation of the FSM
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (state) {
+ case STATE_running:
+ switch(trigger) {
+ case TRIG_ControlPort__setCarLights:
+ {
+ chain = CHAIN_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_ControlPort__setPedLights:
+ {
+ chain = CHAIN_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ // TODOTS: model switch for activation
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ @Override
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__running;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /**
+ * 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_running:
+ history[STATE_TOP] = STATE_running;
+ current = STATE_TOP;
+ break;
+ }
+ }
+ }
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @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__running:
+ {
+ action_TRANS_INITIAL_TO__running();
+ return STATE_running;
+ }
+ case CHAIN_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0:
+ {
+ int state = (Integer) generic_data;
+ action_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0(ifitem, state);
+ return STATE_running;
+ }
+ case CHAIN_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1:
+ {
+ int state = (Integer) generic_data;
+ action_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1(ifitem, state);
+ return STATE_running;
+ }
+ }
+ 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_running:
+ // in leaf state: return state id
+ return STATE_running;
+ case STATE_TOP:
+ state = history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__running() {
+ carLights=lights.getCarLights();
+ pedLights=lights.getPedLights();
+ carLights.setState(TrafficLight3.OFF);
+ pedLights.setState(TrafficLight2.OFF);
+ lights.setPort(ControlPort);
+ }
+ protected void action_TRANS_running_TO_running_BY_setCarLightsControlPort_tr0(InterfaceItemBase ifitem, int state) {
+ carLights.setState(state);
+ }
+ protected void action_TRANS_running_TO_running_BY_setPedLightsControlPort_tr1(InterfaceItemBase ifitem, int state) {
+ pedLights.setState(state);
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedControlProtocol.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedControlProtocol.java
new file mode 100644
index 000000000..4b4ef56a6
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedControlProtocol.java
@@ -0,0 +1,232 @@
+package PedLightsController;
+
+import java.util.ArrayList;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.Message;
+import org.eclipse.etrice.runtime.java.modelbase.*;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+
+public class PedControlProtocol {
+ // message IDs
+ // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
+ // error if msgID <= MSG_MIN
+ public static final int MSG_MIN = 0;
+ //IDs for outgoing messages
+ public static final int OUT_setCarLights = 1;
+ public static final int OUT_setPedLights = 2;
+ //IDs for incoming messages
+ public static final int IN_start = 3;
+ //error if msgID >= MSG_MAX
+ public static final int MSG_MAX = 4;
+
+
+ private static String messageStrings[] = {"MIN", "setCarLights","setPedLights", "start","MAX"};
+
+ public String getMessageString(int msg_id) {
+ if (msg_id<0 || msg_id>MSG_MAX+1){
+ // id out of range
+ return "Message ID out of range";
+ }
+ else{
+ return messageStrings[msg_id];
+ }
+ }
+
+
+ // port class
+ static public class PedControlProtocolPort extends PortBase {
+ // constructors
+ public PedControlProtocolPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PedControlProtocolPort(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
+ super(actor, name, localId, idx, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+
+ @Override
+ public void receive(Message m) {
+ if (!(m instanceof EventMessage))
+ return;
+ EventMessage msg = (EventMessage) m;
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ System.out.println("unknown");
+ else {
+ if (messageStrings[msg.getEvtId()] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
+ }
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+
+
+ // sent messages
+ public void setCarLights (int state)
+ {
+ if (messageStrings[ OUT_setCarLights] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_setCarLights]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_setCarLights, state));
+ }
+ public void setPedLights (int state)
+ {
+ if (messageStrings[ OUT_setPedLights] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_setPedLights]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_setPedLights, state));
+ }
+ }
+
+ // replicated port class
+ static public class PedControlProtocolPortRepl {
+ private ArrayList<PedControlProtocolPort> ports;
+ private int replication;
+
+ public PedControlProtocolPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<PedControlProtocol.PedControlProtocolPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PedControlProtocolPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PedControlProtocolPort get(int i) {
+ return ports.get(i);
+ }
+
+ // outgoing messages
+ public void setCarLights (int state)
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).setCarLights( state)
+ ;
+ }
+ }
+ public void setPedLights (int state)
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).setPedLights( state)
+ ;
+ }
+ }
+ }
+
+ // interface for port class
+ public interface IPedControlProtocolPort{
+ // incoming messages
+ public void start ()
+ ;
+ }
+
+ // port class
+ static public class PedControlProtocolConjPort extends PortBase {
+ // constructors
+ public PedControlProtocolConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PedControlProtocolConjPort(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
+ super(actor, name, localId, idx, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+
+ @Override
+ public void receive(Message m) {
+ if (!(m instanceof EventMessage))
+ return;
+ EventMessage msg = (EventMessage) m;
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ System.out.println("unknown");
+ else {
+ if (messageStrings[msg.getEvtId()] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
+ }
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+
+
+ // sent messages
+ public void start ()
+ {
+ if (messageStrings[ IN_start] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_start]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_start));
+ }
+ }
+
+ // replicated port class
+ static public class PedControlProtocolConjPortRepl {
+ private ArrayList<PedControlProtocolConjPort> ports;
+ private int replication;
+
+ public PedControlProtocolConjPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<PedControlProtocol.PedControlProtocolConjPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PedControlProtocolConjPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PedControlProtocolConjPort get(int i) {
+ return ports.get(i);
+ }
+
+ // incoming messages
+ public void start ()
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).start()
+ ;
+ }
+ }
+ }
+
+ // interface for port class
+ public interface IPedControlProtocolConjPort{
+ // outgoing messages
+ public void setCarLights (int state)
+ ;
+ public void setPedLights (int state)
+ ;
+ }
+}
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedLightsTop.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedLightsTop.java
new file mode 100644
index 000000000..d006790ed
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/PedLightsTop.java
@@ -0,0 +1,66 @@
+package PedLightsController;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+
+
+
+public class PedLightsTop extends ActorClassBase {
+
+
+ //--------------------- ports
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ //--------------------- construction
+ public PedLightsTop(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("PedLightsTop");
+
+ // initialize attributes
+
+ // own ports
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //--------------------- no state machine
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
+ handleSystemEvent(ifitem, evt, data);
+ }
+
+ @Override
+ public void executeInitTransition(){
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/SubSys_PedLights.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/SubSys_PedLights.java
new file mode 100644
index 000000000..60a1a947c
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/SubSys_PedLights.java
@@ -0,0 +1,153 @@
+package PedLightsController;
+
+import org.eclipse.etrice.runtime.java.messaging.MessageService;
+import org.eclipse.etrice.runtime.java.messaging.RTServices;
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+
+import room.basic.service.timing.*;
+
+
+
+public class SubSys_PedLights extends SubSystemClassBase{
+
+
+ public SubSys_PedLights(IRTObject parent, String name) {
+ super(parent, name);
+ }
+
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){
+ }
+
+ @Override
+ public void instantiateMessageServices(){
+
+ RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main"));
+ }
+
+ @Override
+ public void instantiateActors(){
+ // all addresses
+ // Addresses for the Subsystem Systemport
+ Address addr_item_SystemPort_0 = new Address(0,0,109);
+ Address addr_item_SystemPort_1 = new Address(0,0,110);
+ Address addr_item_SystemPort_2 = new Address(0,0,111);
+ Address addr_item_SystemPort_3 = new Address(0,0,112);
+
+ // actor instance /SubSys_PedLights/PedLightsTopRef itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SubSys_PedLights_PedLightsTopRef = new Address(0,0,101);
+ // interface items of /SubSys_PedLights/PedLightsTopRef
+ // actor instance /SubSys_PedLights/PedLightsTopRef/adapter itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SubSys_PedLights_PedLightsTopRef_adapter = new Address(0,0,102);
+ // interface items of /SubSys_PedLights/PedLightsTopRef/adapter
+ Address addr_item__SubSys_PedLights_PedLightsTopRef_adapter_ControlPort = new Address(0,0,103);
+ // actor instance /SubSys_PedLights/PedLightsTopRef/controller itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SubSys_PedLights_PedLightsTopRef_controller = new Address(0,0,104);
+ // interface items of /SubSys_PedLights/PedLightsTopRef/controller
+ Address addr_item__SubSys_PedLights_PedLightsTopRef_controller_ControlPort = new Address(0,0,105);
+ Address addr_item__SubSys_PedLights_PedLightsTopRef_controller_timer = new Address(0,0,106);
+ // actor instance /SubSys_PedLights/timingService itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SubSys_PedLights_timingService = new Address(0,0,107);
+ // interface items of /SubSys_PedLights/timingService
+ Address addr_item__SubSys_PedLights_timingService_timeout_0 = new Address(0,0,108);
+
+ // instantiate all actor instances
+ instances = new ActorClassBase[4];
+ instances[0] = new PedLightsTop(
+ this,
+ "PedLightsTopRef",
+ // own interface item addresses
+ new Address[][] {{addr_item__SubSys_PedLights_PedLightsTopRef}
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_0}
+ }
+ );
+ instances[1] = new GuiAdapter(
+ instances[0],
+ "adapter",
+ // own interface item addresses
+ new Address[][] {{addr_item__SubSys_PedLights_PedLightsTopRef_adapter},
+ {
+ addr_item__SubSys_PedLights_PedLightsTopRef_adapter_ControlPort
+ }
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_1},
+ {
+ addr_item__SubSys_PedLights_PedLightsTopRef_controller_ControlPort
+ }
+ }
+ );
+ instances[2] = new Controller(
+ instances[0],
+ "controller",
+ // own interface item addresses
+ new Address[][] {{addr_item__SubSys_PedLights_PedLightsTopRef_controller},
+ {
+ addr_item__SubSys_PedLights_PedLightsTopRef_controller_ControlPort
+ },
+ {
+ addr_item__SubSys_PedLights_PedLightsTopRef_controller_timer
+ }
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_2},
+ {
+ addr_item__SubSys_PedLights_PedLightsTopRef_adapter_ControlPort
+ },
+ {
+ addr_item__SubSys_PedLights_timingService_timeout_0
+ }
+ }
+ );
+ instances[3] = new ATimingService(
+ this,
+ "timingService",
+ // own interface item addresses
+ new Address[][] {{addr_item__SubSys_PedLights_timingService},
+ {
+ },
+ {
+ addr_item__SubSys_PedLights_timingService_timeout_0
+ }
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_3},
+ {
+ },
+ {
+ addr_item__SubSys_PedLights_PedLightsTopRef_controller_timer
+ }
+ }
+ );
+
+ // create the subsystem system port
+ RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort",
+ 0, //local ID
+ // own addresses
+ new Address[]{
+ addr_item_SystemPort_0,
+ addr_item_SystemPort_1,
+ addr_item_SystemPort_2,
+ addr_item_SystemPort_3
+ },
+ // peer addresses
+ new Address[]{
+ addr_item__SubSys_PedLights_PedLightsTopRef,
+ addr_item__SubSys_PedLights_PedLightsTopRef_adapter,
+ addr_item__SubSys_PedLights_PedLightsTopRef_controller,
+ addr_item__SubSys_PedLights_timingService
+ });
+
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/SubSys_PedLightsRunner.java b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/SubSys_PedLightsRunner.java
new file mode 100644
index 000000000..b635412fc
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/PedLightsController/SubSys_PedLightsRunner.java
@@ -0,0 +1,36 @@
+/**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component SubSys_PedLights
+ * it instantiates SubSys_PedLights and starts and ends the lifecycle
+ */
+
+package PedLightsController;
+
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;
+
+class SubSys_PedLightsRunner extends SubSystemRunnerBase {
+
+ static SubSys_PedLights main_component = new SubSys_PedLights(null, "SubSys_PedLights");
+
+ /**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+ public static void main(String[] args) {
+
+ System.out.println("*** T H E B E G I N ***");
+
+ main_component.init(); // lifecycle init
+ main_component.start(); // lifecycle start
+
+ // application runs until quit
+ waitForQuit();
+
+ // end the lifecycle
+ main_component.stop(); // lifecycle stop
+ main_component.destroy(); // lifecycle destroy
+
+ System.out.println("*** T H E E N D ***");
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/DemoData.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/DemoData.java
new file mode 100644
index 000000000..89f235d7a
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/DemoData.java
@@ -0,0 +1,49 @@
+package SendingData;
+
+
+
+public class DemoData {
+ //--------------------- attributes
+ protected int int32Val;protected byte[] int8Array = {1,2,3,4,5,6,7,8,9,10};
+ protected double float64Val;protected String stringVal;
+ //--------------------- attribute setters and getters
+ public void setInt32Val (int int32Val) {
+ this.int32Val = int32Val;
+ }
+ public int getInt32Val () {
+ return int32Val;
+ }public void setInt8Array (byte[] int8Array) {
+ this.int8Array = int8Array;
+ }
+ public byte[] getInt8Array () {
+ return int8Array;
+ }public void setFloat64Val (double float64Val) {
+ this.float64Val = float64Val;
+ }
+ public double getFloat64Val () {
+ return float64Val;
+ }public void setStringVal (String stringVal) {
+ this.stringVal = stringVal;
+ }
+ public String getStringVal () {
+ return stringVal;
+ }
+ //--------------------- operations
+
+ // default constructor
+ public DemoData() {
+ int32Val = 4711;
+ float64Val = 0.0;
+ stringVal = "empty";
+ }
+
+ // deep copy
+ public DemoData deepCopy() {
+ DemoData copy = new DemoData();
+ copy.int32Val = int32Val;
+ for (int i=0;i<10;i++){copy.int8Array[i]=int8Array[i];}
+ copy.float64Val = float64Val;
+ copy.stringVal = stringVal;
+ return copy;
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPing.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPing.java
new file mode 100644
index 000000000..5ea196049
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPing.java
@@ -0,0 +1,276 @@
+package SendingData;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+import SendingData.PingPongProtocol.*;
+
+
+
+public class MrPing extends ActorClassBase {
+
+
+ //--------------------- ports
+ protected PingPongProtocolConjPort PingPongPort = null;
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_PingPongPort = 1;
+
+ //--------------------- attributes
+ //--------------------- operations
+ public void printData (DemoData d){
+ System.out.printf("d.int32Val: %d\n",d.int32Val);
+ System.out.printf("d.float64Val: %f\n",d.float64Val);
+ System.out.printf("d.int8Array: ");
+ for(int i = 0; i<d.int8Array.length; i++) {
+ System.out.printf("%d ",d.int8Array[i]);}
+ System.out.printf("\nd.stringVal: %s\n",d.stringVal);
+ }
+
+ //--------------------- construction
+ public MrPing(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("MrPing");
+
+ // initialize attributes
+
+ // own ports
+ PingPongPort = new PingPongProtocolConjPort(this, "PingPongPort", IFITEM_PingPongPort, 0, port_addr[IFITEM_PingPongPort][0], peer_addr[IFITEM_PingPongPort][0]);
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_waitForPong = 2;
+ protected static final int STATE_waitForPongSimple = 3;
+ protected static final String stateStrings[] = {"<no state>","<top>","waitForPong",
+ "waitForPongSimple"
+ };
+
+ // history
+ // TODOHRR: history defined in ActorClassBase, init in constructor
+ // history = new int[5];
+ // for (int i = 0; i < history.length; i++) {
+ // history[i] = NO_STATE;
+ // }
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+
+ // transition chains
+ protected static final int CHAIN_TRANS_INITIAL_TO__waitForPongSimple = 1;
+ protected static final int CHAIN_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1 = 2;
+ protected static final int CHAIN_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort = 3;
+ protected static final int CHAIN_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2 = 4;
+
+ // triggers 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;
+
+ // receiveEvent contains the main implementation of the FSM
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (state) {
+ case STATE_waitForPong:
+ switch(trigger) {
+ case TRIG_PingPongPort__pong:
+ {
+ chain = CHAIN_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_waitForPongSimple:
+ switch(trigger) {
+ case TRIG_PingPongPort__pongSimple:
+ { int data = (Integer) generic_data;
+ if (data < 10
+ )
+ {
+ chain = CHAIN_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1;
+ catching_state = STATE_TOP;
+ } else
+ {
+ chain = CHAIN_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort;
+ catching_state = STATE_TOP;
+ }
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ // TODOTS: model switch for activation
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ @Override
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__waitForPongSimple;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /**
+ * 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_waitForPong:
+ history[STATE_TOP] = STATE_waitForPong;
+ current = STATE_TOP;
+ break;
+ case STATE_waitForPongSimple:
+ history[STATE_TOP] = STATE_waitForPongSimple;
+ current = STATE_TOP;
+ break;
+ }
+ }
+ }
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @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_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2:
+ {
+ DemoData data = (DemoData) generic_data;
+ action_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2(ifitem, data);
+ return STATE_waitForPong;
+ }
+ case CHAIN_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1:
+ {
+ int data = (Integer) generic_data;
+ action_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1(ifitem, data);
+ return STATE_waitForPongSimple;
+ }
+ case CHAIN_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort:
+ {
+ int data = (Integer) generic_data;
+ action_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort(ifitem, data);
+ return STATE_waitForPong;
+ }
+ case CHAIN_TRANS_INITIAL_TO__waitForPongSimple:
+ {
+ action_TRANS_INITIAL_TO__waitForPongSimple();
+ return STATE_waitForPongSimple;
+ }
+ }
+ 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_waitForPong:
+ // in leaf state: return state id
+ return STATE_waitForPong;
+ case STATE_waitForPongSimple:
+ // in leaf state: return state id
+ return STATE_waitForPongSimple;
+ case STATE_TOP:
+ state = history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_waitForPong_TO_waitForPong_BY_pongPingPongPort_wait2(InterfaceItemBase ifitem, DemoData data) {
+ printData(data);
+ }
+ protected void action_TRANS_waitForPongSimple_TO_waitForPongSimple_BY_pongSimplePingPongPort_wait1(InterfaceItemBase ifitem, int data) {
+ // keep in mind that MrPong increments
+ PingPongPort.pingSimple(data);
+ System.out.printf("data: %d\n",data);
+ }
+ protected void action_TRANS_waitForPongSimple_TO_waitForPong_BY_pongSimplePingPongPort(InterfaceItemBase ifitem, int data) {
+ System.out.printf("data: %d\n",data);
+
+ DemoData d = new DemoData();
+ // send the default values
+ PingPongPort.ping(d);
+ d.int32Val=815;
+ for (int i = 0; i<d.int8Array.length;i++){
+ d.int8Array[i]=(byte)(i+100);
+ }
+ d.stringVal="some contents";
+ d.float64Val=3.141234;
+ PingPongPort.ping(d);
+ }
+ protected void action_TRANS_INITIAL_TO__waitForPongSimple() {
+ PingPongPort.pingSimple(0);
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPong.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPong.java
new file mode 100644
index 000000000..a674ffeb2
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/MrPong.java
@@ -0,0 +1,220 @@
+package SendingData;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+import SendingData.PingPongProtocol.*;
+
+
+
+public class MrPong extends ActorClassBase {
+
+
+ //--------------------- ports
+ protected PingPongProtocolPort PingPongPort = null;
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_PingPongPort = 1;
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ //--------------------- construction
+ public MrPong(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("MrPong");
+
+ // initialize attributes
+
+ // own ports
+ PingPongPort = new PingPongProtocolPort(this, "PingPongPort", IFITEM_PingPongPort, 0, port_addr[IFITEM_PingPongPort][0], peer_addr[IFITEM_PingPongPort][0]);
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_looping = 2;
+ protected static final String stateStrings[] = {"<no state>","<top>","looping"
+ };
+
+ // history
+ // TODOHRR: history defined in ActorClassBase, init in constructor
+ // history = new int[5];
+ // for (int i = 0; i < history.length; i++) {
+ // history[i] = NO_STATE;
+ // }
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+
+ // transition chains
+ protected static final int CHAIN_TRANS_INITIAL_TO__looping = 1;
+ protected static final int CHAIN_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0 = 2;
+ protected static final int CHAIN_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1 = 3;
+
+ // triggers 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;
+
+ // receiveEvent contains the main implementation of the FSM
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (state) {
+ case STATE_looping:
+ switch(trigger) {
+ case TRIG_PingPongPort__ping:
+ {
+ chain = CHAIN_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PingPongPort__pingSimple:
+ {
+ chain = CHAIN_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ // TODOTS: model switch for activation
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ @Override
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__looping;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /**
+ * 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_looping:
+ history[STATE_TOP] = STATE_looping;
+ current = STATE_TOP;
+ break;
+ }
+ }
+ }
+ /**
+ * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data
+ * matching the trigger of this chain. The ID of the final state is returned
+ * @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__looping:
+ {
+ return STATE_looping;
+ }
+ case CHAIN_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0:
+ {
+ DemoData data = (DemoData) generic_data;
+ action_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0(ifitem, data);
+ return STATE_looping;
+ }
+ case CHAIN_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1:
+ {
+ int data = (Integer) generic_data;
+ action_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1(ifitem, data);
+ return STATE_looping;
+ }
+ }
+ 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_looping:
+ // in leaf state: return state id
+ return STATE_looping;
+ case STATE_TOP:
+ state = history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ //*** Entry and Exit Codes
+
+ //*** Action Codes
+ protected void action_TRANS_looping_TO_looping_BY_pingPingPongPort_tr0(InterfaceItemBase ifitem, DemoData data) {
+ PingPongPort.pong(data);
+ }
+ protected void action_TRANS_looping_TO_looping_BY_pingSimplePingPongPort_tr1(InterfaceItemBase ifitem, int data) {
+ PingPongPort.pongSimple(data+1);
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/PingPongProtocol.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/PingPongProtocol.java
new file mode 100644
index 000000000..cd00ff067
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/PingPongProtocol.java
@@ -0,0 +1,251 @@
+package SendingData;
+
+import java.util.ArrayList;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.Message;
+import org.eclipse.etrice.runtime.java.modelbase.*;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+
+public class PingPongProtocol {
+ // message IDs
+ // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
+ // error if msgID <= MSG_MIN
+ public static final int MSG_MIN = 0;
+ //IDs for outgoing messages
+ public static final int OUT_pong = 1;
+ 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;
+
+
+ private static String messageStrings[] = {"MIN", "pong","pongSimple", "ping","pingSimple","MAX"};
+
+ public String getMessageString(int msg_id) {
+ if (msg_id<0 || msg_id>MSG_MAX+1){
+ // id out of range
+ return "Message ID out of range";
+ }
+ else{
+ return messageStrings[msg_id];
+ }
+ }
+
+
+ // port class
+ static public class PingPongProtocolPort extends PortBase {
+ // constructors
+ public PingPongProtocolPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PingPongProtocolPort(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
+ super(actor, name, localId, idx, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+
+ @Override
+ public void receive(Message m) {
+ if (!(m instanceof EventMessage))
+ return;
+ EventMessage msg = (EventMessage) m;
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ System.out.println("unknown");
+ else {
+ if (messageStrings[msg.getEvtId()] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
+ }
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+
+
+ // sent messages
+ public void pong (DemoData data)
+ {
+ if (messageStrings[ OUT_pong] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_pong]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_pong, data.deepCopy()));
+ }
+ public void pongSimple (int data)
+ {
+ if (messageStrings[ OUT_pongSimple] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_pongSimple]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_pongSimple, data));
+ }
+ }
+
+ // replicated port class
+ static public class PingPongProtocolPortRepl {
+ private ArrayList<PingPongProtocolPort> ports;
+ private int replication;
+
+ public PingPongProtocolPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<PingPongProtocol.PingPongProtocolPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PingPongProtocolPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PingPongProtocolPort get(int i) {
+ return ports.get(i);
+ }
+
+ // outgoing messages
+ public void pong (DemoData data)
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).pong( data)
+ ;
+ }
+ }
+ public void pongSimple (int data)
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).pongSimple( data)
+ ;
+ }
+ }
+ }
+
+ // interface for port class
+ public interface IPingPongProtocolPort{
+ // incoming messages
+ public void ping (DemoData data)
+ ;
+ public void pingSimple (int data)
+ ;
+ }
+
+ // port class
+ static public class PingPongProtocolConjPort extends PortBase {
+ // constructors
+ public PingPongProtocolConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PingPongProtocolConjPort(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
+ super(actor, name, localId, idx, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+
+ @Override
+ public void receive(Message m) {
+ if (!(m instanceof EventMessage))
+ return;
+ EventMessage msg = (EventMessage) m;
+ if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+ System.out.println("unknown");
+ else {
+ if (messageStrings[msg.getEvtId()] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
+ }
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+
+
+ // sent messages
+ public void ping (DemoData data)
+ {
+ if (messageStrings[ IN_ping] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_ping]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_ping, data.deepCopy()));
+ }
+ public void pingSimple (int data)
+ {
+ if (messageStrings[ IN_pingSimple] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_pingSimple]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_pingSimple, data));
+ }
+ }
+
+ // replicated port class
+ static public class PingPongProtocolConjPortRepl {
+ private ArrayList<PingPongProtocolConjPort> ports;
+ private int replication;
+
+ public PingPongProtocolConjPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<PingPongProtocol.PingPongProtocolConjPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PingPongProtocolConjPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PingPongProtocolConjPort get(int i) {
+ return ports.get(i);
+ }
+
+ // incoming messages
+ public void ping (DemoData data)
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).ping( data)
+ ;
+ }
+ }
+ public void pingSimple (int data)
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).pingSimple( data)
+ ;
+ }
+ }
+ }
+
+ // interface for port class
+ public interface IPingPongProtocolConjPort{
+ // outgoing messages
+ public void pong (DemoData data)
+ ;
+ public void pongSimple (int data)
+ ;
+ }
+}
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingDataTop.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingDataTop.java
new file mode 100644
index 000000000..91d716d07
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingDataTop.java
@@ -0,0 +1,66 @@
+package SendingData;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+
+
+
+public class SendingDataTop extends ActorClassBase {
+
+
+ //--------------------- ports
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ //--------------------- construction
+ public SendingDataTop(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("SendingDataTop");
+
+ // initialize attributes
+
+ // own ports
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //--------------------- no state machine
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
+ handleSystemEvent(ifitem, evt, data);
+ }
+
+ @Override
+ public void executeInitTransition(){
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingData_SubSystem.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingData_SubSystem.java
new file mode 100644
index 000000000..20b905bfc
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingData_SubSystem.java
@@ -0,0 +1,117 @@
+package SendingData;
+
+import org.eclipse.etrice.runtime.java.messaging.MessageService;
+import org.eclipse.etrice.runtime.java.messaging.RTServices;
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.RTSystemServicesProtocol.*;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+
+
+
+
+public class SendingData_SubSystem extends SubSystemClassBase{
+
+
+ public SendingData_SubSystem(IRTObject parent, String name) {
+ super(parent, name);
+ }
+
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){
+ }
+
+ @Override
+ public void instantiateMessageServices(){
+
+ RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main"));
+ }
+
+ @Override
+ public void instantiateActors(){
+ // all addresses
+ // Addresses for the Subsystem Systemport
+ Address addr_item_SystemPort_0 = new Address(0,0,106);
+ Address addr_item_SystemPort_1 = new Address(0,0,107);
+ Address addr_item_SystemPort_2 = new Address(0,0,108);
+
+ // actor instance /SendingData_SubSystem/SendigDataTopRef itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SendingData_SubSystem_SendigDataTopRef = new Address(0,0,101);
+ // interface items of /SendingData_SubSystem/SendigDataTopRef
+ // actor instance /SendingData_SubSystem/SendigDataTopRef/ref0 itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SendingData_SubSystem_SendigDataTopRef_ref0 = new Address(0,0,102);
+ // interface items of /SendingData_SubSystem/SendigDataTopRef/ref0
+ Address addr_item__SendingData_SubSystem_SendigDataTopRef_ref0_PingPongPort = new Address(0,0,103);
+ // actor instance /SendingData_SubSystem/SendigDataTopRef/ref1 itself => Systemport Address
+ // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+ Address addr_item__SendingData_SubSystem_SendigDataTopRef_ref1 = new Address(0,0,104);
+ // interface items of /SendingData_SubSystem/SendigDataTopRef/ref1
+ Address addr_item__SendingData_SubSystem_SendigDataTopRef_ref1_PingPongPort = new Address(0,0,105);
+
+ // instantiate all actor instances
+ instances = new ActorClassBase[3];
+ instances[0] = new SendingDataTop(
+ this,
+ "SendigDataTopRef",
+ // own interface item addresses
+ new Address[][] {{addr_item__SendingData_SubSystem_SendigDataTopRef}
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_0}
+ }
+ );
+ instances[1] = new MrPing(
+ instances[0],
+ "ref0",
+ // own interface item addresses
+ new Address[][] {{addr_item__SendingData_SubSystem_SendigDataTopRef_ref0},
+ {
+ addr_item__SendingData_SubSystem_SendigDataTopRef_ref0_PingPongPort
+ }
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_1},
+ {
+ addr_item__SendingData_SubSystem_SendigDataTopRef_ref1_PingPongPort
+ }
+ }
+ );
+ instances[2] = new MrPong(
+ instances[0],
+ "ref1",
+ // own interface item addresses
+ new Address[][] {{addr_item__SendingData_SubSystem_SendigDataTopRef_ref1},
+ {
+ addr_item__SendingData_SubSystem_SendigDataTopRef_ref1_PingPongPort
+ }
+ },
+ // peer interface item addresses
+ new Address[][] {{addr_item_SystemPort_2},
+ {
+ addr_item__SendingData_SubSystem_SendigDataTopRef_ref0_PingPongPort
+ }
+ }
+ );
+
+ // create the subsystem system port
+ RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort",
+ 0, //local ID
+ // own addresses
+ new Address[]{
+ addr_item_SystemPort_0,
+ addr_item_SystemPort_1,
+ addr_item_SystemPort_2
+ },
+ // peer addresses
+ new Address[]{
+ addr_item__SendingData_SubSystem_SendigDataTopRef,
+ addr_item__SendingData_SubSystem_SendigDataTopRef_ref0,
+ addr_item__SendingData_SubSystem_SendigDataTopRef_ref1
+ });
+
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingData_SubSystemRunner.java b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingData_SubSystemRunner.java
new file mode 100644
index 000000000..15189bbaa
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/SendingData/SendingData_SubSystemRunner.java
@@ -0,0 +1,36 @@
+/**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component SendingData_SubSystem
+ * it instantiates SendingData_SubSystem and starts and ends the lifecycle
+ */
+
+package SendingData;
+
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemRunnerBase;
+
+class SendingData_SubSystemRunner extends SubSystemRunnerBase {
+
+ static SendingData_SubSystem main_component = new SendingData_SubSystem(null, "SendingData_SubSystem");
+
+ /**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+ public static void main(String[] args) {
+
+ System.out.println("*** T H E B E G I N ***");
+
+ main_component.init(); // lifecycle init
+ main_component.start(); // lifecycle start
+
+ // application runs until quit
+ waitForQuit();
+
+ // end the lifecycle
+ main_component.stop(); // lifecycle stop
+ main_component.destroy(); // lifecycle destroy
+
+ System.out.println("*** T H E E N D ***");
+ }
+};
diff --git a/examples/org.eclipse.etrice.tutorials/src-gen/readme.txt b/examples/org.eclipse.etrice.tutorials/src-gen/readme.txt
new file mode 100644
index 000000000..c3b99d458
--- /dev/null
+++ b/examples/org.eclipse.etrice.tutorials/src-gen/readme.txt
@@ -0,0 +1,4 @@
+This directory is an eTrice code generation target.
+It will be erased every time the generator is executed.
+
+DO NOT PLACE OTHER FILES HERE!

Back to the top