source: MML/trunk/mml/links/mca_asp/setpvonline.m

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

Initial import--MML version from SOLEIL@2013

File size: 1.2 KB
Line 
1function ErrorFlag = setpvonline(ChannelNames, NewSP, DataType);
2%SETPVONLINE - Sets the online value
3% ErrorFlag = setpvonline(ChannelNames, NewSP, DataType)
4
5if nargin < 2
6    error('Must have at least two inputs');
7end
8
9ErrorFlag = 0;
10
11
12% Vectorized put
13
14% There can be multiple channel names due to "ganged" power supplies
15[ChannelNames, i] = unique(ChannelNames, 'rows');
16
17% if size(ChannelNames,1) == size(NewSP,1)
18%     % ChannelNames equals the number of power supplies
19% else
20NewSP = NewSP(i,:);
21% end
22
23
24%if size(ChannelNames,1) ~= size(NewSP,1)
25%    error('Size of NewSP must be equal to the DeviceList, a scalar, or the number of unique channelnames in the family');
26%end
27
28
29% Remove ' ' and fill with NaN latter (' ' should always be the first row)
30if isempty(deblank(ChannelNames(1,:)))
31    ChannelNames(1,:) = [];
32    NewSP(1,:) = [];
33end
34
35
36% Build the MCA-handle array
37for k = size(ChannelNames,1):-1:1
38    ChanName = deblank(ChannelNames(k,:));
39    % Get handle and/or open connection
40    hh = mcaisopen(ChanName);
41    h(k,1) = hh(1);
42    if ~h(k,1)
43        h(k,1) = mcaopen(ChanName);
44    end
45
46    if h(k) == 0
47        error(sprintf('mcaopen error on channel name %s', ChanName));
48    end
49end
50
51
52% Put data
53mcaput(h, NewSP);
54   
Note: See TracBrowser for help on using the repository browser.