Skip to main content
aboutsummaryrefslogblamecommitdiffstats
blob: 070e710345bab4902afdd913627db6bcca2a27fa (plain) (tree)
1
2
3
4
5
6
7
8






                                                                                                           
 







                                                                                                 


                                                                       










                                                               
                                                         




                                              
                                               



                                                                                                                                                                                                                                                                  

                                         

                                                                  



                                                                              
                                                
                                                                                               
                                                                                    














                                                             

                                            





                                                                              
                                                
                                                                      
                                                                                            


                                                                                          
                                                                                                  
                                                  
























































                                                                                              








                                                               
                                                                         



                                                              

                                                           
















                                                                              
                                                      



                                                                     












                                                                       
                                                                          









                                                                         





                                                                                     

                                                     
                                                  
                                                              




                                                                                  










                                                                                  












































































                                                                













































































                                                                     
 
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 -> tp0 of state0
				State state0 {
					subgraph {
						EntryPoint tp0
						ExitPoint tp1
					TransitionPoint tp2
					ExitPoint tp3
					}
				}
				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
					EntryPoint tr1
					}
				}
				Transition tr2: tp1 of state2 -> Done
				State Done
			TransitionPoint tp0
				Transition tr3: my tp0 -> state1 {
					triggers {
						<reply0: port>
					}
				}
			ChoicePoint cp0
				Transition tr4: state0 -> cp cp0 {
					triggers {
						<reply0: port>
					}
				}
				Transition tr5: cp cp0 -> tp0 of state2
				Transition tr6:  cp cp0 -> tr1 of state2 {
					cond {
						"true"
					}
				}
				Transition tr7: cp cp0 -> tp0 of state0 {
					cond {
						"true"
					}
				}
				Transition tr8: tp3 of state0 -> cp cp0
			}
		}
	}

	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 {
								<reply2:port>
							}
						}
						Transition tr2: state0 -> my tp3 {
							triggers {
								<reply3:port>
							}
						}
						
					}
				}
			}
		}
	}

	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();"
					}
				}
			}
		}
	}

	ActorClass ReplicationTop {
		
	Structure {
			ActorRef replSub1 [3]: ReplicationSub1
			ActorRef replSub2 [3]: ReplicationSub2
		Binding replSub1.port and replSub2.port
		ActorRef replSub3_1 [1]: ReplicationSub3
		ActorRef replSub3_2: ReplicationSub3
			conjugated Port replPort [8]: PStartStop
		Binding replPort and replSub3_1.replPort
			Binding replPort and replSub3_2.replPort
		}
	Behavior {
			StateMachine {
				State state0 {
					entry {
						"replPort.start();"
					}
				}
				State DONE
				State state1
				Transition init0: initial -> state0
				Transition tr0: state0 -> state1 {
					triggers {
						<started: replPort>
					}
				}
				Transition tr1: state1 -> DONE {
					triggers {
						<started: replPort>
					}
				}
			}
		}
	}
	
	ActorClass ReplicationSub1 {
		
	Interface {
			conjugated Port port: PStartStop
		}
		Structure {
			external Port port
		}
	}

	ActorClass ReplicationSub2 {
		
	Interface {
			Port port: PStartStop
		}
		Structure {
			external Port port
		}
	}
	ActorClass ReplicationSub3 {
		
	Interface {
			Port replPort [1]: PStartStop
		}
		Structure {
			external Port replPort
		}
		Behavior {
			StateMachine { State state0
				State state1
				Transition init0: initial -> state0
				Transition tr0: state0 -> state1 {
					triggers {
						<start: replPort>
					}
					action {
						"replPort.started();"
					}
				}
			}
		}
	}
}

Back to the top