7.6 Define Actor Structure and Behavior

Save the model and visit the outline view. Within the outline view, right click on the MrPong actor and select Edit Structure. Select an Interface Port from the toolbox and add it to MrPong. Name the Port PingPongPort and select the PingPongProtocol.

PIC

Do the same with MrPing but mark the port as conjugated

7.6.1 Define MrPongs behavior

Within the outline view, right click MrPong and select Edit Behavior. Create the following state machine:

PIC

The transition dialogues should look like this: For ping:

PIC

For pingSimple:

PIC

7.6.2 Define MrPing behavior

Within the outline view double click MrPing. Navigate the cursor to the behavior of MrPing. With the help of content assist create a new operation.

PIC

Name the operation printData and define the DemoData as a parameter.

Fill in the following code:

Operation printData(d: DemoData) : void {  
            "System.out.printf(\"d.int32Val: %d\\n\",d.int32Val);"  
            "System.out.printf(\"d.float64Val: %f\\n\",d.float64Val);"  
            "System.out.printf(\"d.int8Array: \");"  
            "for(int i = 0; i<d.int8Array.length; i++) {"  
            "System.out.printf(\"%d \",d.int8Array[i]);}"  
            "System.out.printf(\"\\nd.stringVal: %s\\n\",d.stringVal);"  
}

For MrPing create the following state machine: (Remember that you can copy and paste the action code from the tutorial directory.)

PIC

The transition dialogues should look like this:

For init:

PIC

For wait1:

PIC

For next:

PIC

For wait2:

PIC