Skip to content

Commit d42a8d7

Browse files
committed
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.
1 parent 684645f commit d42a8d7

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

toolbox/dependencies/+bossapi

toolbox/src/bossdevice.m

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ function stop(obj)
367367
end
368368

369369
function generator_running = get.isGeneratorRunning(obj)
370-
generator_running = getsignal(obj, 'Unit Delay', 1);
370+
generator_running = obj.getsignal('GEN',5);
371371
end
372372

373373
function obj = arm(obj)
@@ -420,20 +420,24 @@ function stop(obj)
420420
end
421421
end
422422

423-
function sendPulse(obj, port)
423+
function sendPulse(obj, port, width, marker)
424424
arguments
425425
obj
426426
port {mustBeInteger,mustBeInRange(port,1,4)}
427+
width {mustBeScalarOrEmpty, mustBeNonnegative} = 0.001
428+
marker {mustBeScalarOrEmpty, mustBeInteger} = []
427429
end
428430

429431
if obj.isRunning
430-
marker = port;
432+
if isempty(marker)
433+
marker = port;
434+
end
431435

432436
setparam(obj, 'GEN', 'enabled', 0);
433437
setparam(obj, 'TRG', 'enabled', 0);
434438
setparam(obj, 'GEN', 'manualtrigger', 0);
435439

436-
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
440+
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
437441

438442
obj.manualTrigger;
439443
else
@@ -446,8 +450,16 @@ function manualTrigger(obj)
446450
setparam(obj, 'TRG', 'enabled', 0);
447451

448452
setparam(obj, 'GEN', 'manualtrigger', 1);
449-
pause(0.1);
450453
setparam(obj, 'GEN', 'manualtrigger', 0);
454+
455+
disp('Triggering sequence...');
456+
457+
% Block execution of manualTrigger while generator is running
458+
while obj.isGeneratorRunning
459+
pause(0.1);
460+
end
461+
462+
disp('Sequence completed.');
451463
end
452464

453465
function openDocumentation(obj)
@@ -504,6 +516,8 @@ function setparam(obj, path, varargin)
504516
function val = getparam(obj, path, varargin)
505517
if obj.isInitialized
506518
val = getparam(obj.targetObject, [obj.appName,'/bosslogic/', path], varargin{:});
519+
else
520+
val = [];
507521
end
508522
end
509523

0 commit comments

Comments
 (0)