Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2011-12-28 12:19:15 +0000
committerThomas Schuetz2011-12-28 12:19:15 +0000
commitc79f92e56625e20d78899a236102fe31ef4a8783 (patch)
treeb06a0dec0cf81ed5121170b4c455cf64d93fcee4 /examples
parent24ed21d2aa4e3767be47119d8a02441274e7480a (diff)
downloadorg.eclipse.etrice-c79f92e56625e20d78899a236102fe31ef4a8783.tar.gz
org.eclipse.etrice-c79f92e56625e20d78899a236102fe31ef4a8783.tar.xz
org.eclipse.etrice-c79f92e56625e20d78899a236102fe31ef4a8783.zip
[generator.c] c-gen structures, msg-IDs, ... for ProtocolClass
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room2
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Broadcast.c2
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Broadcast.h333
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c1
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h46
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c24
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h33
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c18
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h25
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.c2
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.h219
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.c2
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.h215
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src-gen/readme.txt4
14 files changed, 926 insertions, 0 deletions
diff --git a/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
index 4b285f88a..87d9b5f24 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
+++ b/examples/org.eclipse.etrice.generator.c.reference/model/cGenRef.room
@@ -165,6 +165,8 @@ RoomModel cGenRef {
ProtocolClass CommunicationProtocol {
incoming {
Message sendData(data: int32)
+ Message sendData2(data: DataClass1)
+
}
outgoing {
Message receivedData()
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Broadcast.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Broadcast.c
new file mode 100644
index 000000000..abb345c93
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Broadcast.c
@@ -0,0 +1,2 @@
+#include "Broadcast.h"
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Broadcast.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Broadcast.h
new file mode 100644
index 000000000..57236b772
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Broadcast.h
@@ -0,0 +1,333 @@
+#ifndef _Broadcast_H_
+#define _Broadcast_H_
+
+#include "datatypes.h"
+
+package cGenRef;
+
+
+
+
+#include "CommunicationProtocol.h"
+
+
+
+public class Broadcast extends ActorClassBase {
+
+
+ //--------------------- ports
+ protected CommunicationProtocolPort dataIn = null;
+ protected CommunicationProtocolConjPortRepl dataOut = null;
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_dataIn = 1;
+ protected static final int IFITEM_dataOut = 2;
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ //--------------------- construction
+ public Broadcast(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("Broadcast");
+
+ // initialize attributes
+
+ // own ports
+ dataIn = new CommunicationProtocolPort(this, "dataIn", IFITEM_dataIn, 0, port_addr[IFITEM_dataIn][0], peer_addr[IFITEM_dataIn][0]);
+ dataOut = new CommunicationProtocolConjPortRepl(this, "dataOut", IFITEM_dataOut, port_addr[IFITEM_dataOut], peer_addr[IFITEM_dataOut]);
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_Idle = 2;
+ protected static final int STATE_Sending = 3;
+ protected static final int STATE_Sending_WaitingForReceived = 4;
+ protected static final int STATE_Sending_ReceivedOne = 5;
+ protected static final int STATE_Sending_ReceivedTheOther = 6;
+ protected static final int STATE_ReceivedBoth = 7;
+ protected static final String stateStrings[] = {"<no state>","<top>","Idle",
+ "Sending",
+ "Sending_WaitingForReceived",
+ "Sending_ReceivedOne",
+ "Sending_ReceivedTheOther",
+ "ReceivedBoth"
+ };
+
+ // history
+ // TODOHRR: history defined in ActorClassBase, init in constructor
+ // history = new int[5];
+ // for (int i = 0; i < history.length; i++) {
+ // history[i] = NO_STATE;
+ // }
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE,NO_STATE};
+
+ // transition chains
+ protected static final int CHAIN_Sending_TRANS_ReceivedOne_TO_tp1_BY_receivedDatadataOut = 1;
+ protected static final int CHAIN_Sending_TRANS_ReceivedTheOther_TO_tp1_BY_receivedDatadataOut = 2;
+ protected static final int CHAIN_Sending_TRANS_WaitingForReceived_TO_ReceivedOne_BY_receivedDatadataOut = 3;
+ protected static final int CHAIN_Sending_TRANS_WaitingForReceived_TO_ReceivedTheOther_BY_receivedDatadataOut = 4;
+ protected static final int CHAIN_TRANS_INITIAL_TO__Idle = 5;
+ protected static final int CHAIN_TRANS_Idle_TO_Sending_tp0_BY_sendDatadataIn = 6;
+
+ // triggers for FSM
+ protected static final int TRIG_dataIn__sendData = IFITEM_dataIn + EVT_SHIFT*CommunicationProtocol.IN_sendData;
+ protected static final int TRIG_dataOut__receivedData = IFITEM_dataOut + EVT_SHIFT*CommunicationProtocol.OUT_receivedData;
+
+ // 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_Idle:
+ switch(trigger) {
+ case TRIG_dataIn__sendData:
+ {
+ chain = CHAIN_TRANS_Idle_TO_Sending_tp0_BY_sendDatadataIn;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_Sending_WaitingForReceived:
+ switch(trigger) {
+ case TRIG_dataOut__receivedData:
+ {
+ if (true
+ )
+ {
+ chain = CHAIN_Sending_TRANS_WaitingForReceived_TO_ReceivedOne_BY_receivedDatadataOut;
+ catching_state = STATE_Sending;
+ } else
+ if (false
+ )
+ {
+ chain = CHAIN_Sending_TRANS_WaitingForReceived_TO_ReceivedTheOther_BY_receivedDatadataOut;
+ catching_state = STATE_Sending;
+ }
+ }
+ break;
+ }
+ break;
+ case STATE_Sending_ReceivedOne:
+ switch(trigger) {
+ case TRIG_dataOut__receivedData:
+ {
+ if (true
+ )
+ {
+ chain = CHAIN_Sending_TRANS_ReceivedOne_TO_tp1_BY_receivedDatadataOut;
+ catching_state = STATE_Sending;
+ }
+ }
+ break;
+ }
+ break;
+ case STATE_Sending_ReceivedTheOther:
+ switch(trigger) {
+ case TRIG_dataOut__receivedData:
+ {
+ if (false
+ )
+ {
+ chain = CHAIN_Sending_TRANS_ReceivedTheOther_TO_tp1_BY_receivedDatadataOut;
+ catching_state = STATE_Sending;
+ }
+ }
+ break;
+ }
+ break;
+ case STATE_ReceivedBoth:
+ 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__Idle;
+ 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_Idle:
+ history[STATE_TOP] = STATE_Idle;
+ current = STATE_TOP;
+ break;
+ case STATE_Sending:
+ history[STATE_TOP] = STATE_Sending;
+ current = STATE_TOP;
+ break;
+ case STATE_Sending_WaitingForReceived:
+ history[STATE_Sending] = STATE_Sending_WaitingForReceived;
+ current = STATE_Sending;
+ break;
+ case STATE_Sending_ReceivedOne:
+ history[STATE_Sending] = STATE_Sending_ReceivedOne;
+ current = STATE_Sending;
+ break;
+ case STATE_Sending_ReceivedTheOther:
+ history[STATE_Sending] = STATE_Sending_ReceivedTheOther;
+ current = STATE_Sending;
+ break;
+ case STATE_ReceivedBoth:
+ history[STATE_TOP] = STATE_ReceivedBoth;
+ 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__Idle:
+ {
+ return STATE_Idle;
+ }
+ case CHAIN_TRANS_Idle_TO_Sending_tp0_BY_sendDatadataIn:
+ {
+ int data = (Integer) generic_data;
+ action_TRANS_Idle_TO_Sending_tp0_BY_sendDatadataIn(ifitem, data);
+ return STATE_Sending_WaitingForReceived;
+ }
+ case CHAIN_Sending_TRANS_WaitingForReceived_TO_ReceivedOne_BY_receivedDatadataOut:
+ {
+ return STATE_Sending_ReceivedOne;
+ }
+ case CHAIN_Sending_TRANS_WaitingForReceived_TO_ReceivedTheOther_BY_receivedDatadataOut:
+ {
+ return STATE_Sending_ReceivedTheOther;
+ }
+ case CHAIN_Sending_TRANS_ReceivedOne_TO_tp1_BY_receivedDatadataOut:
+ {
+ action_TRANS_Sending_tp1_TO_ReceivedBoth(ifitem);
+ return STATE_ReceivedBoth;
+ }
+ case CHAIN_Sending_TRANS_ReceivedTheOther_TO_tp1_BY_receivedDatadataOut:
+ {
+ action_TRANS_Sending_tp1_TO_ReceivedBoth(ifitem);
+ return STATE_ReceivedBoth;
+ }
+ }
+ 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_Idle:
+ // in leaf state: return state id
+ return STATE_Idle;
+ case STATE_Sending:
+ // state has a sub graph
+ // without init transition
+ state = history[STATE_Sending];
+ break;
+ case STATE_Sending_WaitingForReceived:
+ // in leaf state: return state id
+ return STATE_Sending_WaitingForReceived;
+ case STATE_Sending_ReceivedOne:
+ // in leaf state: return state id
+ return STATE_Sending_ReceivedOne;
+ case STATE_Sending_ReceivedTheOther:
+ // in leaf state: return state id
+ return STATE_Sending_ReceivedTheOther;
+ case STATE_ReceivedBoth:
+ // in leaf state: return state id
+ return STATE_ReceivedBoth;
+ 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_Idle_TO_Sending_tp0_BY_sendDatadataIn(InterfaceItemBase ifitem, int data) {
+ //dataOut.get(0).sendData(data);
+ //dataOut.get(1).sendData(data);
+ dataOut.sendData(data);
+ }
+ protected void action_TRANS_Sending_tp1_TO_ReceivedBoth(InterfaceItemBase ifitem) {
+ dataIn.receivedData();
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
+
+#endif /* _Broadcast_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c
new file mode 100644
index 000000000..d819ff9eb
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.c
@@ -0,0 +1 @@
+#include "CommunicationProtocol.h"
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h
new file mode 100644
index 000000000..c90a0ce16
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/CommunicationProtocol.h
@@ -0,0 +1,46 @@
+#ifndef _CommunicationProtocol_H_
+#define _CommunicationProtocol_H_
+
+#include "datatypes.h"
+
+
+
+#include "CommunicationProtocol.h"
+
+typedef struct {
+
+
+} CommunicationProtocol;
+
+/* message IDs */
+enum {
+ MSG_CommunicationProtocol_MIN = 0,
+ /* IDs for outgoing messages */
+ OUT_CommunicationProtocol_receivedData = 1,
+ /* IDs for incoming messages */
+ IN_CommunicationProtocol_sendData = 2,
+ IN_CommunicationProtocol_sendData2 = 3,
+ /* error if msgID >= MSG_MAX */
+ MSG_CommunicationProtocol_MAX = 4
+};
+
+
+/* message names as strings for debugging (generate MSC) */
+/* TODO: make this optional or different for smaller footprint */
+static char CommunicationProtocol_messageStrings[][] = {"MIN", "receivedData","sendData", "sendData2", "MAX"};
+
+char* CommunicationProtocol_getMessageString(int msg_id) {
+ if (msg_id<MSG_CommunicationProtocol_MIN || msg_id>MSG_CommunicationProtocol_MAX+1){
+ /* id out of range */
+ return "Message ID out of range";
+ }
+ else{
+ return CommunicationProtocol_messageStrings[msg_id];
+ }
+}
+
+
+
+
+#endif /* _CommunicationProtocol_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c
new file mode 100644
index 000000000..715b0fb44
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.c
@@ -0,0 +1,24 @@
+#include "DataClass1.h"
+
+#include <string.h>
+
+//--------------------- begin user code
+ // usercode3
+//--------------------- end user code
+
+// TODO: do we need setters and getters for C and C++ ?
+
+//--------------------- operations
+int32 DataClass1_MultiplyWithAttr1 (DataClass1* self, int32 value){
+ return self->Attr1*value;
+}
+float32 DataClass1_MultiplyWithAttr3 (DataClass1* self, float32 value){
+ return self->Attr3*value;
+}
+
+// deep copy
+void DataClass1_deepCopy(DataClass1* source, DataClass1* target) {
+ memcpy(target, source, sizeof(DataClass1));
+}
+
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h
new file mode 100644
index 000000000..8c3708d72
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass1.h
@@ -0,0 +1,33 @@
+#ifndef _DataClass1_H_
+#define _DataClass1_H_
+
+#include "datatypes.h"
+
+/* TODO: includes only for used DataClasses, also for other models */
+#include "DataClass2.h"
+
+//--------------------- begin user code
+ // usercode1
+//--------------------- end user code
+
+typedef struct {
+ //--------------------- begin user code
+ // usercode2
+ //--------------------- end user code
+ //--------------------- attributes
+ int32 Attr1;
+ DataClass2 ComplexAttr;
+ float32 Attr3;
+} DataClass1;
+
+// TODO: do we need setters and getters for C and C++ ?
+
+//--------------------- operations
+int32 DataClass1_MultiplyWithAttr1 (DataClass1* self, int32 value);
+float32 DataClass1_MultiplyWithAttr3 (DataClass1* self, float32 value);
+
+// deep copy
+void DataClass1_deepCopy(DataClass1* source, DataClass1* target);
+
+#endif /* _DataClass1_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c
new file mode 100644
index 000000000..2a94fd07e
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.c
@@ -0,0 +1,18 @@
+#include "DataClass2.h"
+
+#include <string.h>
+
+
+// TODO: do we need setters and getters for C and C++ ?
+
+//--------------------- operations
+void DataClass2_Operation1 (DataClass2* self){
+ /*nothing to do*/
+}
+
+// deep copy
+void DataClass2_deepCopy(DataClass2* source, DataClass2* target) {
+ memcpy(target, source, sizeof(DataClass2));
+}
+
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h
new file mode 100644
index 000000000..6d7259267
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/DataClass2.h
@@ -0,0 +1,25 @@
+#ifndef _DataClass2_H_
+#define _DataClass2_H_
+
+#include "datatypes.h"
+
+/* TODO: includes only for used DataClasses, also for other models */
+
+
+typedef struct {
+ //--------------------- attributes
+ int32 Attr1;
+ float32 Attr2;
+ int32 Attr3;
+} DataClass2;
+
+// TODO: do we need setters and getters for C and C++ ?
+
+//--------------------- operations
+void DataClass2_Operation1 (DataClass2* self);
+
+// deep copy
+void DataClass2_deepCopy(DataClass2* source, DataClass2* target);
+
+#endif /* _DataClass2_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.c
new file mode 100644
index 000000000..041300249
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.c
@@ -0,0 +1,2 @@
+#include "Receiver.h"
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.h
new file mode 100644
index 000000000..198bb3cf8
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Receiver.h
@@ -0,0 +1,219 @@
+#ifndef _Receiver_H_
+#define _Receiver_H_
+
+#include "datatypes.h"
+
+package cGenRef;
+
+
+
+#include "DataClass1.h"
+
+#include "CommunicationProtocol.h"
+
+
+
+public class Receiver extends ActorClassBase {
+
+
+ //--------------------- ports
+ protected CommunicationProtocolPort dataIn = null;
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_dataIn = 1;
+
+ //--------------------- attributes
+ DataClass1 attr1;
+ //--------------------- operations
+
+ //--------------------- construction
+ public Receiver(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("Receiver");
+
+ // initialize attributes
+ attr1 = new DataClass1();
+
+ // own ports
+ dataIn = new CommunicationProtocolPort(this, "dataIn", IFITEM_dataIn, 0, port_addr[IFITEM_dataIn][0], peer_addr[IFITEM_dataIn][0]);
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_Idle = 2;
+ protected static final int STATE_DataReceived = 3;
+ protected static final String stateStrings[] = {"<no state>","<top>","Idle",
+ "DataReceived"
+ };
+
+ // 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__Idle = 1;
+ protected static final int CHAIN_TRANS_Idle_TO_DataReceived_BY_sendDatadataIn = 2;
+
+ // triggers for FSM
+ protected static final int TRIG_dataIn__sendData = IFITEM_dataIn + EVT_SHIFT*CommunicationProtocol.IN_sendData;
+
+ // 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_Idle:
+ switch(trigger) {
+ case TRIG_dataIn__sendData:
+ {
+ chain = CHAIN_TRANS_Idle_TO_DataReceived_BY_sendDatadataIn;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_DataReceived:
+ 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__Idle;
+ 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_Idle:
+ history[STATE_TOP] = STATE_Idle;
+ current = STATE_TOP;
+ break;
+ case STATE_DataReceived:
+ history[STATE_TOP] = STATE_DataReceived;
+ 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__Idle:
+ {
+ return STATE_Idle;
+ }
+ case CHAIN_TRANS_Idle_TO_DataReceived_BY_sendDatadataIn:
+ {
+ int data = (Integer) generic_data;
+ action_TRANS_Idle_TO_DataReceived_BY_sendDatadataIn(ifitem, data);
+ return STATE_DataReceived;
+ }
+ }
+ 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_Idle:
+ // in leaf state: return state id
+ return STATE_Idle;
+ case STATE_DataReceived:
+ // in leaf state: return state id
+ return STATE_DataReceived;
+ 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_Idle_TO_DataReceived_BY_sendDatadataIn(InterfaceItemBase ifitem, int data) {
+ dataIn.receivedData();
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
+
+#endif /* _Receiver_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.c b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.c
new file mode 100644
index 000000000..a7c1e7190
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.c
@@ -0,0 +1,2 @@
+#include "Sender.h"
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.h b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.h
new file mode 100644
index 000000000..8c93be918
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/cGenRef/Sender.h
@@ -0,0 +1,215 @@
+#ifndef _Sender_H_
+#define _Sender_H_
+
+#include "datatypes.h"
+
+package cGenRef;
+
+
+
+
+#include "CommunicationProtocol.h"
+
+
+
+public class Sender extends ActorClassBase {
+
+
+ //--------------------- ports
+ protected CommunicationProtocolConjPort dataOut = null;
+ //--------------------- saps
+ //--------------------- services
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_dataOut = 1;
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ //--------------------- construction
+ public Sender(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("Sender");
+
+ // initialize attributes
+
+ // own ports
+ dataOut = new CommunicationProtocolConjPort(this, "dataOut", IFITEM_dataOut, 0, port_addr[IFITEM_dataOut][0], peer_addr[IFITEM_dataOut][0]);
+ // own saps
+ // own service implementations
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+ public void stop(){
+ stopUser();
+ }
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_SendingData = 2;
+ protected static final int STATE_Done = 3;
+ protected static final String stateStrings[] = {"<no state>","<top>","SendingData",
+ "Done"
+ };
+
+ // 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__SendingData = 1;
+ protected static final int CHAIN_TRANS_SendingData_TO_Done_BY_receivedDatadataOut = 2;
+
+ // triggers for FSM
+ protected static final int TRIG_dataOut__receivedData = IFITEM_dataOut + EVT_SHIFT*CommunicationProtocol.OUT_receivedData;
+
+ // 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_SendingData:
+ switch(trigger) {
+ case TRIG_dataOut__receivedData:
+ {
+ chain = CHAIN_TRANS_SendingData_TO_Done_BY_receivedDatadataOut;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ case STATE_Done:
+ 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__SendingData;
+ 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_SendingData:
+ history[STATE_TOP] = STATE_SendingData;
+ current = STATE_TOP;
+ break;
+ case STATE_Done:
+ history[STATE_TOP] = STATE_Done;
+ 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__SendingData:
+ {
+ return STATE_SendingData;
+ }
+ case CHAIN_TRANS_SendingData_TO_Done_BY_receivedDatadataOut:
+ {
+ return STATE_Done;
+ }
+ }
+ 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_SendingData:
+ if (!(skip_entry || handler)) entry_SendingData();
+ // in leaf state: return state id
+ return STATE_SendingData;
+ case STATE_Done:
+ // in leaf state: return state id
+ return STATE_Done;
+ case STATE_TOP:
+ state = history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ //*** Entry and Exit Codes
+ protected void entry_SendingData() {
+ dataOut.sendData(1234);
+ }
+
+ //*** Action Codes
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
+
+#endif /* _Sender_H_ */
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src-gen/readme.txt b/examples/org.eclipse.etrice.generator.c.reference/src-gen/readme.txt
new file mode 100644
index 000000000..1dc2b35ab
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src-gen/readme.txt
@@ -0,0 +1,4 @@
+This directory is an eTrice code generation target.
+It will be erased every time the generator is executed.
+
+DO NOT PLACE OTHER FILES HERE!

Back to the top