Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments/Documentation for the test classes #14

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Testing/DSTestPulseBuilder.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
classdef DSTestPulseBuilder < TestPulseBuilder
% DSTestPulseBuilder Provides a pulse group for tests of the
% downsampling operation.
%
% Each call to addPulse constructs a new pulse that holds a voltage
% level between mask.begin and mask.end and holds the negative value of
% this voltage for the rest of the pulse. The expected data for each
% pulse is that voltage level. Each call to addPulse adds a value to
% the expected data.

properties (Constant, GetAccess = public)
meanErrorThreshold = 1e-4;
Expand Down
8 changes: 8 additions & 0 deletions Testing/IOTestDriver.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
classdef IOTestDriver
% IOTestDriver A driver for a single hardware IO test configured by a
% TestConfigurationProvider (and thus a TestPulseBuilder) instance.
%
% IOTestDriver sets up a VAWG object and initializes a DAC instance
% using the given TestConfigurationProvider object. It then obtains the
% test pulse group from the TestConfigurationProvider instance,
% executes the test and compares mean and single errors to the
% thresholds given.

properties (SetAccess = private, GetAccess = private)
vawg;
Expand Down
9 changes: 9 additions & 0 deletions Testing/PeriodicMaskTestConfigurationProvider.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
classdef PeriodicMaskTestConfigurationProvider < TestConfigurationProvider
% PeriodicMaskTestConfigurationProvider Provides a test configuration for
% a periodic mask.
%
% The default mask has a period of 1000 and a readout window from 400
% to 600. It can be replaced by any other periodic mask in the
% constructor (optional).
% The test pulse group is constructed by creating a given number of
% pulses with the same mask. This number of iterations defaults to 100
% but can be changed via the class constructor (optional).

