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

Fix issues with undeleted comm interfaces

On deletion/disconnect, communication-objects of lower layers are now
properly deleted and disconnected.
parent fb5f6434
Branches
Tags
No related merge requests found
......@@ -127,6 +127,11 @@ classdef EV3 < handle
ev3.init = 0;
end
function delete(ev3)
if ev3.isConnected
ev3.disconnect();
end
end
%% Connection
function connect(ev3, varargin)
%connect Connects EV3-object and its Motors and Sensors to physical brick.
......@@ -152,8 +157,6 @@ classdef EV3 < handle
ev3.brick = 0;
ev3.isConnected = 0;
% error('EV3::connect: Aborted connection.');
end
end
......@@ -219,9 +222,9 @@ classdef EV3 < handle
% b.disconnect();
%
if ~ev3.isConnected
error('EV3::connect: No brick connected.');
end
% if ~ev3.isConnected
% error('EV3::connect: No brick connected.');
% end
% Disconnect motors
% -> set references to brick object to 0
......@@ -238,7 +241,9 @@ classdef EV3 < handle
ev3.sensor4.disconnect();
% Delete handle to brick object
if isBrickValid(ev3.brick) && ev3.brick ~= 0
ev3.brick.delete();
end
ev3.brick = 0;
ev3.isConnected = 0;
......
......@@ -256,9 +256,9 @@ classdef Motor < handle
% brickInterface.delete(); % Actual disconnecting!!!
%
if ~motor.isConnected
error('Motor::disconnect: No brick connected.');
end
% if ~motor.isConnected
% error('Motor::disconnect: No brick connected.');
% end
motor.brick = 0; % Note: actual deleting is done in EV3::disconnect.
motor.isConnected = 0;
......
......@@ -136,9 +136,9 @@ classdef Sensor < handle
function disconnect(sensor)
%disconnect Disconnects Sensor-object from physical brick
if ~sensor.isConnected
error('Sensor::disconnect: No brick connected.');
end
% if ~sensor.isConnected
% error('Sensor::disconnect: No brick connected.');
% end
sensor.brick = 0; % Note: actual deleting is done in EV3::disconnect.
sensor.isConnected = 0;
......@@ -163,8 +163,8 @@ classdef Sensor < handle
if strcmp(class(oldMode),class(newMode)) && oldMode~=newMode
if ~strcmp(class(oldMode), 'DeviceMode.Error') && ...
~strcmp(class(newMode), 'DeviceMode.Error')
warning(['Sensor::update: Physical sensor''s mode was not ',...
'the specified one. Changing...']);
%warning(['Sensor::update: Physical sensor''s mode was not ',...
% 'the specified one. Changing...']);
sensor.setMode(oldMode);
sensor.mode = oldMode;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment