From d42a8d70716144cff390fab73992d9fe44ec0544 Mon Sep 17 00:00:00 2001 From: Pablo Romero Date: Fri, 9 Aug 2024 23:11:10 +0200 Subject: [PATCH] Several improvements: 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. --- toolbox/dependencies/+bossapi | 2 +- toolbox/src/bossdevice.m | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/toolbox/dependencies/+bossapi b/toolbox/dependencies/+bossapi index 5d148fc..3a26491 160000 --- a/toolbox/dependencies/+bossapi +++ b/toolbox/dependencies/+bossapi @@ -1 +1 @@ -Subproject commit 5d148fcd05e9f25b4ee35266d968108e82faf2ee +Subproject commit 3a26491b2b3b4b123ec3d8847a48bdd861fd1689 diff --git a/toolbox/src/bossdevice.m b/toolbox/src/bossdevice.m index f2386e1..3186d7e 100644 --- a/toolbox/src/bossdevice.m +++ b/toolbox/src/bossdevice.m @@ -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) @@ -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 @@ -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) @@ -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