1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <title>Description of writeattribute</title> |
---|
6 | <meta name="keywords" content="writeattribute"> |
---|
7 | <meta name="description" content="WRITEATTRIBUTE - Writes a list of TANGO attributes"> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
10 | <meta name="robots" content="index, follow"> |
---|
11 | <link type="text/css" rel="stylesheet" href="../../../m2html.css"> |
---|
12 | </head> |
---|
13 | <body> |
---|
14 | <a name="_top"></a> |
---|
15 | <div><a href="../../../index.html">Home</a> > <a href="../../index.html">mml</a> > <a href="#">links</a> > <a href="index.html">tango</a> > writeattribute.m</div> |
---|
16 | |
---|
17 | <!--<table width="100%"><tr><td align="left"><a href="../../../index.html"><img alt="<" border="0" src="../../../left.png"> Master index</a></td> |
---|
18 | <td align="right"><a href="index.html">Index for mml/links/tango <img alt=">" border="0" src="../../../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>writeattribute |
---|
21 | </h1> |
---|
22 | |
---|
23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2> |
---|
24 | <div class="box"><strong>WRITEATTRIBUTE - Writes a list of TANGO attributes</strong></div> |
---|
25 | |
---|
26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2> |
---|
27 | <div class="box"><strong>function ErrorFlag = writeattribute(tangolist,val,varargin) </strong></div> |
---|
28 | |
---|
29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2> |
---|
30 | <div class="fragment"><pre class="comment">WRITEATTRIBUTE - Writes a list of TANGO attributes |
---|
31 | writeattribute(tangolist,val,type) |
---|
32 | |
---|
33 | INPUTS |
---|
34 | 1. tangolist - list of tango attributes eg 'ANS-C01/DGsim/BPM.1/X' |
---|
35 | 2. val - vector of tango setpoint values |
---|
36 | |
---|
37 | OPTIONAL |
---|
38 | 3. type - datatype {double by default}, int16 |
---|
39 | 4. 'QueryDB' - Look for attribute typ in DB before writing attribute |
---|
40 | |
---|
41 | OUTPUTS |
---|
42 | 1. ErrorFlag |
---|
43 | |
---|
44 | See also <a href="readattribute.html" class="code" title="function [Data, tout, DataTime, ErrorFlag] = readattribute(tangolist, varargin)">readattribute</a></pre></div> |
---|
45 | |
---|
46 | <!-- crossreference --> |
---|
47 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2> |
---|
48 | This function calls: |
---|
49 | <ul style="list-style-image:url(../../../matlabicon.gif)"> |
---|
50 | <li><a href="getattribute.html" class="code" title="function [AttributeNames, DeviceNames] = getattribute(varargin)">getattribute</a> GETATTRIBUTE - Decomposes a full attributename into device and attribute names</li></ul> |
---|
51 | This function is called by: |
---|
52 | <ul style="list-style-image:url(../../../matlabicon.gif)"> |
---|
53 | </ul> |
---|
54 | <!-- crossreference --> |
---|
55 | |
---|
56 | |
---|
57 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2> |
---|
58 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function ErrorFlag = writeattribute(tangolist,val,varargin)</a> |
---|
59 | 0002 <span class="comment">%WRITEATTRIBUTE - Writes a list of TANGO attributes</span> |
---|
60 | 0003 <span class="comment">% writeattribute(tangolist,val,type)</span> |
---|
61 | 0004 <span class="comment">%</span> |
---|
62 | 0005 <span class="comment">% INPUTS</span> |
---|
63 | 0006 <span class="comment">% 1. tangolist - list of tango attributes eg 'ANS-C01/DGsim/BPM.1/X'</span> |
---|
64 | 0007 <span class="comment">% 2. val - vector of tango setpoint values</span> |
---|
65 | 0008 <span class="comment">%</span> |
---|
66 | 0009 <span class="comment">% OPTIONAL</span> |
---|
67 | 0010 <span class="comment">% 3. type - datatype {double by default}, int16</span> |
---|
68 | 0011 <span class="comment">% 4. 'QueryDB' - Look for attribute typ in DB before writing attribute</span> |
---|
69 | 0012 <span class="comment">%</span> |
---|
70 | 0013 <span class="comment">% OUTPUTS</span> |
---|
71 | 0014 <span class="comment">% 1. ErrorFlag</span> |
---|
72 | 0015 <span class="comment">%</span> |
---|
73 | 0016 <span class="comment">% See also readattribute</span> |
---|
74 | 0017 |
---|
75 | 0018 <span class="comment">%</span> |
---|
76 | 0019 <span class="comment">% Written by Laurent S. Nadolski</span> |
---|
77 | 0020 |
---|
78 | 0021 |
---|
79 | 0022 QueryFlag = 0; <span class="comment">% query attribute type in DB</span> |
---|
80 | 0023 |
---|
81 | 0024 <span class="keyword">for</span> i = length(varargin):-1:1 |
---|
82 | 0025 <span class="keyword">if</span> strcmpi(varargin{i},<span class="string">'QueryDB'</span>) |
---|
83 | 0026 QueryFlag = 1; |
---|
84 | 0027 varargin(i) = []; |
---|
85 | 0028 <span class="keyword">end</span> |
---|
86 | 0029 <span class="keyword">end</span> |
---|
87 | 0030 |
---|
88 | 0031 [attribute device] = <a href="getattribute.html" class="code" title="function [AttributeNames, DeviceNames] = getattribute(varargin)">getattribute</a>(tangolist); |
---|
89 | 0032 |
---|
90 | 0033 <span class="keyword">for</span> k = 1:size(attribute,1) |
---|
91 | 0034 |
---|
92 | 0035 <span class="keyword">if</span> QueryFlag == 0 |
---|
93 | 0036 |
---|
94 | 0037 <span class="keyword">if</span> nargin < 3 |
---|
95 | 0038 tango_write_attribute(device{k},attribute{k},val(k)); |
---|
96 | 0039 <span class="keyword">else</span> |
---|
97 | 0040 <span class="keyword">switch</span> lower(varargin{1}) |
---|
98 | 0041 <span class="keyword">case</span> <span class="string">'int16'</span> |
---|
99 | 0042 tango_write_attribute(device{k},attribute{k},int16(val(k))); |
---|
100 | 0043 <span class="keyword">case</span> <span class="string">'int32'</span> |
---|
101 | 0044 tango_write_attribute(device{k},attribute{k},int32(val(k))); |
---|
102 | 0045 <span class="keyword">case</span> <span class="string">'double'</span> |
---|
103 | 0046 tango_write_attribute(device{k},attribute{k},val(k,:)); |
---|
104 | 0047 <span class="keyword">case</span> <span class="string">'string'</span> |
---|
105 | 0048 <span class="comment">% Type char</span> |
---|
106 | 0049 tango_write_attribute(device{k},attribute{k},char(val(k,:))); |
---|
107 | 0050 <span class="comment">% OK pour mode</span> |
---|
108 | 0051 <span class="comment">% tango_write_attribute(device{k},attribute{k},val{k});</span> |
---|
109 | 0052 <span class="keyword">case</span> {<span class="string">'1-by-1 uint16'</span>,<span class="string">'uint8'</span>} <span class="comment">%DEV_BOOLEAN</span> |
---|
110 | 0053 tango_write_attribute(device{k},attribute{k},uint8(val(k,:))); |
---|
111 | 0054 <span class="keyword">otherwise</span> |
---|
112 | 0055 error(<span class="string">'wrong format'</span>) |
---|
113 | 0056 <span class="keyword">end</span> |
---|
114 | 0057 <span class="keyword">end</span> |
---|
115 | 0058 |
---|
116 | 0059 <span class="keyword">else</span> <span class="comment">% Look for attribute type in Tango DB</span> |
---|
117 | 0060 |
---|
118 | 0061 AttrDesc = tango_attribute_query(device{k},attribute{k}); |
---|
119 | 0062 |
---|
120 | 0063 <span class="keyword">switch</span> AttrDesc.data_type_str |
---|
121 | 0064 <span class="keyword">case</span> <span class="string">'1-by-1 double'</span> |
---|
122 | 0065 tango_write_attribute(device{k},attribute{k}, str2double(val(k,:))); |
---|
123 | 0066 <span class="keyword">case</span> <span class="string">'1-by-n char'</span> <span class="comment">% DEV_DOUBLE DEV_STRING</span> |
---|
124 | 0067 tango_write_attribute(device{k},attribute{k},char(val(k,:))); |
---|
125 | 0068 <span class="keyword">case</span> <span class="string">'1-by-1 int32'</span> <span class="comment">% DEV_LONG</span> |
---|
126 | 0069 tango_write_attribute(device{k},attribute{k},int32(str2double(val(k,:)))); |
---|
127 | 0070 <span class="keyword">case</span> <span class="string">'1-by-1 int16'</span> <span class="comment">% DEV_SHORT</span> |
---|
128 | 0071 tango_write_attribute(device{k},attribute{k},int16(val(k))); |
---|
129 | 0072 <span class="keyword">case</span> <span class="string">'1-by-1 uint16'</span> <span class="comment">% DEV_BOOLEAN</span> |
---|
130 | 0073 tango_write_attribute(device{k},attribute{k},uint8(val(k))); |
---|
131 | 0074 <span class="keyword">otherwise</span> |
---|
132 | 0075 disp(<span class="string">'Do Nothing'</span>) |
---|
133 | 0076 <span class="keyword">end</span> |
---|
134 | 0077 <span class="keyword">end</span> |
---|
135 | 0078 |
---|
136 | 0079 <span class="keyword">if</span> (tango_error == -1) |
---|
137 | 0080 <span class="comment">%- handle error</span> |
---|
138 | 0081 tango_print_error_stack; |
---|
139 | 0082 error(<span class="string">'writeattribute for device'</span>); |
---|
140 | 0083 <span class="keyword">return</span>; |
---|
141 | 0084 <span class="keyword">end</span> |
---|
142 | 0085 <span class="keyword">end</span></pre></div> |
---|
143 | <hr><address>Generated on Mon 21-May-2007 15:29:18 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
144 | </body> |
---|
145 | </html> |
---|