source: MML/trunk/mml/links/labca/setpvonline.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 1.6 KB
Line 
1function ErrorFlag = setpvonline(ChannelNames, NewSP, DataType)
2%SETPVONLINE - Sets the online value
3% ErrorFlag = setpvonline(ChannelNames, NewSP, DataType)
4
5
6if nargin < 2
7    error('Must have at least two inputs');
8end
9if nargin < 3
10    DataType = 'double';
11end
12
13ErrorFlag = 0;
14
15if iscell(ChannelNames)
16
17    % Put data
18    lcaPut(ChannelNames, NewSP, DataType);
19
20    % Not so good, but it's faster
21    %lcaPutNoWait(ChannelNames, NewSP, DataType);
22
23else
24
25    % Vectorized put
26
27    % There can be multiple channel names due to "ganged" power supplies
28    [ChannelNames, i] = unique(ChannelNames, 'rows');
29
30    % if size(ChannelNames,1) == size(NewSP,1)
31    %     % ChannelNames equals the number of power supplies
32    % else
33    NewSP = NewSP(i,:);
34    % end
35
36
37    %if size(ChannelNames,1) ~= size(NewSP,1)
38    %    error('Size of NewSP must be equal to the DeviceList, a scalar, or the number of unique channelnames in the family');
39    %end
40
41
42    % Remove ' ' and fill with NaN latter (' ' should always be the first row)
43    if isempty(deblank(ChannelNames(1,:)))
44        ChannelNames(1,:) = [];
45        NewSP(1,:) = [];
46    end
47
48    % Build the cell array
49    ChanNameCell = cell(size(ChannelNames,1),1);
50    for k = size(ChannelNames,1):-1:1     
51        ChanName = deblank(ChannelNames(k,:));
52        if isempty(ChanName)
53            NewSP(k,:) = [];
54            ChanNameCell(k) = [];
55        else
56            ChanNameCell{k} = ChanName;
57        end
58    end
59   
60    % Put data
61    lcaPut(ChanNameCell, NewSP, DataType);
62   
63    % Not so good, but it's faster
64    %lcaPutNoWait(ChanNameCell, NewSP, DataType);
65   
66end
Note: See TracBrowser for help on using the repository browser.