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

    function outputStringStruct = privatevntslstring(inputString)
%PRIVATEVNTSLSTRING Return a string struct used by simulink VNT MATLAB code.
%
%    OUTPUTSTRINGSTRUCT = PRIVATEVNTSLSTRING(INPUTSTRING) returns a
%    structure, OUTPUTSTRINGSTRUCT that contains message strings specific
%    to the input query passed in INPUTSTRING.
%    Valid values for INPUTSTRING are:
%    1. 'ErrorStrings' - Returns all error and user message strings. 
%    2. 'cancb' - Returns tags for CAN Configuration block. 
%    3. 'canrb' - Returns tags for CAN Receive block. 
%    4. 'cantb' - Returns tags for CAN Transmit block. 
%    5. 'canpack' - Returns tags for CAN Pack block. 
%    6. 'canunpack' - Returns tags for CAN Unpack block. 
%    7. 'canrep' - Returns tags for CAN Replay block.
%    8. 'canlog' - Returns tags for CAN Log block.
%    9. 'alltags' - Returns tags for all the blocks. 
%   10. 'allprompts' - Returns the widget prompts for the VNT blocks.

%    SS 04-01-08
%    Copyright 2008-2015 The MathWorks, Inc.


% Return the structure requested by the input string.
switch lower(inputString)
    case 'errorstrings' %Error Strings.
        outputStringStruct = localInitErrorStrings([]);
    case 'cancb' % CAN Configuration block widget tags only.
        outputStringStruct = localInitCommonTags([]);        
        outputStringStruct = localInitCANConfigurationTags(outputStringStruct);
    case 'canrb' % CAN Receive block widget tags only.
        outputStringStruct = localInitCommonTags([]);        
        outputStringStruct = localInitCANReceiveTags(outputStringStruct);
    case 'cantb' % CAN Transmit block widget tags only.        
        outputStringStruct = localInitCommonTags([]);        
        outputStringStruct = localInitCANTransmitTags(outputStringStruct);
    case 'canrep' % CAN Replay block widget tags only.        
        outputStringStruct = localInitCommonTags([]);        
        outputStringStruct = localInitCANReplayTags(outputStringStruct);
    case 'canlog' % CAN Log block widget tags only.        
        outputStringStruct = localInitCommonTags([]);        
        outputStringStruct = localInitCANLogTags(outputStringStruct);        
    case 'canpack' % CAN Pack block widget tags only.
        outputStringStruct = canslgate('privatecanslstring', 'canpack');
    case 'canunpack' % CAN Unpack block widget tags only.
        outputStringStruct = canslgate('privatecanslstring', 'canunpack');        
    case 'alltags' % All tags for the blocks.
        outputStringStruct = canslgate('privatecanslstring', 'alltags');        
        outputStringStruct = localInitCommonTags(outputStringStruct);        
        outputStringStruct = localInitCANConfigurationTags(outputStringStruct);
        outputStringStruct = localInitCANReceiveTags(outputStringStruct);
        outputStringStruct = localInitCANTransmitTags(outputStringStruct);
        outputStringStruct = localInitCANReplayTags(outputStringStruct);
        outputStringStruct = localInitCANLogTags(outputStringStruct);
        outputStringStruct = localInitCANTLTags(outputStringStruct);
    case 'allprompts' % All prompts for the blocks. 
        outputStringStruct = localInitCommonPrompts([]);        
        outputStringStruct = localInitCANConfigurationPrompts(outputStringStruct);
        outputStringStruct = localInitCANReceivePrompts(outputStringStruct);
        outputStringStruct = localInitCANTransmitPrompts(outputStringStruct);
        outputStringStruct = localInitCANReplayPrompts(outputStringStruct);
        outputStringStruct = localInitCANLogPrompts(outputStringStruct);
    otherwise
        % Assert as an invalid string is passed. 
        assert(false, 'vnt:vntblks:InvalidString', 'Wrong input string.');
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function structToReturn = localInitCommonTags(structToReturn)

% Initializes common widget tags.
structToReturn.ParameterPane = 'ParameterPane';
structToReturn.Description = 'Description';
structToReturn.DescriptionPane = 'DescriptionPane';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function structToReturn = localInitCANConfigurationTags(structToReturn)

% Init CAN configuration widget tags.
structToReturn.Device = 'Device';

structToReturn.DeviceMenu = 'DeviceMenu';
structToReturn.DeviceMenuText = 'DeviceMenuText';

structToReturn.BusSpeed = 'BusSpeed';
structToReturn.BusSpeedText = 'BusSpeedText';

structToReturn.EnableBitParameters = 'EnableBitParameters';

structToReturn.SJW = 'SJW';
structToReturn.SJWText = 'SJWText';

structToReturn.TSEG1 = 'TSEG1';
structToReturn.TSEG1Text = 'TSEG1Text';

structToReturn.TSEG2 = 'TSEG2';
structToReturn.TSEG2Text = 'TSEG2Text';

structToReturn.NSamples = 'NSamples';
structToReturn.NSamplesText = 'NSamplesText';

structToReturn.VerifyBitValidity = 'VerifyBitValidity';
structToReturn.AckMode = 'AckMode';
structToReturn.AckModeText = 'AckModeText';

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function structToReturn = localInitCANReceiveTags(structToReturn)

% Init CAN receive widget tags.
structToReturn.Device = 'Device';

structToReturn.DeviceMenu = 'DeviceMenu';
structToReturn.DeviceMenuText = 'DeviceMenuText';

structToReturn.EnableStandardIDsFilter = 'EnableStandardIDsFilter';
structToReturn.StandardIDs = 'StandardIDs';
structToReturn.StandardIDsFilterText = 'StandardIDsFilterText';
structToReturn.StandardIDsCombo = 'StdIDsCombo';
structToReturn.StandardExampleField = 'StandardExampleField';
structToReturn.EnableExtendedIDsFilter = 'EnableExtendedIDsFilter';
structToReturn.ExtendedIDs = 'ExtendedIDs';
structToReturn.ExtendedIDsCombo = 'ExtIDsCombo';
structToReturn.ExtendedIDsFilterText = 'ExtendedIDsFilterText';
structToReturn.ExtendedExampleField = 'ExtendedExampleField';

structToReturn.SampleTime = 'SampleTime';
structToReturn.SampleTimeText = 'SampleTimeText';

structToReturn.MsgsPerTimestepText = 'MsgsPerTimestepText';
structToReturn.MsgsPerTimestep = 'MsgsPerTimestep';

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function structToReturn = localInitCANTransmitTags(structToReturn)

% Init CAN Transmit widget tags.
structToReturn.Device = 'Device';
structToReturn.DeviceMenu = 'DeviceMenu';
structToReturn.DeviceMenuText = 'DeviceMenuText';
structToReturn.TransmitPeriodicMessage = 'EnablePeriodicTransmit';
structToReturn.MessagePeriod = 'MessagePeriod';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function structToReturn = localInitCANReplayTags(structToReturn)

% Init CAN Replay widget tags.
structToReturn.FullPathFileName = 'FullPathFileName';
structToReturn.FileName = 'FileName';
structToReturn.FileNameText = 'FileNameText';
structToReturn.VariableName = 'VariableName';
structToReturn.VariableNameText = 'VariableNameText';
structToReturn.Browse = 'Browse';

structToReturn.NoTimesReplay = 'NoTimesReplay';
structToReturn.NoTimesReplayText = 'NoTimesReplayText';
structToReturn.ReplayMessagesTo = 'ReplayTo';
structToReturn.ReplayMessagesToText = 'ReplayToText';

structToReturn.Device = 'Device';
structToReturn.DeviceMenu = 'DeviceMenu';
structToReturn.DeviceMenuText = 'DeviceMenuText';
structToReturn.SampleTime = 'SampleTime';
structToReturn.SampleTimeText = 'SampleTimeText';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function structToReturn = localInitCANLogTags(structToReturn)

% Init CAN Log widget tags.
structToReturn.FullPathFileName = 'FullPathFileName';
structToReturn.FileName = 'FileName';
structToReturn.FileNameText = 'FileNameText';
structToReturn.VariableName = 'VariableName';
structToReturn.VariableNameText = 'VariableNameText';
structToReturn.Browse = 'Browse';

