www.gusucode.com > robotsimulink 工具箱 matlab源码程序 > robotsimulink/robotslros/+robotics/+slros/+internal/+block/SampleTimeImpl.m
classdef SampleTimeImpl < ... matlab.system.mixin.internal.SampleTime %This class is for internal use only. It may be removed in the future. %SampleTimeImpl Base class for all ROS source blocks that need to expose sample time % This implementation was modeled after % realtime.internal.iosSampleTime. % Copyright 2015 The MathWorks, Inc. %#codegen %#ok<*EMCA> properties %SampleTime Sample time % Specify the sample time in seconds as a positive, real scalar, or -1. % Default: -1 (inherited sample time) SampleTime = -1 end methods function obj = SampleTimeImpl %SampleTime Standard constructor coder.allowpcode('plain'); end end methods function set.SampleTime(obj, sampleTime) %set.SampleTime Set sample time for this source block % If the conversion to a numeric array fails, the return will be [], % which will be caught be the subsequent validateattributes. % We have to use str2num here to allow parsing of an array. validateattributes( sampleTime, {'numeric'}, ... {'nonempty', 'real', 'nonnan'}, ... '', 'SampleTime'); % Different error checks for the validity of the sample time coder.internal.errorIf(~isreal(sampleTime(1)) || numel(sampleTime) > 2, ... 'robotics:robotslros:sampletime:InvalidSampleTimeNeedScalar'); coder.internal.errorIf(numel(sampleTime) == 2 && sampleTime(1) > 0.0 && sampleTime(2) >= sampleTime(1), ... 'robotics:robotslros:sampletime:InvalidSampleTimeNeedSmallerOffset'); coder.internal.errorIf(numel(sampleTime) == 2 && sampleTime(1) == -1.0 && sampleTime(2) ~= 0.0, ... 'robotics:robotslros:sampletime:InvalidSampleTimeNeedZeroOffset'); coder.internal.errorIf(numel(sampleTime) == 2 && sampleTime(1) == 0.0 && sampleTime(2) ~= 1.0, ... 'robotics:robotslros:sampletime:InvalidSampleTimeNeedOffsetOne'); obj.SampleTime = sampleTime; end end methods (Access = protected) %% Inherited from matlab.system.mixin.internal.SampleTime function st = getSampleTimeImpl(obj) st = obj.SampleTime; end end end