diff --git a/source/private/DeviceMode.m b/source/private/DeviceMode.m index beaae0299598448cd9c8d6689072796b4eabdd09..17ab32ce54059136984535f150b06d11705e542a 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 37638483673a654c555398a802cec3fcdf3df0b8..a5049f978e727186f74f09b1ab612addab88bfe8 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