Skip to content
Snippets Groups Projects
Commit 1c8f3a2e authored by Maximilian Schnabel's avatar Maximilian Schnabel
Browse files

added warning to setProperties, if invalid input parameters are given

parent 25040967
Branches
No related tags found
2 merge requests!7Keep going if mountpoint exists (persistent),!6Docs NXT compatibility
...@@ -347,17 +347,15 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -347,17 +347,15 @@ classdef Motor < MaskedHandle & dynamicprops
% * This is a pretty 'heavy' function, as it tests if both motors are % * This is a pretty 'heavy' function, as it tests if both motors are
% connected AND aren't running, wasting four packets, keep that in mind. % connected AND aren't running, wasting four packets, keep that in mind.
% %
%::
%
% Example: % Example:
% brick = EV3(); % b = EV3(); % |br|
% brick.connect('usb'); % b.connect('usb'); % |br|
% motor = brick.motorA; % m = b.motorA; % |br|
% slave = brick.motorB; % slave = b.motorB; % |br|
% motor.power = 50; % m.power = 50; % |br|
% motor.syncedStart(slave); % m.syncedStart(slave); % |br|
% % Do stuff % % Do stuff |br|
% motor.stop(); % m.stop(); % |br|
% %
% See also MOTOR.STOP, MOTOR.SYNCEDSTOP / :meth:`stop`, :meth:`syncedStop` % See also MOTOR.STOP, MOTOR.SYNCEDSTOP / :meth:`stop`, :meth:`syncedStop`
...@@ -715,21 +713,20 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -715,21 +713,20 @@ classdef Motor < MaskedHandle & dynamicprops
% power (numeric in [-100,100]): *[OPTIONAL]* % power (numeric in [-100,100]): *[OPTIONAL]*
% batteryMode ('Voltage'|'Percentage'): *[OPTIONAL]* % batteryMode ('Voltage'|'Percentage'): *[OPTIONAL]*
% %
% ::
%
% Example: % Example:
% brick = EV3(); % b = EV3(); % |br|
% brick.connect('bt', 'serPort', '/dev/rfcomm0'); % b.connect('bt', 'serPort', '/dev/rfcomm0'); % |br|
% brick.motorA.setProperties('debug', 'on', 'power', 50, 'limitValue', 720, 'speedRegulation', 'on'); % b.motorA.setProperties('debug', 'on', 'power', 50, 'limitValue', 720, 'speedRegulation', 'on'); % |br|
% % Instead of: brick.motorA.debug = 'on'; % % Instead of: b.motorA.debug = 'on'; |br|
% % brick.motorA.power = 50; % % b.motorA.power = 50; |br|
% % brick.motorA.limitValue = 720; % % b.motorA.limitValue = 720; |br|
% % brick.motorA.speedRegulation = 'on'; % % b.motorA.speedRegulation = 'on'; |br|
% %
p = inputParser(); p = inputParser();
p.KeepUnmatched = 1; p.KeepUnmatched = 1;
% Set default values % Set default values
if motor.init if motor.init
defaultDebug = 0; defaultDebug = 0;
...@@ -768,6 +765,16 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -768,6 +765,16 @@ classdef Motor < MaskedHandle & dynamicprops
% Parse... % Parse...
p.parse(varargin{:}); p.parse(varargin{:});
if ~isempty(fieldnames(p.Unmatched))
A = fieldnames(p.Unmatched);
warn = 'The following input parameters were invalid: ';
warn = [warn A{1}];
for i = 2:length(A)
warn = [warn ', ' A{i}];
end
warning(warn)
end
% Set properties % Set properties
if motor.init if motor.init
motor.port = p.Results.port; motor.port = p.Results.port;
...@@ -1042,10 +1049,9 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -1042,10 +1049,9 @@ classdef Motor < MaskedHandle & dynamicprops
end end
% If motor is *busily* running, stop it. That avoids suicidal stuff like: % If motor is *busily* running, stop it. That avoids suicidal stuff like:
% brick = EV3(); % b = EV3(); b.connect('usb');
% brick.connect('usb'); % b.motorA.start();
% brick.motorA.start(); % b.disconnect(); -> Motor still running and cannot directly be stopped anymore
% brick.disconnect(); -> Motor still running and cannot directly be stopped anymore
if motor.isRunning if motor.isRunning
motor.stop(); motor.stop();
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment