root/branches/telle/v2.00-at/mfiles/@NXTmotor/display.m @ 403

Revision 403, 3.2 KB (checked in by telle, 5 years ago)

* Port to new MATLAB R2008 class syntax
* output at least one set of settings in ReadFromNXT, also if no output arg is given

Line 
1function display( obj )
2% DISPLAY Display method for NXTmotor objects.
3%
4%   DISPLAY(OBJ) displays information pertaining to the NXTmotor
5%   object OBJ.
6%
7%   See also NXTmotor, NXTmotor/get.
8%
9
10% Signature
11%   Author: Aulis Telle (see AUTHORS)
12%   Date: 2008/08/15
13%   Copyright: 2007-2008, RWTH Aachen University
14%
15%
16% ***********************************************************************************************
17% *  This file is part of the RWTH - Mindstorms NXT Toolbox.                                    *
18% *                                                                                             *
19% *  The RWTH - Mindstorms NXT Toolbox is free software: you can redistribute it and/or modify  *
20% *  it under the terms of the GNU General Public License as published by the Free Software     *
21% *  Foundation, either version 3 of the License, or (at your option) any later version.        *
22% *                                                                                             *
23% *  The RWTH - Mindstorms NXT Toolbox is distributed in the hope that it will be useful,       *
24% *  but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  *
25% *  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
26% *                                                                                             *
27% *  You should have received a copy of the GNU General Public License along with the           *
28% *  RWTH - Mindstorms NXT Toolbox. If not, see <http://www.gnu.org/licenses/>.                 *
29% ***********************************************************************************************
30
31if ~isa(obj,'NXTmotor')
32    error('MATLAB:RWTHMindstormsNXT:InvalidObject',...
33        'No NXTmotor object.');
34end
35
36if isscalar(obj)
37    fprintf([...
38        '\n'...
39        'NXTmotor object properties:\n\n' ...
40        '           Port(s): '    infoStrPort(  obj.Port)              '\n' ...
41        '             Power: '    infoStrNumber(obj.Power)             '\n' ...
42        '   SpeedRegulation: '    infoStrOnOff( obj.SpeedRegulation)   '\n' ...
43        '        TachoLimit: '    infoStrNumber(obj.TachoLimit)        '\n' ...
44        ' BrakeAtTachoLimit: '    infoStrYesNo( obj.BrakeAtTachoLimit) '\n' ...
45        '         TurnRatio: '    infoStrNumber(obj.TurnRatio)         '\n' ...
46        '\n']);
47else
48    disp(obj);
49end
50
51end
52
53function s = infoStrPort(p)
54if numel(p) == 1
55    s = num2str(p);
56else
57    s = mat2str(p);
58end
59
60s = [s, ' (' portString(p) ')'];
61end %% END FUNCTION INFOSTRPORT
62
63
64function s = portString(p)
65s = '''';
66for k = 1:length(p)
67    if k > 1
68        s = [s ''','''];
69    end
70    switch(p(k))
71        case 0
72            s = [s, 'A'];
73        case 1
74            s = [s, 'B'];
75        case 2
76            s = [s, 'C'];
77        otherwise
78            s = 'undefined';
79    end
80end
81s = [s , ''''];
82end %% END FUNCTION PORTSTRING
83
84function s = infoStrNumber(n)
85s = num2str(n);
86end %% END FUNTION INFOSTRNUMBER
87
88function s = infoStrOnOff(b)
89s = num2str(b);
90if b
91    s = [s, ' (''on'')'];
92else
93    s = [s, ' (''off'')'];
94end
95end %% END FUNCTION INFOSTRONOFF
96
97function s = infoStrYesNo(b)
98s = num2str(b);
99if b
100    s = [s, ' (''yes'')'];
101else
102    s = [s, ' (''no'')'];
103end 
104end %% END FUNCTION INFOSTRYESNO
Note: See TracBrowser for help on using the browser.