www.gusucode.com > ros 工具箱 matlab源码程序 > ros/+robotics/+ros/+msggen/+controller_manager_msgs/ControllerStatistics.m

    classdef ControllerStatistics < robotics.ros.Message
    %ControllerStatistics MATLAB implementation of controller_manager_msgs/ControllerStatistics
    %   This class was automatically generated by
    %   robotics.ros.msg.internal.gen.MessageClassGenerator.
    
    %   Copyright 2014-2016 The MathWorks, Inc.
    
    %#ok<*INUSD>
    
    properties (Constant)
        MessageType = 'controller_manager_msgs/ControllerStatistics' % The ROS message type
    end
    
    properties (Constant, Hidden)
        MD5Checksum = '697780c372c8d8597a1436d0e2ad3ba8' % The MD5 Checksum of the message definition
    end
    
    properties (Access = protected)
        JavaMessage % The Java message object
    end
    
    properties (Constant, Access = protected)
        DurationClass = robotics.ros.msg.internal.MessageFactory.getClassForType('duration') % Dispatch to MATLAB class for message type duration
        TimeClass = robotics.ros.msg.internal.MessageFactory.getClassForType('time') % Dispatch to MATLAB class for message type time
    end
    
    properties (Dependent)
        Name
        Type
        Timestamp
        Running
        MaxTime
        MeanTime
        VarianceTime
        NumControlLoopOverruns
        TimeLastControlLoopOverrun
    end
    
    properties (Access = protected)
        Cache = struct('Timestamp', [], 'MaxTime', [], 'MeanTime', [], 'VarianceTime', [], 'TimeLastControlLoopOverrun', []) % The cache for fast data access
    end
    
    properties (Constant, Hidden)
        PropertyList = {'MaxTime', 'MeanTime', 'Name', 'NumControlLoopOverruns', 'Running', 'TimeLastControlLoopOverrun', 'Timestamp', 'Type', 'VarianceTime'} % List of non-constant message properties
        ROSPropertyList = {'max_time', 'mean_time', 'name', 'num_control_loop_overruns', 'running', 'time_last_control_loop_overrun', 'timestamp', 'type', 'variance_time'} % List of non-constant ROS message properties
    end
    
    methods
        function obj = ControllerStatistics(msg)
            %ControllerStatistics Construct the message object ControllerStatistics
            import com.mathworks.toolbox.robotics.ros.message.MessageInfo;
            
            % Support default constructor
            if nargin == 0
                obj.JavaMessage = obj.createNewJavaMessage;
                return;
            end
            
            % Construct appropriate empty array
            if isempty(msg)
                obj = obj.empty(0,1);
                return;
            end
            
            % Make scalar construction fast
            if isscalar(msg)
                % Check for correct input class
                if ~MessageInfo.compareTypes(msg(1), obj.MessageType)
                    error(message('robotics:ros:message:NoTypeMatch', obj.MessageType, ...
                        char(MessageInfo.getType(msg(1))) ));
                end
                obj.JavaMessage = msg(1);
                return;
            end
            
            % Check that this is a vector of scalar messages. Since this
            % is an object array, use arrayfun to verify.
            if ~all(arrayfun(@isscalar, msg))
                error(message('robotics:ros:message:MessageArraySizeError'));
            end
            
            % Check that all messages in the array have the correct type
            if ~all(arrayfun(@(x) MessageInfo.compareTypes(x, obj.MessageType), msg))
                error(message('robotics:ros:message:NoTypeMatchArray', obj.MessageType));
            end
            
            % Construct array of objects if necessary
            objType = class(obj);
            for i = 1:length(msg)
                obj(i,1) = feval(objType, msg(i)); %#ok<AGROW>
            end
        end
        
        function name = get.Name(obj)
            %get.Name Get the value for property Name
            name = char(obj.JavaMessage.getName);
        end
        
        function set.Name(obj, name)
            %set.Name Set the value for property Name
            validateattributes(name, {'char'}, {}, 'ControllerStatistics', 'Name');
            
            obj.JavaMessage.setName(name);
        end
        
        function type = get.Type(obj)
            %get.Type Get the value for property Type
            type = char(obj.JavaMessage.getType);
        end
        
        function set.Type(obj, type)
            %set.Type Set the value for property Type
            validateattributes(type, {'char'}, {}, 'ControllerStatistics', 'Type');
            
            obj.JavaMessage.setType(type);
        end
        
        function timestamp = get.Timestamp(obj)
            %get.Timestamp Get the value for property Timestamp
            if isempty(obj.Cache.Timestamp)
                obj.Cache.Timestamp = feval(obj.TimeClass, obj.JavaMessage.getTimestamp);
            end
            timestamp = obj.Cache.Timestamp;
        end
        
        function set.Timestamp(obj, timestamp)
            %set.Timestamp Set the value for property Timestamp
            validateattributes(timestamp, {obj.TimeClass}, {'nonempty', 'scalar'}, 'ControllerStatistics', 'Timestamp');
            
            obj.JavaMessage.setTimestamp(timestamp.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.Timestamp)
                obj.Cache.Timestamp.setJavaObject(timestamp.getJavaObject);
            end
        end
        
        function running = get.Running(obj)
            %get.Running Get the value for property Running
            running = logical(obj.JavaMessage.getRunning);
        end
        
        function set.Running(obj, running)
            %set.Running Set the value for property Running
            validateattributes(running, {'logical', 'numeric'}, {'nonempty', 'scalar'}, 'ControllerStatistics', 'Running');
            
            obj.JavaMessage.setRunning(running);
        end
        
        function maxtime = get.MaxTime(obj)
            %get.MaxTime Get the value for property MaxTime
            if isempty(obj.Cache.MaxTime)
                obj.Cache.MaxTime = feval(obj.DurationClass, obj.JavaMessage.getMaxTime);
            end
            maxtime = obj.Cache.MaxTime;
        end
        
        function set.MaxTime(obj, maxtime)
            %set.MaxTime Set the value for property MaxTime
            validateattributes(maxtime, {obj.DurationClass}, {'nonempty', 'scalar'}, 'ControllerStatistics', 'MaxTime');
            
            obj.JavaMessage.setMaxTime(maxtime.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.MaxTime)
                obj.Cache.MaxTime.setJavaObject(maxtime.getJavaObject);
            end
        end
        
        function meantime = get.MeanTime(obj)
            %get.MeanTime Get the value for property MeanTime
            if isempty(obj.Cache.MeanTime)
                obj.Cache.MeanTime = feval(obj.DurationClass, obj.JavaMessage.getMeanTime);
            end
            meantime = obj.Cache.MeanTime;
        end
        
        function set.MeanTime(obj, meantime)
            %set.MeanTime Set the value for property MeanTime
            validateattributes(meantime, {obj.DurationClass}, {'nonempty', 'scalar'}, 'ControllerStatistics', 'MeanTime');
            
            obj.JavaMessage.setMeanTime(meantime.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.MeanTime)
                obj.Cache.MeanTime.setJavaObject(meantime.getJavaObject);
            end
        end
        
        function variancetime = get.VarianceTime(obj)
            %get.VarianceTime Get the value for property VarianceTime
            if isempty(obj.Cache.VarianceTime)
                obj.Cache.VarianceTime = feval(obj.DurationClass, obj.JavaMessage.getVarianceTime);
            end
            variancetime = obj.Cache.VarianceTime;
        end
        
        function set.VarianceTime(obj, variancetime)
            %set.VarianceTime Set the value for property VarianceTime
            validateattributes(variancetime, {obj.DurationClass}, {'nonempty', 'scalar'}, 'ControllerStatistics', 'VarianceTime');
            
            obj.JavaMessage.setVarianceTime(variancetime.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.VarianceTime)
                obj.Cache.VarianceTime.setJavaObject(variancetime.getJavaObject);
            end
        end
        
        function numcontrolloopoverruns = get.NumControlLoopOverruns(obj)
            %get.NumControlLoopOverruns Get the value for property NumControlLoopOverruns
            numcontrolloopoverruns = int32(obj.JavaMessage.getNumControlLoopOverruns);
        end
        
        function set.NumControlLoopOverruns(obj, numcontrolloopoverruns)
            %set.NumControlLoopOverruns Set the value for property NumControlLoopOverruns
            validateattributes(numcontrolloopoverruns, {'numeric'}, {'nonempty', 'scalar'}, 'ControllerStatistics', 'NumControlLoopOverruns');
            
            obj.JavaMessage.setNumControlLoopOverruns(numcontrolloopoverruns);
        end
        
        function timelastcontrolloopoverrun = get.TimeLastControlLoopOverrun(obj)
            %get.TimeLastControlLoopOverrun Get the value for property TimeLastControlLoopOverrun
            if isempty(obj.Cache.TimeLastControlLoopOverrun)
                obj.Cache.TimeLastControlLoopOverrun = feval(obj.TimeClass, obj.JavaMessage.getTimeLastControlLoopOverrun);
            end
            timelastcontrolloopoverrun = obj.Cache.TimeLastControlLoopOverrun;
        end
        
        function set.TimeLastControlLoopOverrun(obj, timelastcontrolloopoverrun)
            %set.TimeLastControlLoopOverrun Set the value for property TimeLastControlLoopOverrun
            validateattributes(timelastcontrolloopoverrun, {obj.TimeClass}, {'nonempty', 'scalar'}, 'ControllerStatistics', 'TimeLastControlLoopOverrun');
            
            obj.JavaMessage.setTimeLastControlLoopOverrun(timelastcontrolloopoverrun.getJavaObject);
            
            % Update cache if necessary
            if ~isempty(obj.Cache.TimeLastControlLoopOverrun)
                obj.Cache.TimeLastControlLoopOverrun.setJavaObject(timelastcontrolloopoverrun.getJavaObject);
            end
        end
    end
    
    methods (Access = protected)
        function resetCache(obj)
            %resetCache Resets any cached properties
            obj.Cache.Timestamp = [];
            obj.Cache.MaxTime = [];
            obj.Cache.MeanTime = [];
            obj.Cache.VarianceTime = [];
            obj.Cache.TimeLastControlLoopOverrun = [];
        end
        
        function cpObj = copyElement(obj)
            %copyElement Implements deep copy behavior for message
            
            % Call default copy method for shallow copy
            cpObj = copyElement@robotics.ros.Message(obj);
            
            % Clear any existing cached properties
            cpObj.resetCache;
            
            % Create a new Java message object
            cpObj.JavaMessage = obj.createNewJavaMessage;
            
            % Iterate over all primitive properties
            cpObj.Name = obj.Name;
            cpObj.Type = obj.Type;
            cpObj.Running = obj.Running;
            cpObj.NumControlLoopOverruns = obj.NumControlLoopOverruns;
            
            % Recursively copy compound properties
            cpObj.Timestamp = copy(obj.Timestamp);
            cpObj.MaxTime = copy(obj.MaxTime);
            cpObj.MeanTime = copy(obj.MeanTime);
            cpObj.VarianceTime = copy(obj.VarianceTime);
            cpObj.TimeLastControlLoopOverrun = copy(obj.TimeLastControlLoopOverrun);
        end
        
        function reload(obj, strObj)
            %reload Called by loadobj to assign properties
            obj.Name = strObj.Name;
            obj.Type = strObj.Type;
            obj.Running = strObj.Running;
            obj.NumControlLoopOverruns = strObj.NumControlLoopOverruns;
            obj.Timestamp = feval([obj.TimeClass '.loadobj'], strObj.Timestamp);
            obj.MaxTime = feval([obj.DurationClass '.loadobj'], strObj.MaxTime);
            obj.MeanTime = feval([obj.DurationClass '.loadobj'], strObj.MeanTime);
            obj.VarianceTime = feval([obj.DurationClass '.loadobj'], strObj.VarianceTime);
            obj.TimeLastControlLoopOverrun = feval([obj.TimeClass '.loadobj'], strObj.TimeLastControlLoopOverrun);
        end
    end
    
    methods (Access = ?robotics.ros.Message)
        function strObj = saveobj(obj)
            %saveobj Implements saving of message to MAT file
            
            % Return an empty element if object array is empty
            if isempty(obj)
                strObj = struct.empty;
                return
            end
            
            strObj.Name = obj.Name;
            strObj.Type = obj.Type;
            strObj.Running = obj.Running;
            strObj.NumControlLoopOverruns = obj.NumControlLoopOverruns;
            strObj.Timestamp = saveobj(obj.Timestamp);
            strObj.MaxTime = saveobj(obj.MaxTime);
            strObj.MeanTime = saveobj(obj.MeanTime);
            strObj.VarianceTime = saveobj(obj.VarianceTime);
            strObj.TimeLastControlLoopOverrun = saveobj(obj.TimeLastControlLoopOverrun);
        end
    end
    
    methods (Static, Access = {?matlab.unittest.TestCase, ?robotics.ros.Message})
        function obj = loadobj(strObj)
            %loadobj Implements loading of message from MAT file
            
            % Return an empty object array if the structure element is not defined
            if isempty(strObj)
                obj = robotics.ros.msggen.controller_manager_msgs.ControllerStatistics.empty(0,1);
                return
            end
            
            % Create an empty message object
            obj = robotics.ros.msggen.controller_manager_msgs.ControllerStatistics;
            obj.reload(strObj);
        end
    end
end