54
54
% 0.8446
55
55
%
56
56
%
57
+ % KNOWN BUGS:
58
+ % Going from smaller to larger image sizes causes a crash when running on a simulated device.
59
+ %
60
+ %
57
61
% Requirements
58
62
% DAQmx and the Vidrio dabs.ni.daqmx wrapper
59
63
%
155
159
156
160
% Make an empty axis and fill with a blank image
157
161
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
163
163
164
164
% Call a method to connect to the DAQ. If the following line fails, the Tasks are
165
165
% cleaned up gracefully and the object is deleted. This is all done by the method
@@ -426,8 +426,9 @@ function regnerateWaveforms(obj)
426
426
% Set the buffer size
427
427
nSamples= size(obj .waveforms ,1 );
428
428
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' )
431
432
432
433
obj .hAOTask .cfgSampClkTiming(obj .desiredSampleRate , ' DAQmx_Val_ContSamps' , nSamples );
433
434
obj .hAOTask .set(' writeRegenMode' , ' DAQmx_Val_AllowRegen' );
@@ -444,10 +445,21 @@ function regnerateWaveforms(obj)
444
445
obj .delete
445
446
return
446
447
end
448
+
449
+ obj .makeBlankFigure
447
450
obj .start
448
451
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
451
463
452
464
end % close the vidrio.mixed.basicScanner class definition
453
465
0 commit comments