Skip to content
Snippets Groups Projects
Commit 3062ff73 authored by Tim Stadtmann's avatar Tim Stadtmann
Browse files

Add Device-class from which HL classes now inherit

WIP, not yet working. Only implemented debug-parameter as a first test
parent 22d352ce
No related branches found
No related tags found
No related merge requests found
classdef EV3 < MaskedHandle
classdef EV3 < Device
% High-level class to work with physical bricks.
%
% This is the 'central' class (from user's view) when working with this toolbox. It
......@@ -53,14 +53,6 @@ classdef EV3 < MaskedHandle
% batteryMode (string in {'Percentage', 'Voltage'}): Mode for reading battery charge. [WRITABLE]
% See also BATTERYVALUE
batteryMode;
% debug (numeric in {0,1,2}): Debug mode. [WRITABLE]
% - 0: Debug turned off
% - 1: (High-level-) Debug turned on for EV3-object - enables feedback in the
% console about what firmware-commands have been called when using a method
% - 2: Low-level-Debug turned on - each packet sent and received is printed to the
% console
debug;
end
properties (Dependent) % Parameters to be read directly from physical brick
......@@ -101,18 +93,16 @@ classdef EV3 < MaskedHandle
sensor4;
end
properties (Access = private)
properties (Hidden, Access = protected) % Hidden properties for internal use only
% init (bool): Indicates init-phase (i.e. constructor is running).
init = true;
% commInterface (CommunicationInterface): Interface to communication layer
% All commands sent to the Brick are created and written through this object. Each
% Motor- and Sensor-object has a reference to it.
commInterface = 0;
end
properties (Hidden, Access = private) % Hidden properties for internal use only
% init (bool): Indicates init-phase (i.e. constructor is running).
init = true;
end
methods % Standard methods
%% Constructor
function ev3 = EV3(varargin)
......@@ -394,8 +384,8 @@ classdef EV3 < MaskedHandle
ev3.batteryMode = batteryMode;
end
function set.debug(ev3, debug)
function setDebug(ev3, debug)
if ~isBool(debug) && debug ~= 2
error('EV3::set.debug: Given parameter is not a bool.');
end
......
classdef Motor < MaskedHandle & dynamicprops
classdef Motor < Device & dynamicprops
% High-level class to work with motors.
%
% This class is supposed to ease the use of the brick's motors. It is possible to set all
......@@ -91,11 +91,6 @@ classdef Motor < MaskedHandle & dynamicprops
% If 'Coast', the motor will (at tacholimit, if ~=0) coast to a stop. If 'Brake',
% the motor will stop immediately (at tacholimit, if ~=0) and hold the brake.
brakeMode;
% debug (bool): Debug turned on or off. [WRITABLE]
% In debug mode, everytime a command is passed to the sublayer ('communication
% layer'), there is feedback in the console about what command has been called.
debug;
end
properties (Dependent) % Read-only parameters to be read directly from physical brick
......@@ -115,7 +110,7 @@ classdef Motor < MaskedHandle & dynamicprops
type;
end
properties (Hidden, Access = private) % Hidden properties for internal use only
properties (Hidden, Access = protected) % Hidden properties for internal use only
% commInterface (CommunicationInterface): Commands are created and sent via the
% communication interface class.
commInterface;
......@@ -791,14 +786,6 @@ classdef Motor < MaskedHandle & dynamicprops
motor.commInterface = comm;
end
function set.debug(motor, debug)
if ~isBool(debug)
error('Motor::set.debug: Given parameter is not a bool.');
end
motor.debug = str2bool(debug);
end
function setProperties(motor, varargin)
% Sets multiple Motor properties at once using MATLAB's inputParser.
%
......
classdef Sensor < MaskedHandle
classdef Sensor < Device
% High-level class to work with sensors.
%
% The Sensor-class facilitates the communication with sensors. This mainly consists of
......@@ -160,11 +160,6 @@ classdef Sensor < MaskedHandle
% * DeviceMode.HTColor.All
% See also SENSOR.VALUE, SENSOR.TYPE
mode;
% debug (bool): Debug turned on or off. In debug mode, everytime a command is passed to
% the sublayer ('communication layer'), there is feedback in the console about what
% command has been called. [WRITABLE]
debug;
end
properties (Dependent) % Parameters to be read directly from physical brick
......@@ -197,7 +192,7 @@ classdef Sensor < MaskedHandle
type;
end
properties (Hidden, Access = private) % Hidden properties for internal use only
properties (Hidden, Access = protected) % Hidden properties for internal use only
% commInterface (CommunicationInterface): Commands are created and sent via the
% communication interface class.
commInterface;
......@@ -282,15 +277,6 @@ classdef Sensor < MaskedHandle
end
end
function set.debug(sensor, debug)
% Check if debug is valid and set sensor.debug if it is.
if ~isBool(debug)
error('Sensor::set.debug: Given parameter is not a bool.');
end
sensor.debug = str2bool(debug);
end
function set.port(sensor, port)
if ~isPortStrValid(class(sensor),port)
error('Sensor::set.port: Given port is not a valid port.');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment