Skip to content

Commit

Permalink
Merge pull request #63 from sync2brain/fix_triggersRemaining
Browse files Browse the repository at this point in the history
Fixes triggers remaining and adds test case
  • Loading branch information
pablorcum authored Jul 31, 2024
2 parents 0353a7d + 375bb35 commit 4da3d48
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions tests/commonSetupTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
function setupBossdevice(testCase)
import matlab.unittest.constraints.Eventually
import matlab.unittest.constraints.IsTrue
import matlab.unittest.fixtures.SuppressedWarningsFixture

testCase.applyFixture(SuppressedWarningsFixture("MATLAB:pfileOlderThanMfile"));

[testCase.isSGinstalled, testCase.sgPath] = bossapi.sg.isSpeedgoatBlocksetInstalled;
if testCase.isSGinstalled
Expand Down
8 changes: 5 additions & 3 deletions tests/smokeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
methods (Test, TestTags = {'bdConnected'})
% Test methods with bossdevice connected and reachable from the host PC
function bdInitialization(testCase)
testCase.bd = bossdevice;
testCase.bd.initialize;
testCase.verifyTrue(testCase.bd.isConnected);
testCase.verifyTrue(testCase.bd.isInitialized);
testCase.verifyFalse(testCase.bd.isRunning);
testCase.verifyFalse(testCase.bd.isArmed);
testCase.verifyFalse(testCase.bd.isGeneratorRunning);
pause(1);
end

function bdShortRun(testCase)
testCase.bd = bossdevice;
testCase.bd.start;
testCase.verifyTrue(testCase.bd.isRunning);
testCase.bd.stop;
Expand All @@ -23,6 +20,11 @@ function bdShortRun(testCase)
pause(1);
testCase.verifyTrue(testCase.bd.isInitialized);
end

function getTriggersRunning(testCase)
testCase.bd.start;
testCase.verifyGreaterThan(testCase.bd.triggers_remaining,0);
end
end

end
16 changes: 13 additions & 3 deletions toolbox/src/bossdevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function stop(obj)
end

function val = get.triggers_remaining(obj)
val = getsignal(obj,'TRG',2);
val = getsignal(obj,{'TRG','TRG/Count Down'},1);
end

function set.triggers_remaining(obj, val)
Expand Down Expand Up @@ -505,9 +505,19 @@ function setparam(obj, path, varargin)
end
end

function val = getsignal(obj, path, varargin)
function val = getsignal(obj, path, portIndex)
arguments
obj
path {mustBeText}
portIndex {mustBeScalarOrEmpty}
end

if obj.isInitialized
val = getsignal(obj.targetObject, [obj.appName,'/bosslogic/', path], varargin{:});
if ~iscell(path)
val = getsignal(obj.targetObject, [obj.appName,'/bosslogic/', path], portIndex);
else
val = getsignal(obj.targetObject, [{[obj.appName,'/bosslogic/', path{1}]},path(2:end)], portIndex);
end
end
end

Expand Down

0 comments on commit 4da3d48

Please sign in to comment.