properties (GetAccess = protected)
mask = struct( ...
Expand Down
11 changes: 11 additions & 0 deletions Testing/RSATestPulseBuilder.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
classdef RSATestPulseBuilder < TestPulseBuilder
% RSATestPulseBuilder Provides a pulse group for tests of the
% repetitive signal averaging operation.
%
% Each call to addPulse constructs a new pulse that has a random
% pattern of voltage levels between mask.begin and mask.end and holds
% the negative of the first and the last of these values repectively
% before and after this time window. This random pattern is the same
% for all constructed pulses although the time window may vary (it must
% be of the same length for all calls).
% The expected data is this voltage pattern which is constructed in
% the first call to addPulse and not altered in subsequent calls.

properties (Constant, GetAccess = public)
meanErrorThreshold = 1e-4;
Expand Down
6 changes: 6 additions & 0 deletions Testing/RandomTestPulseBuilder.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
classdef RandomTestPulseBuilder < TestPulseBuilder
% RandomTestPulseBuilder Provides a pulse group for tests of the
% raw hardware IO functionality.
%
% Calls to addPulse create a pulse with a random pattern of voltage
% values disregarding mask.begin and mask.end. The expected data is
% exactly this pattern of values.

properties (Constant, GetAccess = public)
meanErrorThreshold = 1e-3;
Expand Down
8 changes: 7 additions & 1 deletion Testing/RawIOTestConfigurationProvider.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
classdef RawIOTestConfigurationProvider < TestConfigurationProvider
% RawIOTestConfigurationProvider Provides a mask for raw IO input
% testing.
%
% The default mask has a period of 10000 and an equally long readout
% window. It can be changed via the constructor (optional).


properties (GetAccess = protected)
mask = struct( ...
'begin', 0, ...
'end', 10000, ...
'period', 10000 ...
);
iterations = 1;
iterations = 1;
end

methods (Access = protected)
Expand Down
8 changes: 8 additions & 0 deletions Testing/TableMaskTestConfigurationProvider.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
classdef TableMaskTestConfigurationProvider < TestConfigurationProvider
% TableMaskTestConfigurationProvider Provides a test configuration for
% a table mask.
%
% The default mask has a period of 1000 and 100 readout windows:
% [400,600], [402, 602], .... [600, 800]. The default mask can be
% replaced by any other table mask in the constructor (optional).
% The constructed test pulse group is contains the according amount of
% pulses in sequence.

properties (GetAccess = protected)
mask = struct( ...
Expand Down
23 changes: 21 additions & 2 deletions Testing/TestConfigurationProvider.m
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
classdef TestConfigurationProvider < handle
% TestConfigurationProvider An abstract base for classes that provide
% a readout mask for hardware IO Tests and construct a pulse group
% using a TestPulseBuilder instance accordingly.
%
% Subclasses need to implement the following properties/methods:
% - mask
% - computePulseGroup

properties (SetAccess = private, GetAccess = public)
inputChannel = 1;
meanErrorThreshold;
singleErrorThreshold;
meanErrorThreshold; % Value copied from pulseBuilder object in constructor
singleErrorThreshold; % Value copied from pulseBuilder object in constructor
end

properties (SetAccess = private, GetAccess = protected)
pulseBuilder;
end

properties (Abstract, GetAccess = protected)
% The readout mask used in the DAC (periodic or table mask).
mask;
end

methods (Abstract, Access = protected)
% Constructs the pulse group. Must not use plsdefgrp(..). Called by
% createPulseGroup().
computePulseGroup(self);
end

Expand All @@ -30,20 +40,29 @@
self.singleErrorThreshold = self.pulseBuilder.singleErrorThreshold;
end

% Create the pulse group using the provider TestPulseBuilder
% instance with the internally implemented pulse group construction
% algorithm.
function createPulseGroup(self)
self.pulseBuilder.reset();
self.computePulseGroup();
plsdefgrp(self.pulseBuilder.pulseGroup);
end

% Obtains the created pulse group. Make sure to call
% createPulseGroup first.
function pulseGroup = getPulseGroup(self)
pulseGroup = self.pulseBuilder.pulseGroup;
end

% Obtains the expected data. Make sure to call createPulseGroup
% first.
function expectedData = getExpectedData(self)
expectedData = self.pulseBuilder.expectedData;
end

% Constructs and returns the DAC object for the test initialized
% with the specific readout mask for the test.
function dac = createDAC(self)
switch (self.pulseBuilder.dacOperation)
case 'raw'
Expand Down
22 changes: 22 additions & 0 deletions Testing/TestPulseBuilder.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
classdef TestPulseBuilder < handle
% TestPulseBuilder An abstract base for classes that provide pulse
% groups for hardware IO tests.
%
% Subclasses provide functionality to construct a pulse group and the
% expected data to test a specific DAC operation according to provided
% readout masks.
% The following properties/methods need to be implemented:
% - meanErrorThreshold
% - singleErrrorThreshold
% - dacOperation ('raw', 'ds' or 'rsa')
% - pulseGroupPrototype
% - createPulse

properties (Constant, Abstract, GetAccess = public)
meanErrorThreshold;
Expand All @@ -7,6 +19,8 @@
end

properties (Constant, Abstract, GetAccess = protected)
% A prototype for an empty pulse group. Used in the reset
% operation.
pulseGroupPrototype;
end

Expand All @@ -20,6 +34,9 @@
end

methods (Abstract, Access = protected)
% Creates a single pulse and expected data according to the mask
% and the DAC operation and adds the created pulse to the pulse
% pulse group in construction. Called by addPulse().
createPulse(self, mask, repetitions);
end

Expand All @@ -33,11 +50,16 @@

methods (Access = public)

% addPulse adds a pulse to the constructed pulse group according to
% the mask and alters the expected data accordingly. The create
% pulse is guaranteed to be as long as mask.period.
function addPulse(self, mask, repetitions)
self.pulseCount = self.pulseCount + repetitions * mask.period;
self.createPulse(mask, repetitions);
end

% reset resets the currently constructed pulse group and expected
% data.
function reset(self)
self.pulseGroup = self.pulseGroupPrototype;
self.pulseCount = 0;
Expand Down