gusucode.com > vnt工具箱matlab源码程序 > vnt/vntblks/vntmasks/private/privatevntslxcptlbusspeed.m
function privatevntslxcptlbusspeed(dialog, value, tag) %PRIVATEVNTSLXCPTLBUSSPEED Callback to validate the bus speed CAN TL block. % % SUCCESS = PRIVATEVNTSLXCPTLBUSSPEED(DIALOG, VALUE, TAG) is used as a % callback to validate the bus speed contained in DIALOG, a dialog object % and VALUE is the current changed value of the field, TAG. % SS 04-01-12 % Copyright 2012 The MathWorks, Inc. % Get the source object from the dialog. obj = dialog.getDialogSource; if strcmpi(obj.Device, 'Select a device'); return; end % Get XCP CAN TL block widget tags. tags = privatevntslstring('alltags'); % Get error strings. msgStrings = privatevntslstring('errorstrings'); % Get the bus speed setting. busSpeed = str2double(value); % Check validity of value for positiveness. if (isempty(busSpeed) || ~isscalar(busSpeed) || isnan(busSpeed) || ... isinf(busSpeed) || busSpeed<=0 || busSpeed~=floor(busSpeed) || busSpeed>1000000) % Check for scalar, positive, numeric, non-zero tamslgate('privatesldialogbox', dialog, msgStrings.BusSpeedInvalid, ... msgStrings.ErrorDialogTitle); obj.Block.(tag) = obj.(tag); return; end % Create the CAN Object to verify; bus speed try canch = eval(obj.ObjConstructor); catch %#ok<CTCH> % TODO: Error or warn about unavailability of the device to verify bus % speed. end % Return if no init access. if ~canch.InitializationAccess return; end try configBusSpeed(canch, busSpeed); % Success obj.(tag) = obj.Block.(tag); catch %#ok<CTCH> % Failure. errorStrings = privatevntslstring('errorstrings'); uiwait(errordlg(errorStrings.BusSpeedNotSettable, errorStrings.ErrorDialogTitle, 'modal')); obj.Block.(tag) = obj.(tag); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%