| RoomModel ContractMonitor { |
| |
| import etrice.api.types.* |
| import etrice.api.contracts.definitions.* |
| |
| ProtocolClass PLoginProtocol { |
| @InterfaceContract(definedBy = "LoginProtocolContract") |
| incoming { |
| Message hello() |
| Message login(int16) |
| Message cancel() |
| } |
| outgoing { |
| Message hello() |
| Message wrong() |
| Message attemptsLimitReached() |
| Message ok() |
| } |
| } |
| |
| ActorClass LoginProtocolContract { |
| @InterfaceContractDefinition(protocol = "PLoginProtocol", generatedMonitorName = "LoginProtocolMonitor") |
| Interface { |
| conjugated Port serverPort: PLoginProtocol |
| Port loginPort: PLoginProtocol |
| } |
| Structure { |
| external Port serverPort |
| external Port loginPort |
| Attribute attempts: int16 |
| } |
| Behavior { |
| StateMachine { |
| State idle { |
| entry '''attempts = 0;''' |
| } |
| State connecting |
| State connected |
| State checking { |
| entry '''attempts += 1;''' |
| } |
| Transition init0: initial -> idle |
| Transition tr0: idle -> connecting { |
| triggers { |
| <hello: loginPort> |
| } |
| } |
| Transition tr1: connecting -> connected { |
| triggers { |
| <hello: serverPort> |
| } |
| } |
| Transition tr2: connected -> idle { |
| triggers { |
| <cancel: loginPort> |
| } |
| } |
| Transition tr3: connected -> checking { |
| triggers { |
| <login: loginPort> |
| } |
| } |
| Transition tr4: checking -> idle { |
| triggers { |
| <ok: serverPort> |
| } |
| } |
| Transition tr5: checking -> connected { |
| triggers { |
| <wrong: serverPort guard '''attempts <= 3'''> |
| } |
| } |
| Transition tr6: checking -> idle { |
| triggers { |
| <attemptsLimitReached: serverPort guard '''attempts > 3'''> |
| } |
| } |
| } |
| } |
| } |
| } |