From 5ccba86cbefc9cbd21f8c19d5b1363a7d89c5960 Mon Sep 17 00:00:00 2001 From: Tim Stadtmann <tim.stadtmann@rwth-aachen.de> Date: Fri, 30 Jun 2017 17:30:34 +0200 Subject: [PATCH] Fix minor bugs in mode/type test functions --- source/private/DeviceMode.m | 8 +++----- source/private/isModeValid.m | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/private/DeviceMode.m b/source/private/DeviceMode.m index beaae02..17ab32c 100755 --- a/source/private/DeviceMode.m +++ b/source/private/DeviceMode.m @@ -10,15 +10,13 @@ function mode = DeviceMode(type, modeNo) % Motors are a special case where the mode name does not equal the type name if type == DeviceType.LargeMotor || type == DeviceType.MediumMotor mode = DeviceMode.Motor(modeNo); + elseif type == DeviceType.Unknown || type == DeviceType.None || type == DeviceType.Error + mode = DeviceMode.Default.Undefined; else mode = DeviceMode.(char(type))(modeNo); end catch ME - if strcmp(ME.identifier,'MATLAB:undefinedVarOrClass') - mode = DeviceMode.Default.Undefined; % Need to think about this... - else - error('ModeNo ''%d'' not valid for given type.', modeNo); - end + error('ModeNo ''%d'' not valid for given type.', modeNo); end end diff --git a/source/private/isModeValid.m b/source/private/isModeValid.m index 3763848..a5049f9 100755 --- a/source/private/isModeValid.m +++ b/source/private/isModeValid.m @@ -1,6 +1,7 @@ function isValid = isModeValid(mode, type) % Returns whether given mode is a valid mode in given type. if strcmp(class(mode), 'DeviceMode.Default') + isValid = true; return; end -- GitLab