Files
imdd_silas/Classes/05_Lab/Awg2Scope.m
Silas Labor Zizou 6b0f9de118 Lab changes
2024-10-10 11:07:59 +02:00

110 lines
3.5 KiB
Matlab

classdef Awg2Scope
%NAME Summary of this class goes here
% Detailed explanation goes here
properties(Access=public)
Awg
Scope
mapping;
end
methods (Access=public)
function obj = Awg2Scope(Awg,Scope,mapping)
%Simple class to call the Awg and Scope and map the signals
%accordingly in the correct formats with correct l
% ogbook
%entries...
arguments
Awg
Scope
mapping
end
obj.Awg = Awg;
obj.Scope = Scope;
obj.mapping = mapping; % AWG CH [1,2,3,4] -> Scope CH [0,0,0,1]
end
function [S1,S2,S3,S4] = process(obj,channels)
arguments
obj
% leave this as it is! Important for further handling/ parsing
channels.signal1 Informationsignal = Informationsignal([])
channels.signal2 Informationsignal = Informationsignal([])
channels.signal3 Informationsignal = Informationsignal([])
channels.signal4 Informationsignal = Informationsignal([])
% add new optional arguments here
end
[S1,S2,S3,S4]=obj.Awg.upload("signal1",channels.signal1,...
"signal2",channels.signal2,...
"signal3",channels.signal3,...
"signal4",channels.signal4...
);
scpe_sig_cell = obj.Scope.read();
% Map Scope measurement to output signal
% mapping index is the AWG chanel and mapping number is the
% respective Scope channel
% mapping=[1 2 3 4] means that AWG chann 1 is mapped to Scope ch 1 and so on
% mapping=[0 0 2 1] means that
% AWG chann 3 is mapped to Scope ch 2
% AWG chann 4 is mapped to Scope ch 1
lbdesc = ['Scope Record'];
try
S1 = Electricalsignal(S1,"fs",S1.fs,"logbook",S1.logbook);
S1.signal = scpe_sig_cell{obj.mapping(1)}.signal;
S1.fs = scpe_sig_cell{obj.mapping(1)}.fs;
S1 = S1.logbookentry(lbdesc,obj);
catch
% S1.signal = scpe_sig_cell{1};
end
try
S2 = Electricalsignal(S2,"fs",S2.fs,"logbook",S2.logbook);
S2.signal = scpe_sig_cell{obj.mapping(2)}.signal;
S2.fs = scpe_sig_cell{obj.mapping(2)}.fs;
S2 = S2.logbookentry(lbdesc,obj);
catch
% S2.signal = scpe_sig_cell{2};
S2 = S2.logbookentry(lbdesc,obj);
end
try
S3 = Electricalsignal(S3,"fs",S3.fs,"logbook",S3.logbook);
S3.signal = scpe_sig_cell{obj.mapping(3)}.signal;
S3.fs = scpe_sig_cell{obj.mapping(3)}.fs;
S3 = S3.logbookentry(lbdesc,obj);
catch
% S3.signal = scpe_sig_cell{3};
S3 = S3.logbookentry(lbdesc,obj);
end
try
S4 = Electricalsignal(S4,"fs",S4.fs,"logbook",S4.logbook);
S4.signal = scpe_sig_cell{obj.mapping(4)}.signal;
S4.fs = scpe_sig_cell{obj.mapping(4)}.fs;
S4 = S4.logbookentry(lbdesc,obj);
catch
% S4.signal = scpe_sig_cell{4};
S4 = S4.logbookentry(lbdesc,obj);
end
end
end
end