Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-01-09 16:30:56 +0000
committerHenrik Rentz-Reichert2012-01-09 16:30:56 +0000
commit122e7dbbefb9987413d6b917cc522b28c5a06513 (patch)
treeaa305803962ea911e5df2ede2ce6493d18f87815 /runtime
parent84e965103b17a8ff32b27581244d261bbb34ee04 (diff)
downloadorg.eclipse.etrice-122e7dbbefb9987413d6b917cc522b28c5a06513.tar.gz
org.eclipse.etrice-122e7dbbefb9987413d6b917cc522b28c5a06513.tar.xz
org.eclipse.etrice-122e7dbbefb9987413d6b917cc522b28c5a06513.zip
[modellib] added ALogService to launch configuration, added generated
files, fixes in JavaTypes
Diffstat (limited to 'runtime')
-rw-r--r--runtime/org.eclipse.etrice.modellib/gen_modellib.launch1
-rw-r--r--runtime/org.eclipse.etrice.modellib/models/JavaTypes.room4
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java70
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java43
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java303
-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.java52
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/Log.java246
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java2
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java6
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java6
12 files changed, 1074 insertions, 9 deletions
diff --git a/runtime/org.eclipse.etrice.modellib/gen_modellib.launch b/runtime/org.eclipse.etrice.modellib/gen_modellib.launch
index f9bf330d9..97f121538 100644
--- a/runtime/org.eclipse.etrice.modellib/gen_modellib.launch
+++ b/runtime/org.eclipse.etrice.modellib/gen_modellib.launch
@@ -6,6 +6,7 @@
<listAttribute key="ModelFiles">
<listEntry value="${workspace_loc:/org.eclipse.etrice.modellib/models/Socket.room}"/>
<listEntry value="${workspace_loc:/org.eclipse.etrice.modellib/models/TimingService.room}"/>
+<listEntry value="${workspace_loc:/org.eclipse.etrice.modellib/models/ALogService.room}"/>
</listAttribute>
<booleanAttribute key="SaveGenModel" value="false"/>
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
diff --git a/runtime/org.eclipse.etrice.modellib/models/JavaTypes.room b/runtime/org.eclipse.etrice.modellib/models/JavaTypes.room
index e99bc6ea0..77f776a95 100644
--- a/runtime/org.eclipse.etrice.modellib/models/JavaTypes.room
+++ b/runtime/org.eclipse.etrice.modellib/models/JavaTypes.room
@@ -1,6 +1,6 @@
RoomModel room.basic.types.java {
- PrimitiveType boolean -> int32 (Boolean) default "false"
+ PrimitiveType boolean -> boolean (Boolean) default "false"
PrimitiveType char -> char (Char) default "0"
PrimitiveType int8 -> byte (Byte) default "0"
PrimitiveType int16 -> short (Short) default "0"
@@ -8,6 +8,6 @@ RoomModel room.basic.types.java {
PrimitiveType int64 -> long (Long) default "0"
PrimitiveType float32 -> float (Float) default "0"
PrimitiveType float64 -> double (Double) default "0"
- ExternalType string -> String
+ PrimitiveType string -> String (String) default "\"\""
} \ No newline at end of file
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
new file mode 100644
index 000000000..d79ea15fa
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketConfiguration.java
@@ -0,0 +1,70 @@
+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() {
+ // initialize attributes
+ serverName = "";
+ portNumber = 0;
+ protocol = 0;
+ checkCookie = false;
+ mode = 0;
+ }
+
+ // 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
new file mode 100644
index 000000000..6aa26a518
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/DSocketData.java
@@ -0,0 +1,43 @@
+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() {
+ // initialize attributes
+ size = 0;
+ 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
new file mode 100644
index 000000000..279e19fdb
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/PSocket.java
@@ -0,0 +1,303 @@
+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 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()));
+ }
+ }
+
+ // 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
new file mode 100644
index 000000000..8affaf89e
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/org/eclipse/etrice/modellib/Socket/SocketClient.java
@@ -0,0 +1,70 @@
+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
new file mode 100644
index 000000000..37d2e2737
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/ALogService.java
@@ -0,0 +1,280 @@
+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
new file mode 100644
index 000000000..91aef4ab2
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/InternalLogData.java
@@ -0,0 +1,52 @@
+package room.basic.service.logging;
+
+
+
+
+public class InternalLogData {
+
+
+ //--------------------- attributes
+ protected String timeStamp = "";
+ protected String sender = "";
+ protected String userString = "";
+
+ //--------------------- attribute setters and getters
+ public void setTimeStamp (String timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+ public String getTimeStamp () {
+ return this.timeStamp;
+ }
+ public void setSender (String sender) {
+ this.sender = sender;
+ }
+ public String getSender () {
+ return this.sender;
+ }
+ public void setUserString (String userString) {
+ this.userString = userString;
+ }
+ public String getUserString () {
+ return this.userString;
+ }
+
+ //--------------------- operations
+
+ // default constructor
+ public InternalLogData() {
+ // initialize attributes
+ timeStamp = "";
+ sender = "";
+ userString = "";
+ }
+
+ // deep copy
+ public InternalLogData deepCopy() {
+ InternalLogData copy = new InternalLogData();
+ copy.timeStamp = timeStamp;
+ copy.sender = sender;
+ copy.userString = userString;
+ 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
new file mode 100644
index 000000000..5dae83b59
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/logging/Log.java
@@ -0,0 +1,246 @@
+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_setLogLevel = 2;
+ public static final int IN_close = 3;
+ public static final int IN_internalLog = 4;
+ //error if msgID >= MSG_MAX
+ public static final int MSG_MAX = 5;
+
+
+ private static String messageStrings[] = {"MIN", "open","setLogLevel","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 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 setLogLevel (int l)
+ {
+ logLevel=l;
+ if (logLevel > LOG_LEVEL_HIGH) logLevel=LOG_LEVEL_HIGH;
+ }
+ 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));
+ }
+ public void internalLog (InternalLogData data)
+ {
+ System.out.printf("\ndonīt use the internalLog messages !\n");
+ }
+ }
+
+ // 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 setLogLevel (int l)
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).setLogLevel( l)
+ ;
+ }
+ }
+ public void close ()
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).close()
+ ;
+ }
+ }
+ public 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/timing/ATimingService.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
index 971ae2b42..2f23163f0 100644
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
@@ -37,7 +37,7 @@ public class ATimingService extends ActorClassBase {
//--------------------- attributes
//--------------------- operations
- public void stop (){
+ public void stop() {
System.out.println(toString() + "::stop()");
timerService.cancel();
timerService = null;
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
index 69f7d7886..42b4a0b83 100644
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
@@ -135,7 +135,7 @@ public class PTimeout {
//--------------------- attributes
//--------------------- operations
- public void timeout (Integer id){
+ public void timeout(Integer id) {
//regular PortClass Operation timeout
DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
getPeerAddress(), messageStrings[OUT_timeoutTick]);
@@ -152,8 +152,8 @@ public class PTimeout {
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_timeoutTick]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_timeoutTick));
- }
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_timeoutTick));
+ }
}
// replicated port class
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
index d69c4ba55..74a4d4d9c 100644
--- a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
@@ -135,7 +135,7 @@ public class PTimer {
//--------------------- attributes
//--------------------- operations
- public void timer (Integer id){
+ public void timer(Integer id) {
//regular PortClass Operation timer
DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
getPeerAddress(), messageStrings[OUT_timerTick]);
@@ -152,8 +152,8 @@ public class PTimer {
DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_timerTick]);
}
if (getPeerAddress()!=null)
- getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_timerTick));
- }
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_timerTick));
+ }
}
// replicated port class

Back to the top