diff --git a/source/Motor.m b/source/Motor.m index 5e2431415a3bf74f3e3d21f7c009ca315949da53..c9609946eb7920d75f680cb58fc20882e249cbe2 100755 --- a/source/Motor.m +++ b/source/Motor.m @@ -98,6 +98,7 @@ classdef Motor < MaskedHandle & dynamicprops connectedToBrick = false; % Connection to physical Brick? init = true; % Indicates 'init-phase' (True as long as constructor is running) + startedNotBusy = false; % Set to true if motor started w/o tacholimit and unsynced sendPowerOnSet = false; % If true, OUTPUT_POWER is sent when setting power % Bitfield representing which opCodes should be sent on Motor.start() @@ -201,6 +202,7 @@ classdef Motor < MaskedHandle & dynamicprops if motor.debug fprintf('(DEBUG) Motor::start: Called outputStart on Port %s\n', port2str('Motor', motor.port)); end + motor.startedNotBusy = true; else limit = motor.limitValue - (motor.smoothStart + motor.smoothStop); if limit < 0 @@ -270,6 +272,8 @@ classdef Motor < MaskedHandle & dynamicprops if motor.debug fprintf('(DEBUG) Motor::stop: Called outputStop on Port %s\n', port2str('Motor', motor.port)); end + + motor.startedNotBusy = false; end function syncedStart(motor, syncMotor, varargin) @@ -842,9 +846,15 @@ classdef Motor < MaskedHandle & dynamicprops function running = get.isRunning(motor) running = 0; + if motor.connectedToBrick - running = motor.getBusyFlag(); + busyFlag = motor.getBusyFlag(); + else + busyFlag = 0; end + + assert(~(motor.startedNotBusy && busyFlag)); + running = motor.startedNotBusy || busyFlag; end function synced = get.isSynced(motor) @@ -1053,6 +1063,7 @@ classdef Motor < MaskedHandle & dynamicprops end end + methods (Access = {?EV3}) function connect(motor,commInterface) %connect Connects Motor-object to physical brick.