Code covered by the BSD License  

Highlights from
MPC555 Motor Control Function Blockset

MPC555 Motor Control Function Blockset

by

 

20 Mar 2006 (Updated )

Additional I/O blocks for MPC555 target - specifically targetting TPU functionality

mpc555_mtrctrl_validate_error(parameterspecs, ...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function str_message = mpc555_mtrctrl_validate_error(parameterspecs, ...
%    validate)
%
% This function generates the string to be used for an error message
% indicating that a mask value that has been entered is out of range.
%
% Input arguments are:
%   'parameterspecs':   Structure containing the specification for the
%                       parameter.
%   'validate':         Structure containing specification of what went
%                       wrong.
function str_message = mpc555_mtrctrl_validate_error(parameterspecs, ...
    validate)

% Check to see if the type necessary is integral or not
if strfind(parameterspecs.DataType, 'int')
    str_param_type = 'integer';
else
    str_param_type = 'number';
end

if ~iscell(parameterspecs.ArrayLengthMax)
    if parameterspecs.ArrayLengthMax > 1
        str_param_array = ['an array of length between ', ...
            num2str(parameterspecs.ArrayLengthMin), ' and ', ...
            num2str(parameterspecs.ArrayLengthMax), ' of ', ...
            str_param_type, 's'];
    else
        str_param_array = ['a(n) ', str_param_type];
    end
else
    str_param_array = ['a matrix of size between [', ...
        num2str(parameterspecs.ArrayLengthMin{1}), ', ' ... 
        num2str(parameterspecs.ArrayLengthMin{2}), '] and [', ...
        num2str(parameterspecs.ArrayLengthMax{1}), ', ', ...
        num2str(parameterspecs.ArrayLengthMax{2}), '] of ', ...
        str_param_type, 's'];
end

% Define a variable containing the newline character sequence
newline = sprintf('\n');

% Now just define the error message that should be used
str_message = [ 'The ', parameterspecs.PrettyName, ...
    ' parameter should be ', ... 
    str_param_array, ...
    ' in the range:', ...
    newline, newline, ...
    num2str(parameterspecs.MinVal), ...
    ' <= ', parameterspecs.PrettyName, ' <= ', ...
    num2str(parameterspecs.MaxVal), '.', ...
    newline, newline];

% Now tell the user what's wrong
if ~validate.Range
    str_message = [str_message, ' A value for ', parameterspecs.PrettyName, ...
        ' has been entered that is not in this range.', ...
        ' To fix this, enter a value that is in this range.', ...
        newline, newline];
end
if ~validate.Length
    str_message = [str_message, ' An entry for ', parameterspecs.PrettyName, ...
        ' of the wrong length has been made.  To fix this, enter a', ...
        ' number or array of the correct length', newline, newline];
end
if ~isempty(validate.Conditions)
        for currenterror = validate.Conditions
            str_message = [str_message, ...
                parameterspecs.SpecialConditions(currenterror).ErrorMsg, ...
                newline, newline];
        end
end
end

Contact us