Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Papyrus-RT/Developer/Design/0.8/Codegen Code Pattern

< Papyrus-RT‎ | Developer‎ | Design
Revision as of 12:06, 18 August 2015 by Unnamed Poltroon (Talk) (Created page with "This documents the code pattern that is realized in the PingPong-001 project in the CodePatterns repository. This code pattern was created with a focus on the structural eleme...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This documents the code pattern that is realized in the PingPong-001 project in the CodePatterns repository. This code pattern was created with a focus on the structural elements of UML-RT models. The structural elements are the capsules, port, connectors, and protocols. It is specifically not the state machine or contained elements which are labelled the "behavioural" elements.

Overview

The PingPong-001 model is a simple Top-level capsule containing two Capsule roles. One role, the Pinger sends a ping message whenever it receives a pong message. It also sends a ping message as part of its initialization. The other role, the Ponger sends a pong message whenever it receives a ping. This is show in the following figure.

PapyrusRT-CodePatternStructure-01.png

The PingPongProtocol has one message with a single data item and one message with two data values. This is just to ensure that the code pattern is not limited to only one value.

The rest of this document describes the parts of the code pattern. For reference I've included parts of the code pattern directly within this document. However, the code pattern in the repository should be used as the master copy -- this document will likely become out of date when compared against that master copy.

Protocols and Ports

The code pattern for a protocol is designed to allow user-level action code to send signals with:

portName().signalName( data1, data2 ).send()

Signal functions

This is implemented by generating a Protocol class containing a function for each signal. In this example the protocol class would have a function called signalName, accepting the data1 and data2 parameters. The type of the parameters matches the type specified in the UML-RT model.

The return value of the class is an instance of UMLRTSignal. This is a class defined in the RTS which implements the #send function.

OutSignals and InSignals

Each protocol class defines two nested classes, one each for the outgoing and incoming signals. Each of these classes contains the corresponding signal functions (as described in the previous section). Each class also has a signal function for each bi-directional signal.

Back to the top