structToReturn.MaxNumMessages = 'MaxNumMessages';
structToReturn.MaxNumMessagesText = 'MaxNumMessagesText';
structToReturn.LogMessagesFrom = 'LogFrom';
structToReturn.LogMessagesFromText = 'LogFromText';

structToReturn.Device = 'Device';
structToReturn.DeviceMenu = 'DeviceMenu';
structToReturn.DeviceMenuText = 'DeviceMenuText';
structToReturn.SampleTime = 'SampleTime';
structToReturn.SampleTimeText = 'SampleTimeText';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function structToReturn = localInitCANTLTags(structToReturn)
% Initializes all CAN TL tags.
structToReturn.ConfigName = 'ConfigName';
structToReturn.ConfigNameText = 'ConfigNameText';
structToReturn.Device = 'Device';
structToReturn.DeviceMenu = 'DeviceMenu';
structToReturn.DeviceMenuText = 'DeviceMenuText';
structToReturn.BusSpeedStr = 'BusSpeedStr';
structToReturn.BusSpeedStrText = 'BusSpeedStrText';
structToReturn.SampleTime = 'SampleTime';
structToReturn.SampleTimeText = 'SampleTimeText';

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function structToReturn = localInitCommonPrompts(structToReturn)
structToReturn.DeviceMenuPrompt = sprintf('Device:');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function structToReturn = localInitCANConfigurationPrompts(structToReturn)
structToReturn.BusSpeedPrompt = sprintf('Bus speed:');
structToReturn.EnableBitParametersPrompt = sprintf('Enable bit parameters manually:');
structToReturn.SJWPrompt = sprintf('Synchronization jump width:');
structToReturn.TSEG1Prompt = sprintf('Time segment 1:');
structToReturn.TSEG2Prompt = sprintf('Time segment 2:');
structToReturn.NSamplesPrompt = sprintf('Number of samples:');
structToReturn.VerifyBitValidityPrompt = sprintf('Verify bit parameter settings validity ...');
structToReturn.AckModePrompt = sprintf('Acknowledge mode:');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function structToReturn = localInitCANReceivePrompts(structToReturn)

structToReturn.EnableStandardIDsFilterPrompt = sprintf('Filter for accepted Standard IDs range');
structToReturn.StandardIDsPrompt = sprintf('Standard IDs Filter:');
structToReturn.StandardIDsComboPrompt = sprintf('Standard IDs Combo Box:');
structToReturn.StandardExamplePrompt = sprintf('Example: [100 [110:115]]');
structToReturn.EnableExtendedIDsFilterPrompt = sprintf('Filter for accepted Extended IDs range');
structToReturn.ExtendedIDsPrompt = sprintf('Extended IDs Filter:');
structToReturn.ExtendedIDsComboPrompt = sprintf('Extended IDs Combo Box:');
structToReturn.ExtendedExamplePrompt = sprintf('Example: [4000 [4100:4105]]');
structToReturn.SampleTimePrompt = sprintf('Sample time:');
structToReturn.MsgsPerTimestepPrompt = sprintf('Number of messages received at each timestep:');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function structToReturn = localInitCANTransmitPrompts(structToReturn)
structToReturn.TransmitPeriodicMessagePrompt = sprintf('Transmit messages periodically');
structToReturn.MessagePeriodPrompt = sprintf('Message period (in seconds):');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function structToReturn = localInitCANReplayPrompts(structToReturn)
structToReturn.FileNamePrompt = sprintf('File name:');
structToReturn.BrowsePrompt = sprintf('Browse...');
structToReturn.VariableNamePrompt = sprintf('Variable name:');
structToReturn.NoTimesReplayPrompt = sprintf('Number of times to replay messages:');
structToReturn.ReplayMessagesToPrompt = sprintf('Replay messages to:');
structToReturn.SampleTimePrompt = sprintf('Sample time:');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function structToReturn = localInitCANLogPrompts(structToReturn)
structToReturn.FileNamePrompt = sprintf('File name:');
structToReturn.VariableNamePrompt = sprintf('Variable name:');
structToReturn.MaxNumMessagesPrompt = sprintf('Maximum number of messages to log:');
structToReturn.LogMessagesFromPrompt = sprintf('Log messages from:');
structToReturn.SampleTimePrompt = sprintf('Sample time:');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function structToReturn = localInitErrorStrings(structToReturn)

