-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapPM.m
83 lines (73 loc) · 2.3 KB
/
mapPM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
%% mapPM.m MN 2018-09-19
% Maps available power meters to their VISA resources and other attributes
%
% Requirements:
% - None
%
% Usage: meterStruct = mapPM(meterID)
% Returns:
% meterStruct: Power meter information:
% .ID: string to use as meterID
% .type: string containing the model/manufacturer to select correct SCPI commands
% .interface: function handle to interface function
% .visaAddr: string containing the typical VISA connection address
% .serial: serial number/string
% .minT: minimum usable averaging time, in seconds
% .powerlim: 1x2 vector containing the min and max power measurable, in watts
% .wavelim: 1x2 vector containing the min and max wavelength, in nm
% .description: string with a description of the meter
%
% Parameters:
% meterID: Meter ID; pass 'list' for a cell array of available IDs,
% 'types' for available types
%
% TODO:
% -
function meterStruct = mapPM(meterID)
%% Validate and initialize
if ~ischar(meterID)
if isnumeric(meterID)
meterID = num2str(meterID);
else
meterID = char(meterID);
end
end
meters = cell(0);
%% List of meters
% Sample meter
meterStruct = struct;
meterStruct.ID = 'test';
meterStruct.type = 'ThorLabs PM101';
meterStruct.interface = @instPM_ThorLabsPM101;
meterStruct.visaAddr = '';
meterStruct.serial = '12345';
meterStruct.minT = 0.1;
meterStruct.powerlim = [1e-12 1];
meterStruct.wavelim = [900 1800];
meterStruct.description = 'Small red power meter';
meters{end+1} = meterStruct;
% Next meter
meterStruct = struct;
meterStruct.ID = 'Station2';
meterStruct.type = 'Newport 1830-R';
meterStruct.interface = @instPM_Newport1830;
meterStruct.visaAddr = 'GPIB0::4::INSTR';
meterStruct.serial = '10042';
meterStruct.minT = 0.001;
meterStruct.powerlim = [0 0.1];
meterStruct.wavelim = [800 2000];
meterStruct.description = 'Newport meter at station 2';
meters{end+1} = meterStruct;
%% Return desired meter
if strcmpi(meterID, 'list')
meterStruct = cellfun(@(x) x.ID, meters, 'UniformOutput', 0);
elseif strcmpi(meterID, 'types')
else
ii = find(cellfun(@(x) strcmpi(x.ID, meterID), meters) | cellfun(@(x) strcmpi(x.serial, meterID), meters));
if ii>0
meterStruct = meters{ii};
else
error('Meter %s not found!', meterID);
end
end
end