Skip to content

Commit f2f4c38

Browse files
committed
Re-size axis window when changing image size.
1 parent ec328ab commit f2f4c38

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

code/DAQmx_Scanners/listDeviceIDs.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,11 @@ function displayDevice(thisDevice,padNameTo)
9898

9999
details = dabs.ni.daqmx.Device(thisDevice);
100100
cleanProdCat = regexprep(details.productCategory,'DAQmx_Val_(\w)(\w+)DAQ','$1-$2 DAQ');
101-
fprintf('\t%s\t%s\t%s\n', paddedName, cleanProdCat, details.productType)
101+
102+
if details.serialNum==0 %Then it's a simulated device
103+
simString='SIMULATED';
104+
else
105+
simString='';
106+
end
107+
fprintf('\t%s\t%s\t%s\t%s\n', paddedName, cleanProdCat, ...
108+
details.productType, simString)

code/DAQmx_Scanners/polishedScanner.m

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
% 0.8446
5555
%
5656
%
57+
% KNOWN BUGS:
58+
% Going from smaller to larger image sizes causes a crash when running on a simulated device.
59+
%
60+
%
5761
% Requirements
5862
% DAQmx and the Vidrio dabs.ni.daqmx wrapper
5963
%
@@ -155,11 +159,7 @@
155159

156160
%Make an empty axis and fill with a blank image
157161
obj.imAxes = axes('Parent', obj.hFig, 'Position', [0.05 0.05 0.9 0.9]);
158-
obj.hIm = imagesc(obj.imAxes,zeros(obj.imSize));
159-
obj.hTitle = title('');
160-
set(obj.imAxes, 'XTick', [], 'YTIck', [], 'CLim', [0,obj.AIrange], 'Box', 'on')
161-
axis square
162-
colormap gray
162+
obj.makeBlankFigure % Add a blank image based upon the current image size
163163

164164
% Call a method to connect to the DAQ. If the following line fails, the Tasks are
165165
% cleaned up gracefully and the object is deleted. This is all done by the method
@@ -426,8 +426,9 @@ function regnerateWaveforms(obj)
426426
% Set the buffer size
427427
nSamples=size(obj.waveforms,1);
428428

429-
obj.hAOTask.control('DAQmx_Val_Task_Unreserve') %This line is critical for allowing new data to be written
430-
obj.hAOTask.set('writeRelativeTo','DAQmx_Val_FirstSample')
429+
% We must unreserve the DAQ device before writing to the buffer:
430+
% https://forums.ni.com/t5/Multifunction-DAQ/How-to-flush-output-buffer-optionally-resize-it-and-write-to-it/td-p/3138640
431+
obj.hAOTask.control('DAQmx_Val_Task_Unreserve')
431432

432433
obj.hAOTask.cfgSampClkTiming(obj.desiredSampleRate, 'DAQmx_Val_ContSamps', nSamples);
433434
obj.hAOTask.set('writeRegenMode', 'DAQmx_Val_AllowRegen');
@@ -444,10 +445,21 @@ function regnerateWaveforms(obj)
444445
obj.delete
445446
return
446447
end
448+
449+
obj.makeBlankFigure
447450
obj.start
448451

449-
end
450-
end
452+
end % close regnerateWaveforms
453+
454+
function makeBlankFigure(obj)
455+
obj.hIm = imagesc(obj.imAxes,zeros(obj.imSize));
456+
obj.hTitle = title('');
457+
set(obj.imAxes, 'XTick', [], 'YTIck', [], 'CLim', [0,obj.AIrange], 'Box', 'on')
458+
axis square
459+
colormap gray
460+
end % close makeBlankFigure
461+
462+
end %close hidden methods block
451463

452464
end %close the vidrio.mixed.basicScanner class definition
453465

0 commit comments

Comments
 (0)