gusucode.com > vnt工具箱matlab源码程序 > vnt/vnt/+can/+vector/VendorInfo.m

    classdef (Hidden) VendorInfo < can.VendorInfo
% VendorInfo Retrieve Vector specific CAN device information.
%
%   This class contains information on Vector CAN devices. It also
%   contains child classes for each identified CAN device channel.
%
%   See also VNT.

% Authors: JDP
% Copyright 2007-2013 The MathWorks, Inc.

methods
    
    function obj = VendorInfo()
    % VendorInfo Construct an object containing information on Vector devices.
        
        % Set the name of the vendor.
        vendorName = 'Vector';
        % Set the driver interface description.
        vendorDriverDescription = 'XL Driver Library';
        
        % Get driver information.
        [vendorDriverVersion, vendorDriverData] = ...
            can.vector.XLDriverLibrary.xlGetDriverConfig();
        
        % Convert the driver version to a hex string.
        vendorDriverVersion = dec2hex(vendorDriverVersion);
        
        % Initialize a ChannelInfo object as empty.
        channelInfo = can.vector.ChannelInfo.empty();
        % Initialize an index for counting ChannelInfo objects.
        channelInfoIndex = 1;
        
        % Disconnected devices show as an entry in the driver data
        % array, but they are unusable. Loop through the array and
        % create channels only for the valid entries.
        for index = 1:numel(vendorDriverData)
            % Check that the device type is supported by the toolbox.
            % Also verify that the device is properly configured for
            % CAN communication by checking for a 1 in the least
            % significant bit position of the bus capabilities field of
            % the driver information.
            if ((can.vector.Utility.isDeviceSupported(vendorDriverData(index).hwType)) &&...
                (bitand(vendorDriverData(index).channelBusCapabilities, can.vector.Utility.XL_BUS_COMPATIBLE_CAN)) && ...
                (bitand(vendorDriverData(index).channelBusCapabilities, can.vector.Utility.XL_BUS_ACTIVE_CAP_CAN)))
                
                % Create a child class for this channel.
                channelInfo(channelInfoIndex) = can.vector.ChannelInfo(vendorDriverData(index));
                % Increment the channel counter.
                channelInfoIndex = channelInfoIndex + 1;
            end
        end
        
        % Call the superclass constructor.
        obj@can.VendorInfo(...
            vendorName,...
            vendorDriverDescription,...
            vendorDriverVersion,...
            channelInfo);
    end
    
end

end