diff options
author | Thomas Schuetz | 2016-09-05 14:54:04 +0000 |
---|---|---|
committer | Thomas Schuetz | 2016-09-05 14:54:04 +0000 |
commit | fdba2ed37d16e853ef97f9ce1cb6bb94df159117 (patch) | |
tree | 016f28a83cc02ffcc508bebfde2d5594583869a5 /examples | |
parent | b87704281399063f9083a028d2bf0e879f772df4 (diff) | |
download | org.eclipse.etrice-fdba2ed37d16e853ef97f9ce1cb6bb94df159117.tar.gz org.eclipse.etrice-fdba2ed37d16e853ef97f9ce1cb6bb94df159117.tar.xz org.eclipse.etrice-fdba2ed37d16e853ef97f9ce1cb6bb94df159117.zip |
[generator.cpp.reference] added reference models for sending dataclasses
with new attribute (based on Containers StaticString and StaticArray)
Change-Id: Ia148ab02e5148916837080c669a6cd3e9fa9d36b
Diffstat (limited to 'examples')
6 files changed, 43 insertions, 23 deletions
diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_ActorClasses.room b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_ActorClasses.room index aa2aa447f..b5386fffb 100644 --- a/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_ActorClasses.room +++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_ActorClasses.room @@ -5,6 +5,7 @@ RoomModel ReferenceCPP_ActorClasses { import ReferenceCPP_ProtocolClasses.* from "ReferenceCPP_ProtocolClasses.room" import room.basic.annotations.* from "../../org.eclipse.etrice.modellib.cpp/model/Annotations.room" + import room.basic.types.* from "../../org.eclipse.etrice.modellib.cpp/model/Types.room" ActorClass ActorToplevel [ "instantiate all element to enforce code generation" ] { @@ -24,22 +25,25 @@ RoomModel ReferenceCPP_ActorClasses { Attribute allDatatypes: DAllDatatypes Attribute char1: char Attribute char2: char - Attribute charArray[100]: char + Attribute charArray [ 100 ]: char external Port portSend } Behavior { StateMachine { State state0 { entry - { - "sprintf(charArray, \"Hallo eTrice\");" - "DAllDatatypes data(-1, -2, -3, -4, 1,2,3,4, 123.456, -123.456, false, \'A\', charArray);" - "portSend.sendAllDatatypes(data);" + "\tsprintf(charArray.getData(), \"Hallo eTrice\"); // no very secure -> only for testcase" + "\t//DAllDatatypes data(-1, -2, -3, -4, 1,2,3,4, 123.456, -123.456, false, \'A\', charArray);" + "\tDAllDatatypes data;" + "\tdata.attribute_char_array[3]=65;" + "\tdata.attribute_string32 = \"Hallo\";" + "\tdata.attribute_charPtr = charArray.getData();" + "\tportSend.sendAllDatatypes(data);" } } - Transition init: initial -> state0 - State state1 + Transition init: initial -> state0 + State state1 Transition tr0: state0 -> state1 { triggers { <mirrorAllDatatypes: portSend> @@ -48,6 +52,8 @@ RoomModel ReferenceCPP_ActorClasses { { "//printf(\"%d, %ld, %f, %d, %c, %s\\n\", data.attribute_int8, data.attribute_uint64, data.attribute_float64, data.attribute_boolean, data.attribute_char, data.attribute_charPtr);" + "// TODO: code proposals for data. do not work" + "printf(\"\\nReceived: (%c, %s, %s)\\n\", data.attribute_char_array[3], data.attribute_string32.getData(), data.attribute_charPtr);" } } } @@ -63,15 +69,27 @@ RoomModel ReferenceCPP_ActorClasses { external Port portMirror } Behavior { - StateMachine { State state0 + StateMachine { + State state0 State state1 Transition init: initial -> state0 Transition tr0: state0 -> state1 { triggers { <sendAllDatatypes: portMirror> } - action { + action + + + + { "allDatatypes = data;" + "printf(\"\\nEmpfangen: (%c, %s, %s)\\n\", data.attribute_char_array[3], data.attribute_string32.getData(), data.attribute_charPtr);" + "" + "allDatatypes.attribute_char_array[3]++;" + "allDatatypes.attribute_string32+=\"2\";" + "allDatatypes.attribute_charPtr[0]=\'X\';" + "printf(\"\\nGesendet: (%c, %s, %s)\\n\", allDatatypes.attribute_char_array[3], allDatatypes.attribute_string32.getData(), allDatatypes.attribute_charPtr);" + "" "portMirror.mirrorAllDatatypes(allDatatypes);" } } diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_DataClasses.room b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_DataClasses.room index 0eb0ad4f2..5c2b0872e 100644 --- a/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_DataClasses.room +++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/ReferenceCPP_DataClasses.room @@ -25,15 +25,17 @@ RoomModel ReferenceCPP_DataClasses { Attribute attribute_boolean : boolean Attribute attribute_char : char Attribute attribute_charPtr : charPtr -// TODO: string does not compile -// Attribute attribute_string : string -// Attribute attribute_voidTypeRef : voidType ref + + // strings + Attribute attribute_string : string // maps to std::string attribute_string; (standard template library) + Attribute attribute_string32 : string32 // maps to StaticString<32> attribute_string32; (in org.eclipse.etrice.runtime.cpp\src\common\containers) + + // references + Attribute attribute_voidTypeRef : voidType ref // arrays - // TODO: arrays for attributes do not compile -// Attribute attribute_char_array[4] : char -// Attribute attribute_int32_array[4] : int32 - - + Attribute attribute_char_array[4] : char // maps to StaticArray<char, 4> attribute_char_array; (in org.eclipse.etrice.runtime.cpp\src\common\containers) + Attribute attribute_int32_array[4] : int32 // maps to StaticArray<int32, 4> attribute_int32_array; (in org.eclipse.etrice.runtime.cpp\src\common\containers) } -}
\ No newline at end of file +} + diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorAllDataClasses.behavior b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorAllDataClasses.behavior index 459d0605a..df57664dd 100644 --- a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorAllDataClasses.behavior +++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorAllDataClasses.behavior @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ASCII"?> -<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.behavior" name="Behavior of ActorAllDataClasses" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@connections.0/@link //@children.0/@children.3/@link //@connections.1/@link" verticalGridUnit="0" version="0.12.0"> +<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.behavior" name="Behavior of ActorAllDataClasses" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@connections.0/@link //@children.0/@children.3/@link //@connections.1/@link" verticalGridUnit="0" version="0.11.0"> <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/> <link> <businessObjects href="../ReferenceCPP_ActorClasses.room#ActorClass:ActorAllDataClasses"/> @@ -34,7 +34,7 @@ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="120" height="90" x="302" y="97"> <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" background="//@colors.3" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="60" height="30" x="30" y="30" cornerHeight="20" cornerWidth="20"> <graphicsAlgorithmChildren xsi:type="al:RoundedRectangle" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="15" height="8" x="35" y="3" cornerHeight="5" cornerWidth="5"/> - <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" lineVisible="true" transparency="0.0" x="30" y="24"> + <graphicsAlgorithmChildren xsi:type="al:Polygon" foreground="//@colors.2" lineWidth="1" filled="false" transparency="0.0" x="30" y="24"> <points x="-3" y="-3"/> <points x="-3" y="3"/> <points x="-11" y="3"/> diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorAllDataClassesMirror.behavior b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorAllDataClassesMirror.behavior index d7e06270d..f00232a04 100644 --- a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorAllDataClassesMirror.behavior +++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorAllDataClassesMirror.behavior @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ASCII"?> -<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.behavior" name="Behavior of ActorAllDataClassesMirror" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@connections.0/@link //@children.0/@children.3/@link //@connections.1/@link" verticalGridUnit="0" version="0.12.0"> +<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.behavior" name="Behavior of ActorAllDataClassesMirror" pictogramLinks="//@link //@children.0/@link //@children.0/@children.1/@link //@children.0/@children.2/@link //@connections.0/@link //@children.0/@children.3/@link //@connections.1/@link" verticalGridUnit="0" version="0.11.0"> <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/> <link> <businessObjects href="../ReferenceCPP_ActorClasses.room#ActorClass:ActorAllDataClassesMirror"/> diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorToplevel.structure b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorToplevel.structure index 46129332c..3077ed1a1 100644 --- a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorToplevel.structure +++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_ActorClasses.ActorToplevel.structure @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ASCII"?> -<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.structure" name="Structure of ActorToplevel" pictogramLinks="//@link //@children.0/@link //@children.0/@children.0/@link //@children.0/@children.1/@link //@children.0/@children.1/@children.2/@link //@children.0/@children.2/@link //@children.0/@children.2/@children.2/@link //@connections.0/@link" verticalGridUnit="0" version="0.12.0"> +<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.structure" name="Structure of ActorToplevel" pictogramLinks="//@link //@children.0/@link //@children.0/@children.0/@link //@children.0/@children.1/@link //@children.0/@children.1/@children.2/@link //@children.0/@children.2/@link //@children.0/@children.2/@children.2/@link //@connections.0/@link" verticalGridUnit="0" version="0.11.0"> <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/> <link> <businessObjects href="../ReferenceCPP_ActorClasses.room#ActorClass:ActorToplevel"/> diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_Main.SubSysClass.structure b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_Main.SubSysClass.structure index 84331c56d..d01911115 100644 --- a/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_Main.SubSysClass.structure +++ b/examples/org.eclipse.etrice.generator.cpp.reference/model/diagrams/ReferenceCPP_Main.SubSysClass.structure @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ASCII"?> -<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.structure" name="Structure of SubSysClass" pictogramLinks="//@link //@children.0/@link //@children.0/@children.0/@link //@children.0/@children.1/@link //@children.0/@children.1/@children.2/@link //@connections.0/@link" verticalGridUnit="0" version="0.12.0"> +<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" diagramTypeId="room.structure" name="Structure of SubSysClass" pictogramLinks="//@link //@children.0/@link //@children.0/@children.0/@link //@children.0/@children.1/@link //@children.0/@children.1/@children.2/@link //@connections.0/@link" verticalGridUnit="0" version="0.11.0"> <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/> <link> <businessObjects href="../ReferenceCPP_Main.room#SubSystemClass:SubSysClass"/> |