Une image contenant texte, signe

Description générée automatiquement

Multicast for Proxy Ports

 

Overview

Rhapsody does not natively support multicasting of events through proxy ports. This simplifier provides that facility.

 

Applicable To

N/A

Menu Entry

N/A

Demonstration

Watch the Video

Operation

This feature is not a traditional helper but is instead a code simplifier (these are explained in the Advanced section below). To enable the simplifier, set the following property to ByUserPostDefault on the active Component:

CPP_CG::Class::Simplify

In the sample model supplied there are two components:

 

·       NoMulticastingSimplifier

Uses Rhapsody’s standard code generation. In this case Rhapsody generates code that will not compile (and in Rhapsody Systems Designer the model will not execute).

 

·       MulticastingSimplifierEnabled

This component enables the Simplifier:

 

A screenshot of a computer

Description automatically generated

Enabling Multicasting at Port Level

In general, multicasting should be enabled for the appropriate proxy ports using the following property on those ports (or above them hierarchically).

CPP_CG::Port::SupportMulticast

Note that this property is enabled by default (so this property should already be set unless it has been overridden by the user)

Simplifier-Enabled Multicasting

Multiple patterns are supported (note that both Send Actions and OUT_PORT macros are supported)

 

Broadcast

Sent events are broadcast to all connected parts.

A screenshot of a computer

Description automatically generated

A screenshot of a computer

Description automatically generated

A diagram of a block diagram

Description automatically generated with medium confidence

External Broadcast

Sent events are broadcast to all externally connected parts.

A screenshot of a computer

Description automatically generated

Internal Broadcast

Sent events are broadcast to all internally connected parts.

A screenshot of a computer

Description automatically generated

Advanced

How Code Simplifiers Work

Rhapsody’s code generation architecture is a two-stage process. The first stage is the transformation of the user model into a simplified code model. It is simplified in the sense that it only contains primitives that are realizable in the target language. The second stage is the transformation of that simplified model into code. Code simplifiers are very powerful mechanisms that allow you to customize the way the code is generated by manipulating this simplified model before it is transformed into code.

A diagram of a software development

Description automatically generated

Viewing the Simplified Model

By default, the simplified model is not visible to the user. Viewing the simplified model is not necessary for the functionality to work but may be of interest to the advanced user. To view the simplified model, set the following property to true:

CPP_CG::Configuration::ShowCgSimplifiedModelPackage

The next time code is generated the simplified model will be shown in the model browser:

A close-up of a text

Description automatically generated

 

 

How this Simplifier Works

The Multicast for Proxy Ports simplifier searches the simplified model for the ‘send’ operations that Rhapsody generates to allow the multicasting of events through a port:

A screenshot of a computer

Description automatically generated

The original Rhapsody-generated code for these operations sends each event in the port to one target only:

A screenshot of a computer screen

Description automatically generated

The simplifier modifies this code to send events to all connected targets using a for-loop defined in a template in the following property:

RhapsodyPowerPack.MulticastForProxyPorts.SendTemplate

            if(event->isTypeOf($eventID$)) {

                        $eventParametersPointer$

                        for (int i = 0; i < its$eventNameCapital$_ProxyReceptionInterface.getCount(); i++)

                        {

                                    res =  its$eventNameCapital$_ProxyReceptionInterface[i]->send(new $eventName$($eventParameters$)$params$);

                                    if(res==false) break;

                        }

            }

(the simplifier helper replaces the $xxx$ parameters with the details of the event(s) to be sent through the port).

 

A screenshot of a computer code

Description automatically generated

 

Note that this also requires the following property to be set (this is set on the Rhapsody Power Pack Profile. This ensures Rhapsody code generation uses OUT_PORT (compatible with the simplifier) instead of MULTICAST_GEN (which only works for standard ports)

A screenshot of a pattern

Description automatically generated