Main Content

rtw.connectivity.ConfigRegistry

Register connectivity configuration

Description

Register your connectivity configuration with MATLAB® or Simulink®.

Creation

Description

config = rtw.connectivity.ConfigRegistry returns a handle to an rtw.connectivity.ConfigRegistry object.

To create this class:

  • For MATLAB, use an rtwTargetInfo.m file, which you must place on the MATLAB search path. In the rtwTargetInfo.m file, a call to registerTargetInfo registers the connectivity configuration.

  • For Simulink, use an sl_customization.m file, which you must place on the MATLAB search path. When Simulink starts, it reads the file, and registers your connectivity configuration through a call to registerTargetInfo in the file.

Through the first two properties of this class, you can specify for your connectivity configuration:

  • A unique name.

  • An associated connectivity implementation class, which is a subclass of rtw.connectivity.Config.

Through the remaining properties, you can define:

  • For MATLAB, the code that is compatible with the connectivity implementation class.

  • For Simulink, the set of models that are compatible with the connectivity implementation class.

A comparison of the union of these properties against the MATLAB Coder™ configuration settings or Simulink model parameters determines compatibility. For example with Simulink, whether the SystemTargetFile, TemplateMakefile, and HardwareBoard properties jointly match the corresponding model parameters.

Properties

expand all

Unique name for configuration.

Full class name of the connectivity implementation that you want to register.

For Simulink, system target files that support the rtw.connectivity.ConfigRegistry object you create. A comparison of this cell array against the SystemTargetFile configuration parameter of the model determines whether the created object is valid for use. An empty cell array matches any system target file.

For Simulink, template makefiles that support the rtw.connectivity.ConfigRegistry object you create. A comparison of this cell array against the TemplateMakefile configuration parameter of the model determines whether the created object is valid for use. An empty cell array matches any template makefile and non-makefile target (GenerateMakefile: off).

If you use a toolchain to build the generated code, do not specify the TemplateMakefile configuration parameter. Instead, specify the Toolchain configuration parameter.

Toolchains that support the rtw.connectivity.ConfigRegistry object you create:

  • For MATLAB, a comparison of this cell array against the MATLAB Coder Toolchain configuration setting determines whether the created object is valid for use.

  • For Simulink, a comparison of this cell array against the Toolchain configuration parameter of the model determines whether the created object is valid for use. If you do not use a toolchain to build the generated code, do not specify the Toolchain configuration parameter. Instead, specify the TemplateMakefile configuration parameter.

An empty cell array matches any toolchain.

Hardware boards that support the rtw.connectivity.ConfigRegistry object you create:

  • For MATLAB, a comparison of this cell array against the MATLAB Coder HardwareBoard configuration setting determines whether the created object is valid for use.

  • For Simulink, a comparison of this cell array against the HardwareBoard configuration parameter of the model determines whether the created object is valid for use.

An empty cell array matches any hardware board.

Hardware device types that support the rtw.connectivity.ConfigRegistry object you create:

  • For MATLAB, a comparison of this cell array against the MATLAB Coder TargetHWDeviceType configuration setting determines whether the created object is valid for use.

  • For Simulink, a comparison of this cell array against the TargetHWDeviceType configuration parameter of the model determines whether the created object is valid for use.

An empty cell array matches any hardware device type.

Examples

Create rtwTargetInfo.m File

This code is an example rtwTargetInfo.m file. Use the function syntax exactly as shown.

function rtwTargetInfo(tr)
% Register PIL connectivity config: mypil.ConnectivityConfig

tr.registerTargetInfo(@loc_createConfig);

% local function
function config = loc_createConfig

% Create object for connectivity configuration
config = rtw.connectivity.ConfigRegistry;
% Assign connectivity configuration name
config.ConfigName = 'My PIL Example';
% Associate the connectivity configuration with the connectivity
% API implementation
config.ConfigClass = 'mypil.ConnectivityConfig';

% Specify toolchains for host-based PIL
config.Toolchain =  rtw.connectivity.Utils.getHostToolchainNames;

