summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortjung2012-04-10 10:48:22 (EDT)
committertjung2012-04-10 10:48:22 (EDT)
commitd4b5d92f50764e4e5ddd6ec335d4dddff7ff4b9a (patch)
treed1350c83955ad2b94eddb9d9a5f86f1104411413
parentb5f5299045365d45f86bf6f42a4cfde03efb09d1 (diff)
downloadorg.eclipse.etrice-d4b5d92f50764e4e5ddd6ec335d4dddff7ff4b9a.zip
org.eclipse.etrice-d4b5d92f50764e4e5ddd6ec335d4dddff7ff4b9a.tar.gz
org.eclipse.etrice-d4b5d92f50764e4e5ddd6ec335d4dddff7ff4b9a.tar.bz2
[generator.test] launch config for sending data test
-rw-r--r--orga/spec/Ref_Impl.odsbin13055 -> 13397 bytes
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java25
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend17
-rw-r--r--plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java97
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/genSendingDataTest.launch11
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/model/CTypes.room4
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/model/ChoicePointTest.room12
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/model/HandlerTest.room2
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/model/SendingDataTest.room478
9 files changed, 602 insertions, 44 deletions
diff --git a/orga/spec/Ref_Impl.ods b/orga/spec/Ref_Impl.ods
index 9429b9f..4334f6a 100644
--- a/orga/spec/Ref_Impl.ods
+++ b/orga/spec/Ref_Impl.ods
Binary files differ
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java
index 5d3af62..c46aa89 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CLanguageGenerator.java
@@ -12,20 +12,35 @@ public class CLanguageGenerator extends AbstractLanguageGenerator {
String typeName = data.getRefType().getType().getName();
String castTypeName = typeName+"*";
- boolean byVal = false;
+ String typedData;
+ //boolean byVal = false;
if (data.getRefType().getType() instanceof PrimitiveType) {
typeName = ((PrimitiveType)data.getRefType().getType()).getTargetName();
castTypeName = typeName+"*";
String ct = ((PrimitiveType)data.getRefType().getType()).getCastName();
- byVal = true;
- if (ct!=null && !ct.isEmpty())
+ //byVal = true;
+ if (ct!=null && !ct.isEmpty()){
castTypeName = ct;
+ }
+ if (data.getRefType().isRef()) {
+ //byVal = false;
+ typedData = typeName+" "+data.getName() + " = **(("+castTypeName+"*) generic_data);\n";
+ } else {
+ //byVal = true;
+ typedData = typeName+" "+data.getName() + " = *(("+castTypeName+") generic_data);\n";
+ }
}
else {
- typeName = typeName+"*";
+ if (data.getRefType().isRef()) {
+ typeName = typeName+"*";
+ typedData = typeName+" "+data.getName() + " = *(("+castTypeName+"*) generic_data);\n";
+ }else{
+ typeName = typeName+"*";
+ typedData = typeName+" "+data.getName() + " = (("+castTypeName+") generic_data);\n";
+ }
}
- String typedData = typeName+" "+data.getName() + " = "+(byVal? "*":"")+"(("+castTypeName+") generic_data);\n";
+ //typedData = typeName+" "+data.getName() + " = "+(byVal? "*":"")+"(("+castTypeName+") generic_data);\n";
String dataArg = ", "+data.getName();
String typedArgList = ", "+typeName+" "+data.getName();
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
index db886ac..2565b00 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend
@@ -143,7 +143,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«FOR message : messages»
«var hasData = message.data!=null»
«var typeName = if (hasData) message.data.refType.type.typeName else ""»
- «var refp = if (hasData && !(message.data.refType.type instanceof PrimitiveType)) "*" else ""»
+ «var refp = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
«var data = if (hasData) ", "+typeName+refp+" data" else ""»
«messageSignature(portClassName, message.name, "", data)»;
«messageSignature(replPortClassName, message.name, "_broadcast", data)»;
@@ -207,19 +207,20 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
var replPortClassName = pc.getPortClassName(conj, true)
var messages = if (conj) pc.allIncomingMessages else pc.allOutgoingMessages
var dir = if (conj) "IN_" else "OUT_"
-
+
'''
«FOR message : messages»
«var hasData = message.data!=null»
«var typeName = if (hasData) message.data.refType.type.typeName else ""»
- «var refp = if (hasData && !(message.data.refType.type instanceof PrimitiveType)) "*" else ""»
- «var refa = if (hasData && (message.data.refType.type instanceof PrimitiveType)) "&" else ""»
- «var data = if (hasData) ", "+typeName+refp+" data" else ""»
+ «var refp = if (hasData && ((message.data.refType.ref))) "*" else ""»
+ «var refpd = if (hasData && (!(message.data.refType.type instanceof PrimitiveType)||(message.data.refType.ref))) "*" else ""»
+ «var refa = if (hasData && (!(message.data.refType.type instanceof PrimitiveType))&&(!(message.data.refType.ref))) "" else "&"»
+ «var data = if (hasData) ", "+typeName+refpd+" data" else ""»
«messageSignature(portClassName, message.name, "", data)» {
ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
if (self->receiveMessageFunc!=NULL) {
- «sendMessageCall(hasData, "self", memberInUse(pc.name, dir+message.name), typeName, refa+"data")»
+ «sendMessageCall(hasData, "self", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
}
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -228,7 +229,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
int i;
ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
for (i=0; i<self->size; ++i) {
- «sendMessageCall(hasData, "(etPort*)(&self->ports[i])", memberInUse(pc.name, dir+message.name), typeName, refa+"data")»
+ «sendMessageCall(hasData, "(etPort*)(&self->ports[i])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
}
ET_MSC_LOGGER_SYNC_EXIT
}
@@ -236,7 +237,7 @@ class ProtocolClassGen extends GenericProtocolClassGenerator {
«messageSignature(replPortClassName, message.name, "", ", int idx"+data)» {
ET_MSC_LOGGER_SYNC_ENTRY("«replPortClassName»", "«message.name»")
if (0<=idx && idx<self->size) {
- «sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", memberInUse(pc.name, dir+message.name), typeName, refa+"data")»
+ «sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", memberInUse(pc.name, dir+message.name), typeName+refp, refa+"data")»
}
ET_MSC_LOGGER_SYNC_EXIT
}
diff --git a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
index 4dad7f5..1114337 100644
--- a/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
+++ b/plugins/org.eclipse.etrice.generator.c/xtend-gen/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.java
@@ -322,11 +322,20 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
if (!hasData) {
_operator_and = false;
} else {
+ boolean _operator_or = false;
VarDecl _data_2 = message.getData();
RefableType _refType_1 = _data_2.getRefType();
DataType _type_1 = _refType_1.getType();
boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- _operator_and = BooleanExtensions.operator_and(hasData, _operator_not);
+ if (_operator_not) {
+ _operator_or = true;
+ } else {
+ VarDecl _data_3 = message.getData();
+ RefableType _refType_2 = _data_3.getRefType();
+ boolean _isRef = _refType_2.isRef();
+ _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef);
+ }
+ _operator_and = BooleanExtensions.operator_and(hasData, _operator_or);
}
if (_operator_and) {
_xifexpression_2 = "*";
@@ -648,9 +657,8 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
} else {
VarDecl _data_2 = message.getData();
RefableType _refType_1 = _data_2.getRefType();
- DataType _type_1 = _refType_1.getType();
- boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
- _operator_and = BooleanExtensions.operator_and(hasData, _operator_not);
+ boolean _isRef = _refType_1.isRef();
+ _operator_and = BooleanExtensions.operator_and(hasData, _isRef);
}
if (_operator_and) {
_xifexpression_3 = "*";
@@ -664,28 +672,66 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
if (!hasData) {
_operator_and_1 = false;
} else {
+ boolean _operator_or = false;
VarDecl _data_3 = message.getData();
RefableType _refType_2 = _data_3.getRefType();
- DataType _type_2 = _refType_2.getType();
- _operator_and_1 = BooleanExtensions.operator_and(hasData, (_type_2 instanceof PrimitiveType));
+ DataType _type_1 = _refType_2.getType();
+ boolean _operator_not = BooleanExtensions.operator_not((_type_1 instanceof PrimitiveType));
+ if (_operator_not) {
+ _operator_or = true;
+ } else {
+ VarDecl _data_4 = message.getData();
+ RefableType _refType_3 = _data_4.getRefType();
+ boolean _isRef_1 = _refType_3.isRef();
+ _operator_or = BooleanExtensions.operator_or(_operator_not, _isRef_1);
+ }
+ _operator_and_1 = BooleanExtensions.operator_and(hasData, _operator_or);
}
if (_operator_and_1) {
- _xifexpression_4 = "&";
+ _xifexpression_4 = "*";
} else {
_xifexpression_4 = "";
}
- String refa = _xifexpression_4;
+ String refpd = _xifexpression_4;
_builder.newLineIfNotEmpty();
String _xifexpression_5 = null;
+ boolean _operator_and_2 = false;
+ boolean _operator_and_3 = false;
+ if (!hasData) {
+ _operator_and_3 = false;
+ } else {
+ VarDecl _data_5 = message.getData();
+ RefableType _refType_4 = _data_5.getRefType();
+ DataType _type_2 = _refType_4.getType();
+ boolean _operator_not_1 = BooleanExtensions.operator_not((_type_2 instanceof PrimitiveType));
+ _operator_and_3 = BooleanExtensions.operator_and(hasData, _operator_not_1);
+ }
+ if (!_operator_and_3) {
+ _operator_and_2 = false;
+ } else {
+ VarDecl _data_6 = message.getData();
+ RefableType _refType_5 = _data_6.getRefType();
+ boolean _isRef_2 = _refType_5.isRef();
+ boolean _operator_not_2 = BooleanExtensions.operator_not(_isRef_2);
+ _operator_and_2 = BooleanExtensions.operator_and(_operator_and_3, _operator_not_2);
+ }
+ if (_operator_and_2) {
+ _xifexpression_5 = "";
+ } else {
+ _xifexpression_5 = "&";
+ }
+ String refa = _xifexpression_5;
+ _builder.newLineIfNotEmpty();
+ String _xifexpression_6 = null;
if (hasData) {
String _operator_plus = StringExtensions.operator_plus(", ", typeName);
- String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refp);
+ String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, refpd);
String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, " data");
- _xifexpression_5 = _operator_plus_2;
+ _xifexpression_6 = _operator_plus_2;
} else {
- _xifexpression_5 = "";
+ _xifexpression_6 = "";
}
- String data = _xifexpression_5;
+ String data = _xifexpression_6;
_builder.newLineIfNotEmpty();
_builder.newLine();
String _name = message.getName();
@@ -709,8 +755,9 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
String _name_3 = message.getName();
String _operator_plus_3 = StringExtensions.operator_plus(dir, _name_3);
String _memberInUse = this.stdExt.memberInUse(_name_2, _operator_plus_3);
- String _operator_plus_4 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, typeName, _operator_plus_4);
+ String _operator_plus_4 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_5 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall = this.sendMessageCall(hasData, "self", _memberInUse, _operator_plus_4, _operator_plus_5);
_builder.append(_sendMessageCall, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -744,10 +791,11 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\t\t");
String _name_6 = pc.getName();
String _name_7 = message.getName();
- String _operator_plus_5 = StringExtensions.operator_plus(dir, _name_7);
- String _memberInUse_1 = this.stdExt.memberInUse(_name_6, _operator_plus_5);
- String _operator_plus_6 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall_1 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[i])", _memberInUse_1, typeName, _operator_plus_6);
+ String _operator_plus_6 = StringExtensions.operator_plus(dir, _name_7);
+ String _memberInUse_1 = this.stdExt.memberInUse(_name_6, _operator_plus_6);
+ String _operator_plus_7 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_8 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall_1 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[i])", _memberInUse_1, _operator_plus_7, _operator_plus_8);
_builder.append(_sendMessageCall_1, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
@@ -760,8 +808,8 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.newLine();
_builder.newLine();
String _name_8 = message.getName();
- String _operator_plus_7 = StringExtensions.operator_plus(", int idx", data);
- String _messageSignature_2 = this.messageSignature(replPortClassName, _name_8, "", _operator_plus_7);
+ String _operator_plus_9 = StringExtensions.operator_plus(", int idx", data);
+ String _messageSignature_2 = this.messageSignature(replPortClassName, _name_8, "", _operator_plus_9);
_builder.append(_messageSignature_2, "");
_builder.append(" {");
_builder.newLineIfNotEmpty();
@@ -779,10 +827,11 @@ public class ProtocolClassGen extends GenericProtocolClassGenerator {
_builder.append("\t\t");
String _name_10 = pc.getName();
String _name_11 = message.getName();
- String _operator_plus_8 = StringExtensions.operator_plus(dir, _name_11);
- String _memberInUse_2 = this.stdExt.memberInUse(_name_10, _operator_plus_8);
- String _operator_plus_9 = StringExtensions.operator_plus(refa, "data");
- String _sendMessageCall_2 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", _memberInUse_2, typeName, _operator_plus_9);
+ String _operator_plus_10 = StringExtensions.operator_plus(dir, _name_11);
+ String _memberInUse_2 = this.stdExt.memberInUse(_name_10, _operator_plus_10);
+ String _operator_plus_11 = StringExtensions.operator_plus(typeName, refp);
+ String _operator_plus_12 = StringExtensions.operator_plus(refa, "data");
+ String _sendMessageCall_2 = this.sendMessageCall(hasData, "(etPort*)(&self->ports[idx])", _memberInUse_2, _operator_plus_11, _operator_plus_12);
_builder.append(_sendMessageCall_2, " ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
diff --git a/tests/org.eclipse.etrice.generator.c.tests/genSendingDataTest.launch b/tests/org.eclipse.etrice.generator.c.tests/genSendingDataTest.launch
new file mode 100644
index 0000000..be15c22
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.c.tests/genSendingDataTest.launch
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.etrice.generator.launch.c.launchConfigurationType">
+<booleanAttribute key="GenInstanceDiagram" value="false"/>
+<stringAttribute key="GenModelPath" value=""/>
+<booleanAttribute key="Lib" value="false"/>
+<listAttribute key="ModelFiles">
+<listEntry value="${workspace_loc:/org.eclipse.etrice.generator.c.tests/model/SendingDataTest.room}"/>
+</listAttribute>
+<booleanAttribute key="SaveGenModel" value="false"/>
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
+</launchConfiguration>
diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/CTypes.room b/tests/org.eclipse.etrice.generator.c.tests/model/CTypes.room
index 662d4b9..9ba7311 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/model/CTypes.room
+++ b/tests/org.eclipse.etrice.generator.c.tests/model/CTypes.room
@@ -16,6 +16,6 @@ RoomModel room.basic.types.c {
PrimitiveType float64 -> float64 default "0"
// TODO: define strings for C
- // PrimitiveType string -> string (String) default "\"\""
-
+ PrimitiveType charPtr -> charPtr default "0"
+ PrimitiveType string -> charPtr default "0"
} \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/ChoicePointTest.room b/tests/org.eclipse.etrice.generator.c.tests/model/ChoicePointTest.room
index de09523..2fc3aa0 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/model/ChoicePointTest.room
+++ b/tests/org.eclipse.etrice.generator.c.tests/model/ChoicePointTest.room
@@ -1,7 +1,7 @@
RoomModel ChoicePointTest {
-
+
import room.basic.types.c.* from "CTypes.room"
-
+
LogicalSystem System_HandlerTest {
SubSystemRef SubSystem_CPTest: SubSystem_CPTest
}
@@ -24,9 +24,10 @@ RoomModel ChoicePointTest {
Port TestPort1: TestProtocol
}
Structure {
- usercode3{
- "#include \"etUnit/etUnit.h\"" }
-
+ usercode3 {
+ "#include \"etUnit/etUnit.h\""
+ "#include \"SubSystem_CPTest.h\""
+ }
external Port TestPort1
Attribute counter: int32
}
@@ -173,6 +174,7 @@ RoomModel ChoicePointTest {
entry {
"EXPECT_ORDER_END(\"<|MODEL_LOCATION|>\\\\n\", 20);"
"etUnit_closeAll();"
+ "SubSystem_CPTest_shutdown();"
}
}
}
diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/HandlerTest.room b/tests/org.eclipse.etrice.generator.c.tests/model/HandlerTest.room
index 962ec5c..8df352a 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/model/HandlerTest.room
+++ b/tests/org.eclipse.etrice.generator.c.tests/model/HandlerTest.room
@@ -30,6 +30,7 @@ RoomModel HandlerTest {
Structure {
usercode3 {
"#include \"etUnit/etUnit.h\""
+ "#include \"SubSystem_HandlerTest.h\""
}
external Port TestPort1
Attribute counter: int32
@@ -262,6 +263,7 @@ RoomModel HandlerTest {
entry {
"EXPECT_ORDER_END(\"<|MODEL_LOCATION|>\\\\n\", 50);"
"etUnit_closeAll();"
+ "SubSystem_HandlerTest_shutdown();"
}
}
State E28_E29 {
diff --git a/tests/org.eclipse.etrice.generator.c.tests/model/SendingDataTest.room b/tests/org.eclipse.etrice.generator.c.tests/model/SendingDataTest.room
new file mode 100644
index 0000000..5d52245
--- /dev/null
+++ b/tests/org.eclipse.etrice.generator.c.tests/model/SendingDataTest.room
@@ -0,0 +1,478 @@
+RoomModel SendingDataTest {
+
+ import room.basic.types.c.* from "CTypes.room"
+
+ LogicalSystem LogSys_SendingData {
+ SubSystemRef application: SubSys_SendingData
+ }
+
+ SubSystemClass SubSys_SendingData {
+ ActorRef top: SendingDataTop
+ }
+
+ ActorClass SendingDataTop {
+ Structure {
+ ActorRef mrPong: MrPong
+ ActorRef ref0: MrPing
+ Binding ref0.PingPongPort and mrPong.PingPongPort
+ }
+ Behavior { }
+ }
+
+ ActorClass MrPong {
+ Interface {
+ Port PingPongPort: PingPongProtocol
+ }
+ Structure {
+ external Port PingPongPort
+ }
+ Behavior {
+ StateMachine {
+ Transition tr0: reply -> reply {
+ triggers {
+ <pingInt16: PingPongPort>
+ }
+ action {
+ "PingPongPort.pongInt16(d);"
+ }
+ }
+ Transition tr1: reply -> reply {
+ triggers {
+ <pingInt8: PingPongPort>
+ }
+ action {
+ "PingPongPort.pongInt8(d);"
+ }
+ }
+ Transition init: initial -> reply { }
+ Transition tr2: reply -> reply {
+ triggers {
+ <pingInt32: PingPongPort>
+ }
+ action {
+ "PingPongPort.pongInt32(d);"
+ }
+ }
+ Transition tr3: reply -> reply {
+ triggers {
+ <pingFloat32: PingPongPort>
+ }
+ action {
+ "PingPongPort.pongFloat32(d);"
+ }
+ }
+ Transition tr4: reply -> reply {
+ triggers {
+ <pingFloat64: PingPongPort>
+ }
+ action {
+ "PingPongPort.pongFloat64(d);"
+ }
+ }
+ Transition tr7: reply -> cp cp0 {
+ triggers {
+ <pingInt32Ref: PingPongPort guard {
+ "d!=0"
+ }>
+ }
+ }
+ Transition tr8: cp cp0 -> reply {
+ action {
+ "PingPongPort.pongInt32(d+1);"
+ }
+ }
+ Transition tr6: cp cp0 -> reply {
+ cond {
+ "d!=5"
+ }
+ action {
+ "PingPongPort.pongInt32(d);"
+ }
+ }
+ Transition tr9: reply -> reply {
+ triggers {
+ <pingComplex: PingPongPort>
+ }
+ action {
+ "PingPongPort.pongComplex(d);"
+ }
+ }
+ Transition tr11: reply -> cp cp1 {
+ triggers {
+ <pingComplexRef: PingPongPort>
+ }
+ }
+ Transition tr10: cp cp1 -> reply {
+ action {
+ "d->i8Val++;"
+ "PingPongPort.pongComplex(d);"
+ }
+ }
+ Transition tr12: cp cp1 -> reply {
+ cond {
+ "(*d).i8Val!=0"
+ }
+ action {
+ "PingPongPort.pongComplex(d);"
+ }
+ }
+ ChoicePoint cp0
+ ChoicePoint cp1
+ State reply
+ }
+ }
+ }
+
+ ActorClass MrPing {
+ Interface {
+ conjugated Port PingPongPort: PingPongProtocol
+ }
+ Structure {
+ usercode3 {
+ "#include \"etUnit/etUnit.h\""
+ "#include \"SubSys_SendingData.h\""
+ }
+ external Port PingPongPort
+ Attribute i32Array [ 10 ]: int32
+ Attribute i32Val: int32
+ Attribute i8ValAC:int8
+ Attribute data: PingPongData
+ Attribute lastError: int32 = "0"
+ }
+ Behavior {
+ Operation checkData(d:PingPongData, mode:int8):int8{
+ "
+ int8 result = 1;
+ if (mode == 0){
+ if (d.i8Val != 10) result = 0;
+ if (*(d.i8ValRef) != 9) result = 0;
+ i8ValAC = 27;
+ if (d.i8Array[0] != 1) result = 0;
+ if (d.i8Array[1] != 2) result = 0;
+ if (d.i8Array[2] != 3) result = 0;
+ if (*(d.i8ArrayRef[0]) != 27) result = 0;
+ if (*(d.i8ArrayRef[1]) != 27) result = 0;
+ if (d.complexVal.i32Val1 != 127) result = 0;
+ if (d.complexVal.i32Val2 != 130) result = 0;
+ }else{
+ if (d.i8Val != 50) result = 0;
+ if (*(d.i8ValRef) != 12) result = 0;
+ i8ValAC = 52;
+ if (d.i8Array[0] != 10) result = 0;
+ if (d.i8Array[1] != 20) result = 0;
+ if (d.i8Array[2] != 30) result = 0;
+ if (*(d.i8ArrayRef[0]) != 52) result = 0;
+ if (*(d.i8ArrayRef[1]) != 10) result = 0;
+ if (d.complexVal.i32Val1 != 150) result = 0;
+ if (d.complexVal.i32Val2 != 170) result = 0;
+ }
+ return result;
+ "
+ }
+ StateMachine {
+ Transition init: initial -> tp0 of waitForPong {
+ action {
+ "etUnit_openAll(\"tmp/testlog\",\"GeneratorTest1\", \"GeneratorTest1\", \"GeneratorTest1\");"
+ "static etInt16 resultlist[] = {1,2,3,4,5,6,7,8,9,10,50};"
+ "EXPECT_ORDER_START(resultlist, 11);"
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\", 1);"
+ "PingPongPort.pingInt8(8);"
+ "PingPongPort.pingInt16(16);"
+ "PingPongPort.pingInt32(32);"
+ }
+ }
+ Transition tr7: tp1 of waitForPong -> tp0 of waitForPongFloat {
+ action {
+ "PingPongPort.pingFloat32(32.76453653f);"
+ "PingPongPort.pingFloat64(64.12344354364533);"
+ }
+ }
+ Transition tr0: tp1 of waitForPongFloat -> tp0 of waitForPongRef
+ Transition tr4: tp1 of waitForComplex -> TestFinished
+ Transition tr2: tp1 of waitForPongRef -> tp0 of waitForComplex
+ State waitForPong {
+ subgraph {
+ Transition tr0: my tp0 -> state0
+ Transition tr1: state0 -> cp cp0 {
+ triggers {
+ <pongInt8: PingPongPort>
+ }
+ }
+ Transition tr2: cp cp0 -> state1 {
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\", 0xFF);"
+ }
+ }
+ Transition E2: cp cp0 -> state1 {
+ cond {
+ "d==8"
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",2);"
+ }
+ }
+ Transition tr3: state2 -> cp cp1 {
+ triggers {
+ <pongInt32: PingPongPort>
+ }
+ }
+ Transition E4: cp cp1 -> my tp1 {
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\", 4);"
+ }
+ }
+ Transition tr4: cp cp1 -> my tp1 {
+ cond {
+ "d != 32"
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\", 0xFF);"
+ }
+ }
+ Transition tr5: state1 -> state2 {
+ triggers {
+ <pongInt16: PingPongPort>
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\", 0xFF);"
+ }
+ }
+ Transition E3: state1 -> state2 {
+ triggers {
+ <pongInt16: PingPongPort guard {
+ "d==16"
+ }>
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\", 3);"
+ }
+ }
+ ChoicePoint cp0
+ ChoicePoint cp1
+ EntryPoint tp0
+ ExitPoint tp1
+ State state0
+ State state1
+ State state2
+ }
+ }
+ State TestFinished {
+ entry {
+ "EXPECT_ORDER_END(\"<|MODEL_LOCATION|>\\n\", 50);"
+ "etUnit_closeAll();"
+ "SubSys_SendingData_shutdown();"
+ }
+ }
+ State waitForPongFloat {
+ subgraph {
+ Transition tr0: my tp0 -> state0
+ Transition tr1: state0 -> cp cp0 {
+ triggers {
+ <pongFloat32: PingPongPort>
+ }
+ }
+ Transition tr2: cp cp0 -> state1 {
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",0xFF);"
+ }
+ }
+ Transition E5: cp cp0 -> state1 {
+ cond {
+ "((d>32)&&(d<33))"
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",5);"
+ }
+ }
+ Transition tr3: state1 -> cp cp1 {
+ triggers {
+ <pongFloat64: PingPongPort>
+ }
+ }
+ Transition tr4: cp cp1 -> my tp1 {
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",0xFF);"
+ }
+ }
+ Transition E6: cp cp1 -> my tp1 {
+ cond {
+ "((d>64)&&(d<65))"
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",6);"
+ }
+ }
+ ChoicePoint cp0
+ ChoicePoint cp1
+ EntryPoint tp0
+ ExitPoint tp1
+ State state0
+ State state1
+ }
+ }
+ State waitForPongRef {
+ subgraph {
+ Transition tr0: my tp0 -> state0 {
+ action {
+ "i32Val=5;"
+ "PingPongPort.pingInt32Ref(&i32Val);"
+ "i32Val=10;"
+ "PingPongPort.pingInt32Ref(&i32Val);"
+ }
+ }
+ Transition E7: state0 -> state1 {
+ triggers {
+ <pongInt32: PingPongPort guard {
+ "d==10"
+ }>
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",7);"
+ }
+ }
+ Transition tr2: state0 -> state1 {
+ triggers {
+ <pongInt32: PingPongPort>
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",0xFF);"
+ }
+ }
+ Transition E8: state1 -> my tp1 {
+ triggers {
+ <pongInt32: PingPongPort guard {
+ "d==10"
+ }>
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",8);"
+ }
+ }
+ Transition tr4: state1 -> my tp1 {
+ triggers {
+ <pongInt32: PingPongPort>
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",0xFF);"
+ }
+ }
+ EntryPoint tp0
+ ExitPoint tp1
+ State state0
+ State state1
+ }
+ }
+ State waitForComplex {
+ subgraph {
+ Transition tr0: my tp0 -> state0 {
+ action {
+ "i8ValAC=7;"
+ "data.i8Val=10;"
+ "data.i8Array[0]=1;"
+ "data.i8Array[1]=2;"
+ "data.i8Array[2]=3;"
+ "data.i8ArrayRef[0]=&i8ValAC;"
+ "data.i8ArrayRef[1]=&i8ValAC;"
+ "data.i8ValRef=&i8ValAC;"
+ "data.complexVal.i32Val1=127;"
+ "data.complexVal.i32Val2=130;"
+ "PingPongPort.pingComplex(&data);"
+ "i8ValAC=9;"
+ "data.i8Val=12;"
+ }
+ }
+ Transition tr2: state0 -> cp cp0 {
+ triggers {
+ <pongComplex: PingPongPort>
+ }
+ }
+ Transition tr1: cp cp0 -> state1 {
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",0xFF);"
+ }
+ }
+ Transition E9: cp cp0 -> state1 {
+ cond {
+ "checkData(*d,0)"
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",9);"
+ ""
+ "PingPongPort.pingComplexRef(&data);"
+ ""
+ "i8ValAC=12;"
+ "data.i8Val=50;"
+ "data.i8Array[0]=10;"
+ "data.i8Array[1]=20;"
+ "data.i8Array[2]=30;"
+ "data.i8ArrayRef[0]=&i8ValAC;"
+ "data.i8ArrayRef[1]=&(data.i8Array[0]);"
+ "data.i8ValRef=&i8ValAC;"
+ "data.complexVal.i32Val1=150;"
+ "data.complexVal.i32Val2=170;"
+ }
+ }
+ Transition tr3: state1 -> my tp1 {
+ triggers {
+ <pongComplex: PingPongPort>
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",0xFF);"
+ }
+ }
+ Transition E10: state1 -> my tp1 {
+ triggers {
+ <pongComplex: PingPongPort guard {
+ "checkData(*d,1)"
+ }>
+ }
+ action {
+ "EXPECT_ORDER(\"<|MODEL_LOCATION|>\\\\n\",10);"
+ }
+ }
+ ChoicePoint cp0
+ EntryPoint tp0
+ ExitPoint tp1
+ State state0
+ State state1
+ }
+ }
+ }
+ }
+ }
+
+ ProtocolClass PingPongProtocol {
+ incoming {
+ Message pingInt8(d: int8)
+ Message pingInt16(d: int16)
+ Message pingInt32(d: int32)
+ Message pingFloat32(d: float32)
+ Message pingFloat64(d: float64)
+ Message pingInt32Ref(d: int32 ref)
+ Message pingComplex (d:PingPongData)
+ Message pingComplexRef (d:PingPongData ref)
+ }
+ outgoing {
+ Message pongInt8(d: int8)
+ Message pongInt16(d: int16)
+ Message pongInt32(d: int32)
+ Message pongFloat32(d: float32)
+ Message pongFloat64(d: float64)
+ Message pongComplex(d:PingPongData)
+ }
+ }
+
+ DataClass PingPongData {
+ Attribute i8Val:int8
+ Attribute i8ValRef:int8 ref
+ Attribute i8Array [3] :int8
+ Attribute i8ArrayRef [2] : int8 ref
+ Attribute complexVal: PingPongDataDeep
+ }
+
+ DataClass PingPongDataDeep {
+ Attribute i32Val1:int32
+ Attribute i32Val2:int32
+ }
+
+} \ No newline at end of file