| RoomModel ReferenceCPP_ActorClasses { |
| |
| import ReferenceCPP_DataClasses.* from "ReferenceCPP_DataClasses.room" |
| |
| 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" ] { |
| Structure { |
| ActorRef allDataClasses: ActorAllDataClasses |
| ActorRef actorWithImplementationSubclass: ActorWithImplementationSubclass |
| Binding mirrorDataClasses.portMirror and allDataClasses.portSend |
| ActorRef mirrorDataClasses: ActorAllDataClassesMirror |
| Binding derived.port and mirror.port |
| ActorRef mirror: GenericMirror |
| ActorRef derived: InheritanceDerivedClassSimple |
| } |
| } |
| |
| ActorClass ActorAllDataClasses { |
| Interface { |
| conjugated Port portSend: PAllDatatypes |
| } |
| Structure { |
| Attribute allDatatypes: DAllDatatypes |
| Attribute char1: char |
| Attribute char2: char |
| Attribute charArray [ 100 ]: char |
| external Port portSend |
| } |
| Behavior { |
| StateMachine { |
| State state0 { |
| entry { |
| "sprintf(charArray.getData(), \"Hallo eTrice\"); // no very secure -> only for testcase" |
| "DAllDatatypes data(-1, -2, -3, -4, 1,2,3,4, 123.456, -123.456, false, 'A', charArray.getData(), std::string(\"ABC\"), string32(\"XYZ\"), (void*)0x0F0F, StaticArray<char, 4>(66), StaticArray<int32, 4>(55555));" |
| "data.printAll(\"data 1 send\");" |
| "portSend.sendAllDatatypes(data);" |
| } |
| } |
| Transition init: initial -> state0 |
| State state1 |
| Transition tr0: state0 -> state1 { |
| triggers { |
| <mirrorAllDatatypes: portSend> |
| } |
| action { |
| "// TODO: code proposals for data. do not work" |
| "data.printAll(\"data 4 receive\");" |
| } |
| } |
| } |
| } |
| } |
| |
| ActorClass ActorAllDataClassesMirror { |
| Interface { |
| Port portMirror: PAllDatatypes |
| } |
| Structure { |
| Attribute allDatatypes: DAllDatatypes |
| external Port portMirror |
| } |
| Behavior { |
| StateMachine { |
| State state0 |
| State state1 |
| Transition init: initial -> state0 |
| Transition tr0: state0 -> state1 { |
| triggers { |
| <sendAllDatatypes: portMirror> |
| } |
| action { |
| "allDatatypes = data;" |
| "allDatatypes.printAll(\"data 2 receive\");" |
| "allDatatypes.attribute_char_array[3]++;" |
| "allDatatypes.attribute_string32+=\"2\";" |
| "allDatatypes.attribute_charPtr[0]=\'X\';" |
| "allDatatypes.printAll(\"data 3 modify & send\");" |
| "" |
| "portMirror.mirrorAllDatatypes(allDatatypes);" |
| } |
| } |
| } |
| } |
| } |
| |
| ProtocolClass PStartStop { |
| incoming { |
| Message start() |
| Message stop() |
| } |
| outgoing { |
| Message started() |
| Message stopped() |
| } |
| } |
| |
| datadriven ActorClass ActorWithImplementationSubclass { |
| @ImplementationSubclass(fqnClassName = "ActorWithImplementationSubclass_Impl") |
| Behavior { |
| StateMachine { |
| State State1 { |
| entry { |
| "//" |
| } |
| exit { |
| "//" |
| } |
| } |
| State State2 { |
| entry { |
| "//" |
| } |
| exit { |
| "//" |
| } do { |
| "//" |
| } |
| } |
| Transition init: initial -> State1 { |
| action { |
| "//" |
| } |
| } |
| Transition tr0: State1 -> State2 { |
| guard { |
| "true" |
| } |
| action { |
| "//" |
| } |
| } |
| } |
| } |
| } |
| |
| abstract ActorClass InheritanceBaseClassSimple { |
| Interface { |
| conjugated Port port: PNumberedMessages |
| } |
| Structure { |
| external Port port |
| } |
| Behavior { |
| StateMachine { |
| Transition init: initial -> state1 |
| State state0 { |
| subgraph { |
| EntryPoint tp0 |
| ExitPoint tp1 |
| } |
| } |
| Transition tr0: tp1 of state0 -> tp0 of state2 |
| State state1 { |
| entry { |
| "port.message2();" |
| } |
| } |
| Transition tr1: state1 -> tp0 of state0 { |
| triggers { |
| <reply2: port> |
| } |
| } |
| State state2 { |
| subgraph { |
| EntryPoint tp0 |
| ExitPoint tp1 |
| } |
| } |
| Transition tr2: tp1 of state2 -> Done |
| State Done |
| } |
| } |
| } |
| |
| ActorClass InheritanceDerivedClassSimple extends InheritanceBaseClassSimple { |
| Behavior { |
| StateMachine { |
| RefinedState state0 { |
| subgraph { |
| State state0 { |
| entry { |
| "port.message0();" |
| } |
| } |
| Transition tr0: my tp0 -> state0 |
| Transition tr1: state0 -> my tp1 { |
| triggers { |
| <reply0: port> |
| } |
| } |
| } |
| } |
| RefinedState state2 { |
| subgraph { |
| Transition tr0: my tp0 -> my tp1 |
| } |
| } |
| } |
| } |
| } |
| |
| ActorClass GenericMirror { |
| Interface { |
| Port port: PNumberedMessages |
| } |
| Structure { |
| external Port port |
| } |
| Behavior { |
| StateMachine { |
| State Idle |
| Transition init: initial -> Idle |
| Transition tr0: Idle -> Idle { |
| triggers { |
| <message0: port> |
| } |
| action { |
| "port.reply0();" |
| } |
| } |
| Transition tr1: Idle -> Idle { |
| triggers { |
| <message1: port> |
| } |
| action { |
| "port.reply1();" |
| } |
| } |
| Transition tr2: Idle -> Idle { |
| triggers { |
| <message2: port> |
| } |
| action { |
| "port.reply2();" |
| } |
| } |
| Transition tr3: Idle -> Idle { |
| triggers { |
| <message3: port> |
| } |
| action { |
| "port.reply3();" |
| } |
| } |
| Transition tr4: Idle -> Idle { |
| triggers { |
| <message4: port> |
| } |
| action { |
| "port.reply4();" |
| } |
| } |
| Transition tr5: Idle -> Idle { |
| triggers { |
| <message5: port> |
| } |
| action { |
| "port.reply5();" |
| } |
| } |
| Transition tr6: Idle -> Idle { |
| triggers { |
| <message6: port> |
| } |
| action { |
| "port.reply6();" |
| } |
| } |
| } |
| } |
| } |
| |
| } |