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

isRunning is now also true if motor runs w/o limit

The implementation is based on a new flag, 'startedNotBusy', which
is set to true if single motor is started w/o limit.
parent 88f22201
No related branches found
No related tags found
No related merge requests found
...@@ -98,6 +98,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -98,6 +98,7 @@ classdef Motor < MaskedHandle & dynamicprops
connectedToBrick = false; % Connection to physical Brick? connectedToBrick = false; % Connection to physical Brick?
init = true; % Indicates 'init-phase' (True as long as constructor is running) 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 sendPowerOnSet = false; % If true, OUTPUT_POWER is sent when setting power
% Bitfield representing which opCodes should be sent on Motor.start() % Bitfield representing which opCodes should be sent on Motor.start()
...@@ -201,6 +202,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -201,6 +202,7 @@ classdef Motor < MaskedHandle & dynamicprops
if motor.debug if motor.debug
fprintf('(DEBUG) Motor::start: Called outputStart on Port %s\n', port2str('Motor', motor.port)); fprintf('(DEBUG) Motor::start: Called outputStart on Port %s\n', port2str('Motor', motor.port));
end end
motor.startedNotBusy = true;
else else
limit = motor.limitValue - (motor.smoothStart + motor.smoothStop); limit = motor.limitValue - (motor.smoothStart + motor.smoothStop);
if limit < 0 if limit < 0
...@@ -270,6 +272,8 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -270,6 +272,8 @@ classdef Motor < MaskedHandle & dynamicprops
if motor.debug if motor.debug
fprintf('(DEBUG) Motor::stop: Called outputStop on Port %s\n', port2str('Motor', motor.port)); fprintf('(DEBUG) Motor::stop: Called outputStop on Port %s\n', port2str('Motor', motor.port));
end end
motor.startedNotBusy = false;
end end
function syncedStart(motor, syncMotor, varargin) function syncedStart(motor, syncMotor, varargin)
...@@ -842,9 +846,15 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -842,9 +846,15 @@ classdef Motor < MaskedHandle & dynamicprops
function running = get.isRunning(motor) function running = get.isRunning(motor)
running = 0; running = 0;
if motor.connectedToBrick if motor.connectedToBrick
running = motor.getBusyFlag(); busyFlag = motor.getBusyFlag();
else
busyFlag = 0;
end end
assert(~(motor.startedNotBusy && busyFlag));
running = motor.startedNotBusy || busyFlag;
end end
function synced = get.isSynced(motor) function synced = get.isSynced(motor)
...@@ -1053,6 +1063,7 @@ classdef Motor < MaskedHandle & dynamicprops ...@@ -1053,6 +1063,7 @@ classdef Motor < MaskedHandle & dynamicprops
end end
end end
methods (Access = {?EV3}) methods (Access = {?EV3})
function connect(motor,commInterface) function connect(motor,commInterface)
%connect Connects Motor-object to physical brick. %connect Connects Motor-object to physical brick.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment