Skip to content

Commit

Permalink
Several improvements:
Browse files Browse the repository at this point in the history
getparam outputs empty value if bossdevice is not ready.
sendPulse supports two more function arguments: pulse width in seconds, and marker value.
manualTrigger is now blocking.
  • Loading branch information
pablorcum committed Aug 9, 2024
1 parent 684645f commit d42a8d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion toolbox/dependencies/+bossapi
24 changes: 19 additions & 5 deletions toolbox/src/bossdevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ function stop(obj)
end

function generator_running = get.isGeneratorRunning(obj)
generator_running = getsignal(obj, 'Unit Delay', 1);
generator_running = obj.getsignal('GEN',5);
end

function obj = arm(obj)
Expand Down Expand Up @@ -420,20 +420,24 @@ function stop(obj)
end
end

function sendPulse(obj, port)
function sendPulse(obj, port, width, marker)
arguments
obj
port {mustBeInteger,mustBeInRange(port,1,4)}
width {mustBeScalarOrEmpty, mustBeNonnegative} = 0.001
marker {mustBeScalarOrEmpty, mustBeInteger} = []
end

if obj.isRunning
marker = port;
if isempty(marker)
marker = port;
end

setparam(obj, 'GEN', 'enabled', 0);
setparam(obj, 'TRG', 'enabled', 0);
setparam(obj, 'GEN', 'manualtrigger', 0);

obj.configure_generator_sequence([0 0.001 port marker]); % 0 seconds after the trigger and during 0.001 seconds, trigger port 1 and send marker 1
obj.configure_generator_sequence([0 width port marker]); % 0 seconds after the trigger and during 0.001 seconds, trigger port 1 and send marker 1

obj.manualTrigger;
else
Expand All @@ -446,8 +450,16 @@ function manualTrigger(obj)
setparam(obj, 'TRG', 'enabled', 0);

setparam(obj, 'GEN', 'manualtrigger', 1);
pause(0.1);
setparam(obj, 'GEN', 'manualtrigger', 0);

disp('Triggering sequence...');

% Block execution of manualTrigger while generator is running
while obj.isGeneratorRunning
pause(0.1);
end

disp('Sequence completed.');
end

function openDocumentation(obj)
Expand Down Expand Up @@ -504,6 +516,8 @@ function setparam(obj, path, varargin)
function val = getparam(obj, path, varargin)
if obj.isInitialized
val = getparam(obj.targetObject, [obj.appName,'/bosslogic/', path], varargin{:});
else
val = [];
end
end

Expand Down

0 comments on commit d42a8d7

Please sign in to comment.