@@ -91,6 +91,85 @@ class _Lock(object):
9191
9292% endif
9393% if len (config[' repeated_capabilities' ]) > 0 :
94+
95+ % if config[' rep_cap_expansion' ] == ' custom' :
96+ # Dynamically handle repeated capabilities
97+ % for rep_cap in config[' repeated_capabilities' ]:
98+
99+ class _RepCap${ rep_cap[' python_name' ].capitalize()} (object):
100+ % for attribute in helper.sorted_attrs(helper.filter_rep_cap_supported_attributes(attributes, rep_cap[' python_name' ])):
101+ <%
102+ helper.add_attribute_rep_cap_tip(attributes[attribute], config)
103+ %> \
104+ % if attributes[attribute][' enum' ]:
105+ % if helper.enum_uses_converter(enums[attributes[attribute][' enum' ]]):
106+ ${ attributes[attribute][' python_name' ]} = _attributes.AttributeEnumWithConverter(_attributes.AttributeEnum(_attributes.Attribute${ attributes[attribute][' type' ]} , enums.${ enums[attributes[attribute][' enum' ]][' python_name' ]} , ${ attribute} ), _converters.${ enums[attributes[attribute][' enum' ]][' enum_to_converted_value_function_name' ]} , _converters.${ enums[attributes[attribute][' enum' ]][' converted_value_to_enum_function_name' ]} )
107+ % else :
108+ ${ attributes[attribute][' python_name' ]} = _attributes.AttributeEnum(_attributes.Attribute${ attributes[attribute][' type' ]} , enums.${ enums[attributes[attribute][' enum' ]][' python_name' ]} , ${ attribute} )
109+ % endif
110+ % else :
111+ ${ attributes[attribute][' python_name' ]} = _attributes.${ attributes[attribute][' attribute_class' ]} (${ attribute} )
112+ % endif
113+ % if ' documentation' in attributes[attribute] and len (helper.get_documentation_for_node_docstring(attributes[attribute], config, indent = 4 ).strip()) > 0 :
114+ '''Type: ${ attributes[attribute][' type_in_documentation' ]}
115+
116+ ${ helper.get_documentation_for_node_docstring(attributes[attribute], config, indent = 4 )}
117+ '''
118+ % endif
119+ % endfor
120+ def __init__(self, session, repeated_capability_list):
121+ object.__setattr__(self, '_session', session)
122+ object.__setattr__(self, '_repeated_capability_list', repeated_capability_list)
123+ object.__setattr__(self, '_prefix', '${ rep_cap[" prefix" ]} ')
124+ object.__setattr__(self, '_current_repeated_capability_list', repeated_capability_list if len(repeated_capability_list) > 0 else [''])
125+ object.__setattr__(self, '_separator', '')
126+
127+ def __setattr__(self, key, value):
128+ if key not in dir(self):
129+ raise AttributeError("'{0}' object has no attribute '{1}'".format(type(self).__name__, key))
130+ object.__setattr__(self, key, value)
131+
132+ def __getitem__(self, repeated_capability):
133+ '''Set/get properties or call methods with a repeated capability (i.e. channels)'''
134+ rep_caps_list = _converters.convert_repeated_capabilities(repeated_capability, self._prefix)
135+ complete_rep_cap_list = [
136+ current_rep_cap + self._separator + rep_cap
137+ for current_rep_cap in self._current_repeated_capability_list
138+ for rep_cap in rep_caps_list
139+ ]
140+ object.__setattr__(self, '_current_repeated_capability_list', complete_rep_cap_list)
141+ self._current_repeated_capability_list = complete_rep_cap_list
142+
143+ return self
144+
145+ def _get_attribute_vi_real64(self, attribute):
146+ repeated_capability = ','.join(self._current_repeated_capability_list)
147+ value = self._session._interpreter.get_attribute_vi_real64(repeated_capability, attribute)
148+ return value
149+
150+ def _set_attribute_vi_real64(self, attribute, value):
151+ repeated_capability = ','.join(self._current_repeated_capability_list)
152+ self._session._interpreter.set_attribute_vi_real64(repeated_capability, attribute, value)
153+
154+ def _get_attribute_vi_int32(self, attribute):
155+ repeated_capability = ','.join(self._current_repeated_capability_list)
156+ value = self._session._interpreter.get_attribute_vi_int32(repeated_capability, attribute)
157+ return value
158+
159+ def _set_attribute_vi_int32(self, attribute, value):
160+ repeated_capability = ','.join(self._current_repeated_capability_list)
161+ self._session._interpreter.set_attribute_vi_int32(repeated_capability, attribute, value)
162+
163+ def _get_attribute_vi_string(self, attribute):
164+ repeated_capability = ','.join(self._current_repeated_capability_list)
165+ value = self._session._interpreter.get_attribute_vi_string(repeated_capability, attribute)
166+ return value
167+
168+ def _set_attribute_vi_string(self, attribute, value):
169+ repeated_capability = ','.join(self._current_repeated_capability_list)
170+ self._session._interpreter.set_attribute_vi_string(repeated_capability, attribute, value)
171+ % endfor
172+ % else :
94173class _RepeatedCapabilities(object):
95174 def __init__(self, session, prefix, current_repeated_capability_list):
96175 self._session = session
0 commit comments