% Through the HardwareBoard and TargetHWDeviceType properties,
% define compatible code for the target connectivity configuration 
config.HardwareBoard = {};
config.TargetHWDeviceType = {'Generic->32-bit x86 compatible' ...
                             'Generic->Custom' ...
                             'Intel->x86-64 (Windows64)', ...
                             'Intel->x86-64 (Mac OS X)', ...
                             'Intel->x86-64 (Linux 64)'};

The function performs the following steps:

  1. Creates an instance of the rtw.connectivity.ConfigRegistry class. For example:

    config = rtw.connectivity.ConfigRegistry;
  2. Assigns a connectivity configuration name to the ConfigName property of the object. For example:

    config.ConfigName = 'My PIL Example';
  3. Associates the connectivity configuration with the connectivity API implementation created in step 1. For example:

    config.ConfigClass = 'mypil.ConnectivityConfig';
  4. Defines compatible code for this target connectivity configuration, by setting the HardwareBoard and TargetHWDeviceType properties of the object. For example:

    config.HardwareBoard = {};  % Any hardware board
    config.TargetHWDeviceType = {'Generic->32-bit x86 compatible' ...
                                 'Generic->Custom' ...
                                 'Intel->x86-64 (Windows64)', ...
                                 'Intel->x86-64 (Mac OS X)', ...
                                 'Intel->x86-64 (Linux 64)'};
    

Create sl_customization.m File

This code is an example of an sl_customization.m file. Use the sl_customization.m file structure, and call the registerTargetInfo function exactly as shown.

function sl_customization(cm)
% SL_CUSTOMIZATION for PIL connectivity config:...
% mypil.ConnectivityConfig

% Copyright 2008 The MathWorks, Inc.

cm.registerTargetInfo(@loc_createConfig);

% local function
function config = loc_createConfig

config = rtw.connectivity.ConfigRegistry;
config.ConfigName = 'My PIL Example';
config.ConfigClass = 'mypil.ConnectivityConfig';

% Match only ert.tlc
config.SystemTargetFile = {'ert.tlc'};

% If you use a toolchain to build your generated code,
% specify the config.Toolchain property to match your
% Simulink model toolchain setting. Otherwise, for a
% non-toolchain approach, match the TMF
config.TemplateMakefile = {'ert_default_tmf' ...
                           'ert_unix.tmf', ...
                           'ert_vcx64.tmf', ...
                           'ert_lcc.tmf'};

% Match hardware boards and hardware device types
config.HardwareBoard = {};  % Any hardware board
config.TargetHWDeviceType = {'Generic->32-bit x86 compatible' ...
                             'Generic->Custom' ...
                             'Intel->x86-64 (Windows64)', ...
                             'Intel->x86-64 (Mac OS X)', ...
                             'Intel->x86-64 (Linux 64)'};

You must configure the file to perform the following steps when Simulink starts:

  1. Create an instance of the rtw.connectivity.ConfigRegistry class. For example:

    config = rtw.connectivity.ConfigRegistry;
  2. Assign a connectivity configuration name to the ConfigName property of the object. For example:

    config.ConfigName = 'My PIL Example';
  3. Associate the connectivity configuration with the connectivity API implementation (created in step 1). For example:

    config.ConfigClass = 'mypil.ConnectivityConfig';
  4. Define compatible models for this target connectivity configuration, by setting these properties of the properties of the object:

    • SystemTargetFile

    • Toolchain or TemplateMakefile

    • HardwareBoard

    • TargetHWDeviceType

    For example:

    config.SystemTargetFile = {'ert.tlc'};
    config.TemplateMakefile = {'ert_default_tmf' ...
                               'ert_unix.tmf', ...
                               'ert_vcx64.tmf', ...
                               'ert_lcc.tmf'};
    config.HardwareBoard = {};
    config.TargetHWDeviceType = {'Generic->32-bit x86 compatible' ...
                                 'Generic->Custom' ...
                                 'Intel->x86-64 (Windows64)', ...
                                 'Intel->x86-64 (Mac OS X)', ...
                                 'Intel->x86-64 (Linux 64)'};

Using rtw.connectivity.ConfigRegistry in PIL Connectivity

For an example that shows how to use this object in setting up PIL connectivity, see:

Introduced in R2008b