% Initializes the error strings. 

% No device exists.
structToReturn.NoDevice = sprintf('No CAN devices are available.');

% Loading error: Device selected no longer exists. 
structToReturn.DifferentDevice = ['CAN device ''%s'' is ' ...
    'unavailable.\nThe ''%s'' device will be selected.'];
% Dialog title.
structToReturn.DeviceErrorTitle = sprintf('Device Selection Error');

% Error Dialog Title.
structToReturn.ErrorDialogTitle = sprintf('Configuration Error');

% Bus Speed invalid value.
structToReturn.RateNegative = 'Bus speed must be a positive integer.';

% Invalid variable value.
structToReturn.VarNameInvalid = '%s is an invalid MATLAB variable name. Please specify a valid variable name.';

structToReturn.NumTimesInvalid = 'Number of times to replay must be a positive integer.';

structToReturn.MaxMessagesInvalid = 'Maximum number of messages to log must be a positive integer.';

structToReturn.SelectValidDeviceReplay = 'A valid CAN device must be selected to replay CAN messages to the CAN Bus.';
structToReturn.SelectValidDeviceLog = 'A valid CAN device must be selected to log CAN messages from the CAN Bus.';

% Invalid bit parameter setting.
structToReturn.BitParameterInvalid = '%s must be a positive integer.';

% Invalid identifier range setting.
structToReturn.InvalidIdentifier = '%s IDs must be positive, numeric integer and between %d and %d.';

% Verify button message. 
structToReturn.BitParameterSettingsValid = sprintf('The specified bit parameter settings are valid.');
structToReturn.BitParameterSettingsInvalid = ...
            sprintf(['The bus speed could not be set on the CAN device using the specified bit parameter settings.' ...
                        '\n\nSpecify a different bus speed or change the bit parameter settings to a valid combination.']);
structToReturn.BusSpeedNotSettable = ...
            sprintf('The bus speed could not be set on the CAN device. \nSpecify a different bus speed value.');        
structToReturn.BusSpeedInvalid = sprintf('The bus speed must be a positive, numeric, scalar, integer value less than or equal to 1000000.');
structToReturn.SuccessDialogTitle = sprintf('Success');
structToReturn.WarningDialogTitle = sprintf('Warning');
% If unable to verify bit parameters as channel does not have init access.
structToReturn.UnableToVerifyBP = sprintf(['The bit parameter settings could not be validated as your channel does not ' ...
                                            'have initialization access.']);

structToReturn.MessagePeriodInvalid = sprintf('Message Period must be a positive, numeric, scalar value greater than or equal to 5 milliseconds.');

% Simulation error messages. 
structToReturn.NoCCBlocksID = sprintf('vnt:vntblks:noCCBlocks');
structToReturn.NoCCBlocks = ['The model contains no CAN configuration block for the device %s. Please ' ...
                             'use the ''CAN Configuration'' block from the Vehicle Network '...
                             'Toolbox block library to configure %s.'];
                         
structToReturn.ConfigNotFound = 'Cannot find J1939 Network Configuration block corresponding to config name ''%s''. Select a different configuration.';                         
structToReturn.NoConfigFound = 'There are no J1939 Network Configuration blocks in the model. Set up the J1939 Network configuration block before configuring other J1939 blocks.';

% Multiple CAN configuration blocks for same device.
structToReturn.MultipleCCBlocksID = sprintf('vnt:vntblks:multipleCCBlocks');
structToReturn.MultipleCCBlocks = ['The model contains more than one ''CAN Configuration'' block ' ...
                                   'configured to the same device %s. You must have only one ' ...
                                   ' ''CAN Configuration'' block for %s in a model.'];                         

structToReturn.NoDeviceSelectedID = sprintf('vnt:vntblks:noDeviceSelected');
structToReturn.NoDeviceSelected = 'No device has been selected to %s a CAN network. Please select a valid device.';

