gusucode.com > vnt工具箱matlab源码程序 > vnt/vntblks/vntmasks/private/privatevntslcantlinit.m

    function privatevntslcantlinit(blockName)
%PRIVATEVNTSLCANTLINIT Initializes the XCP CAN TL subsystem block.
%
%    PRIVATEVNTSLCANTLINIT populates the CAN TL block with information on the
%    available devices.

%    Copyright 2015 The MathWorks, Inc.

sysDeviceList = 'CANDEVICELIST';
sysDevice = 'CANDEVICE';
sysConstructor = 'CANOBJCONSTRUCTOR';

% For multi port option of display, this is required.
set_param(blockName, 'MaskSelfModifiable','on');

styleString = get_param(blockName, 'MaskStyleString');
if isempty( strfind(styleString, sysDeviceList) )
    % Block already initialized.
    return;
end

% Query the system for the available hardware.
[devices, constructors] = vntslgate('privatevntslparsehwinfo');

% Select the default device.
devices = [{'Select a device'} devices];
constructors = [{'Select a constructor'} constructors];

% Select the default device.
firstDevice = devices{1};
objConstructor = constructors{1};

% Create pop up strings. 
devices{end+1} = '(none)';
allDevices = localCreatePopUpStrings(devices);

styleString = get_param(blockName, 'MaskStyleString');
styleString = strrep(styleString, sysDeviceList, allDevices);
set_param(blockName, 'MaskStyleString', styleString);

valueString = get_param(blockName, 'MaskValueString');
valueString = strrep(valueString, sysDevice, firstDevice);
valueString = strrep(valueString, sysConstructor, objConstructor);

% Update Mask value string.
set_param(blockName, 'MaskValueString', valueString);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function retString = localCreatePopUpStrings(entries)

% Create popup strings for the block combobox.
if isempty(entries)
    retString = '';
else
    retString = sprintf('%s|', entries{:});
    retString = retString(1:end-1);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%