www.gusucode.com > vnt工具箱matlab源码程序 > vnt/vntblks/vntmasks/private/privatecanslmessageperiod.m
function success = privatecanslmessageperiod(dialog, value) %PRIVATECANSLMESSAGEPERIOD Callback to validate the bus speed and bit parameters. % % SUCCESS = PRIVATECANSLMESSAGEPERIOD(DIALOG, VALUE) is used as a % callback to validate the message period contained in % DIALOG, a dialog object and VALUE is the current changed value. % % Returns a boolean, SUCCESS, true if the message period settings % were valid. False, otherwise. % SS 03-01-10 % Copyright 2010 The MathWorks, Inc. % Initialize success. success = true; % Get the source object from the dialog. obj = dialog.getDialogSource; % Get error strings. msgStrings = privatevntslstring('errorstrings'); % Convert message period to number. messagePeriod = str2num(value); %#ok<ST2NM> % Check for non-numeric and negative values. if isempty(messagePeriod) || ~isscalar(messagePeriod) || ~isnumeric(messagePeriod) || ... isnan(messagePeriod) || (messagePeriod*1000<5) || isinf(messagePeriod) || ~isreal(messagePeriod) % Allow period values >=5 only. success = false; end % Call error if present. if ~success % Call T&M function to display error dialog. tamslgate('privatesldialogbox', dialog, ... msgStrings.MessagePeriodInvalid, ... msgStrings.ErrorDialogTitle ); % Check for empty. obj.MessagePeriod = '1.000'; % Restore the previous value on the dialog. obj.Block.MessagePeriod = obj.MessagePeriod; return; end % Assign the message period from the block to the source. obj.Block.MessagePeriod = value; obj.MessagePeriod = obj.Block.MessagePeriod; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%