% Unable to create CAN channel object.                                
structToReturn.ChannelCreationError = 'Unable to create a CAN channel object for the device %s.';

% Error on receive.
structToReturn.ReceiveErrorMessage = 'A runtime error occurred while receiving messages from the device ''%s''.';

% Error on transmit.
structToReturn.TransmitErrorMessage = 'A runtime error occurred while transmitting messages to the device ''%s''.';

% Error when unable to set bus speed settings.
structToReturn.NoInitAccessID = sprintf('vnt:vntblks:noInitAccess');
structToReturn.NoInitAccess = ['Unable to set the desired bus speed and bit timing parameters for ' ...
                                '''%s'' as it does not have initialization access. The current setting ' ...
                                'will be used for the simulation.'];
structToReturn.NoInitAccessAckModeID = sprintf('vnt:vntblks:noInitAccess');
structToReturn.NoInitAccessAckMode = ['Unable to set the desired acknowledge mode to %s for ' ...
                                '''%s'' as it does not have initialization access for the channel. '];                            

structToReturn.NoInitAccessAckModeSilent = 'The channel will not be transmitting any messages and will not be performing CAN protocol tasks on the network such as acknowledging messages and creating error frames.';

structToReturn.NoInitAccessAckModeNormal = 'The channel will not be transmitting any messages but will still be performing CAN protocol tasks on the network such as acknowledging messages and creating error frames.';

% Message to user for requirement of CAN Configuration block. 
structToReturn.AddCANConfigBlock = ...
    ['You have successfully set the parameters for the ''CAN %s'' block. '...
     'This block requires a ''CAN Configuration'' block to configure '...
     'the hardware properties.\n\nWould you like to add a ''CAN Configuration'' '... 
     'block from the Vehicle Network Toolbox block library at this time?'];
structToReturn.QuestDlgTitle = sprintf('Success');
 
 % Warning message when channel not online.
structToReturn.SilentModeID = sprintf('vnt:vntblks:silentMode');
structToReturn.SilentModeMsgForBlock = ...
    ['The block ''%s'' configured to use ''%s'' will not be transmitting any messages to the network as '...
    'the corresponding configuration block ''%s'' has set ''Acknowledge ' ...
    'Mode'' to be Silent. If you wish to turn this warning off, type ''warning(''off'', ''vnt:vntblks:silentMode'')'' at the command line.'];


structToReturn.InvalidAccessMaskID = 'vnt:vntblks:accessMaskError';
structToReturn.InvalidAccessMaskMsg = ['A valid Access Mask was not obtained for the device used by %s.'...
                                       ' The driver returned the error code: %s.' ];

structToReturn.UnableOpenPortID = 'vnt:vntblks:unableOpenPort';
structToReturn.UnableOpenPortMsg = ['The %s encountered an error with the device driver.'...
                                    'The block %s was unable to open the requested port for the device %s.'];
                                
structToReturn.DriverErrorID = 'vnt:vntblks:driverError';
structToReturn.DriverOpenErrorMsg = 'Unable to open the %s.';
structToReturn.DriverErrorMsg = ['The %s encountered an error with the device driver.'...
                                ' The driver returned an error code: ''%s''.'];

structToReturn.UnableSetBitParamsMsg = ['The %s encountered an error with the device driver.'...
                                    'The block %s was unable to set the bit parameters for the device %s.'];
structToReturn.UnableSetSilentModeMsg = ['The %s encountered an error with the device driver.'...
                                    'The block %s was unable set the Acknowledge mode for the device %s.'];

structToReturn.DeviceInaccessible = ['The channel %s is currently inaccessible and may be in use outside of Simulink.'...
                                    'Please close other existing connections and retry this channel.'];

structToReturn.ReplayMATFileNotFound = 'The file ''%s'' specified by CAN Replay block was not found. Please update your CAN Replay block parameters to specify a valid file name.';
structToReturn.LogDirNotFound = 'The folder ''%s'' specified by the CAN Log block to log file was not found. Please update your CAN Log block parameters to specify a valid file name.';
structToReturn.LogDirNotWritable = 'The folder ''%s'' specified by the CAN Log block to log file does not have write permissions. Please update your CAN Log block parameters to specify a valid file name.';

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%