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

    function privatevntslresetmaskparams
%PRIVATEVNTSLRESETMASKPARAMS Reset mask parameters to pre-defined properties.
%
%    PRIVATEVNTSLRESETMASKPARAMS Sets mask parameters to predefined value
%    suitable for library intilization. 
%

%    MO 12-05-14
%    Copyright 2014-2015 The MathWorks, Inc.

libName = get_param(bdroot,'Name');

switch libName
    case 'canlib';
        blk = [libName '/CAN Configuration'];
        set_param(blk,'BlockHandle','CANCONFIGBLOCKHANDLE');
        updateDropdownList(blk, 'DeviceMenu', 'CANCONFIGDEVICELIST');
        set_param(blk,'Device','CANCONFIGDEVICE');
        set_param(blk,'ObjConstructor','CANCONFIGCONSTRUCTOR');
        set_param(blk,'BusSpeed','CANCONFIGBUSSPEED');
        set_param(blk,'SJW','CANCONFIGSJW');
        set_param(blk,'TSEG1','CANCONFIGTSEG1');
        set_param(blk,'TSEG2','CANCONFIGTSEG2');
        set_param(blk,'NSamples','CANCONFIGNSAMPLES');
        
        blk = [libName '/CAN Receive'];
        set_param(blk,'BlockHandle','CANRECBLOCKHANDLE');
        updateDropdownList(blk, 'DeviceMenu', 'CANRECDEVICELIST');
        set_param(blk,'Device','CANRECDEVICE');
        set_param(blk,'ObjConstructor','CANRECCONSTRUCTOR');
        
        blk = [libName '/CAN Transmit'];
        set_param(blk,'BlockHandle','CANTRANBLOCKHANDLE');
        updateDropdownList(blk, 'DeviceMenu', 'CANTRANDEVICELIST');
        set_param(blk,'Device','CANTRANDEVICE');
        set_param(blk,'ObjConstructor','CANTRANCONSTRUCTOR');
        
        blk = [libName '/CAN Replay'];
        set_param(blk,'BlockHandle','CANREPBLOCKHANDLE');
        updateDropdownList(blk, 'DeviceMenu', 'CANREPDEVICELIST');
        set_param(blk,'Device','CANREPDEVICE');
        set_param(blk,'ObjConstructor','CANREPCONSTRUCTOR');
        
        blk = [libName '/CAN Log'];
        set_param(blk,'BlockHandle','CANLOGBLOCKHANDLE');
        updateDropdownList(blk, 'DeviceMenu', 'CANLOGDEVICELIST');
        set_param(blk,'Device','CANLOGDEVICE');
        set_param(blk,'ObjConstructor','CANLOGCONSTRUCTOR');
        
    case 'vntxcptllib';
        blk = [libName '/XCP CAN Transport Layer'];
        updateDropdownList(blk, 'DeviceMenu', 'CANDEVICELIST');
        set_param(blk,'Device','CANDEVICE');
        set_param(blk,'ObjConstructor','CANOBJCONSTRUCTOR');
        
    case 'vntj1939tllib';
        blk = [libName '/J1939 CAN Transport Layer'];
        updateDropdownList(blk, 'DeviceMenu', 'CANDEVICELIST');
%         set_param(blk,'Device','CANDEVICE');
        set_param(blk,'ObjConstructor','CANOBJCONSTRUCTOR');        
    otherwise
        % Error out for un recognized libraries
        if ~ismember(libName, {'vntlib','xcplib'})
            error(['Library ' libName ' is not recognized by privatevntslresetmaskparams function']);
        end
end

function updateDropdownList(blk, propertyName, replaceString)
% Get style string
styleString = get_param(blk, 'MaskStyleString');
% Get current setting 
currentString = get_param(blk,propertyName);
% Find a match of 'popup(.*curreString' for the target field 
currentString = strrep(currentString,'(','\(');
currentString = strrep(currentString,')','\)');
styleTokens = regexp(styleString,',','split');
isTargetCell = regexp(styleTokens,['popup\(.*' currentString]);
isTargetStruct = cellfun(@(x)~isempty(x),isTargetCell);
targetString = styleTokens{isTargetStruct};
% Replace the target field with pre-define property
newStyleString = strrep(styleString,targetString,['popup(' replaceString ')']);
% Apply updated style string back
set_param(blk, 'MaskStyleString',newStyleString);