[17] | 1 | function S = getminsp(Family, DeviceList) |
---|
| 2 | %GETMINSP - Gets minimum value of the setpoint |
---|
| 3 | % |
---|
| 4 | % FamilyName/DeviceList Method |
---|
| 5 | % SPmin = getmaxsp(Family, DeviceList) |
---|
| 6 | % SPmin = getmaxsp(DataStructure) |
---|
| 7 | % |
---|
| 8 | % ChannelName Method |
---|
| 9 | % SPmin = getmaxsp(ChannelNames) |
---|
| 10 | % |
---|
| 11 | % CommonName Method |
---|
| 12 | % SPmin = getmaxsp(Family, CommonName) |
---|
| 13 | % |
---|
| 14 | % INPUTS |
---|
| 15 | % 1. Family = Family Name |
---|
| 16 | % Data Structure |
---|
| 17 | % Accelerator Object |
---|
| 18 | % Cell Array of Accelerator Objects or Family Names |
---|
| 19 | % For CommonNames, Family=[] searches all families |
---|
| 20 | % ChannelName = Channel access channel name |
---|
| 21 | % Matrix of channel names |
---|
| 22 | % Cell array of channel names |
---|
| 23 | % CommonName = Common name |
---|
| 24 | % Matrix of common names |
---|
| 25 | % Cell array of common names |
---|
| 26 | % 2. DeviceList = [Sector Device #] or [element #] list {default or empty list: whole family} |
---|
| 27 | % Cell Array of DeviceList |
---|
| 28 | % |
---|
| 29 | % OUTPUTS |
---|
| 30 | % 1. SPmin = Minimum setpoint of the device |
---|
| 31 | % Empty if not found |
---|
| 32 | % |
---|
| 33 | % See also getmaxsp, getfamilydata(Family, Field, 'Range') |
---|
| 34 | |
---|
| 35 | % |
---|
| 36 | % Written by Gregory J. Portmann |
---|
| 37 | % Modified by Laurent S. Nadolski |
---|
| 38 | |
---|
| 39 | S = []; |
---|
| 40 | |
---|
| 41 | if nargin == 0 |
---|
| 42 | error('At least one input required'); |
---|
| 43 | end |
---|
| 44 | |
---|
| 45 | if iscell(Family) |
---|
| 46 | if nargin >= 2 |
---|
| 47 | if ~iscell(DeviceList) |
---|
| 48 | error('If Family is a cell array, then DeviceList must be a cell array.'); |
---|
| 49 | end |
---|
| 50 | if length(Family) ~= length(DeviceList) |
---|
| 51 | error('Family and DeviceList must be the same size cell arrays.'); |
---|
| 52 | end |
---|
| 53 | end |
---|
| 54 | |
---|
| 55 | for i = 1:length(Family) |
---|
| 56 | if nargin == 1 |
---|
| 57 | S{i} = getminsp(Family{i}); |
---|
| 58 | else |
---|
| 59 | S{i} = getminsp(Family{i}, DeviceList{i}); |
---|
| 60 | end |
---|
| 61 | end |
---|
| 62 | return |
---|
| 63 | end |
---|
| 64 | |
---|
| 65 | if isstruct(Family) |
---|
| 66 | if any(size(Family) > 1) |
---|
| 67 | error('Only structures of size = [1 1] allowed') |
---|
| 68 | end |
---|
| 69 | if isfield(Family,'FamilyName') & isfield(Family,'Field') |
---|
| 70 | % Data structure |
---|
| 71 | S = getfamilydata(Family.FamilyName, Family.Field, 'Range', Family.DeviceList); |
---|
| 72 | if ~isempty(S) |
---|
| 73 | S = S(:,1); |
---|
| 74 | end |
---|
| 75 | return |
---|
| 76 | else |
---|
| 77 | % AO structure |
---|
| 78 | if nargin < 2 |
---|
| 79 | S = Family.Setpoint.Range; |
---|
| 80 | else |
---|
| 81 | if size(DeviceList,2) == 1 |
---|
| 82 | Index = findrowindex(DeviceList, ElementList); |
---|
| 83 | else |
---|
| 84 | Index = findrowindex(DeviceList, Family.DeviceList); |
---|
| 85 | end |
---|
| 86 | S = Family.Setpoint.Range(Index,1); |
---|
| 87 | end |
---|
| 88 | end |
---|
| 89 | end |
---|
| 90 | |
---|
| 91 | if isempty(Family) |
---|
| 92 | % Common names with no family name |
---|
| 93 | if nargin < 2 |
---|
| 94 | error('If Family=[], 2 inputs are required.'); |
---|
| 95 | end |
---|
| 96 | CommonNames = DeviceList; |
---|
| 97 | for i = 1:size(CommonNames,1) |
---|
| 98 | Family = common2family(CommonNames(i,:)); |
---|
| 99 | [FamilyIndex, ACCELERATOR_OBJECT] = isfamily(Family); |
---|
| 100 | DeviceList = common2dev(CommonNames(i,:), ACCELERATOR_OBJECT); |
---|
| 101 | if isempty(DeviceList) | isempty(DeviceList) |
---|
| 102 | error('Common name could not be converted to a Family and DeviceList.'); |
---|
| 103 | end |
---|
| 104 | S(i,:) = getminsp(Family, DeviceList); |
---|
| 105 | end |
---|
| 106 | return |
---|
| 107 | |
---|
| 108 | elseif ~isfamily(Family(1,:)) |
---|
| 109 | % Channel name method |
---|
| 110 | % Try to convert to a family and device |
---|
| 111 | |
---|
| 112 | ChannelNames = Family; |
---|
| 113 | for i = 1:size(ChannelNames,1) |
---|
| 114 | Family = channel2family(ChannelNames(i,:)); |
---|
| 115 | [FamilyIndex, ACCELERATOR_OBJECT] = isfamily(Family); |
---|
| 116 | DeviceList = channel2dev(ChannelNames(i,:), ACCELERATOR_OBJECT); |
---|
| 117 | if isempty(DeviceList) | isempty(DeviceList) |
---|
| 118 | error('Channel name could not be converted to a Family and DeviceList.'); |
---|
| 119 | end |
---|
| 120 | S(i,:) = getminsp(Family, DeviceList); |
---|
| 121 | end |
---|
| 122 | return |
---|
| 123 | end |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | if nargin == 1 |
---|
| 127 | S = getfamilydata(Family, 'Setpoint', 'Range', []); |
---|
| 128 | else |
---|
| 129 | % Convert common name to a DeviceList |
---|
| 130 | if isstr(DeviceList) |
---|
| 131 | DeviceList = common2dev(DeviceList, Family); |
---|
| 132 | end |
---|
| 133 | S = getfamilydata(Family, 'Setpoint', 'Range', DeviceList); |
---|
| 134 | end |
---|
| 135 | if ~isempty(S) |
---|
| 136 | S = S(:,1); |
---|
| 137 | end |
---|