Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-10-10 15:35:24 +0000
committerHenrik Rentz-Reichert2012-10-10 15:35:24 +0000
commite1d85e345a19a3d716af6f5a35963bf36f128423 (patch)
treeb6ccd74825cb29c043adab853c14e136a7f01a5b /runtime
parentcbef8ddd449f7e165009cba604f7bed64502c0c8 (diff)
downloadorg.eclipse.etrice-e1d85e345a19a3d716af6f5a35963bf36f128423.tar.gz
org.eclipse.etrice-e1d85e345a19a3d716af6f5a35963bf36f128423.tar.xz
org.eclipse.etrice-e1d85e345a19a3d716af6f5a35963bf36f128423.zip
[integration.tests, modellib.java] re-generated
Diffstat (limited to 'runtime')
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java78
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java51
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java270
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/SocketClient.java84
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java287
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/InternalLogData.java60
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/Log.java230
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java724
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java401
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpControl.java102
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpPayload.java126
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpControl.java430
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpPayload.java384
13 files changed, 2344 insertions, 883 deletions
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java
new file mode 100644
index 000000000..cf5a0c40c
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java
@@ -0,0 +1,78 @@
+package org.eclipse.etrice.modellib.Socket;
+
+
+
+
+public class DSocketConfiguration {
+
+
+ /*--------------------- attributes ---------------------*/
+ String serverName;
+ int portNumber;
+ int protocol;
+ boolean checkCookie;
+ int mode;
+
+ //--------------------- attribute setters and getters
+ public void setServerName (String serverName) {
+ this.serverName = serverName;
+ }
+ public String getServerName () {
+ return this.serverName;
+ }
+ public void setPortNumber (int portNumber) {
+ this.portNumber = portNumber;
+ }
+ public int getPortNumber () {
+ return this.portNumber;
+ }
+ public void setProtocol (int protocol) {
+ this.protocol = protocol;
+ }
+ public int getProtocol () {
+ return this.protocol;
+ }
+ public void setCheckCookie (boolean checkCookie) {
+ this.checkCookie = checkCookie;
+ }
+ public boolean getCheckCookie () {
+ return this.checkCookie;
+ }
+ public void setMode (int mode) {
+ this.mode = mode;
+ }
+ public int getMode () {
+ return this.mode;
+ }
+
+ /*--------------------- operations ---------------------*/
+
+ // default constructor
+ public DSocketConfiguration() {
+ super();
+
+ // initialize attributes
+ }
+
+ // constructor using fields
+ public DSocketConfiguration(String serverName, int portNumber, int protocol, boolean checkCookie, int mode) {
+ super();
+
+ this.serverName = serverName;
+ this.portNumber = portNumber;
+ this.protocol = protocol;
+ this.checkCookie = checkCookie;
+ this.mode = mode;
+ }
+
+ // deep copy
+ public DSocketConfiguration deepCopy() {
+ DSocketConfiguration copy = new DSocketConfiguration();
+ copy.serverName = serverName;
+ copy.portNumber = portNumber;
+ copy.protocol = protocol;
+ copy.checkCookie = checkCookie;
+ copy.mode = mode;
+ return copy;
+ }
+};
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java
new file mode 100644
index 000000000..02aef15f0
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java
@@ -0,0 +1,51 @@
+package org.eclipse.etrice.modellib.Socket;
+
+
+
+
+public class DSocketData {
+
+
+ /*--------------------- attributes ---------------------*/
+ int size;
+ String data;
+
+ //--------------------- attribute setters and getters
+ public void setSize (int size) {
+ this.size = size;
+ }
+ public int getSize () {
+ return this.size;
+ }
+ public void setData (String data) {
+ this.data = data;
+ }
+ public String getData () {
+ return this.data;
+ }
+
+ /*--------------------- operations ---------------------*/
+
+ // default constructor
+ public DSocketData() {
+ super();
+
+ // initialize attributes
+ }
+
+ // constructor using fields
+ public DSocketData(int size, String data) {
+ super();
+
+ this.size = size;
+ this.data = data;
+ }
+
+ // deep copy
+ public DSocketData deepCopy() {
+ DSocketData copy = new DSocketData();
+ copy.size = size;
+ copy.data = data;
+ return copy;
+ }
+};
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java
new file mode 100644
index 000000000..ddc67785f
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java
@@ -0,0 +1,270 @@
+package org.eclipse.etrice.modellib.Socket;
+
+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 PSocket {
+ // message IDs
+ public static final int MSG_MIN = 0;
+ public static final int OUT_connected = 1;
+ public static final int OUT_disconnected = 2;
+ public static final int OUT_receivedData = 3;
+ public static final int OUT_sentData = 4;
+ public static final int OUT_error = 5;
+ public static final int IN_connect = 6;
+ public static final int IN_disconnect = 7;
+ public static final int IN_sendData = 8;
+ public static final int MSG_MAX = 9;
+
+
+ private static String messageStrings[] = {"MIN", "connected","disconnected","receivedData","sentData","error", "connect","disconnect","sendData","MAX"};
+
+ public String getMessageString(int msg_id) {
+ if (msg_id<MSG_MIN || 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 PSocketPort extends PortBase {
+ // constructors
+ public PSocketPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ this(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PSocketPort(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"){
+ 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 connected() {
+ if (messageStrings[ OUT_connected] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_connected]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_connected));
+ }
+ public void disconnected() {
+ if (messageStrings[ OUT_disconnected] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_disconnected]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_disconnected));
+ }
+ public void receivedData() {
+ if (messageStrings[ OUT_receivedData] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_receivedData]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_receivedData));
+ }
+ public void sentData() {
+ if (messageStrings[ OUT_sentData] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_sentData]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_sentData));
+ }
+ public void error() {
+ if (messageStrings[ OUT_error] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_error]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_error));
+ }
+ }
+
+ // replicated port class
+ static public class PSocketReplPort {
+ private ArrayList<PSocketPort> ports;
+ private int replication;
+
+ public PSocketReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<PSocket.PSocketPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PSocketPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PSocketPort get(int i) {
+ return ports.get(i);
+ }
+
+ // outgoing messages
+ public void connected(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).connected();
+ }
+ }
+ public void disconnected(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).disconnected();
+ }
+ }
+ public void receivedData(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).receivedData();
+ }
+ }
+ public void sentData(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).sentData();
+ }
+ }
+ public void error(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).error();
+ }
+ }
+ }
+
+
+ // port class
+ static public class PSocketConjPort extends PortBase {
+ // constructors
+ public PSocketConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ this(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PSocketConjPort(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"){
+ 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 connect(DSocketConfiguration config) {
+ if (messageStrings[ IN_connect] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_connect]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_connect, config.deepCopy()));
+ }
+ public void connect(String serverName, int portNumber, int protocol, boolean checkCookie, int mode) {
+ connect(new DSocketConfiguration(serverName, portNumber, protocol, checkCookie, mode));
+ }
+ public void disconnect() {
+ if (messageStrings[ IN_disconnect] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_disconnect]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_disconnect));
+ }
+ public void sendData(DSocketData data) {
+ if (messageStrings[ IN_sendData] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_sendData]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_sendData, data.deepCopy()));
+ }
+ public void sendData(int size, String data) {
+ sendData(new DSocketData(size, data));
+ }
+ }
+
+ // replicated port class
+ static public class PSocketConjReplPort {
+ private ArrayList<PSocketConjPort> ports;
+ private int replication;
+
+ public PSocketConjReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<PSocket.PSocketConjPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PSocketConjPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PSocketConjPort get(int i) {
+ return ports.get(i);
+ }
+
+ // incoming messages
+ public void connect(DSocketConfiguration config){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).connect( config);
+ }
+ }
+ public void disconnect(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).disconnect();
+ }
+ }
+ public void sendData(DSocketData data){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).sendData( data);
+ }
+ }
+ }
+
+}
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/SocketClient.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/SocketClient.java
new file mode 100644
index 000000000..582f3a4bd
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/org/eclipse/etrice/modellib/Socket/SocketClient.java
@@ -0,0 +1,84 @@
+package org.eclipse.etrice.modellib.Socket;
+
+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 static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;
+
+
+import org.eclipse.etrice.modellib.Socket.PSocket.*;
+
+
+
+public class SocketClient extends ActorClassBase {
+
+
+
+ //--------------------- ports
+ protected PSocketPort fct = null;
+
+ //--------------------- saps
+
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ public static final int IFITEM_fct = 1;
+
+
+ /*--------------------- attributes ---------------------*/
+ /*--------------------- operations ---------------------*/
+
+ //--------------------- construction
+ public SocketClient(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("SocketClient");
+
+ // initialize attributes
+
+ // own ports
+ fct = new PSocketPort(this, "fct", IFITEM_fct, 0, port_addr[IFITEM_fct][0], peer_addr[IFITEM_fct][0]);
+
+ // own saps
+
+ // own service implementations
+ }
+
+
+ //--------------------- attribute setters and getters
+
+
+ //--------------------- port getters
+ public PSocketPort getFct (){
+ return this.fct;
+ }
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ }
+
+ //--------------------- no state machine
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
+ handleSystemEvent(ifitem, evt, data);
+ }
+
+ @Override
+ public void executeInitTransition(){
+ }
+};
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java
new file mode 100644
index 000000000..1b8cd7168
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java
@@ -0,0 +1,287 @@
+package room.basic.service.logging;
+
+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 static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;
+
+
+import room.basic.service.logging.Log.*;
+
+/*--------------------- begin user code ---------------------*/
+import java.io.*;
+import java.util.*;
+/*--------------------- end user code ---------------------*/
+
+
+public class ALogService extends ActorClassBase {
+
+ /*--------------------- begin user code ---------------------*/
+ FileOutputStream file = null;
+ PrintStream p = null;
+ static long tStart = System.currentTimeMillis();
+ /*--------------------- end user code ---------------------*/
+
+
+ //--------------------- ports
+
+ //--------------------- saps
+
+ //--------------------- services
+ protected LogReplPort log = null;
+
+ //--------------------- interface item IDs
+ public static final int IFITEM_log = 1;
+
+
+ /*--------------------- attributes ---------------------*/
+ /*--------------------- operations ---------------------*/
+ public void destroyUser() {
+ if (p!= null) {
+ p.flush();
+ p.close();
+ p=null;
+ }
+ }
+
+ //--------------------- construction
+ public ALogService(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("ALogService");
+
+ // initialize attributes
+
+ // own ports
+
+ // own saps
+
+ // own service implementations
+ log = new LogReplPort(this, "log", IFITEM_log, port_addr[IFITEM_log], peer_addr[IFITEM_log]);
+ }
+
+
+ //--------------------- attribute setters and getters
+
+
+ //--------------------- port getters
+ public LogReplPort getLog (){
+ return this.log;
+ }
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ }
+
+
+ /* state IDs */
+ public static final int STATE_closed = 2;
+ public static final int STATE_opened = 3;
+
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__closed = 1;
+ public static final int CHAIN_TRANS_open_FROM_closed_TO_opened_BY_openlog = 2;
+ public static final int CHAIN_TRANS_tr0_FROM_opened_TO_closed_BY_closelog = 3;
+ public static final int CHAIN_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1 = 4;
+
+ /* triggers */
+ public static final int POLLING = 0;
+ public static final int TRIG_log__close = IFITEM_log + EVT_SHIFT*Log.IN_close;
+ public static final int TRIG_log__internalLog = IFITEM_log + EVT_SHIFT*Log.IN_internalLog;
+ public static final int TRIG_log__open = IFITEM_log + EVT_SHIFT*Log.IN_open;
+
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","closed",
+ "opened"
+ };
+
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ /* Entry and Exit Codes */
+
+ /* Action Codes */
+ protected void action_TRANS_open_FROM_closed_TO_opened_BY_openlog(InterfaceItemBase ifitem, String fileName) {
+ Date d=new Date(tStart);
+ try{
+ file=new FileOutputStream(fileName);
+ p=new PrintStream(file);
+ p.println("Log opened at "+ d.toString());
+ p.println("--------------------------------------------------");
+ } catch (Exception e){
+ System.out.println("Log file not opened !");
+ }
+ }
+ protected void action_TRANS_tr0_FROM_opened_TO_closed_BY_closelog(InterfaceItemBase ifitem) {
+ p.flush();
+ p.close();
+ p=null;
+ }
+ protected void action_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1(InterfaceItemBase ifitem, InternalLogData data) {
+ p.println("Timestamp: " + Long.toString(data.timeStamp-tStart) + "ms");
+ p.println("SenderInstance: "+ data.sender);
+ p.println("UserString: " + data.userString);
+ p.println("--------------------------------------------------");
+ System.out.printf(data.userString);
+ }
+
+ /**
+ * 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_closed:
+ this.history[STATE_TOP] = STATE_closed;
+ current = STATE_TOP;
+ break;
+ case STATE_opened:
+ this.history[STATE_TOP] = STATE_opened;
+ 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__closed:
+ {
+ return STATE_closed;
+ }
+ case CHAIN_TRANS_open_FROM_closed_TO_opened_BY_openlog:
+ {
+ String fileName = (String) generic_data;
+ action_TRANS_open_FROM_closed_TO_opened_BY_openlog(ifitem, fileName);
+ return STATE_opened;
+ }
+ case CHAIN_TRANS_tr0_FROM_opened_TO_closed_BY_closelog:
+ {
+ action_TRANS_tr0_FROM_opened_TO_closed_BY_closelog(ifitem);
+ return STATE_closed;
+ }
+ case CHAIN_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1:
+ {
+ InternalLogData data = (InternalLogData) generic_data;
+ action_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1(ifitem, data);
+ return STATE_opened;
+ }
+ }
+ 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_closed:
+ // in leaf state: return state id
+ return STATE_closed;
+ case STATE_opened:
+ // in leaf state: return state id
+ return STATE_opened;
+ case STATE_TOP:
+ state = this.history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__closed;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_closed:
+ switch(trigger) {
+ case TRIG_log__open:
+ {
+ chain = CHAIN_TRANS_open_FROM_closed_TO_opened_BY_openlog;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_opened:
+ switch(trigger) {
+ case TRIG_log__close:
+ {
+ chain = CHAIN_TRANS_tr0_FROM_opened_TO_closed_BY_closelog;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_log__internalLog:
+ {
+ chain = CHAIN_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/InternalLogData.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/InternalLogData.java
new file mode 100644
index 000000000..67f715a96
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/InternalLogData.java
@@ -0,0 +1,60 @@
+package room.basic.service.logging;
+
+
+
+
+public class InternalLogData {
+
+
+ /*--------------------- attributes ---------------------*/
+ String userString;
+ String sender;
+ long timeStamp;
+
+ //--------------------- attribute setters and getters
+ public void setUserString (String userString) {
+ this.userString = userString;
+ }
+ public String getUserString () {
+ return this.userString;
+ }
+ public void setSender (String sender) {
+ this.sender = sender;
+ }
+ public String getSender () {
+ return this.sender;
+ }
+ public void setTimeStamp (long timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+ public long getTimeStamp () {
+ return this.timeStamp;
+ }
+
+ /*--------------------- operations ---------------------*/
+
+ // default constructor
+ public InternalLogData() {
+ super();
+
+ // initialize attributes
+ }
+
+ // constructor using fields
+ public InternalLogData(String userString, String sender, long timeStamp) {
+ super();
+
+ this.userString = userString;
+ this.sender = sender;
+ this.timeStamp = timeStamp;
+ }
+
+ // deep copy
+ public InternalLogData deepCopy() {
+ InternalLogData copy = new InternalLogData();
+ copy.userString = userString;
+ copy.sender = sender;
+ copy.timeStamp = timeStamp;
+ return copy;
+ }
+};
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/Log.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/Log.java
new file mode 100644
index 000000000..eb0d7fcb1
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/Log.java
@@ -0,0 +1,230 @@
+package room.basic.service.logging;
+
+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 Log {
+ // message IDs
+ public static final int MSG_MIN = 0;
+ public static final int IN_open = 1;
+ public static final int IN_close = 2;
+ public static final int IN_internalLog = 3;
+ public static final int MSG_MAX = 4;
+
+ /*--------------------- begin user code ---------------------*/
+ public static final int LOG_LEVEL_LOW = 1;
+ public static final int LOG_LEVEL_MEDIUM = 2;
+ public static final int LOG_LEVEL_HIGH = 3;
+ /*--------------------- end user code ---------------------*/
+
+ private static String messageStrings[] = {"MIN", "open","close","internalLog","MAX"};
+
+ public String getMessageString(int msg_id) {
+ if (msg_id<MSG_MIN || 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 LogPort extends PortBase {
+ // constructors
+ public LogPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ this(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public LogPort(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"){
+ 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 LogReplPort {
+ private ArrayList<LogPort> ports;
+ private int replication;
+
+ public LogReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<Log.LogPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new LogPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public LogPort get(int i) {
+ return ports.get(i);
+ }
+
+ // outgoing messages
+ }
+
+
+ // port class
+ static public class LogConjPort extends PortBase {
+ /*--------------------- begin user code ---------------------*/
+ static int logLevel=0;
+ InternalLogData d = new InternalLogData();
+ /*--------------------- end user code ---------------------*/
+ // constructors
+ public LogConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ this(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public LogConjPort(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
+ super(actor, name, localId, idx, addr, peerAddress);
+ // initialize attributes
+ 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"){
+ 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);
+ }
+ }
+
+ /*--------------------- attributes ---------------------*/
+ // TODO JH: Avoid collision attr getters/setter <-> user operations
+ //--------------------- attribute setters and getters
+ /*--------------------- operations ---------------------*/
+ public void setLogLevel(int l) {
+ logLevel=l;
+ if (logLevel > LOG_LEVEL_HIGH) logLevel=LOG_LEVEL_HIGH;
+ }
+ public void log(int logLevel, String userString) {
+ long s;
+ if (logLevel>this.logLevel){
+ d.userString=userString;
+ d.timeStamp=System.currentTimeMillis();
+ d.sender=getInstancePath();
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalLog, d.deepCopy()));
+ }
+ }
+
+ // sent messages
+ public void open(String fileName) {
+ if (messageStrings[ IN_open] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_open]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_open, fileName));
+ }
+ public void close() {
+ if (messageStrings[ IN_close] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_close]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_close));
+ }
+ private void internalLog(InternalLogData data) {
+ if (messageStrings[ IN_internalLog] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalLog]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalLog, data.deepCopy()));
+ }
+ public void internalLog(String userString, String sender, long timeStamp) {
+ internalLog(new InternalLogData(userString, sender, timeStamp));
+ }
+ }
+
+ // replicated port class
+ static public class LogConjReplPort {
+ private ArrayList<LogConjPort> ports;
+ private int replication;
+
+ public LogConjReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<Log.LogConjPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new LogConjPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public LogConjPort get(int i) {
+ return ports.get(i);
+ }
+
+ // incoming messages
+ public void open(String fileName){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).open( fileName);
+ }
+ }
+ public void close(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).close();
+ }
+ }
+ private void internalLog(InternalLogData data){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).internalLog( data);
+ }
+ }
+ }
+
+}
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java
index e374b4dab..6c1e24d6c 100644
--- a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java
@@ -1,362 +1,362 @@
-package room.basic.service.tcp;
-
-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 static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;
-
-
-import room.basic.service.tcp.PTcpControl.*;
-import room.basic.service.tcp.PTcpPayload.*;
-
-/*--------------------- begin user code ---------------------*/
-import java.net.Socket;
-import java.io.*;
-
- class ClientRxThread extends Thread{
- private Socket sock;
- PTcpPayloadPort port;
- public ClientRxThread (PTcpPayloadPort port, Socket sock){
- this.sock = sock;
- this.port = port;
- }
- public void run(){
- try{
- InputStream in = sock.getInputStream();
- DTcpPayload d = new DTcpPayload();
- d.setConnectionId(0);
- int c;
- while ((c=in.read(d.getData()))!=-1){
- d.setLength(c);
- port.receive(d);
- }
- }catch (IOException e){
- System.err.println("ClientRx: " + e.toString());
- }
-
- }
- }
-/*--------------------- end user code ---------------------*/
-
-
-public class ATcpClient extends ActorClassBase {
-
- /*--------------------- begin user code ---------------------*/
- Socket socket;
- InputStream in;
- OutputStream out;
- /*--------------------- end user code ---------------------*/
-
-
- //--------------------- ports
- protected PTcpControlPort ControlPort = null;
- protected PTcpPayloadPort PayloadPort = null;
-
- //--------------------- saps
-
- //--------------------- services
-
- //--------------------- interface item IDs
- public static final int IFITEM_ControlPort = 1;
- public static final int IFITEM_PayloadPort = 2;
-
-
- /*--------------------- attributes ---------------------*/
- int lastError;
- /*--------------------- operations ---------------------*/
- public void stopUser() {
- try{
- if(socket != null){
- socket.close();
- }
- }catch(IOException e){
- System.err.println(e.toString());}
- }
-
- //--------------------- construction
- public ATcpClient(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
- super(parent, name, port_addr[0][0], peer_addr[0][0]);
- setClassName("ATcpClient");
-
- // initialize attributes
- lastError = 0;
-
- // own ports
- ControlPort = new PTcpControlPort(this, "ControlPort", IFITEM_ControlPort, 0, port_addr[IFITEM_ControlPort][0], peer_addr[IFITEM_ControlPort][0]);
- PayloadPort = new PTcpPayloadPort(this, "PayloadPort", IFITEM_PayloadPort, 0, port_addr[IFITEM_PayloadPort][0], peer_addr[IFITEM_PayloadPort][0]);
-
- // own saps
-
- // own service implementations
- }
-
-
- //--------------------- attribute setters and getters
- public void setLastError (int lastError) {
- this.lastError = lastError;
- }
- public int getLastError () {
- return this.lastError;
- }
-
-
- //--------------------- port getters
- public PTcpControlPort getControlPort (){
- return this.ControlPort;
- }
- public PTcpPayloadPort getPayloadPort (){
- return this.PayloadPort;
- }
-
- //--------------------- lifecycle functions
- public void init(){
- initUser();
- }
-
- public void start(){
- startUser();
- }
-
- public void stop(){
- stopUser();
- }
-
- public void destroy(){
- }
-
-
- /* state IDs */
- public static final int STATE_closed = 2;
- public static final int STATE_opened = 3;
- public static final int STATE_error = 4;
-
- /* transition chains */
- public static final int CHAIN_TRANS_INITIAL_TO__closed = 1;
- public static final int CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort = 2;
- public static final int CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort = 3;
- public static final int CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3 = 4;
-
- /* triggers */
- public static final int POLLING = 0;
- public static final int TRIG_ControlPort__close = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_close;
- public static final int TRIG_ControlPort__open = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_open;
- public static final int TRIG_PayloadPort__send = IFITEM_PayloadPort + EVT_SHIFT*PTcpPayload.IN_send;
-
- // state names
- protected static final String stateStrings[] = {"<no state>","<top>","closed",
- "opened",
- "error"
- };
-
- // history
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
-
- private void setState(int new_state) {
- DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
- if (stateStrings[new_state]!="Idle") {
- System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
- }
- this.state = new_state;
- }
-
- /* Entry and Exit Codes */
-
- /* Action Codes */
- protected void action_TRANS_INITIAL_TO__closed() {
- System.out.println("Client Init !");
- }
- protected void action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(InterfaceItemBase ifitem, DTcpControl data) {
- lastError=0;
- try{
- socket = new Socket(data.IPAddr,data.TcpPort);
- (new ClientRxThread(PayloadPort, socket)).start();
- out = socket.getOutputStream();
- }catch(IOException e){
- System.err.println(e.toString());
- lastError=1;
- }
- }
- protected void action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(InterfaceItemBase ifitem) {
- try{
- if (socket!=null){
- socket.close();
- }
- } catch (IOException e){
- System.err.println(e.toString());
- }
- }
- protected void action_TRANS_tr2_FROM_cp0_TO_opened(InterfaceItemBase ifitem, DTcpControl data) {
- ControlPort.established();
- }
- protected void action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(InterfaceItemBase ifitem, DTcpControl data) {
- ControlPort.error();
- try{
- socket.close();
- } catch(IOException e){
- System.err.println(e.toString());
- }
- }
- protected void action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(InterfaceItemBase ifitem, DTcpPayload data) {
- try{
- out.write(data.getData(),0,data.length);
- }catch(IOException e){
- System.err.println(e.toString());
- }
- }
-
- /**
- * 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_closed:
- this.history[STATE_TOP] = STATE_closed;
- current = STATE_TOP;
- break;
- case STATE_opened:
- this.history[STATE_TOP] = STATE_opened;
- current = STATE_TOP;
- break;
- case STATE_error:
- this.history[STATE_TOP] = STATE_error;
- 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__closed:
- {
- action_TRANS_INITIAL_TO__closed();
- return STATE_closed;
- }
- case CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort:
- {
- DTcpControl data = (DTcpControl) generic_data;
- action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(ifitem, data);
- if (lastError!=0) {
- action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(ifitem, data);
- return STATE_error;}
- else {
- action_TRANS_tr2_FROM_cp0_TO_opened(ifitem, data);
- return STATE_opened;}
- }
- case CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort:
- {
- action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(ifitem);
- return STATE_closed;
- }
- case CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3:
- {
- DTcpPayload data = (DTcpPayload) generic_data;
- action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(ifitem, data);
- return STATE_opened;
- }
- }
- 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_closed:
- // in leaf state: return state id
- return STATE_closed;
- case STATE_opened:
- // in leaf state: return state id
- return STATE_opened;
- case STATE_error:
- // in leaf state: return state id
- return STATE_error;
- case STATE_TOP:
- state = this.history[STATE_TOP];
- break;
- }
- skip_entry = false;
- }
- //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
- }
-
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__closed;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
- }
-
- /* receiveEvent contains the main implementation of the FSM */
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (this.state) {
- case STATE_closed:
- switch(trigger) {
- case TRIG_ControlPort__open:
- {
- chain = CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_opened:
- switch(trigger) {
- case TRIG_ControlPort__close:
- {
- chain = CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_PayloadPort__send:
- {
- chain = CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_error:
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(this.state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
-
- //******************************************
- // END of generated code for FSM
- //******************************************
-};
+package room.basic.service.tcp;
+
+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 static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;
+
+
+import room.basic.service.tcp.PTcpControl.*;
+import room.basic.service.tcp.PTcpPayload.*;
+
+/*--------------------- begin user code ---------------------*/
+import java.net.Socket;
+import java.io.*;
+
+ class ClientRxThread extends Thread{
+ private Socket sock;
+ PTcpPayloadPort port;
+ public ClientRxThread (PTcpPayloadPort port, Socket sock){
+ this.sock = sock;
+ this.port = port;
+ }
+ public void run(){
+ try{
+ InputStream in = sock.getInputStream();
+ DTcpPayload d = new DTcpPayload();
+ d.setConnectionId(0);
+ int c;
+ while ((c=in.read(d.getData()))!=-1){
+ d.setLength(c);
+ port.receive(d);
+ }
+ }catch (IOException e){
+ System.err.println("ClientRx: " + e.toString());
+ }
+
+ }
+ }
+/*--------------------- end user code ---------------------*/
+
+
+public class ATcpClient extends ActorClassBase {
+
+ /*--------------------- begin user code ---------------------*/
+ Socket socket;
+ InputStream in;
+ OutputStream out;
+ /*--------------------- end user code ---------------------*/
+
+
+ //--------------------- ports
+ protected PTcpControlPort ControlPort = null;
+ protected PTcpPayloadPort PayloadPort = null;
+
+ //--------------------- saps
+
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ public static final int IFITEM_ControlPort = 1;
+ public static final int IFITEM_PayloadPort = 2;
+
+
+ /*--------------------- attributes ---------------------*/
+ int lastError;
+ /*--------------------- operations ---------------------*/
+ public void stopUser() {
+ try{
+ if(socket != null){
+ socket.close();
+ }
+ }catch(IOException e){
+ System.err.println(e.toString());}
+ }
+
+ //--------------------- construction
+ public ATcpClient(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("ATcpClient");
+
+ // initialize attributes
+ lastError = 0;
+
+ // own ports
+ ControlPort = new PTcpControlPort(this, "ControlPort", IFITEM_ControlPort, 0, port_addr[IFITEM_ControlPort][0], peer_addr[IFITEM_ControlPort][0]);
+ PayloadPort = new PTcpPayloadPort(this, "PayloadPort", IFITEM_PayloadPort, 0, port_addr[IFITEM_PayloadPort][0], peer_addr[IFITEM_PayloadPort][0]);
+
+ // own saps
+
+ // own service implementations
+ }
+
+
+ //--------------------- attribute setters and getters
+ public void setLastError (int lastError) {
+ this.lastError = lastError;
+ }
+ public int getLastError () {
+ return this.lastError;
+ }
+
+
+ //--------------------- port getters
+ public PTcpControlPort getControlPort (){
+ return this.ControlPort;
+ }
+ public PTcpPayloadPort getPayloadPort (){
+ return this.PayloadPort;
+ }
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ }
+
+
+ /* state IDs */
+ public static final int STATE_closed = 2;
+ public static final int STATE_opened = 3;
+ public static final int STATE_error = 4;
+
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__closed = 1;
+ public static final int CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort = 2;
+ public static final int CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort = 3;
+ public static final int CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3 = 4;
+
+ /* triggers */
+ public static final int POLLING = 0;
+ public static final int TRIG_ControlPort__close = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_close;
+ public static final int TRIG_ControlPort__open = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_open;
+ public static final int TRIG_PayloadPort__send = IFITEM_PayloadPort + EVT_SHIFT*PTcpPayload.IN_send;
+
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","closed",
+ "opened",
+ "error"
+ };
+
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ /* Entry and Exit Codes */
+
+ /* Action Codes */
+ protected void action_TRANS_INITIAL_TO__closed() {
+ System.out.println("Client Init !");
+ }
+ protected void action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(InterfaceItemBase ifitem, DTcpControl data) {
+ lastError=0;
+ try{
+ socket = new Socket(data.IPAddr,data.TcpPort);
+ (new ClientRxThread(PayloadPort, socket)).start();
+ out = socket.getOutputStream();
+ }catch(IOException e){
+ System.err.println(e.toString());
+ lastError=1;
+ }
+ }
+ protected void action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(InterfaceItemBase ifitem) {
+ try{
+ if (socket!=null){
+ socket.close();
+ }
+ } catch (IOException e){
+ System.err.println(e.toString());
+ }
+ }
+ protected void action_TRANS_tr2_FROM_cp0_TO_opened(InterfaceItemBase ifitem, DTcpControl data) {
+ ControlPort.established();
+ }
+ protected void action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(InterfaceItemBase ifitem, DTcpControl data) {
+ ControlPort.error();
+ try{
+ socket.close();
+ } catch(IOException e){
+ System.err.println(e.toString());
+ }
+ }
+ protected void action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(InterfaceItemBase ifitem, DTcpPayload data) {
+ try{
+ out.write(data.getData(),0,data.length);
+ }catch(IOException e){
+ System.err.println(e.toString());
+ }
+ }
+
+ /**
+ * 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_closed:
+ this.history[STATE_TOP] = STATE_closed;
+ current = STATE_TOP;
+ break;
+ case STATE_opened:
+ this.history[STATE_TOP] = STATE_opened;
+ current = STATE_TOP;
+ break;
+ case STATE_error:
+ this.history[STATE_TOP] = STATE_error;
+ 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__closed:
+ {
+ action_TRANS_INITIAL_TO__closed();
+ return STATE_closed;
+ }
+ case CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort:
+ {
+ DTcpControl data = (DTcpControl) generic_data;
+ action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(ifitem, data);
+ if (lastError!=0) {
+ action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(ifitem, data);
+ return STATE_error;}
+ else {
+ action_TRANS_tr2_FROM_cp0_TO_opened(ifitem, data);
+ return STATE_opened;}
+ }
+ case CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort:
+ {
+ action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(ifitem);
+ return STATE_closed;
+ }
+ case CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3:
+ {
+ DTcpPayload data = (DTcpPayload) generic_data;
+ action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(ifitem, data);
+ return STATE_opened;
+ }
+ }
+ 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_closed:
+ // in leaf state: return state id
+ return STATE_closed;
+ case STATE_opened:
+ // in leaf state: return state id
+ return STATE_opened;
+ case STATE_error:
+ // in leaf state: return state id
+ return STATE_error;
+ case STATE_TOP:
+ state = this.history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__closed;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_closed:
+ switch(trigger) {
+ case TRIG_ControlPort__open:
+ {
+ chain = CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_opened:
+ switch(trigger) {
+ case TRIG_ControlPort__close:
+ {
+ chain = CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PayloadPort__send:
+ {
+ chain = CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_error:
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java
new file mode 100644
index 000000000..48408e69a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java
@@ -0,0 +1,401 @@
+package room.basic.service.tcp;
+
+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 static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;
+
+
+import room.basic.service.tcp.PTcpControl.*;
+import room.basic.service.tcp.PTcpPayload.*;
+
+/*--------------------- begin user code ---------------------*/
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.io.*;
+import java.util.*;
+
+ class ServerRxThread extends Thread{
+ private int connectionId;
+ private Socket sock;
+ PTcpPayloadPort port;
+
+ public ServerRxThread (int connectionId, PTcpPayloadPort port, Socket sock){
+ this.sock = sock;
+ this.connectionId = connectionId;
+ this.port = port;
+ }
+
+ public void run(){
+ try{
+ InputStream in = sock.getInputStream();
+ DTcpPayload d = new DTcpPayload();
+ d.setConnectionId(connectionId);
+ int c;
+ while ((c=in.read(d.getData()))!=-1){
+ d.setLength(c);
+ port.receive(d);
+ }
+ }catch (IOException e){
+ System.err.println("ServerRx: " + e.toString());
+ }
+ }
+ }
+
+ class ServerAcceptThread extends Thread{
+ private ServerSocket sock;
+ private PTcpPayloadPort port;
+ private ATcpServer parent;
+ public ServerAcceptThread (PTcpPayloadPort port, ServerSocket sock, ATcpServer parent){
+ this.sock = sock;
+ this.port = port;
+ this.parent = parent;
+ }
+ public void run(){
+ int cnt=0;
+ try{
+ while (true){
+ Socket s = sock.accept();
+ parent.addOutStreamToHashmap(cnt, s.getOutputStream());
+ (new ServerRxThread(cnt, port, s)).start();
+ cnt++;
+ }
+ }catch (IOException e){
+ System.err.println("Server Accept: " + e.toString());
+ }
+ }
+ }
+
+/*--------------------- end user code ---------------------*/
+
+
+public class ATcpServer extends ActorClassBase {
+
+ /*--------------------- begin user code ---------------------*/
+ ServerSocket socket = null;
+ InputStream in = null;
+ OutputStream out = null;
+ Hashtable<Integer,OutputStream> outStreams = new Hashtable<Integer,OutputStream>();
+
+ synchronized protected void addOutStreamToHashmap(int cnt, OutputStream out){
+ outStreams.put(cnt,out);
+ }
+
+ /*--------------------- end user code ---------------------*/
+
+
+ //--------------------- ports
+ protected PTcpControlPort ControlPort = null;
+ protected PTcpPayloadPort PayloadPort = null;
+
+ //--------------------- saps
+
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ public static final int IFITEM_ControlPort = 1;
+ public static final int IFITEM_PayloadPort = 2;
+
+
+ /*--------------------- attributes ---------------------*/
+ int lastError;
+ int payloadPortReplocation;
+ /*--------------------- operations ---------------------*/
+ public void stopUser() {
+ try{
+ if(socket != null){
+ socket.close();
+ }
+ }catch(IOException e){
+ System.err.println(e.toString());}
+ }
+
+ //--------------------- construction
+ public ATcpServer(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("ATcpServer");
+
+ // initialize attributes
+ lastError = 0;
+ payloadPortReplocation = 0;
+
+ // own ports
+ ControlPort = new PTcpControlPort(this, "ControlPort", IFITEM_ControlPort, 0, port_addr[IFITEM_ControlPort][0], peer_addr[IFITEM_ControlPort][0]);
+ PayloadPort = new PTcpPayloadPort(this, "PayloadPort", IFITEM_PayloadPort, 0, port_addr[IFITEM_PayloadPort][0], peer_addr[IFITEM_PayloadPort][0]);
+
+ // own saps
+
+ // own service implementations
+ }
+
+
+ //--------------------- attribute setters and getters
+ public void setLastError (int lastError) {
+ this.lastError = lastError;
+ }
+ public int getLastError () {
+ return this.lastError;
+ }
+ public void setPayloadPortReplocation (int payloadPortReplocation) {
+ this.payloadPortReplocation = payloadPortReplocation;
+ }
+ public int getPayloadPortReplocation () {
+ return this.payloadPortReplocation;
+ }
+
+
+ //--------------------- port getters
+ public PTcpControlPort getControlPort (){
+ return this.ControlPort;
+ }
+ public PTcpPayloadPort getPayloadPort (){
+ return this.PayloadPort;
+ }
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ }
+
+
+ /* state IDs */
+ public static final int STATE_closed = 2;
+ public static final int STATE_opened = 3;
+ public static final int STATE_error = 4;
+
+ /* transition chains */
+ public static final int CHAIN_TRANS_INITIAL_TO__closed = 1;
+ public static final int CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort = 2;
+ public static final int CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort = 3;
+ public static final int CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3 = 4;
+
+ /* triggers */
+ public static final int POLLING = 0;
+ public static final int TRIG_ControlPort__close = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_close;
+ public static final int TRIG_ControlPort__open = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_open;
+ public static final int TRIG_PayloadPort__send = IFITEM_PayloadPort + EVT_SHIFT*PTcpPayload.IN_send;
+
+ // state names
+ protected static final String stateStrings[] = {"<no state>","<top>","closed",
+ "opened",
+ "error"
+ };
+
+ // history
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ /* Entry and Exit Codes */
+
+ /* Action Codes */
+ protected void action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(InterfaceItemBase ifitem, DTcpControl data) {
+ lastError=0;
+ try{
+ socket = new ServerSocket(data.TcpPort);
+ (new ServerAcceptThread(PayloadPort, socket, this)).start();
+ }catch(IOException e){
+ System.err.println(e.toString());
+ lastError=1;
+ }
+ }
+ protected void action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(InterfaceItemBase ifitem) {
+ try{
+ if(socket!=null){
+ socket.close();
+ }
+ }catch(IOException e){
+ System.err.println(e.toString());
+ }
+ }
+ protected void action_TRANS_tr2_FROM_cp0_TO_opened(InterfaceItemBase ifitem, DTcpControl data) {
+ ControlPort.established();
+ }
+ protected void action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(InterfaceItemBase ifitem, DTcpControl data) {
+ ControlPort.error();
+ try{
+ socket.close();
+ } catch(IOException e){
+ System.err.println(e.toString());
+ }
+ }
+ protected void action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(InterfaceItemBase ifitem, DTcpPayload data) {
+ try{
+ outStreams.get(data.getConnectionId()).write(data.getData(),0,data.length);
+ }catch(IOException e){
+ System.err.println(e.toString());
+ }
+ }
+
+ /**
+ * 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_closed:
+ this.history[STATE_TOP] = STATE_closed;
+ current = STATE_TOP;
+ break;
+ case STATE_opened:
+ this.history[STATE_TOP] = STATE_opened;
+ current = STATE_TOP;
+ break;
+ case STATE_error:
+ this.history[STATE_TOP] = STATE_error;
+ 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__closed:
+ {
+ return STATE_closed;
+ }
+ case CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort:
+ {
+ DTcpControl data = (DTcpControl) generic_data;
+ action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(ifitem, data);
+ if (lastError!=0) {
+ action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(ifitem, data);
+ return STATE_error;}
+ else {
+ action_TRANS_tr2_FROM_cp0_TO_opened(ifitem, data);
+ return STATE_opened;}
+ }
+ case CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort:
+ {
+ action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(ifitem);
+ return STATE_closed;
+ }
+ case CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3:
+ {
+ DTcpPayload data = (DTcpPayload) generic_data;
+ action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(ifitem, data);
+ return STATE_opened;
+ }
+ }
+ 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_closed:
+ // in leaf state: return state id
+ return STATE_closed;
+ case STATE_opened:
+ // in leaf state: return state id
+ return STATE_opened;
+ case STATE_error:
+ // in leaf state: return state id
+ return STATE_error;
+ case STATE_TOP:
+ state = this.history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__closed;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /* receiveEvent contains the main implementation of the FSM */
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
+ int chain = NOT_CAUGHT;
+ int catching_state = NO_STATE;
+ boolean is_handler = false;
+ boolean skip_entry = false;
+
+ if (!handleSystemEvent(ifitem, evt, generic_data)) {
+ switch (this.state) {
+ case STATE_closed:
+ switch(trigger) {
+ case TRIG_ControlPort__open:
+ {
+ chain = CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_opened:
+ switch(trigger) {
+ case TRIG_ControlPort__close:
+ {
+ chain = CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_PayloadPort__send:
+ {
+ chain = CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_error:
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(this.state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpControl.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpControl.java
index cfeeff425..5316b3057 100644
--- a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpControl.java
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpControl.java
@@ -1,51 +1,51 @@
-package room.basic.service.tcp;
-
-
-
-
-public class DTcpControl {
-
-
- /*--------------------- attributes ---------------------*/
- String IPAddr;
- int TcpPort;
-
- //--------------------- attribute setters and getters
- public void setIPAddr (String IPAddr) {
- this.IPAddr = IPAddr;
- }
- public String getIPAddr () {
- return this.IPAddr;
- }
- public void setTcpPort (int TcpPort) {
- this.TcpPort = TcpPort;
- }
- public int getTcpPort () {
- return this.TcpPort;
- }
-
- /*--------------------- operations ---------------------*/
-
- // default constructor
- public DTcpControl() {
- super();
-
- // initialize attributes
- }
-
- // constructor using fields
- public DTcpControl(String IPAddr, int TcpPort) {
- super();
-
- this.IPAddr = IPAddr;
- this.TcpPort = TcpPort;
- }
-
- // deep copy
- public DTcpControl deepCopy() {
- DTcpControl copy = new DTcpControl();
- copy.IPAddr = IPAddr;
- copy.TcpPort = TcpPort;
- return copy;
- }
-};
+package room.basic.service.tcp;
+
+
+
+
+public class DTcpControl {
+
+
+ /*--------------------- attributes ---------------------*/
+ String IPAddr;
+ int TcpPort;
+
+ //--------------------- attribute setters and getters
+ public void setIPAddr (String IPAddr) {
+ this.IPAddr = IPAddr;
+ }
+ public String getIPAddr () {
+ return this.IPAddr;
+ }
+ public void setTcpPort (int TcpPort) {
+ this.TcpPort = TcpPort;
+ }
+ public int getTcpPort () {
+ return this.TcpPort;
+ }
+
+ /*--------------------- operations ---------------------*/
+
+ // default constructor
+ public DTcpControl() {
+ super();
+
+ // initialize attributes
+ }
+
+ // constructor using fields
+ public DTcpControl(String IPAddr, int TcpPort) {
+ super();
+
+ this.IPAddr = IPAddr;
+ this.TcpPort = TcpPort;
+ }
+
+ // deep copy
+ public DTcpControl deepCopy() {
+ DTcpControl copy = new DTcpControl();
+ copy.IPAddr = IPAddr;
+ copy.TcpPort = TcpPort;
+ return copy;
+ }
+};
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpPayload.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpPayload.java
index 7a23d06e2..0bd40e08e 100644
--- a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpPayload.java
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpPayload.java
@@ -1,63 +1,63 @@
-package room.basic.service.tcp;
-
-
-
-
-public class DTcpPayload {
-
-
- /*--------------------- attributes ---------------------*/
- int connectionId;
- int length;
- byte data[];
-
- //--------------------- attribute setters and getters
- public void setConnectionId (int connectionId) {
- this.connectionId = connectionId;
- }
- public int getConnectionId () {
- return this.connectionId;
- }
- public void setLength (int length) {
- this.length = length;
- }
- public int getLength () {
- return this.length;
- }
- public void setData (byte[] data) {
- this.data = data;
- }
- public byte[] getData () {
- return this.data;
- }
-
- /*--------------------- operations ---------------------*/
-
- // default constructor
- public DTcpPayload() {
- super();
-
- // initialize attributes
- data = new byte[1000];
- }
-
- // constructor using fields
- public DTcpPayload(int connectionId, int length, byte[] data) {
- super();
-
- this.connectionId = connectionId;
- this.length = length;
- this.data = data;
- }
-
- // deep copy
- public DTcpPayload deepCopy() {
- DTcpPayload copy = new DTcpPayload();
- copy.connectionId = connectionId;
- copy.length = length;
- for (int i=0;i<data.length;i++){
- copy.data[i] = data[i];
- }
- return copy;
- }
-};
+package room.basic.service.tcp;
+
+
+
+
+public class DTcpPayload {
+
+
+ /*--------------------- attributes ---------------------*/
+ int connectionId;
+ int length;
+ byte data[];
+
+ //--------------------- attribute setters and getters
+ public void setConnectionId (int connectionId) {
+ this.connectionId = connectionId;
+ }
+ public int getConnectionId () {
+ return this.connectionId;
+ }
+ public void setLength (int length) {
+ this.length = length;
+ }
+ public int getLength () {
+ return this.length;
+ }
+ public void setData (byte[] data) {
+ this.data = data;
+ }
+ public byte[] getData () {
+ return this.data;
+ }
+
+ /*--------------------- operations ---------------------*/
+
+ // default constructor
+ public DTcpPayload() {
+ super();
+
+ // initialize attributes
+ data = new byte[1000];
+ }
+
+ // constructor using fields
+ public DTcpPayload(int connectionId, int length, byte[] data) {
+ super();
+
+ this.connectionId = connectionId;
+ this.length = length;
+ this.data = data;
+ }
+
+ // deep copy
+ public DTcpPayload deepCopy() {
+ DTcpPayload copy = new DTcpPayload();
+ copy.connectionId = connectionId;
+ copy.length = length;
+ for (int i=0;i<data.length;i++){
+ copy.data[i] = data[i];
+ }
+ return copy;
+ }
+};
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpControl.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpControl.java
index 8236e5db2..1bddfd5bc 100644
--- a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpControl.java
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpControl.java
@@ -1,215 +1,215 @@
-package room.basic.service.tcp;
-
-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 PTcpControl {
- // message IDs
- public static final int MSG_MIN = 0;
- public static final int OUT_established = 1;
- public static final int OUT_error = 2;
- public static final int IN_open = 3;
- public static final int IN_close = 4;
- public static final int MSG_MAX = 5;
-
-
- private static String messageStrings[] = {"MIN", "established","error", "open","close","MAX"};
-
- public String getMessageString(int msg_id) {
- if (msg_id<MSG_MIN || 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 PTcpControlPort extends PortBase {
- // constructors
- public PTcpControlPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
- this(actor, name, localId, 0, addr, peerAddress);
- DebuggingService.getInstance().addPortInstance(this);
- }
- public PTcpControlPort(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"){
- 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 established() {
- if (messageStrings[ OUT_established] != "timerTick"){
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_established]);
- }
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_established));
- }
- public void error() {
- if (messageStrings[ OUT_error] != "timerTick"){
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_error]);
- }
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_error));
- }
- }
-
- // replicated port class
- static public class PTcpControlReplPort {
- private ArrayList<PTcpControlPort> ports;
- private int replication;
-
- public PTcpControlReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = addr==null? 0:addr.length;
- ports = new ArrayList<PTcpControl.PTcpControlPort>(replication);
- for (int i=0; i<replication; ++i) {
- ports.add(new PTcpControlPort(
- actor, name+i, localId, i, addr[i], peerAddress[i]));
- }
- }
-
- public int getReplication() {
- return replication;
- }
-
- public int getIndexOf(InterfaceItemBase ifitem){
- return ifitem.getIdx();
- }
-
- public PTcpControlPort get(int i) {
- return ports.get(i);
- }
-
- // outgoing messages
- public void established(){
- for (int i=0; i<replication; ++i) {
- ports.get(i).established();
- }
- }
- public void error(){
- for (int i=0; i<replication; ++i) {
- ports.get(i).error();
- }
- }
- }
-
-
- // port class
- static public class PTcpControlConjPort extends PortBase {
- // constructors
- public PTcpControlConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
- this(actor, name, localId, 0, addr, peerAddress);
- DebuggingService.getInstance().addPortInstance(this);
- }
- public PTcpControlConjPort(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"){
- 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 open(DTcpControl data) {
- if (messageStrings[ IN_open] != "timerTick"){
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_open]);
- }
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_open, data.deepCopy()));
- }
- public void open(String IPAddr, int TcpPort) {
- open(new DTcpControl(IPAddr, TcpPort));
- }
- public void close() {
- if (messageStrings[ IN_close] != "timerTick"){
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_close]);
- }
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_close));
- }
- }
-
- // replicated port class
- static public class PTcpControlConjReplPort {
- private ArrayList<PTcpControlConjPort> ports;
- private int replication;
-
- public PTcpControlConjReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = addr==null? 0:addr.length;
- ports = new ArrayList<PTcpControl.PTcpControlConjPort>(replication);
- for (int i=0; i<replication; ++i) {
- ports.add(new PTcpControlConjPort(
- actor, name+i, localId, i, addr[i], peerAddress[i]));
- }
- }
-
- public int getReplication() {
- return replication;
- }
-
- public int getIndexOf(InterfaceItemBase ifitem){
- return ifitem.getIdx();
- }
-
- public PTcpControlConjPort get(int i) {
- return ports.get(i);
- }
-
- // incoming messages
- public void open(DTcpControl data){
- for (int i=0; i<replication; ++i) {
- ports.get(i).open( data);
- }
- }
- public void close(){
- for (int i=0; i<replication; ++i) {
- ports.get(i).close();
- }
- }
- }
-
-}
+package room.basic.service.tcp;
+
+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 PTcpControl {
+ // message IDs
+ public static final int MSG_MIN = 0;
+ public static final int OUT_established = 1;
+ public static final int OUT_error = 2;
+ public static final int IN_open = 3;
+ public static final int IN_close = 4;
+ public static final int MSG_MAX = 5;
+
+
+ private static String messageStrings[] = {"MIN", "established","error", "open","close","MAX"};
+
+ public String getMessageString(int msg_id) {
+ if (msg_id<MSG_MIN || 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 PTcpControlPort extends PortBase {
+ // constructors
+ public PTcpControlPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ this(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PTcpControlPort(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"){
+ 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 established() {
+ if (messageStrings[ OUT_established] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_established]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_established));
+ }
+ public void error() {
+ if (messageStrings[ OUT_error] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_error]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_error));
+ }
+ }
+
+ // replicated port class
+ static public class PTcpControlReplPort {
+ private ArrayList<PTcpControlPort> ports;
+ private int replication;
+
+ public PTcpControlReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<PTcpControl.PTcpControlPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PTcpControlPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PTcpControlPort get(int i) {
+ return ports.get(i);
+ }
+
+ // outgoing messages
+ public void established(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).established();
+ }
+ }
+ public void error(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).error();
+ }
+ }
+ }
+
+
+ // port class
+ static public class PTcpControlConjPort extends PortBase {
+ // constructors
+ public PTcpControlConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ this(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PTcpControlConjPort(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"){
+ 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 open(DTcpControl data) {
+ if (messageStrings[ IN_open] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_open]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_open, data.deepCopy()));
+ }
+ public void open(String IPAddr, int TcpPort) {
+ open(new DTcpControl(IPAddr, TcpPort));
+ }
+ public void close() {
+ if (messageStrings[ IN_close] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_close]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_close));
+ }
+ }
+
+ // replicated port class
+ static public class PTcpControlConjReplPort {
+ private ArrayList<PTcpControlConjPort> ports;
+ private int replication;
+
+ public PTcpControlConjReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<PTcpControl.PTcpControlConjPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PTcpControlConjPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PTcpControlConjPort get(int i) {
+ return ports.get(i);
+ }
+
+ // incoming messages
+ public void open(DTcpControl data){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).open( data);
+ }
+ }
+ public void close(){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).close();
+ }
+ }
+ }
+
+}
diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpPayload.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpPayload.java
index c8155e351..dbec6de16 100644
--- a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpPayload.java
+++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpPayload.java
@@ -1,192 +1,192 @@
-package room.basic.service.tcp;
-
-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 PTcpPayload {
- // message IDs
- public static final int MSG_MIN = 0;
- public static final int OUT_receive = 1;
- public static final int IN_send = 2;
- public static final int MSG_MAX = 3;
-
-
- private static String messageStrings[] = {"MIN", "receive", "send","MAX"};
-
- public String getMessageString(int msg_id) {
- if (msg_id<MSG_MIN || 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 PTcpPayloadPort extends PortBase {
- // constructors
- public PTcpPayloadPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
- this(actor, name, localId, 0, addr, peerAddress);
- DebuggingService.getInstance().addPortInstance(this);
- }
- public PTcpPayloadPort(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"){
- 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 receive(DTcpPayload data) {
- if (messageStrings[ OUT_receive] != "timerTick"){
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_receive]);
- }
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_receive, data.deepCopy()));
- }
- public void receive(int connectionId, int length, byte[] data) {
- receive(new DTcpPayload(connectionId, length, data));
- }
- }
-
- // replicated port class
- static public class PTcpPayloadReplPort {
- private ArrayList<PTcpPayloadPort> ports;
- private int replication;
-
- public PTcpPayloadReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = addr==null? 0:addr.length;
- ports = new ArrayList<PTcpPayload.PTcpPayloadPort>(replication);
- for (int i=0; i<replication; ++i) {
- ports.add(new PTcpPayloadPort(
- actor, name+i, localId, i, addr[i], peerAddress[i]));
- }
- }
-
- public int getReplication() {
- return replication;
- }
-
- public int getIndexOf(InterfaceItemBase ifitem){
- return ifitem.getIdx();
- }
-
- public PTcpPayloadPort get(int i) {
- return ports.get(i);
- }
-
- // outgoing messages
- public void receive(DTcpPayload data){
- for (int i=0; i<replication; ++i) {
- ports.get(i).receive( data);
- }
- }
- }
-
-
- // port class
- static public class PTcpPayloadConjPort extends PortBase {
- // constructors
- public PTcpPayloadConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
- this(actor, name, localId, 0, addr, peerAddress);
- DebuggingService.getInstance().addPortInstance(this);
- }
- public PTcpPayloadConjPort(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"){
- 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 send(DTcpPayload data) {
- if (messageStrings[ IN_send] != "timerTick"){
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_send]);
- }
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_send, data.deepCopy()));
- }
- public void send(int connectionId, int length, byte[] data) {
- send(new DTcpPayload(connectionId, length, data));
- }
- }
-
- // replicated port class
- static public class PTcpPayloadConjReplPort {
- private ArrayList<PTcpPayloadConjPort> ports;
- private int replication;
-
- public PTcpPayloadConjReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = addr==null? 0:addr.length;
- ports = new ArrayList<PTcpPayload.PTcpPayloadConjPort>(replication);
- for (int i=0; i<replication; ++i) {
- ports.add(new PTcpPayloadConjPort(
- actor, name+i, localId, i, addr[i], peerAddress[i]));
- }
- }
-
- public int getReplication() {
- return replication;
- }
-
- public int getIndexOf(InterfaceItemBase ifitem){
- return ifitem.getIdx();
- }
-
- public PTcpPayloadConjPort get(int i) {
- return ports.get(i);
- }
-
- // incoming messages
- public void send(DTcpPayload data){
- for (int i=0; i<replication; ++i) {
- ports.get(i).send( data);
- }
- }
- }
-
-}
+package room.basic.service.tcp;
+
+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 PTcpPayload {
+ // message IDs
+ public static final int MSG_MIN = 0;
+ public static final int OUT_receive = 1;
+ public static final int IN_send = 2;
+ public static final int MSG_MAX = 3;
+
+
+ private static String messageStrings[] = {"MIN", "receive", "send","MAX"};
+
+ public String getMessageString(int msg_id) {
+ if (msg_id<MSG_MIN || 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 PTcpPayloadPort extends PortBase {
+ // constructors
+ public PTcpPayloadPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ this(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PTcpPayloadPort(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"){
+ 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 receive(DTcpPayload data) {
+ if (messageStrings[ OUT_receive] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_receive]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_receive, data.deepCopy()));
+ }
+ public void receive(int connectionId, int length, byte[] data) {
+ receive(new DTcpPayload(connectionId, length, data));
+ }
+ }
+
+ // replicated port class
+ static public class PTcpPayloadReplPort {
+ private ArrayList<PTcpPayloadPort> ports;
+ private int replication;
+
+ public PTcpPayloadReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<PTcpPayload.PTcpPayloadPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PTcpPayloadPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PTcpPayloadPort get(int i) {
+ return ports.get(i);
+ }
+
+ // outgoing messages
+ public void receive(DTcpPayload data){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).receive( data);
+ }
+ }
+ }
+
+
+ // port class
+ static public class PTcpPayloadConjPort extends PortBase {
+ // constructors
+ public PTcpPayloadConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ this(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PTcpPayloadConjPort(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"){
+ 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 send(DTcpPayload data) {
+ if (messageStrings[ IN_send] != "timerTick"){
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_send]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_send, data.deepCopy()));
+ }
+ public void send(int connectionId, int length, byte[] data) {
+ send(new DTcpPayload(connectionId, length, data));
+ }
+ }
+
+ // replicated port class
+ static public class PTcpPayloadConjReplPort {
+ private ArrayList<PTcpPayloadConjPort> ports;
+ private int replication;
+
+ public PTcpPayloadConjReplPort(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr==null? 0:addr.length;
+ ports = new ArrayList<PTcpPayload.PTcpPayloadConjPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PTcpPayloadConjPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PTcpPayloadConjPort get(int i) {
+ return ports.get(i);
+ }
+
+ // incoming messages
+ public void send(DTcpPayload data){
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).send( data);
+ }
+ }
+ }
+
+}

Back to the top