-
Notifications
You must be signed in to change notification settings - Fork 162
/
Copy path_ai_channel_collection.py.mako
60 lines (50 loc) · 2.1 KB
/
_ai_channel_collection.py.mako
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<%
from codegen.utilities.text_wrappers import wrap
from codegen.utilities.function_helpers import get_functions, get_enums_used
functions = get_functions(data,"AIChannelCollection")
enums_used = get_enums_used(functions)
%>\
# Do not edit this file; it was automatically generated.
import numpy
from nidaqmx.task.channels._ai_channel import AIChannel
from nidaqmx.task.collections._channel_collection import ChannelCollection
from nidaqmx.utils import unflatten_channel_string
%if enums_used:
from nidaqmx.constants import (
${', '.join([c for c in enums_used]) | wrap(4, 4)})
%endif
class AIChannelCollection(ChannelCollection):
"""
Contains the collection of analog input channels for a DAQmx Task.
"""
def __init__(self, task_handle, interpreter):
"""
Do not construct this object directly; instead, construct a nidaqmx.Task and use the task.ai_channels property.
"""
super().__init__(task_handle, interpreter)
def _create_chan(self, physical_channel, name_to_assign_to_channel=''):
"""
Creates and returns an AIChannel object.
Args:
physical_channel (str): Specifies the names of the physical
channels to use to create virtual channels.
name_to_assign_to_channel (Optional[str]): Specifies a name to
assign to the virtual channel this method creates.
Returns:
nidaqmx.task.channels.AIChannel:
Specifies the newly created AIChannel object.
"""
if name_to_assign_to_channel:
num_channels = len(unflatten_channel_string(physical_channel))
if num_channels > 1:
name = '{}0:{}'.format(
name_to_assign_to_channel, num_channels-1)
else:
name = name_to_assign_to_channel
else:
name = physical_channel
return AIChannel(self._handle, name, self._interpreter)
<%namespace name="function_template" file="/function_template.py.mako"/>\
%for function_object in functions:
${function_template.script_function(function_object)}
%endfor