Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-01-25 10:29:46 +0000
committerThomas Schuetz2012-01-25 10:29:46 +0000
commit749b13f65870f2cbdc3ae89c90b432966300d235 (patch)
tree082725e7ff15264393e1f1b37390e652c6c20297 /runtime
parent4ff0a97045e63ba53a013a5f680328d359854731 (diff)
downloadorg.eclipse.etrice-749b13f65870f2cbdc3ae89c90b432966300d235.tar.gz
org.eclipse.etrice-749b13f65870f2cbdc3ae89c90b432966300d235.tar.xz
org.eclipse.etrice-749b13f65870f2cbdc3ae89c90b432966300d235.zip
[generator.c] first version of generator for ProtocolClass
Diffstat (limited to 'runtime')
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java81
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java51
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java285
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/SocketClient.java70
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/ALogService.java280
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/InternalLogData.java61
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/Log.java236
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/LogData.java51
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.abin90996 -> 90996 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h2
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h22
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etPort.c18
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etPort.h42
13 files changed, 84 insertions, 1115 deletions
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java b/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java
deleted file mode 100644
index 0264da386..000000000
--- a/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.eclipse.etrice.modellib.Socket;
-
-
-
-
-public class DSocketConfiguration {
-
-
- //--------------------- attributes
- protected String serverName = "";
- protected int portNumber = 0;
- protected int protocol = 0;
- protected boolean checkCookie = false;
- protected int mode = 0;
-
- //--------------------- 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
- serverName = "";
- portNumber = 0;
- protocol = 0;
- checkCookie = false;
- mode = 0;
- }
-
- // 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/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java b/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java
deleted file mode 100644
index 271a460e3..000000000
--- a/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.eclipse.etrice.modellib.Socket;
-
-
-
-
-public class DSocketData {
-
-
- //--------------------- attributes
- protected int size = 0;
- protected 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
- size = 0;
- data = "";
- }
-
- // 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/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java b/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java
deleted file mode 100644
index c530e5914..000000000
--- a/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java
+++ /dev/null
@@ -1,285 +0,0 @@
-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
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
- public static final int OUT_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;
- //IDs for incoming messages
- public static final int IN_connect = 6;
- public static final int IN_disconnect = 7;
- public static final int IN_sendData = 8;
- //error if msgID >= MSG_MAX
- 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) {
- super(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"){
- // TODOTS: model switch for activation
- DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
- }
- if (msg instanceof EventWithDataMessage)
- getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
- else
- getActor().receiveEvent(this, msg.getEvtId(), null);
- }
- }
-
-
- // sent messages
- public void connected() {
- if (messageStrings[ OUT_connected] != "timerTick"){
- // TODOTS: model switch for activation
- 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"){
- // TODOTS: model switch for activation
- 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"){
- // TODOTS: model switch for activation
- 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"){
- // TODOTS: model switch for activation
- 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"){
- // TODOTS: model switch for activation
- DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_error]);
- }
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_error));
- }
- }
-
- // replicated port class
- static public class PSocketPortRepl {
- private ArrayList<PSocketPort> ports;
- private int replication;
-
- public PSocketPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = 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) {
- super(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"){
- // TODOTS: model switch for activation
- DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
- }
- if (msg instanceof EventWithDataMessage)
- getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
- else
- getActor().receiveEvent(this, msg.getEvtId(), null);
- }
- }
-
-
- // sent messages
- public void connect(DSocketConfiguration config) {
- if (messageStrings[ IN_connect] != "timerTick"){
- // TODOTS: model switch for activation
- 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"){
- // TODOTS: model switch for activation
- 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"){
- // TODOTS: model switch for activation
- 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 PSocketConjPortRepl {
- private ArrayList<PSocketConjPort> ports;
- private int replication;
-
- public PSocketConjPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = 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/src-gen/org/eclipse/etrice/modellib/Socket/SocketClient.java b/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/SocketClient.java
deleted file mode 100644
index 8affaf89e..000000000
--- a/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/SocketClient.java
+++ /dev/null
@@ -1,70 +0,0 @@
-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 org.eclipse.etrice.modellib.Socket.PSocket.*;
-
-
-
-public class SocketClient extends ActorClassBase {
-
-
- //--------------------- ports
- protected PSocketPort fct = null;
- //--------------------- saps
- //--------------------- services
-
- //--------------------- interface item IDs
- protected 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
- }
-
-
- //--------------------- lifecycle functions
- public void init(){
- initUser();
- }
-
- public void start(){
- startUser();
- }
-
- public void stop(){
- stopUser();
- }
-
- public void destroy(){
- destroyUser();
- }
-
- //--------------------- no state machine
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {
- handleSystemEvent(ifitem, evt, data);
- }
-
- @Override
- public void executeInitTransition(){
- }
-};
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/ALogService.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/ALogService.java
deleted file mode 100644
index 37d2e2737..000000000
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/ALogService.java
+++ /dev/null
@@ -1,280 +0,0 @@
-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 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 LogPortRepl log = null;
-
- //--------------------- interface item IDs
- protected 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 LogPortRepl(this, "log", IFITEM_log, port_addr[IFITEM_log], peer_addr[IFITEM_log]);
- }
-
-
- //--------------------- lifecycle functions
- public void init(){
- initUser();
- }
-
- public void start(){
- startUser();
- }
-
- public void stop(){
- stopUser();
- }
-
- public void destroy(){
- destroyUser();
- }
-
- //******************************************
- // START of generated code for FSM
- //******************************************
-
- // State IDs for FSM
- protected static final int STATE_closed = 2;
- protected static final int STATE_opened = 3;
- protected static final String stateStrings[] = {"<no state>","<top>","closed",
- "opened"
- };
-
- // history
- // TODOHRR: history defined in ActorClassBase, init in constructor
- // history = new int[5];
- // for (int i = 0; i < history.length; i++) {
- // history[i] = NO_STATE;
- // }
- protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE};
-
- // transition chains
- protected static final int CHAIN_TRANS_INITIAL_TO__closed = 1;
- protected static final int CHAIN_TRANS_closed_TO_opened_BY_openlog = 2;
- protected static final int CHAIN_TRANS_opened_TO_closed_BY_closelog = 3;
- protected static final int CHAIN_TRANS_opened_TO_opened_BY_internalLoglog_tr1 = 4;
-
- // triggers for FSM
- protected static final int TRIG_log__close = IFITEM_log + EVT_SHIFT*Log.IN_close;
- protected static final int TRIG_log__internalLog = IFITEM_log + EVT_SHIFT*Log.IN_internalLog;
- protected static final int TRIG_log__open = IFITEM_log + EVT_SHIFT*Log.IN_open;
-
- // receiveEvent contains the main implementation of the FSM
- @Override
- public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
- int trigger = ifitem.getLocalId() + EVT_SHIFT*evt;
- int chain = NOT_CAUGHT;
- int catching_state = NO_STATE;
- boolean is_handler = false;
- boolean skip_entry = false;
-
- if (!handleSystemEvent(ifitem, evt, generic_data)) {
- switch (state) {
- case STATE_closed:
- switch(trigger) {
- case TRIG_log__open:
- {
- chain = CHAIN_TRANS_closed_TO_opened_BY_openlog;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- case STATE_opened:
- switch(trigger) {
- case TRIG_log__close:
- {
- chain = CHAIN_TRANS_opened_TO_closed_BY_closelog;
- catching_state = STATE_TOP;
- }
- break;
- case TRIG_log__internalLog:
- {
- chain = CHAIN_TRANS_opened_TO_opened_BY_internalLoglog_tr1;
- catching_state = STATE_TOP;
- }
- break;
- }
- break;
- }
- }
- if (chain != NOT_CAUGHT) {
- exitTo(state, catching_state, is_handler);
- int next = executeTransitionChain(chain, ifitem, generic_data);
- next = enterHistory(next, is_handler, skip_entry);
- setState(next);
- }
- }
-
- private void setState(int new_state) {
- DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
- if (stateStrings[new_state]!="Idle") {
- // TODOTS: model switch for activation
- System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
- }
- this.state = new_state;
- }
-
- @Override
- public void executeInitTransition() {
- int chain = CHAIN_TRANS_INITIAL_TO__closed;
- int next = executeTransitionChain(chain, null, null);
- next = enterHistory(next, false, false);
- setState(next);
- }
-
- /**
- * calls exit codes while exiting from the current state to one of its
- * parent states while remembering the history
- * @param current - the current state
- * @param to - the final parent state
- * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints)
- */
- private void exitTo(int current, int to, boolean handler) {
- while (current!=to) {
- switch (current) {
- case STATE_closed:
- history[STATE_TOP] = STATE_closed;
- current = STATE_TOP;
- break;
- case STATE_opened:
- 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_closed_TO_opened_BY_openlog:
- {
- String fileName = (String) generic_data;
- action_TRANS_closed_TO_opened_BY_openlog(ifitem, fileName);
- return STATE_opened;
- }
- case CHAIN_TRANS_opened_TO_closed_BY_closelog:
- {
- action_TRANS_opened_TO_closed_BY_closelog(ifitem);
- return STATE_closed;
- }
- case CHAIN_TRANS_opened_TO_opened_BY_internalLoglog_tr1:
- {
- InternalLogData data = (InternalLogData) generic_data;
- action_TRANS_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 = history[STATE_TOP];
- break;
- }
- skip_entry = false;
- }
- //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
- }
-
- //*** Entry and Exit Codes
-
- //*** Action Codes
- protected void action_TRANS_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_opened_TO_closed_BY_closelog(InterfaceItemBase ifitem) {
- p.flush();
- p.close();
- p=null;
- }
- protected void action_TRANS_opened_TO_opened_BY_internalLoglog_tr1(InterfaceItemBase ifitem, InternalLogData data) {
- long s = Long.valueOf(data.timeStamp);
- p.println("Timestamp: " + Long.toString(s-tStart) + "ms");
- p.println("SenderInstance: "+ data.sender);
- p.println("UserString: " + data.userString);
- p.println("--------------------------------------------------");
- System.out.printf(data.userString);
- }
-
- //******************************************
- // END of generated code for FSM
- //******************************************
-};
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/InternalLogData.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/InternalLogData.java
deleted file mode 100644
index ad18afdf3..000000000
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/InternalLogData.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package room.basic.service.logging;
-
-
-
-
-public class InternalLogData {
-
-
- //--------------------- attributes
- protected String userString = "";
- protected String sender = "";
- protected String 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 (String timeStamp) {
- this.timeStamp = timeStamp;
- }
- public String getTimeStamp () {
- return this.timeStamp;
- }
-
- //--------------------- operations
-
- // default constructor
- public InternalLogData() {
- super();
- // initialize attributes
- userString = "";
- sender = "";
- timeStamp = "";
- }
-
- // constructor using fields
- public InternalLogData(String userString, String sender, String 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/src-gen/room/basic/service/logging/Log.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/Log.java
deleted file mode 100644
index 4036df8dc..000000000
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/Log.java
+++ /dev/null
@@ -1,236 +0,0 @@
-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
- // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
- // error if msgID <= MSG_MIN
- public static final int MSG_MIN = 0;
- //IDs for outgoing messages
- //IDs for incoming messages
- public static final int IN_open = 1;
- public static final int IN_close = 2;
- public static final int IN_internalLog = 3;
- //error if msgID >= MSG_MAX
- public static final int MSG_MAX = 4;
-
-
- 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) {
- super(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"){
- // TODOTS: model switch for activation
- DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
- }
- if (msg instanceof EventWithDataMessage)
- getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
- else
- getActor().receiveEvent(this, msg.getEvtId(), null);
- }
- }
-
-
- // sent messages
- }
-
- // replicated port class
- static public class LogPortRepl {
- private ArrayList<LogPort> ports;
- private int replication;
-
- public LogPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = 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
- public static final int LOG_LEVEL_LOW = 1;
- public static final int LOG_LEVEL_MEDIUM = 2;
- public static final int LOG_LEVEL_HIGH = 3;
- static int logLevel=0;
- InternalLogData d = new InternalLogData();
- //--------------------- end user code
- // constructors
- public LogConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
- super(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);
- DebuggingService.getInstance().addPortInstance(this);
- }
-
- @Override
- public void receive(Message m) {
- if (!(m instanceof EventMessage))
- return;
- EventMessage msg = (EventMessage) m;
- if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
- System.out.println("unknown");
- else {
- if (messageStrings[msg.getEvtId()] != "timerTick"){
- // TODOTS: model switch for activation
- DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
- }
- if (msg instanceof EventWithDataMessage)
- getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
- else
- getActor().receiveEvent(this, msg.getEvtId(), null);
- }
- }
-
- //--------------------- attributes
- //--------------------- 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;
- s=System.currentTimeMillis();
- d.timeStamp=Long.toString(s);
- d.sender=getInstancePath();
- if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalLog, d));
- }
- }
-
- // sent messages
- public void open(String fileName) {
- if (messageStrings[ IN_open] != "timerTick"){
- // TODOTS: model switch for activation
- 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"){
- // TODOTS: model switch for activation
- 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"){
- // TODOTS: model switch for activation
- 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, String timeStamp) {
- internalLog(new InternalLogData(userString, sender, timeStamp));
- }
- }
-
- // replicated port class
- static public class LogConjPortRepl {
- private ArrayList<LogConjPort> ports;
- private int replication;
-
- public LogConjPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
- Address[] peerAddress) {
- replication = 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/src-gen/room/basic/service/logging/LogData.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/LogData.java
deleted file mode 100644
index c38358251..000000000
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/LogData.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package room.basic.service.logging;
-
-
-
-
-public class LogData {
-
-
- //--------------------- attributes
- protected int logLevel = 0;
- protected String userString = "";
-
- //--------------------- attribute setters and getters
- public void setLogLevel (int logLevel) {
- this.logLevel = logLevel;
- }
- public int getLogLevel () {
- return this.logLevel;
- }
- public void setUserString (String userString) {
- this.userString = userString;
- }
- public String getUserString () {
- return this.userString;
- }
-
- //--------------------- operations
-
- // default constructor
- public LogData() {
- super();
- // initialize attributes
- logLevel = 0;
- userString = "";
- }
-
- // constructor using fields
- public LogData(int logLevel, String userString) {
- super();
- this.logLevel = logLevel;
- this.userString = userString;
- }
-
- // deep copy
- public LogData deepCopy() {
- LogData copy = new LogData();
- copy.logLevel = logLevel;
- copy.userString = userString;
- return copy;
- }
-};
diff --git a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
index f2593d66d..4264199ee 100644
--- a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
+++ b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h
index f1edfa670..ee798d237 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h
@@ -66,4 +66,6 @@ typedef float64 etFloat64;
typedef FILE* etFileHandle;
+typedef int8 etAddressId;
+
#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h
new file mode 100644
index 000000000..6ff9485c3
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etMessageReceiver.h
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+
+#ifndef _ETMESSAGERECEIVER_H_
+#define _ETMESSAGERECEIVER_H_
+
+#include "etMessage.h"
+
+typedef void (*etReceiveMessage)(const etMessage*);
+
+#endif /* _ETMESSAGERECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etPort.c b/runtime/org.eclipse.etrice.runtime.c/src/etPort.c
new file mode 100644
index 000000000..6f122c15b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etPort.c
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "etPort.h"
+
+void etPort_receive(etPort* self, etMessage* msg) {
+ (self->receiveMessageFunc)(self->myActor, self->localId, msg);
+}
+
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etPort.h b/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
new file mode 100644
index 000000000..a714e5058
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etPort.h
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2012 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * CONTRIBUTORS:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+
+#ifndef _ETPORT_H_
+#define _ETPORT_H_
+
+
+#include "etMessage.h"
+#include "etMessageReceiver.h"
+#include "etMessageService.h"
+
+typedef struct {
+ void* myActor;
+ etReceiveMessage receiveMessageFunc;
+ etMessageService* msgService;
+ etAddressId peerAddress;
+ etAddressId localId;
+
+ #ifdef etDEBUG
+ etAddressId address;
+ /* thread ID from msg service: msgService->threadId */
+ #endif
+}
+etPort;
+
+void etPort_receive(etMessage* msg);
+
+
+
+
+#endif /* _ETPORT_H_ */

Back to the top