| @xlia< system , 1.0 >: |
| |
| system<and> PingPongSimulation { |
| |
| @machine: |
| model statemachine Player { |
| @parameter: |
| // this boolean defines whether or not the player has the ball |
| public var bool hasBall; |
| |
| @property: |
| // those are the ports through which the ball is exchanged |
| public port input caught; |
| public port output send; |
| |
| @region: |
| state<initial> source {transition startup --> stand_by {}} |
| |
| state stand_by{ |
| transition receivesBall --> stand_by{ |
| input caught; |
| hasBall = true; |
| } |
| transition sendsBall --> stand_by{ |
| guard(hasBall == true); |
| hasBall = false; |
| output send; |
| } |
| } |
| } |
| |
| @instance: |
| instance statemachine<Player> Ping(hasBall:true); |
| instance statemachine<Player> Pong(hasBall:false); |
| |
| @com: |
| connect<rdv> {input Pong->caught; output Ping->send;} |
| connect<rdv> {input Ping->caught; output Pong->send;} |
| } |
| |
| |