Register connectivity configuration
Register your connectivity configuration with MATLAB® or Simulink®.
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.
rtwTargetInfo.m
FileThis 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:
Creates an instance of the rtw.connectivity.ConfigRegistry
class. For example:
config = rtw.connectivity.ConfigRegistry;
Assigns a connectivity configuration name to the
ConfigName
property of the object. For
example:
config.ConfigName = 'My PIL Example';
Associates the connectivity configuration with the connectivity API implementation created in step 1. For example:
config.ConfigClass = 'mypil.ConnectivityConfig';
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)'};
sl_customization.m
FileThis 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:
Create an instance of the rtw.connectivity.ConfigRegistry
class. For example:
config = rtw.connectivity.ConfigRegistry;
Assign a connectivity configuration name to the
ConfigName
property of the object. For
example:
config.ConfigName = 'My PIL Example';
Associate the connectivity configuration with the connectivity API implementation (created in step 1). For example:
config.ConfigClass = 'mypil.ConnectivityConfig';
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)'};
rtw.connectivity.ConfigRegistry
in PIL ConnectivityFor an example that shows how to use this object in setting up PIL connectivity, see: