blob: 4f7cfb59fe2f3c435ff54239c42cca3756b5302d [file] [log] [blame]
RoomModel etrice.example {
import room.basic.service.tcp.* from "../../../org.eclipse.etrice.modellib.java/model/TcpService.room"
import room.basic.types.* from "../../../org.eclipse.etrice.modellib.java/model/Types.room"
import room.basic.service.timing.* from "../../../org.eclipse.etrice.modellib.java/model/TimingService.room"
LogicalSystem System {
SubSystemRef SubSysRefName: SubSys
}
SubSystemClass SubSys {
ActorRef application: Application
ActorRef timingService: ATimingService
LayerConnection ref application satisfied_by timingService.timer
LogicalThread defaultThread
}
ActorClass Application {
Structure {
ActorRef trafficLightIF: TrafficLightIF
ActorRef trafficLightSocket: ATcpClient
ActorRef controller: TrafficLightController
Binding trafficLightIF.control and trafficLightSocket.ControlPort
Binding trafficLightIF.payload and trafficLightSocket.PayloadPort
Binding controller.trafficLight and trafficLightIF.fct
}
Behavior { }
}
ActorClass TrafficLightIF {
Interface {
conjugated Port control: PTcpControl
conjugated Port payload: PTcpPayload
Port fct: PTrafficLightIF
}
Structure {
external Port control
external Port payload
external Port fct
SAP timeout: PTimer
}
Behavior {
StateMachine {
Transition init: initial -> NotInitialized { }
Transition tr0: Init -> tp0 of Initialized_Blinking {
triggers {
<established: control>
}
}
Transition tr2: Initialized_Blinking -> AllRed {
triggers {
<onForCars: fct>
}
}
Transition tr1: AllRed -> CarGreen {
triggers {
<timeout: timeout>
}
}
Transition tr3: Initialized_Blinking -> AllRed2 {
triggers {
<onForPeds: fct>
}
}
Transition tr4: AllRed2 -> PedGreen {
triggers {
<timeout: timeout>
}
}
Transition tr5: PedGreen -> AllRed {
triggers {
<onForCars: fct>
}
}
Transition tr6: CarGreen -> AllRed2 {
triggers {
<onForPeds: fct>
}
}
Transition tr7: NotInitialized -> Init {
triggers {
<initialize: fct>
}
}
State Init {
entry {
"control.open(new DTcpControl(\"localhost\", 4441));\n\n"
}
}
State Initialized_Blinking {
entry {
"fct.initialized();"
}
subgraph {
Transition tr0: my tp0 -> ON
Transition tr1: ON -> OFF {
triggers {
<timeout: timeout>
}
}
Transition tr2: OFF -> ON {
triggers {
<timeout: timeout>
}
}
EntryPoint tp0
State ON {
entry {
"String text = new String(\"carLights=yellow\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntimeout.startTimeout(500);"
}
exit {
"String text = new String(\"carLights=off\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\n"
}
}
State OFF {
entry {
"timeout.startTimeout(500);"
}
}
}
}
State AllRed {
entry {
"String text = new String(\"carLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntext = new String(\"pedLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntimeout.startTimeout(3000);"
}
}
State CarGreen {
entry {
"String text = new String(\"carLights=green\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntext = new String(\"pedLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\nfct.onForCarsDone();"
}
}
State AllRed2 {
entry {
"String text = new String(\"carLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntext = new String(\"pedLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntimeout.startTimeout(3000);\n"
}
}
State PedGreen {
entry {
"String text = new String(\"carLights=red\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\ntext = new String(\"pedLights=green\\n\");\npayload.send(new DTcpPayload(1, text.length(), text.getBytes()));\nfct.onForPedsDone();\n"
}
}
State NotInitialized
}
}
}
ActorClass TrafficLightController {
Interface {
conjugated Port trafficLight: PTrafficLightIF
}
Structure {
external Port trafficLight
SAP timeout: PTimer
}
Behavior {
StateMachine {
Transition init: initial -> Init { }
Transition tr0: Init -> OnForCars {
triggers {
<initialized: trafficLight>
}
}
Transition tr1: OnForCars -> WaitABit1 {
triggers {
<onForCarsDone: trafficLight>
}
}
Transition tr2: OnForPeds -> WaitABit2 {
triggers {
<onForPedsDone: trafficLight>
}
}
Transition tr3: WaitABit1 -> OnForPeds {
triggers {
<timeout: timeout>
}
}
Transition tr4: WaitABit2 -> OnForCars {
triggers {
<timeout: timeout>
}
}
State Init {
entry {
"trafficLight.initialize();"
}
}
State OnForCars {
entry {
"trafficLight.onForCars();"
}
}
State OnForPeds {
entry {
"trafficLight.onForPeds();"
}
}
State WaitABit1 {
entry {
"timeout.startTimeout(2000);"
}
}
State WaitABit2 {
entry {
"timeout.startTimeout(2000);\n"
}
}
}
}
}
ProtocolClass PTrafficLightIF {
incoming {
Message initialize()
Message onForCars()
Message onForPeds()
}
outgoing {
Message initialized()
Message onForCarsDone()
Message onForPedsDone()
}
}
}