O-band Amp Characterization Measurement
This commit is contained in:
83
Classes/05_Lab/LabDeviceTemplate.m
Normal file
83
Classes/05_Lab/LabDeviceTemplate.m
Normal file
@@ -0,0 +1,83 @@
|
||||
classdef LabDeviceTemplate < handle
|
||||
|
||||
% Minimal template for lab device control via VISA / SCPI
|
||||
% Copy this file and adapt:
|
||||
% - visaAddress
|
||||
% - public API methods
|
||||
% - private SCPI commands
|
||||
|
||||
properties (Access = public)
|
||||
active logical = true
|
||||
end
|
||||
|
||||
properties (Access = protected)
|
||||
visaAddress string
|
||||
end
|
||||
|
||||
methods (Access = public)
|
||||
|
||||
function obj = LabDeviceTemplate(options)
|
||||
arguments
|
||||
options.active logical = true
|
||||
options.visaAddress string = ""
|
||||
end
|
||||
|
||||
% apply options
|
||||
fn = fieldnames(options);
|
||||
for k = 1:numel(fn)
|
||||
obj.(fn{k}) = options.(fn{k});
|
||||
end
|
||||
|
||||
% optional: quick connectivity check
|
||||
if obj.active
|
||||
v = obj.connect();
|
||||
writeline(v,"*IDN?");
|
||||
idn = readline(v);
|
||||
disp("Connected to: " + string(idn));
|
||||
delete(v);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function success = set(obj, value)
|
||||
% Example public API
|
||||
v = obj.connect();
|
||||
success = obj.setValue_(v, value);
|
||||
delete(v);
|
||||
end
|
||||
|
||||
|
||||
function value = read(obj)
|
||||
% Example readback
|
||||
v = obj.connect();
|
||||
value = obj.readValue_(v);
|
||||
delete(v);
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
methods (Access = protected)
|
||||
|
||||
function v = connect(obj)
|
||||
assert(obj.visaAddress ~= "", "No VISA address defined");
|
||||
v = visadev(obj.visaAddress);
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
methods (Access = private)
|
||||
|
||||
function success = setValue_(~, v, value)
|
||||
writeline(v, sprintf("SET %g", value));
|
||||
success = true;
|
||||
end
|
||||
|
||||
function value = readValue_(~, v)
|
||||
writeline(v, "READ?");
|
||||
value = str2double(readline(v));
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user