Main Content

setDataTransfer

Set code configuration in code mappings for signal representing data transfer

Since R2022b

Description

setDataTransfer(coderMapObj,portHandle,DataTransferService=dataTransferService) sets the data transfer service of the signal corresponding to block output port, portHandle.

To configure the data transfer service, an Embedded Coder Dictionary that defines a service interface configuration must be attached to the model.

example

Examples

collapse all

This example model references a shared coder dictionary that defines the default data transfer services for signals representing data transfers. To configure the data transfer to use something other than the default service, use the getDataTransfer and setDataTransfer functions.

Open the component model, ComponentDeploymentFcn.

openExample("ComponentDeploymentFcn");

Get the code mappings for the model using the coder.mapping.api.get function.

cm = coder.mapping.api.get("ComponentDeploymentFcn");

In this model, the signal connecting two Function-Call Subsystem blocks, Accumulator and Integrator represents a data transfer. Get the current data transfer service configuration using the getDataTransfer function.

ph = get_param("ComponentDeploymentFcn/Integrator","PortHandles");
dataTransServ = getDataTransfer(cm,ph.Outport,"DataTransferService")
dataTransServ =

    'Dictionary default'
The signal representing the data transfer is configured to use the default data transfer service defined in the shared coder dictionary.

To configure the signal to communicate data with other functions immediately during function execution instead of before or after execution as specified in the dictionary, use the setDataTransfer function and set the DataTransferService property to DataTransferDuringExe.

setInport(cm,ph.Outport,"DataTransferService","DataTransferDuringExe")

Input Arguments

collapse all

Code mapping object (model code mappings) returned by a call to function coder.mapping.api.get.

Port handle for block output signal representing a data transfer. In a component model, signal lines connecting communicating functions represent data transfers in the generated code. Communicating functions are modeled using Function-Call Subsystem blocks that are aperiodic or periodic functions.

String or character vector containing the name of a data transfer service interface defined in the Embedded Coder Dictionary. To use the dictionary default, specify "Dictionary default".

In the Embedded Coder Dictionary, you can configure the data transfer services to one of the following:

  • Outside execution: The platform communicates data with other functions outside (before and after) function execution.

  • During execution: The platform service communicates data with other functions immediately during function execution.

For more information on data communication methods, see Data Communication Methods.

Data Types: char | string

Version History

Introduced in R2022b