From a14dcf586f9398728ec67e1e8d66f907e56fb1a4 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 18:47:57 -0500 Subject: [PATCH 01/13] rename system collections and add alias --- .../nidaqmx/system/collections/__init__.py | 8 + .../system/collections/_device_collection.py | 0 .../_persisted_channel_collection.py | 0 .../_persisted_scale_collection.py | 0 .../collections/_persisted_task_collection.py | 0 .../_physical_channel_collection.py | 0 .../system/_collections/__init__.py | 0 .../system/collections/__init__.py | 8 + .../system/collections/_device_collection.py | 94 ++++++++ .../_persisted_channel_collection.py | 95 ++++++++ .../_persisted_scale_collection.py | 94 ++++++++ .../collections/_persisted_task_collection.py | 93 ++++++++ .../_physical_channel_collection.py | 210 ++++++++++++++++++ 13 files changed, 602 insertions(+) create mode 100644 generated/nidaqmx/system/collections/__init__.py rename src/handwritten/system/_collections/device_collection.py => generated/nidaqmx/system/collections/_device_collection.py (100%) rename src/handwritten/system/_collections/persisted_channel_collection.py => generated/nidaqmx/system/collections/_persisted_channel_collection.py (100%) rename src/handwritten/system/_collections/persisted_scale_collection.py => generated/nidaqmx/system/collections/_persisted_scale_collection.py (100%) rename src/handwritten/system/_collections/persisted_task_collection.py => generated/nidaqmx/system/collections/_persisted_task_collection.py (100%) rename src/handwritten/system/_collections/physical_channel_collection.py => generated/nidaqmx/system/collections/_physical_channel_collection.py (100%) delete mode 100644 src/handwritten/system/_collections/__init__.py create mode 100644 src/handwritten/system/collections/__init__.py create mode 100644 src/handwritten/system/collections/_device_collection.py create mode 100644 src/handwritten/system/collections/_persisted_channel_collection.py create mode 100644 src/handwritten/system/collections/_persisted_scale_collection.py create mode 100644 src/handwritten/system/collections/_persisted_task_collection.py create mode 100644 src/handwritten/system/collections/_physical_channel_collection.py diff --git a/generated/nidaqmx/system/collections/__init__.py b/generated/nidaqmx/system/collections/__init__.py new file mode 100644 index 000000000..ce1ae1513 --- /dev/null +++ b/generated/nidaqmx/system/collections/__init__.py @@ -0,0 +1,8 @@ + +from nidaqmx.system.collections._device_collection import DeviceCollection +from nidaqmx.system.collections._persisted_channel_collection import PersistedChannelCollection +from nidaqmx.system.collections._persisted_scale_collection import PersistedScaleCollection +from nidaqmx.system.collections._persisted_task_collection import PersistedTaskCollection +from nidaqmx.system.collections._physical_channel_collection import PhysicalChannelCollection + +__all__ = ['DeviceCollection', 'PersistedChannelCollection', 'PersistedScaleCollection', 'PersistedTaskCollection', 'PhysicalChannelCollection'] \ No newline at end of file diff --git a/src/handwritten/system/_collections/device_collection.py b/generated/nidaqmx/system/collections/_device_collection.py similarity index 100% rename from src/handwritten/system/_collections/device_collection.py rename to generated/nidaqmx/system/collections/_device_collection.py diff --git a/src/handwritten/system/_collections/persisted_channel_collection.py b/generated/nidaqmx/system/collections/_persisted_channel_collection.py similarity index 100% rename from src/handwritten/system/_collections/persisted_channel_collection.py rename to generated/nidaqmx/system/collections/_persisted_channel_collection.py diff --git a/src/handwritten/system/_collections/persisted_scale_collection.py b/generated/nidaqmx/system/collections/_persisted_scale_collection.py similarity index 100% rename from src/handwritten/system/_collections/persisted_scale_collection.py rename to generated/nidaqmx/system/collections/_persisted_scale_collection.py diff --git a/src/handwritten/system/_collections/persisted_task_collection.py b/generated/nidaqmx/system/collections/_persisted_task_collection.py similarity index 100% rename from src/handwritten/system/_collections/persisted_task_collection.py rename to generated/nidaqmx/system/collections/_persisted_task_collection.py diff --git a/src/handwritten/system/_collections/physical_channel_collection.py b/generated/nidaqmx/system/collections/_physical_channel_collection.py similarity index 100% rename from src/handwritten/system/_collections/physical_channel_collection.py rename to generated/nidaqmx/system/collections/_physical_channel_collection.py diff --git a/src/handwritten/system/_collections/__init__.py b/src/handwritten/system/_collections/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/handwritten/system/collections/__init__.py b/src/handwritten/system/collections/__init__.py new file mode 100644 index 000000000..ce1ae1513 --- /dev/null +++ b/src/handwritten/system/collections/__init__.py @@ -0,0 +1,8 @@ + +from nidaqmx.system.collections._device_collection import DeviceCollection +from nidaqmx.system.collections._persisted_channel_collection import PersistedChannelCollection +from nidaqmx.system.collections._persisted_scale_collection import PersistedScaleCollection +from nidaqmx.system.collections._persisted_task_collection import PersistedTaskCollection +from nidaqmx.system.collections._physical_channel_collection import PhysicalChannelCollection + +__all__ = ['DeviceCollection', 'PersistedChannelCollection', 'PersistedScaleCollection', 'PersistedTaskCollection', 'PhysicalChannelCollection'] \ No newline at end of file diff --git a/src/handwritten/system/collections/_device_collection.py b/src/handwritten/system/collections/_device_collection.py new file mode 100644 index 000000000..01262ee32 --- /dev/null +++ b/src/handwritten/system/collections/_device_collection.py @@ -0,0 +1,94 @@ +from collections.abc import Sequence + +from nidaqmx.errors import DaqError +from nidaqmx.error_codes import DAQmxErrors +from nidaqmx.system.device import Device, _DeviceAlternateConstructor +from nidaqmx.utils import unflatten_channel_string + + +class DeviceCollection(Sequence): + """ + Contains the collection of devices for a DAQmx system. + + This class defines methods that implements a container object. + """ + def __init__(self, interpreter): + """ + Do not construct this object directly; instead, call nidaqmx.system.System.local().devices. + """ + self._interpreter = interpreter + + def __contains__(self, item): + device_names = self.device_names + + if isinstance(item, str): + items = unflatten_channel_string(item) + return all([i in device_names for i in items]) + elif isinstance(item, Device): + return item.name in device_names + return False + + def __eq__(self, other): + if isinstance(other, self.__class__): + return True + return False + + def __getitem__(self, index): + """ + Indexes a subset of devices on this device collection. + + Args: + index: The value of the index. The following index types are + supported: + - str: Name of the device. You also can specify a string + that contains a list or range of names to this input. + If you have a list of names, use the DAQmx Flatten + Channel String function to convert the list to a + string. + - int: Index/position of the device in the collection. + - slice: Range of the indexes/positions of devices in the + collection. + Returns: + List[nidaqmx.system.device.Device]: + + Indicates the subset of devices indexed. + """ + if isinstance(index, int): + return _DeviceAlternateConstructor(self.device_names[index], self._interpreter) + elif isinstance(index, slice): + return [_DeviceAlternateConstructor(name, self._interpreter) for name in self.device_names[index]] + elif isinstance(index, str): + device_names = unflatten_channel_string(index) + if len(device_names) == 1: + return _DeviceAlternateConstructor(device_names[0], self._interpreter) + return [_DeviceAlternateConstructor(name, self._interpreter) for name in device_names] + else: + raise DaqError( + 'Invalid index type "{}" used to access collection.' + .format(type(index)), DAQmxErrors.UNKNOWN) + + def __iter__(self): + for device_name in self.device_names: + yield _DeviceAlternateConstructor(device_name, self._interpreter) + + def __len__(self): + return len(self.device_names) + + def __ne__(self, other): + return not self.__eq__(other) + + def __reversed__(self): + device_names = self.device_names + device_names.reverse() + + for device_name in device_names: + yield _DeviceAlternateConstructor(device_name, self._interpreter) + + @property + def device_names(self): + """ + List[str]: Indicates the names of all devices on this device + collection. + """ + val = self._interpreter.get_system_info_attribute_string(0x193b) + return unflatten_channel_string(val) diff --git a/src/handwritten/system/collections/_persisted_channel_collection.py b/src/handwritten/system/collections/_persisted_channel_collection.py new file mode 100644 index 000000000..d389a5f84 --- /dev/null +++ b/src/handwritten/system/collections/_persisted_channel_collection.py @@ -0,0 +1,95 @@ +from collections.abc import Sequence + +from nidaqmx.errors import DaqError +from nidaqmx.error_codes import DAQmxErrors +from nidaqmx.system.storage.persisted_channel import PersistedChannel, _PersistedChannelAlternateConstructor +from nidaqmx.utils import unflatten_channel_string + +class PersistedChannelCollection(Sequence): + """ + Contains the collection of global channels for a DAQmx system. + + This class defines methods that implements a container object. + """ + def __init__(self, interpreter): + """ + Do not construct this object directly; instead, call nidaqmx.system.System.local().global_channels. + """ + self._interpreter = interpreter + + def __contains__(self, item): + channel_names = self.global_channel_names + + if isinstance(item, str): + items = unflatten_channel_string(item) + return all([i in channel_names for i in items]) + elif isinstance(item, PersistedChannel): + return item._name in channel_names + + def __eq__(self, other): + if isinstance(other, self.__class__): + return True + return False + + def __getitem__(self, index): + """ + Indexes a subset of global channels on this global channel + collection. + + Args: + index: The value of the index. The following index types + are supported: + - str: Name of the global channel. You also can specify + a string that contains a list or range of names to + this input. If you have a list of names, use the + DAQmx Flatten Channel String function to convert + the list to a string. + - int: Index/position of the global channel in the + collection. + - slice: Range of the indexes/positions of global + channels in the collection. + Returns: + List[nidaqmx.system.storage.persisted_channel.PersistedChannel]: + + Indicates the of global channels indexed. + """ + if isinstance(index, int): + return _PersistedChannelAlternateConstructor(self.global_channel_names[index], self._interpreter) + elif isinstance(index, slice): + return [_PersistedChannelAlternateConstructor(name, self._interpreter) for name in + self.global_channel_names[index]] + elif isinstance(index, str): + names = unflatten_channel_string(index) + if len(names) == 1: + return _PersistedChannelAlternateConstructor(names[0], self._interpreter) + return [_PersistedChannelAlternateConstructor(name, self._interpreter) for name in names] + else: + raise DaqError( + 'Invalid index type "{}" used to access collection.' + .format(type(index)), DAQmxErrors.UNKNOWN) + + def __iter__(self): + for channel_name in self.global_channel_names: + yield _PersistedChannelAlternateConstructor(channel_name, self._interpreter) + + def __len__(self): + return len(self.global_channel_names) + + def __ne__(self, other): + return not self.__eq__(other) + + def __reversed__(self): + channel_names = self.global_channel_names + channel_names.reverse() + + for channel_name in channel_names: + yield _PersistedChannelAlternateConstructor(channel_name, self._interpreter) + + @property + def global_channel_names(self): + """ + List[str]: The names of all the global channels on this + collection. + """ + val = self._interpreter.get_system_info_attribute_string(0x1265) + return unflatten_channel_string(val) diff --git a/src/handwritten/system/collections/_persisted_scale_collection.py b/src/handwritten/system/collections/_persisted_scale_collection.py new file mode 100644 index 000000000..bdbcc5adb --- /dev/null +++ b/src/handwritten/system/collections/_persisted_scale_collection.py @@ -0,0 +1,94 @@ +from collections.abc import Sequence + +from nidaqmx.errors import DaqError +from nidaqmx.error_codes import DAQmxErrors +from nidaqmx.system.storage.persisted_scale import PersistedScale, _PersistedScaleAlternateConstructor +from nidaqmx.utils import unflatten_channel_string + +class PersistedScaleCollection(Sequence): + """ + Contains the collection of custom scales on a DAQmx system. + + This class defines methods that implements a container object. + """ + def __init__(self, interpreter): + """ + Do not construct this object directly; instead, call nidaqmx.system.System.local().scales. + """ + self._interpreter = interpreter + + def __contains__(self, item): + scale_names = self.scale_names + + if isinstance(item, str): + items = unflatten_channel_string(item) + return all([i in scale_names for i in items]) + elif isinstance(item, PersistedScale): + return item._name in scale_names + + def __eq__(self, other): + if isinstance(other, self.__class__): + return True + return False + + def __getitem__(self, index): + """ + Indexes a subset of custom scales on this collection. + + Args: + index: The value of the index. The following index types + are supported: + - str: Name of the custom scale. You also can specify + a string that contains a list or range of names to + this input. If you have a list of names, use the + DAQmx Flatten Channel String function to convert + the list to a string. + - int: Index/position of the custom scale in the + collection. + - slice: Range of the indexes/positions of custom scales + in the collection. + Returns: + List[nidaqmx.system.storage.persisted_scale.PersistedScale]: + + Indicates the subset of custom scales indexed. + """ + if isinstance(index, int): + return _PersistedScaleAlternateConstructor(self.scale_names[index], self._interpreter) + elif isinstance(index, slice): + return [_PersistedScaleAlternateConstructor(name, self._interpreter) for name in + self.scale_names[index]] + elif isinstance(index, str): + names = unflatten_channel_string(index) + if len(names) == 1: + return _PersistedScaleAlternateConstructor(names[0], self._interpreter) + return [_PersistedScaleAlternateConstructor(name, self._interpreter) for name in names] + else: + raise DaqError( + 'Invalid index type "{}" used to access collection.' + .format(type(index)), DAQmxErrors.UNKNOWN) + + def __iter__(self): + for scale_name in self.scale_names: + yield _PersistedScaleAlternateConstructor(scale_name, self._interpreter) + + def __len__(self): + return len(self.scale_names) + + def __ne__(self, other): + return not self.__eq__(other) + + def __reversed__(self): + scale_names = self.scale_names + scale_names.reverse() + + for scale_name in scale_names: + yield _PersistedScaleAlternateConstructor(scale_name, self._interpreter) + + @property + def scale_names(self): + """ + List[str]: Indicates the names of all the custom scales on this + collection. + """ + val = self._interpreter.get_system_info_attribute_string(0x1266) + return unflatten_channel_string(val) diff --git a/src/handwritten/system/collections/_persisted_task_collection.py b/src/handwritten/system/collections/_persisted_task_collection.py new file mode 100644 index 000000000..5d0adea4c --- /dev/null +++ b/src/handwritten/system/collections/_persisted_task_collection.py @@ -0,0 +1,93 @@ +from collections.abc import Sequence + +from nidaqmx.errors import DaqError +from nidaqmx.error_codes import DAQmxErrors +from nidaqmx.system.storage.persisted_task import PersistedTask, _PersistedTaskAlternateConstructor +from nidaqmx.utils import unflatten_channel_string + +class PersistedTaskCollection(Sequence): + """ + Contains the collection of task saved on a DAQmx system. + + This class defines methods that implements a container object. + """ + def __init__(self, interpreter): + """ + Do not construct this object directly; instead, call nidaqmx.system.System.local().tasks. + """ + self._interpreter = interpreter + + def __contains__(self, item): + task_names = self.task_names + + if isinstance(item, str): + items = unflatten_channel_string(item) + return all([i in task_names for i in items]) + elif isinstance(item, PersistedTask): + return item._name in task_names + + def __eq__(self, other): + if isinstance(other, self.__class__): + return True + return False + + def __getitem__(self, index): + """ + Indexes a subset of saved tasks on this collection. + + Args: + index: The value of the index. The following index types + are supported: + - str: Name of the saved task. You also can specify + a string that contains a list or range of names to + this input. If you have a list of names, use the + DAQmx Flatten Channel String function to convert + the list to a string. + - int: Index/position of the saved task in the + collection. + - slice: Range of the indexes/positions of saved tasks + in the collection. + Returns: + List[nidaqmx.system.storage.persisted_task.PersistedTask]: + + Indicates the subset of saved tasks indexed. + """ + if isinstance(index, int): + return _PersistedTaskAlternateConstructor(self.task_names[index], self._interpreter) + elif isinstance(index, slice): + return [_PersistedTaskAlternateConstructor(name, self._interpreter) for name in + self.task_names[index]] + elif isinstance(index, str): + names = unflatten_channel_string(index) + if len(names) == 1: + return _PersistedTaskAlternateConstructor(names[0], self._interpreter) + return [_PersistedTaskAlternateConstructor(name, self._interpreter) for name in names] + else: + raise DaqError( + 'Invalid index type "{}" used to access collection.' + .format(type(index)), DAQmxErrors.UNKNOWN) + + def __iter__(self): + for task_name in self.task_names: + yield _PersistedTaskAlternateConstructor(task_name, self._interpreter) + + def __len__(self): + return len(self.task_names) + + def __ne__(self, other): + return not self.__eq__(other) + + def __reversed__(self): + task_names = self.task_names + task_names.reverse() + + for task_name in task_names: + yield _PersistedTaskAlternateConstructor(task_name, self._interpreter) + + @property + def task_names(self): + """ + List[str]: Indicates the names of all the tasks on this collection. + """ + val = self._interpreter.get_system_info_attribute_string(0x1267) + return unflatten_channel_string(val) diff --git a/src/handwritten/system/collections/_physical_channel_collection.py b/src/handwritten/system/collections/_physical_channel_collection.py new file mode 100644 index 000000000..8e5c27d01 --- /dev/null +++ b/src/handwritten/system/collections/_physical_channel_collection.py @@ -0,0 +1,210 @@ +from collections.abc import Sequence + +from nidaqmx.errors import DaqError +from nidaqmx.error_codes import DAQmxErrors +from nidaqmx.system.physical_channel import PhysicalChannel, _PhysicalChannelAlternateConstructor +from nidaqmx.utils import unflatten_channel_string, flatten_channel_string + +class PhysicalChannelCollection(Sequence): + """ + Contains the collection of physical channels for a DAQmx device. + + This class defines methods that implements a container object. + """ + def __init__(self, device_name, interpreter): + """ + Do not construct this object directly; instead, construct a nidaqmx.system.Device and use the appropriate property, such as device.ai_physical_channels. + """ + self._name = device_name + self._interpreter = interpreter + + def __contains__(self, item): + channel_names = self.channel_names + + if isinstance(item, str): + items = unflatten_channel_string(item) + return all([i in channel_names for i in items]) + elif isinstance(item, PhysicalChannel): + return item._name in channel_names + return False + + def __eq__(self, other): + if isinstance(other, self.__class__): + return self._name == other._name + return False + + def __getitem__(self, index): + """ + Indexes a subset of physical channels on this physical channel + collection. + + Args: + index: The value of the index. The following index types + are supported: + - str: Name of the physical channel, without the + device name prefix, e.g. 'ai0'. You also can + specify a string that contains a list or range of + names to this input. If you have a list of names, + use the DAQmx Flatten Channel String function to + convert the list to a string. + - int: Index/position of the physical channel in the + collection. + - slice: Range of the indexes/positions of physical + channels in the collection. + Returns: + nidaqmx.system.physical_channel.PhysicalChannel: + + Indicates the subset of physical channels indexed. + """ + if isinstance(index, int): + return _PhysicalChannelAlternateConstructor(self.channel_names[index], self._interpreter) + elif isinstance(index, slice): + return _PhysicalChannelAlternateConstructor(self.channel_names[index], self._interpreter) + elif isinstance(index, str): + return _PhysicalChannelAlternateConstructor(f'{self._name}/{index}', self._interpreter) + else: + raise DaqError( + 'Invalid index type "{}" used to access collection.' + .format(type(index)), DAQmxErrors.UNKNOWN) + + def __iter__(self): + for channel_name in self.channel_names: + yield _PhysicalChannelAlternateConstructor(channel_name, self._interpreter) + + def __len__(self): + return len(self.channel_names) + + def __ne__(self, other): + return not self.__eq__(other) + + def __reversed__(self): + channel_names = self.channel_names + channel_names.reverse() + + for channel_name in channel_names: + yield _PhysicalChannelAlternateConstructor(channel_name, self._interpreter) + + @property + def all(self): + """ + nidaqmx.system.physical_channel.PhysicalChannel: Specifies a + physical channel object that represents the entire list of + physical channels on this channel collection. + """ + return _PhysicalChannelAlternateConstructor(flatten_channel_string(self.channel_names), self._interpreter) + + @property + def channel_names(self): + """ + List[str]: Specifies the entire list of physical channels on this + collection. + """ + raise NotImplementedError() + + +class AIPhysicalChannelCollection(PhysicalChannelCollection): + """ + Contains the collection of analog input physical channels for a + DAQmx device. + + This class defines methods that implements a container object. + """ + + @property + def channel_names(self): + val = self._interpreter.get_device_attribute_string(self._name, 0x231e) + return unflatten_channel_string(val) + + +class AOPhysicalChannelCollection(PhysicalChannelCollection): + """ + Contains the collection of analog output physical channels for a + DAQmx device. + + This class defines methods that implements a container object. + """ + + @property + def channel_names(self): + val = self._interpreter.get_device_attribute_string(self._name, 0x231f) + return unflatten_channel_string(val) + + +class CIPhysicalChannelCollection(PhysicalChannelCollection): + """ + Contains the collection of counter input physical channels for a + DAQmx device. + + This class defines methods that implements a container object. + """ + + @property + def channel_names(self): + val = self._interpreter.get_device_attribute_string(self._name, 0x2324) + return unflatten_channel_string(val) + + +class COPhysicalChannelCollection(PhysicalChannelCollection): + """ + Contains the collection of counter output physical channels for a + DAQmx device. + + This class defines methods that implements a container object. + """ + + @property + def channel_names(self): + val = self._interpreter.get_device_attribute_string(self._name, 0x2325) + return unflatten_channel_string(val) + + +class DILinesCollection(PhysicalChannelCollection): + """ + Contains the collection of digital input lines for a DAQmx device. + + This class defines methods that implements a container object. + """ + + @property + def channel_names(self): + val = self._interpreter.get_device_attribute_string(self._name, 0x2320) + return unflatten_channel_string(val) + + +class DOLinesCollection(PhysicalChannelCollection): + """ + Contains the collection of digital output lines for a DAQmx device. + + This class defines methods that implements a container object. + """ + + @property + def channel_names(self): + val = self._interpreter.get_device_attribute_string(self._name, 0x2322) + return unflatten_channel_string(val) + + +class DIPortsCollection(PhysicalChannelCollection): + """ + Contains the collection of digital input ports for a DAQmx device. + + This class defines methods that implements a container object. + """ + + @property + def channel_names(self): + val = self._interpreter.get_device_attribute_string(self._name, 0x2321) + return unflatten_channel_string(val) + + +class DOPortsCollection(PhysicalChannelCollection): + """ + Contains the collection of digital output ports for a DAQmx device. + + This class defines methods that implements a container object. + """ + + @property + def channel_names(self): + val = self._interpreter.get_device_attribute_string(self._name, 0x2323) + return unflatten_channel_string(val) From 6bacb6f29c275115ebb5931a9b12785df84ad23c Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 18:55:33 -0500 Subject: [PATCH 02/13] update docs --- docs/collections.rst | 12 +++++------- docs/device_collection.rst | 6 ------ docs/persisted_channel_collection.rst | 6 ------ docs/persisted_scale_collection.rst | 6 ------ docs/persisted_task_collection.rst | 6 ------ docs/physical_channel_collection.rst | 6 ------ 6 files changed, 5 insertions(+), 37 deletions(-) delete mode 100644 docs/device_collection.rst delete mode 100644 docs/persisted_channel_collection.rst delete mode 100644 docs/persisted_scale_collection.rst delete mode 100644 docs/persisted_task_collection.rst delete mode 100644 docs/physical_channel_collection.rst diff --git a/docs/collections.rst b/docs/collections.rst index 1a53b1216..d7a5fd79c 100644 --- a/docs/collections.rst +++ b/docs/collections.rst @@ -1,10 +1,8 @@ nidaqmx.system.collections ========================== -.. toctree:: - - device_collection - persisted_channel_collection - persisted_scale_collection - persisted_task_collection - physical_channel_collection +.. automodule:: nidaqmx.system.collections + :members: + :show-inheritance: + :member-order: bysource + diff --git a/docs/device_collection.rst b/docs/device_collection.rst deleted file mode 100644 index 889aec74a..000000000 --- a/docs/device_collection.rst +++ /dev/null @@ -1,6 +0,0 @@ -nidaqmx.system.device_collection -================================ - -.. automodule:: nidaqmx.system._collections.device_collection - :members: - :show-inheritance: diff --git a/docs/persisted_channel_collection.rst b/docs/persisted_channel_collection.rst deleted file mode 100644 index ab7aef52f..000000000 --- a/docs/persisted_channel_collection.rst +++ /dev/null @@ -1,6 +0,0 @@ -nidaqmx.system.persisted_channel_collection -=========================================== - -.. automodule:: nidaqmx.system._collections.persisted_channel_collection - :members: - :show-inheritance: diff --git a/docs/persisted_scale_collection.rst b/docs/persisted_scale_collection.rst deleted file mode 100644 index e6ad24971..000000000 --- a/docs/persisted_scale_collection.rst +++ /dev/null @@ -1,6 +0,0 @@ -nidaqmx.system.persisted_scale_collection -========================================= - -.. automodule:: nidaqmx.system._collections.persisted_scale_collection - :members: - :show-inheritance: diff --git a/docs/persisted_task_collection.rst b/docs/persisted_task_collection.rst deleted file mode 100644 index ce1a0c6cb..000000000 --- a/docs/persisted_task_collection.rst +++ /dev/null @@ -1,6 +0,0 @@ -nidaqmx.system.persisted_task_collection -======================================== - -.. automodule:: nidaqmx.system._collections.persisted_task_collection - :members: - :show-inheritance: diff --git a/docs/physical_channel_collection.rst b/docs/physical_channel_collection.rst deleted file mode 100644 index eade825f6..000000000 --- a/docs/physical_channel_collection.rst +++ /dev/null @@ -1,6 +0,0 @@ -nidaqmx.system.physical_channel_collection -========================================== - -.. automodule:: nidaqmx.system._collections.physical_channel_collection - :members: - :show-inheritance: From 4f11269927d54fab5470d3ffbe14c6e6bdda7271 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 19:16:45 -0500 Subject: [PATCH 03/13] update init --- generated/nidaqmx/system/collections/__init__.py | 8 ++++++-- src/handwritten/system/collections/__init__.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/generated/nidaqmx/system/collections/__init__.py b/generated/nidaqmx/system/collections/__init__.py index ce1ae1513..e5645280e 100644 --- a/generated/nidaqmx/system/collections/__init__.py +++ b/generated/nidaqmx/system/collections/__init__.py @@ -3,6 +3,10 @@ from nidaqmx.system.collections._persisted_channel_collection import PersistedChannelCollection from nidaqmx.system.collections._persisted_scale_collection import PersistedScaleCollection from nidaqmx.system.collections._persisted_task_collection import PersistedTaskCollection -from nidaqmx.system.collections._physical_channel_collection import PhysicalChannelCollection +from nidaqmx.system.collections._physical_channel_collection import ( + PhysicalChannelCollection, AIPhysicalChannelCollection, AOPhysicalChannelCollection, + CIPhysicalChannelCollection, COPhysicalChannelCollection, DILinesCollection, + DOLinesCollection, DIPortsCollection, DOPortsCollection +) -__all__ = ['DeviceCollection', 'PersistedChannelCollection', 'PersistedScaleCollection', 'PersistedTaskCollection', 'PhysicalChannelCollection'] \ No newline at end of file +__all__ = ['DeviceCollection', 'PersistedChannelCollection', 'PersistedScaleCollection', 'PersistedTaskCollection', 'PhysicalChannelCollection', 'AIPhysicalChannelCollection', 'AOPhysicalChannelCollection', 'CIPhysicalChannelCollection', 'COPhysicalChannelCollection', 'DILinesCollection', 'DOLinesCollection', 'DIPortsCollection', 'DOPortsCollection',] \ No newline at end of file diff --git a/src/handwritten/system/collections/__init__.py b/src/handwritten/system/collections/__init__.py index ce1ae1513..e5645280e 100644 --- a/src/handwritten/system/collections/__init__.py +++ b/src/handwritten/system/collections/__init__.py @@ -3,6 +3,10 @@ from nidaqmx.system.collections._persisted_channel_collection import PersistedChannelCollection from nidaqmx.system.collections._persisted_scale_collection import PersistedScaleCollection from nidaqmx.system.collections._persisted_task_collection import PersistedTaskCollection -from nidaqmx.system.collections._physical_channel_collection import PhysicalChannelCollection +from nidaqmx.system.collections._physical_channel_collection import ( + PhysicalChannelCollection, AIPhysicalChannelCollection, AOPhysicalChannelCollection, + CIPhysicalChannelCollection, COPhysicalChannelCollection, DILinesCollection, + DOLinesCollection, DIPortsCollection, DOPortsCollection +) -__all__ = ['DeviceCollection', 'PersistedChannelCollection', 'PersistedScaleCollection', 'PersistedTaskCollection', 'PhysicalChannelCollection'] \ No newline at end of file +__all__ = ['DeviceCollection', 'PersistedChannelCollection', 'PersistedScaleCollection', 'PersistedTaskCollection', 'PhysicalChannelCollection', 'AIPhysicalChannelCollection', 'AOPhysicalChannelCollection', 'CIPhysicalChannelCollection', 'COPhysicalChannelCollection', 'DILinesCollection', 'DOLinesCollection', 'DIPortsCollection', 'DOPortsCollection',] \ No newline at end of file From c4f1c404325511647a91b4e4b2ed356d85ddd032 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 19:18:38 -0500 Subject: [PATCH 04/13] update imports and docs --- generated/nidaqmx/system/device.py | 18 +++++++++--------- generated/nidaqmx/system/system.py | 16 ++++++++-------- src/codegen/templates/system/device.py.mako | 18 +++++++++--------- src/codegen/templates/system/system.py.mako | 16 ++++++++-------- tests/legacy/test_system_collections.py | 10 ++-------- 5 files changed, 36 insertions(+), 42 deletions(-) diff --git a/generated/nidaqmx/system/device.py b/generated/nidaqmx/system/device.py index 9961ce636..bf51aff63 100644 --- a/generated/nidaqmx/system/device.py +++ b/generated/nidaqmx/system/device.py @@ -6,7 +6,7 @@ from nidaqmx import utils from nidaqmx._bitfield_utils import enum_bitfield_to_list from nidaqmx.utils import unflatten_channel_string -from nidaqmx.system._collections.physical_channel_collection import ( +from nidaqmx.system.collections._physical_channel_collection import ( AIPhysicalChannelCollection, AOPhysicalChannelCollection, CIPhysicalChannelCollection, COPhysicalChannelCollection, DILinesCollection, DIPortsCollection, DOLinesCollection, DOPortsCollection) @@ -60,7 +60,7 @@ def name(self): @property def ai_physical_chans(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the analog input physical channels available on the device. """ @@ -69,7 +69,7 @@ def ai_physical_chans(self): @property def ao_physical_chans(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the analog output physical channels available on the device. """ @@ -78,7 +78,7 @@ def ao_physical_chans(self): @property def ci_physical_chans(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the counter input physical channels available on the device. """ @@ -87,7 +87,7 @@ def ci_physical_chans(self): @property def co_physical_chans(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the counter output physical channels available on the device. """ @@ -96,7 +96,7 @@ def co_physical_chans(self): @property def di_lines(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the digital input lines available on the device. """ @@ -105,7 +105,7 @@ def di_lines(self): @property def di_ports(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the digital input ports available on the device. """ @@ -114,7 +114,7 @@ def di_ports(self): @property def do_lines(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the digital output lines available on the device. """ @@ -123,7 +123,7 @@ def do_lines(self): @property def do_ports(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the digital output ports available on the device. """ diff --git a/generated/nidaqmx/system/system.py b/generated/nidaqmx/system/system.py index c2489899b..12857fbd7 100644 --- a/generated/nidaqmx/system/system.py +++ b/generated/nidaqmx/system/system.py @@ -6,12 +6,12 @@ import numpy from nidaqmx import utils -from nidaqmx.system._collections.device_collection import DeviceCollection -from nidaqmx.system._collections.persisted_channel_collection import ( +from nidaqmx.system.collections._device_collection import DeviceCollection +from nidaqmx.system.collections._persisted_channel_collection import ( PersistedChannelCollection) -from nidaqmx.system._collections.persisted_scale_collection import ( +from nidaqmx.system.collections._persisted_scale_collection import ( PersistedScaleCollection) -from nidaqmx.system._collections.persisted_task_collection import ( +from nidaqmx.system.collections._persisted_task_collection import ( PersistedTaskCollection) from nidaqmx.utils import flatten_channel_string, unflatten_channel_string from nidaqmx.constants import ( @@ -63,7 +63,7 @@ def remote(grpc_options): @property def devices(self): """ - nidaqmx.system._collections.DeviceCollection: Indicates the + nidaqmx.system.collections.DeviceCollection: Indicates the collection of devices for this DAQmx system. """ return DeviceCollection(self._interpreter) @@ -92,7 +92,7 @@ def driver_version(self): @property def global_channels(self): """ - nidaqmx.system._collections.PersistedChannelCollection: Indicates + nidaqmx.system.collections.PersistedChannelCollection: Indicates the collection of global channels for this DAQmx system. """ return PersistedChannelCollection(self._interpreter) @@ -100,7 +100,7 @@ def global_channels(self): @property def scales(self): """ - nidaqmx.system._collections.PersistedScaleCollection: Indicates + nidaqmx.system.collections.PersistedScaleCollection: Indicates the collection of custom scales for this DAQmx system. """ return PersistedScaleCollection(self._interpreter) @@ -108,7 +108,7 @@ def scales(self): @property def tasks(self): """ - nidaqmx.system._collections.PersistedTaskCollection: Indicates + nidaqmx.system.collections.PersistedTaskCollection: Indicates the collection of saved tasks for this DAQmx system. """ return PersistedTaskCollection(self._interpreter) diff --git a/src/codegen/templates/system/device.py.mako b/src/codegen/templates/system/device.py.mako index 7b817f217..cee605d50 100644 --- a/src/codegen/templates/system/device.py.mako +++ b/src/codegen/templates/system/device.py.mako @@ -15,7 +15,7 @@ from datetime import datetime from nidaqmx import utils from nidaqmx._bitfield_utils import enum_bitfield_to_list from nidaqmx.utils import unflatten_channel_string -from nidaqmx.system._collections.physical_channel_collection import ( +from nidaqmx.system.collections._physical_channel_collection import ( AIPhysicalChannelCollection, AOPhysicalChannelCollection, CIPhysicalChannelCollection, COPhysicalChannelCollection, DILinesCollection, DIPortsCollection, DOLinesCollection, DOPortsCollection) @@ -69,7 +69,7 @@ class Device: @property def ai_physical_chans(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the analog input physical channels available on the device. """ @@ -78,7 +78,7 @@ class Device: @property def ao_physical_chans(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the analog output physical channels available on the device. """ @@ -87,7 +87,7 @@ class Device: @property def ci_physical_chans(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the counter input physical channels available on the device. """ @@ -96,7 +96,7 @@ class Device: @property def co_physical_chans(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the counter output physical channels available on the device. """ @@ -105,7 +105,7 @@ class Device: @property def di_lines(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the digital input lines available on the device. """ @@ -114,7 +114,7 @@ class Device: @property def di_ports(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the digital input ports available on the device. """ @@ -123,7 +123,7 @@ class Device: @property def do_lines(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the digital output lines available on the device. """ @@ -132,7 +132,7 @@ class Device: @property def do_ports(self): """ - List[nidaqmx.system._collections.PhysicalChannelCollection]: + List[nidaqmx.system.collections.PhysicalChannelCollection]: Indicates a collection that contains all the digital output ports available on the device. """ diff --git a/src/codegen/templates/system/system.py.mako b/src/codegen/templates/system/system.py.mako index fe0e2487d..c4a27ecc1 100644 --- a/src/codegen/templates/system/system.py.mako +++ b/src/codegen/templates/system/system.py.mako @@ -13,12 +13,12 @@ import deprecation import numpy from nidaqmx import utils -from nidaqmx.system._collections.device_collection import DeviceCollection -from nidaqmx.system._collections.persisted_channel_collection import ( +from nidaqmx.system.collections._device_collection import DeviceCollection +from nidaqmx.system.collections._persisted_channel_collection import ( PersistedChannelCollection) -from nidaqmx.system._collections.persisted_scale_collection import ( +from nidaqmx.system.collections._persisted_scale_collection import ( PersistedScaleCollection) -from nidaqmx.system._collections.persisted_task_collection import ( +from nidaqmx.system.collections._persisted_task_collection import ( PersistedTaskCollection) from nidaqmx.utils import flatten_channel_string, unflatten_channel_string from nidaqmx.constants import ( @@ -70,7 +70,7 @@ class System: @property def devices(self): """ - nidaqmx.system._collections.DeviceCollection: Indicates the + nidaqmx.system.collections.DeviceCollection: Indicates the collection of devices for this DAQmx system. """ return DeviceCollection(self._interpreter) @@ -99,7 +99,7 @@ class System: @property def global_channels(self): """ - nidaqmx.system._collections.PersistedChannelCollection: Indicates + nidaqmx.system.collections.PersistedChannelCollection: Indicates the collection of global channels for this DAQmx system. """ return PersistedChannelCollection(self._interpreter) @@ -107,7 +107,7 @@ class System: @property def scales(self): """ - nidaqmx.system._collections.PersistedScaleCollection: Indicates + nidaqmx.system.collections.PersistedScaleCollection: Indicates the collection of custom scales for this DAQmx system. """ return PersistedScaleCollection(self._interpreter) @@ -115,7 +115,7 @@ class System: @property def tasks(self): """ - nidaqmx.system._collections.PersistedTaskCollection: Indicates + nidaqmx.system.collections.PersistedTaskCollection: Indicates the collection of saved tasks for this DAQmx system. """ return PersistedTaskCollection(self._interpreter) diff --git a/tests/legacy/test_system_collections.py b/tests/legacy/test_system_collections.py index 453c39a0e..906a47bcd 100644 --- a/tests/legacy/test_system_collections.py +++ b/tests/legacy/test_system_collections.py @@ -4,17 +4,11 @@ import nidaqmx import nidaqmx.system -from nidaqmx.system._collections.device_collection import DeviceCollection -from nidaqmx.system._collections.persisted_channel_collection import ( +from nidaqmx.system.collections import ( + DeviceCollection, PersistedChannelCollection, -) -from nidaqmx.system._collections.persisted_scale_collection import ( PersistedScaleCollection, -) -from nidaqmx.system._collections.persisted_task_collection import ( PersistedTaskCollection, -) -from nidaqmx.system._collections.physical_channel_collection import ( PhysicalChannelCollection, ) From dabc182cd3b15b1bf193f3159ebf716b900893d8 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 19:30:01 -0500 Subject: [PATCH 05/13] delete codegen _collections --- .../nidaqmx/system/_collections/__init__.py | 0 .../system/_collections/device_collection.py | 94 -------- .../persisted_channel_collection.py | 95 -------- .../persisted_scale_collection.py | 94 -------- .../_collections/persisted_task_collection.py | 93 -------- .../physical_channel_collection.py | 210 ------------------ 6 files changed, 586 deletions(-) delete mode 100644 generated/nidaqmx/system/_collections/__init__.py delete mode 100644 generated/nidaqmx/system/_collections/device_collection.py delete mode 100644 generated/nidaqmx/system/_collections/persisted_channel_collection.py delete mode 100644 generated/nidaqmx/system/_collections/persisted_scale_collection.py delete mode 100644 generated/nidaqmx/system/_collections/persisted_task_collection.py delete mode 100644 generated/nidaqmx/system/_collections/physical_channel_collection.py diff --git a/generated/nidaqmx/system/_collections/__init__.py b/generated/nidaqmx/system/_collections/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/generated/nidaqmx/system/_collections/device_collection.py b/generated/nidaqmx/system/_collections/device_collection.py deleted file mode 100644 index 01262ee32..000000000 --- a/generated/nidaqmx/system/_collections/device_collection.py +++ /dev/null @@ -1,94 +0,0 @@ -from collections.abc import Sequence - -from nidaqmx.errors import DaqError -from nidaqmx.error_codes import DAQmxErrors -from nidaqmx.system.device import Device, _DeviceAlternateConstructor -from nidaqmx.utils import unflatten_channel_string - - -class DeviceCollection(Sequence): - """ - Contains the collection of devices for a DAQmx system. - - This class defines methods that implements a container object. - """ - def __init__(self, interpreter): - """ - Do not construct this object directly; instead, call nidaqmx.system.System.local().devices. - """ - self._interpreter = interpreter - - def __contains__(self, item): - device_names = self.device_names - - if isinstance(item, str): - items = unflatten_channel_string(item) - return all([i in device_names for i in items]) - elif isinstance(item, Device): - return item.name in device_names - return False - - def __eq__(self, other): - if isinstance(other, self.__class__): - return True - return False - - def __getitem__(self, index): - """ - Indexes a subset of devices on this device collection. - - Args: - index: The value of the index. The following index types are - supported: - - str: Name of the device. You also can specify a string - that contains a list or range of names to this input. - If you have a list of names, use the DAQmx Flatten - Channel String function to convert the list to a - string. - - int: Index/position of the device in the collection. - - slice: Range of the indexes/positions of devices in the - collection. - Returns: - List[nidaqmx.system.device.Device]: - - Indicates the subset of devices indexed. - """ - if isinstance(index, int): - return _DeviceAlternateConstructor(self.device_names[index], self._interpreter) - elif isinstance(index, slice): - return [_DeviceAlternateConstructor(name, self._interpreter) for name in self.device_names[index]] - elif isinstance(index, str): - device_names = unflatten_channel_string(index) - if len(device_names) == 1: - return _DeviceAlternateConstructor(device_names[0], self._interpreter) - return [_DeviceAlternateConstructor(name, self._interpreter) for name in device_names] - else: - raise DaqError( - 'Invalid index type "{}" used to access collection.' - .format(type(index)), DAQmxErrors.UNKNOWN) - - def __iter__(self): - for device_name in self.device_names: - yield _DeviceAlternateConstructor(device_name, self._interpreter) - - def __len__(self): - return len(self.device_names) - - def __ne__(self, other): - return not self.__eq__(other) - - def __reversed__(self): - device_names = self.device_names - device_names.reverse() - - for device_name in device_names: - yield _DeviceAlternateConstructor(device_name, self._interpreter) - - @property - def device_names(self): - """ - List[str]: Indicates the names of all devices on this device - collection. - """ - val = self._interpreter.get_system_info_attribute_string(0x193b) - return unflatten_channel_string(val) diff --git a/generated/nidaqmx/system/_collections/persisted_channel_collection.py b/generated/nidaqmx/system/_collections/persisted_channel_collection.py deleted file mode 100644 index d389a5f84..000000000 --- a/generated/nidaqmx/system/_collections/persisted_channel_collection.py +++ /dev/null @@ -1,95 +0,0 @@ -from collections.abc import Sequence - -from nidaqmx.errors import DaqError -from nidaqmx.error_codes import DAQmxErrors -from nidaqmx.system.storage.persisted_channel import PersistedChannel, _PersistedChannelAlternateConstructor -from nidaqmx.utils import unflatten_channel_string - -class PersistedChannelCollection(Sequence): - """ - Contains the collection of global channels for a DAQmx system. - - This class defines methods that implements a container object. - """ - def __init__(self, interpreter): - """ - Do not construct this object directly; instead, call nidaqmx.system.System.local().global_channels. - """ - self._interpreter = interpreter - - def __contains__(self, item): - channel_names = self.global_channel_names - - if isinstance(item, str): - items = unflatten_channel_string(item) - return all([i in channel_names for i in items]) - elif isinstance(item, PersistedChannel): - return item._name in channel_names - - def __eq__(self, other): - if isinstance(other, self.__class__): - return True - return False - - def __getitem__(self, index): - """ - Indexes a subset of global channels on this global channel - collection. - - Args: - index: The value of the index. The following index types - are supported: - - str: Name of the global channel. You also can specify - a string that contains a list or range of names to - this input. If you have a list of names, use the - DAQmx Flatten Channel String function to convert - the list to a string. - - int: Index/position of the global channel in the - collection. - - slice: Range of the indexes/positions of global - channels in the collection. - Returns: - List[nidaqmx.system.storage.persisted_channel.PersistedChannel]: - - Indicates the of global channels indexed. - """ - if isinstance(index, int): - return _PersistedChannelAlternateConstructor(self.global_channel_names[index], self._interpreter) - elif isinstance(index, slice): - return [_PersistedChannelAlternateConstructor(name, self._interpreter) for name in - self.global_channel_names[index]] - elif isinstance(index, str): - names = unflatten_channel_string(index) - if len(names) == 1: - return _PersistedChannelAlternateConstructor(names[0], self._interpreter) - return [_PersistedChannelAlternateConstructor(name, self._interpreter) for name in names] - else: - raise DaqError( - 'Invalid index type "{}" used to access collection.' - .format(type(index)), DAQmxErrors.UNKNOWN) - - def __iter__(self): - for channel_name in self.global_channel_names: - yield _PersistedChannelAlternateConstructor(channel_name, self._interpreter) - - def __len__(self): - return len(self.global_channel_names) - - def __ne__(self, other): - return not self.__eq__(other) - - def __reversed__(self): - channel_names = self.global_channel_names - channel_names.reverse() - - for channel_name in channel_names: - yield _PersistedChannelAlternateConstructor(channel_name, self._interpreter) - - @property - def global_channel_names(self): - """ - List[str]: The names of all the global channels on this - collection. - """ - val = self._interpreter.get_system_info_attribute_string(0x1265) - return unflatten_channel_string(val) diff --git a/generated/nidaqmx/system/_collections/persisted_scale_collection.py b/generated/nidaqmx/system/_collections/persisted_scale_collection.py deleted file mode 100644 index bdbcc5adb..000000000 --- a/generated/nidaqmx/system/_collections/persisted_scale_collection.py +++ /dev/null @@ -1,94 +0,0 @@ -from collections.abc import Sequence - -from nidaqmx.errors import DaqError -from nidaqmx.error_codes import DAQmxErrors -from nidaqmx.system.storage.persisted_scale import PersistedScale, _PersistedScaleAlternateConstructor -from nidaqmx.utils import unflatten_channel_string - -class PersistedScaleCollection(Sequence): - """ - Contains the collection of custom scales on a DAQmx system. - - This class defines methods that implements a container object. - """ - def __init__(self, interpreter): - """ - Do not construct this object directly; instead, call nidaqmx.system.System.local().scales. - """ - self._interpreter = interpreter - - def __contains__(self, item): - scale_names = self.scale_names - - if isinstance(item, str): - items = unflatten_channel_string(item) - return all([i in scale_names for i in items]) - elif isinstance(item, PersistedScale): - return item._name in scale_names - - def __eq__(self, other): - if isinstance(other, self.__class__): - return True - return False - - def __getitem__(self, index): - """ - Indexes a subset of custom scales on this collection. - - Args: - index: The value of the index. The following index types - are supported: - - str: Name of the custom scale. You also can specify - a string that contains a list or range of names to - this input. If you have a list of names, use the - DAQmx Flatten Channel String function to convert - the list to a string. - - int: Index/position of the custom scale in the - collection. - - slice: Range of the indexes/positions of custom scales - in the collection. - Returns: - List[nidaqmx.system.storage.persisted_scale.PersistedScale]: - - Indicates the subset of custom scales indexed. - """ - if isinstance(index, int): - return _PersistedScaleAlternateConstructor(self.scale_names[index], self._interpreter) - elif isinstance(index, slice): - return [_PersistedScaleAlternateConstructor(name, self._interpreter) for name in - self.scale_names[index]] - elif isinstance(index, str): - names = unflatten_channel_string(index) - if len(names) == 1: - return _PersistedScaleAlternateConstructor(names[0], self._interpreter) - return [_PersistedScaleAlternateConstructor(name, self._interpreter) for name in names] - else: - raise DaqError( - 'Invalid index type "{}" used to access collection.' - .format(type(index)), DAQmxErrors.UNKNOWN) - - def __iter__(self): - for scale_name in self.scale_names: - yield _PersistedScaleAlternateConstructor(scale_name, self._interpreter) - - def __len__(self): - return len(self.scale_names) - - def __ne__(self, other): - return not self.__eq__(other) - - def __reversed__(self): - scale_names = self.scale_names - scale_names.reverse() - - for scale_name in scale_names: - yield _PersistedScaleAlternateConstructor(scale_name, self._interpreter) - - @property - def scale_names(self): - """ - List[str]: Indicates the names of all the custom scales on this - collection. - """ - val = self._interpreter.get_system_info_attribute_string(0x1266) - return unflatten_channel_string(val) diff --git a/generated/nidaqmx/system/_collections/persisted_task_collection.py b/generated/nidaqmx/system/_collections/persisted_task_collection.py deleted file mode 100644 index 5d0adea4c..000000000 --- a/generated/nidaqmx/system/_collections/persisted_task_collection.py +++ /dev/null @@ -1,93 +0,0 @@ -from collections.abc import Sequence - -from nidaqmx.errors import DaqError -from nidaqmx.error_codes import DAQmxErrors -from nidaqmx.system.storage.persisted_task import PersistedTask, _PersistedTaskAlternateConstructor -from nidaqmx.utils import unflatten_channel_string - -class PersistedTaskCollection(Sequence): - """ - Contains the collection of task saved on a DAQmx system. - - This class defines methods that implements a container object. - """ - def __init__(self, interpreter): - """ - Do not construct this object directly; instead, call nidaqmx.system.System.local().tasks. - """ - self._interpreter = interpreter - - def __contains__(self, item): - task_names = self.task_names - - if isinstance(item, str): - items = unflatten_channel_string(item) - return all([i in task_names for i in items]) - elif isinstance(item, PersistedTask): - return item._name in task_names - - def __eq__(self, other): - if isinstance(other, self.__class__): - return True - return False - - def __getitem__(self, index): - """ - Indexes a subset of saved tasks on this collection. - - Args: - index: The value of the index. The following index types - are supported: - - str: Name of the saved task. You also can specify - a string that contains a list or range of names to - this input. If you have a list of names, use the - DAQmx Flatten Channel String function to convert - the list to a string. - - int: Index/position of the saved task in the - collection. - - slice: Range of the indexes/positions of saved tasks - in the collection. - Returns: - List[nidaqmx.system.storage.persisted_task.PersistedTask]: - - Indicates the subset of saved tasks indexed. - """ - if isinstance(index, int): - return _PersistedTaskAlternateConstructor(self.task_names[index], self._interpreter) - elif isinstance(index, slice): - return [_PersistedTaskAlternateConstructor(name, self._interpreter) for name in - self.task_names[index]] - elif isinstance(index, str): - names = unflatten_channel_string(index) - if len(names) == 1: - return _PersistedTaskAlternateConstructor(names[0], self._interpreter) - return [_PersistedTaskAlternateConstructor(name, self._interpreter) for name in names] - else: - raise DaqError( - 'Invalid index type "{}" used to access collection.' - .format(type(index)), DAQmxErrors.UNKNOWN) - - def __iter__(self): - for task_name in self.task_names: - yield _PersistedTaskAlternateConstructor(task_name, self._interpreter) - - def __len__(self): - return len(self.task_names) - - def __ne__(self, other): - return not self.__eq__(other) - - def __reversed__(self): - task_names = self.task_names - task_names.reverse() - - for task_name in task_names: - yield _PersistedTaskAlternateConstructor(task_name, self._interpreter) - - @property - def task_names(self): - """ - List[str]: Indicates the names of all the tasks on this collection. - """ - val = self._interpreter.get_system_info_attribute_string(0x1267) - return unflatten_channel_string(val) diff --git a/generated/nidaqmx/system/_collections/physical_channel_collection.py b/generated/nidaqmx/system/_collections/physical_channel_collection.py deleted file mode 100644 index 8e5c27d01..000000000 --- a/generated/nidaqmx/system/_collections/physical_channel_collection.py +++ /dev/null @@ -1,210 +0,0 @@ -from collections.abc import Sequence - -from nidaqmx.errors import DaqError -from nidaqmx.error_codes import DAQmxErrors -from nidaqmx.system.physical_channel import PhysicalChannel, _PhysicalChannelAlternateConstructor -from nidaqmx.utils import unflatten_channel_string, flatten_channel_string - -class PhysicalChannelCollection(Sequence): - """ - Contains the collection of physical channels for a DAQmx device. - - This class defines methods that implements a container object. - """ - def __init__(self, device_name, interpreter): - """ - Do not construct this object directly; instead, construct a nidaqmx.system.Device and use the appropriate property, such as device.ai_physical_channels. - """ - self._name = device_name - self._interpreter = interpreter - - def __contains__(self, item): - channel_names = self.channel_names - - if isinstance(item, str): - items = unflatten_channel_string(item) - return all([i in channel_names for i in items]) - elif isinstance(item, PhysicalChannel): - return item._name in channel_names - return False - - def __eq__(self, other): - if isinstance(other, self.__class__): - return self._name == other._name - return False - - def __getitem__(self, index): - """ - Indexes a subset of physical channels on this physical channel - collection. - - Args: - index: The value of the index. The following index types - are supported: - - str: Name of the physical channel, without the - device name prefix, e.g. 'ai0'. You also can - specify a string that contains a list or range of - names to this input. If you have a list of names, - use the DAQmx Flatten Channel String function to - convert the list to a string. - - int: Index/position of the physical channel in the - collection. - - slice: Range of the indexes/positions of physical - channels in the collection. - Returns: - nidaqmx.system.physical_channel.PhysicalChannel: - - Indicates the subset of physical channels indexed. - """ - if isinstance(index, int): - return _PhysicalChannelAlternateConstructor(self.channel_names[index], self._interpreter) - elif isinstance(index, slice): - return _PhysicalChannelAlternateConstructor(self.channel_names[index], self._interpreter) - elif isinstance(index, str): - return _PhysicalChannelAlternateConstructor(f'{self._name}/{index}', self._interpreter) - else: - raise DaqError( - 'Invalid index type "{}" used to access collection.' - .format(type(index)), DAQmxErrors.UNKNOWN) - - def __iter__(self): - for channel_name in self.channel_names: - yield _PhysicalChannelAlternateConstructor(channel_name, self._interpreter) - - def __len__(self): - return len(self.channel_names) - - def __ne__(self, other): - return not self.__eq__(other) - - def __reversed__(self): - channel_names = self.channel_names - channel_names.reverse() - - for channel_name in channel_names: - yield _PhysicalChannelAlternateConstructor(channel_name, self._interpreter) - - @property - def all(self): - """ - nidaqmx.system.physical_channel.PhysicalChannel: Specifies a - physical channel object that represents the entire list of - physical channels on this channel collection. - """ - return _PhysicalChannelAlternateConstructor(flatten_channel_string(self.channel_names), self._interpreter) - - @property - def channel_names(self): - """ - List[str]: Specifies the entire list of physical channels on this - collection. - """ - raise NotImplementedError() - - -class AIPhysicalChannelCollection(PhysicalChannelCollection): - """ - Contains the collection of analog input physical channels for a - DAQmx device. - - This class defines methods that implements a container object. - """ - - @property - def channel_names(self): - val = self._interpreter.get_device_attribute_string(self._name, 0x231e) - return unflatten_channel_string(val) - - -class AOPhysicalChannelCollection(PhysicalChannelCollection): - """ - Contains the collection of analog output physical channels for a - DAQmx device. - - This class defines methods that implements a container object. - """ - - @property - def channel_names(self): - val = self._interpreter.get_device_attribute_string(self._name, 0x231f) - return unflatten_channel_string(val) - - -class CIPhysicalChannelCollection(PhysicalChannelCollection): - """ - Contains the collection of counter input physical channels for a - DAQmx device. - - This class defines methods that implements a container object. - """ - - @property - def channel_names(self): - val = self._interpreter.get_device_attribute_string(self._name, 0x2324) - return unflatten_channel_string(val) - - -class COPhysicalChannelCollection(PhysicalChannelCollection): - """ - Contains the collection of counter output physical channels for a - DAQmx device. - - This class defines methods that implements a container object. - """ - - @property - def channel_names(self): - val = self._interpreter.get_device_attribute_string(self._name, 0x2325) - return unflatten_channel_string(val) - - -class DILinesCollection(PhysicalChannelCollection): - """ - Contains the collection of digital input lines for a DAQmx device. - - This class defines methods that implements a container object. - """ - - @property - def channel_names(self): - val = self._interpreter.get_device_attribute_string(self._name, 0x2320) - return unflatten_channel_string(val) - - -class DOLinesCollection(PhysicalChannelCollection): - """ - Contains the collection of digital output lines for a DAQmx device. - - This class defines methods that implements a container object. - """ - - @property - def channel_names(self): - val = self._interpreter.get_device_attribute_string(self._name, 0x2322) - return unflatten_channel_string(val) - - -class DIPortsCollection(PhysicalChannelCollection): - """ - Contains the collection of digital input ports for a DAQmx device. - - This class defines methods that implements a container object. - """ - - @property - def channel_names(self): - val = self._interpreter.get_device_attribute_string(self._name, 0x2321) - return unflatten_channel_string(val) - - -class DOPortsCollection(PhysicalChannelCollection): - """ - Contains the collection of digital output ports for a DAQmx device. - - This class defines methods that implements a container object. - """ - - @property - def channel_names(self): - val = self._interpreter.get_device_attribute_string(self._name, 0x2323) - return unflatten_channel_string(val) From e438f4f561604b5e19b84b5eab47755d8576b95f Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 19:41:39 -0500 Subject: [PATCH 06/13] update storage submodules --- .../nidaqmx/system/collections/_persisted_channel_collection.py | 2 +- .../nidaqmx/system/collections/_persisted_scale_collection.py | 2 +- .../nidaqmx/system/collections/_persisted_task_collection.py | 2 +- generated/nidaqmx/system/storage/__init__.py | 2 +- generated/nidaqmx/task/_task.py | 2 +- .../system/collections/_persisted_channel_collection.py | 2 +- .../system/collections/_persisted_scale_collection.py | 2 +- .../system/collections/_persisted_task_collection.py | 2 +- src/handwritten/system/storage/__init__.py | 2 +- src/handwritten/task/_task.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/generated/nidaqmx/system/collections/_persisted_channel_collection.py b/generated/nidaqmx/system/collections/_persisted_channel_collection.py index d389a5f84..d2a172c34 100644 --- a/generated/nidaqmx/system/collections/_persisted_channel_collection.py +++ b/generated/nidaqmx/system/collections/_persisted_channel_collection.py @@ -49,7 +49,7 @@ def __getitem__(self, index): - slice: Range of the indexes/positions of global channels in the collection. Returns: - List[nidaqmx.system.storage.persisted_channel.PersistedChannel]: + List[nidaqmx.system.storage.PersistedChannel]: Indicates the of global channels indexed. """ diff --git a/generated/nidaqmx/system/collections/_persisted_scale_collection.py b/generated/nidaqmx/system/collections/_persisted_scale_collection.py index bdbcc5adb..70e3ca78a 100644 --- a/generated/nidaqmx/system/collections/_persisted_scale_collection.py +++ b/generated/nidaqmx/system/collections/_persisted_scale_collection.py @@ -48,7 +48,7 @@ def __getitem__(self, index): - slice: Range of the indexes/positions of custom scales in the collection. Returns: - List[nidaqmx.system.storage.persisted_scale.PersistedScale]: + List[nidaqmx.system.storage.PersistedScale]: Indicates the subset of custom scales indexed. """ diff --git a/generated/nidaqmx/system/collections/_persisted_task_collection.py b/generated/nidaqmx/system/collections/_persisted_task_collection.py index 5d0adea4c..494a96514 100644 --- a/generated/nidaqmx/system/collections/_persisted_task_collection.py +++ b/generated/nidaqmx/system/collections/_persisted_task_collection.py @@ -48,7 +48,7 @@ def __getitem__(self, index): - slice: Range of the indexes/positions of saved tasks in the collection. Returns: - List[nidaqmx.system.storage.persisted_task.PersistedTask]: + List[nidaqmx.system.storage.PersistedTask]: Indicates the subset of saved tasks indexed. """ diff --git a/generated/nidaqmx/system/storage/__init__.py b/generated/nidaqmx/system/storage/__init__.py index 90e8571ba..e9439565f 100644 --- a/generated/nidaqmx/system/storage/__init__.py +++ b/generated/nidaqmx/system/storage/__init__.py @@ -2,4 +2,4 @@ from nidaqmx.system.storage.persisted_scale import PersistedScale from nidaqmx.system.storage.persisted_task import PersistedTask -__all__ = ['persisted_channel', 'persisted_scale', 'persisted_task'] +__all__ = ['PersistedChannel', 'PersistedScale', 'PersistedTask',] diff --git a/generated/nidaqmx/task/_task.py b/generated/nidaqmx/task/_task.py index b70c536e3..b70a51c04 100644 --- a/generated/nidaqmx/task/_task.py +++ b/generated/nidaqmx/task/_task.py @@ -317,7 +317,7 @@ def add_global_channels(self, global_channels): Adds global virtual channels from MAX to the given task. Args: - global_channels (List[nidaqmx.system.storage.persisted_channel.PersistedChannel]): + global_channels (List[nidaqmx.system.storage.PersistedChannel]): Specifies the channels to add to the task. These channels must be valid channels available from MAX. diff --git a/src/handwritten/system/collections/_persisted_channel_collection.py b/src/handwritten/system/collections/_persisted_channel_collection.py index d389a5f84..d2a172c34 100644 --- a/src/handwritten/system/collections/_persisted_channel_collection.py +++ b/src/handwritten/system/collections/_persisted_channel_collection.py @@ -49,7 +49,7 @@ def __getitem__(self, index): - slice: Range of the indexes/positions of global channels in the collection. Returns: - List[nidaqmx.system.storage.persisted_channel.PersistedChannel]: + List[nidaqmx.system.storage.PersistedChannel]: Indicates the of global channels indexed. """ diff --git a/src/handwritten/system/collections/_persisted_scale_collection.py b/src/handwritten/system/collections/_persisted_scale_collection.py index bdbcc5adb..70e3ca78a 100644 --- a/src/handwritten/system/collections/_persisted_scale_collection.py +++ b/src/handwritten/system/collections/_persisted_scale_collection.py @@ -48,7 +48,7 @@ def __getitem__(self, index): - slice: Range of the indexes/positions of custom scales in the collection. Returns: - List[nidaqmx.system.storage.persisted_scale.PersistedScale]: + List[nidaqmx.system.storage.PersistedScale]: Indicates the subset of custom scales indexed. """ diff --git a/src/handwritten/system/collections/_persisted_task_collection.py b/src/handwritten/system/collections/_persisted_task_collection.py index 5d0adea4c..494a96514 100644 --- a/src/handwritten/system/collections/_persisted_task_collection.py +++ b/src/handwritten/system/collections/_persisted_task_collection.py @@ -48,7 +48,7 @@ def __getitem__(self, index): - slice: Range of the indexes/positions of saved tasks in the collection. Returns: - List[nidaqmx.system.storage.persisted_task.PersistedTask]: + List[nidaqmx.system.storage.PersistedTask]: Indicates the subset of saved tasks indexed. """ diff --git a/src/handwritten/system/storage/__init__.py b/src/handwritten/system/storage/__init__.py index 90e8571ba..e9439565f 100644 --- a/src/handwritten/system/storage/__init__.py +++ b/src/handwritten/system/storage/__init__.py @@ -2,4 +2,4 @@ from nidaqmx.system.storage.persisted_scale import PersistedScale from nidaqmx.system.storage.persisted_task import PersistedTask -__all__ = ['persisted_channel', 'persisted_scale', 'persisted_task'] +__all__ = ['PersistedChannel', 'PersistedScale', 'PersistedTask',] diff --git a/src/handwritten/task/_task.py b/src/handwritten/task/_task.py index b70c536e3..b70a51c04 100644 --- a/src/handwritten/task/_task.py +++ b/src/handwritten/task/_task.py @@ -317,7 +317,7 @@ def add_global_channels(self, global_channels): Adds global virtual channels from MAX to the given task. Args: - global_channels (List[nidaqmx.system.storage.persisted_channel.PersistedChannel]): + global_channels (List[nidaqmx.system.storage.PersistedChannel]): Specifies the channels to add to the task. These channels must be valid channels available from MAX. From c6d420c4248cae94b5f20e37b592ce0cb4a03ba9 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 19:41:51 -0500 Subject: [PATCH 07/13] update storage docs --- docs/persisted_channel.rst | 7 ------- docs/persisted_scale.rst | 7 ------- docs/persisted_task.rst | 7 ------- docs/storage.rst | 9 ++++----- 4 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 docs/persisted_channel.rst delete mode 100644 docs/persisted_scale.rst delete mode 100644 docs/persisted_task.rst diff --git a/docs/persisted_channel.rst b/docs/persisted_channel.rst deleted file mode 100644 index f1d592462..000000000 --- a/docs/persisted_channel.rst +++ /dev/null @@ -1,7 +0,0 @@ -nidaqmx.system.persisted_channel -================================ - -.. automodule:: nidaqmx.system.storage.persisted_channel - :members: - :show-inheritance: - :special-members: diff --git a/docs/persisted_scale.rst b/docs/persisted_scale.rst deleted file mode 100644 index c164bbc84..000000000 --- a/docs/persisted_scale.rst +++ /dev/null @@ -1,7 +0,0 @@ -nidaqmx.system.persisted_scale -============================== - -.. automodule:: nidaqmx.system.storage.persisted_scale - :members: - :show-inheritance: - :special-members: diff --git a/docs/persisted_task.rst b/docs/persisted_task.rst deleted file mode 100644 index 2584d67ab..000000000 --- a/docs/persisted_task.rst +++ /dev/null @@ -1,7 +0,0 @@ -nidaqmx.system.persisted_task -============================= - -.. automodule:: nidaqmx.system.storage.persisted_task - :members: - :show-inheritance: - :special-members: diff --git a/docs/storage.rst b/docs/storage.rst index 549632405..7a1af97ba 100644 --- a/docs/storage.rst +++ b/docs/storage.rst @@ -1,8 +1,7 @@ nidaqmx.system.storage ====================== -.. toctree:: - - persisted_channel - persisted_scale - persisted_task +.. automodule:: nidaqmx.system.storage + :members: + :show-inheritance: + :member-order: bysource From 6544fac6123785d451751ff8efabaaadece3c903 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 19:51:15 -0500 Subject: [PATCH 08/13] refactor watchdog submodules --- generated/nidaqmx/system/_watchdog_modules/__init__.py | 0 generated/nidaqmx/system/watchdog/__init__.py | 5 +++++ .../expiration_state.py => watchdog/_expiration_state.py} | 0 .../_expiration_states_collection.py} | 2 +- src/codegen/metadata/script_info.py | 4 ++-- .../_expiration_state.py.mako} | 0 src/handwritten/system/_watchdog_modules/__init__.py | 0 src/handwritten/system/watchdog/__init__.py | 5 +++++ .../_expiration_states_collection.py} | 2 +- 9 files changed, 14 insertions(+), 4 deletions(-) delete mode 100644 generated/nidaqmx/system/_watchdog_modules/__init__.py create mode 100644 generated/nidaqmx/system/watchdog/__init__.py rename generated/nidaqmx/system/{_watchdog_modules/expiration_state.py => watchdog/_expiration_state.py} (100%) rename generated/nidaqmx/system/{_watchdog_modules/expiration_states_collection.py => watchdog/_expiration_states_collection.py} (94%) rename src/codegen/templates/system/{_watchdog_modules/expiration_state.py.mako => watchdog/_expiration_state.py.mako} (100%) delete mode 100644 src/handwritten/system/_watchdog_modules/__init__.py create mode 100644 src/handwritten/system/watchdog/__init__.py rename src/handwritten/system/{_watchdog_modules/expiration_states_collection.py => watchdog/_expiration_states_collection.py} (94%) diff --git a/generated/nidaqmx/system/_watchdog_modules/__init__.py b/generated/nidaqmx/system/_watchdog_modules/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/generated/nidaqmx/system/watchdog/__init__.py b/generated/nidaqmx/system/watchdog/__init__.py new file mode 100644 index 000000000..66b45b120 --- /dev/null +++ b/generated/nidaqmx/system/watchdog/__init__.py @@ -0,0 +1,5 @@ + +from nidaqmx.system.watchdog._expiration_state import ExpirationState +from nidaqmx.system.watchdog._expiration_states_collection import ExpirationStatesCollection + +__all__ = ['ExpirationState', 'ExpirationStatesCollection',] \ No newline at end of file diff --git a/generated/nidaqmx/system/_watchdog_modules/expiration_state.py b/generated/nidaqmx/system/watchdog/_expiration_state.py similarity index 100% rename from generated/nidaqmx/system/_watchdog_modules/expiration_state.py rename to generated/nidaqmx/system/watchdog/_expiration_state.py diff --git a/generated/nidaqmx/system/_watchdog_modules/expiration_states_collection.py b/generated/nidaqmx/system/watchdog/_expiration_states_collection.py similarity index 94% rename from generated/nidaqmx/system/_watchdog_modules/expiration_states_collection.py rename to generated/nidaqmx/system/watchdog/_expiration_states_collection.py index 5d437ef92..5577606f7 100644 --- a/generated/nidaqmx/system/_watchdog_modules/expiration_states_collection.py +++ b/generated/nidaqmx/system/watchdog/_expiration_states_collection.py @@ -1,5 +1,5 @@ from nidaqmx.errors import DaqError -from nidaqmx.system._watchdog_modules.expiration_state import ExpirationState +from nidaqmx.system.watchdog._expiration_state import ExpirationState class ExpirationStatesCollection: diff --git a/src/codegen/metadata/script_info.py b/src/codegen/metadata/script_info.py index 28d74f86f..660e895ae 100644 --- a/src/codegen/metadata/script_info.py +++ b/src/codegen/metadata/script_info.py @@ -29,8 +29,8 @@ "templateFile": "task\\_out_stream.py.mako", }, { - "relativeOutputPath": "system\\_watchdog_modules\\expiration_state.py", - "templateFile": "system\\_watchdog_modules\\expiration_state.py.mako", + "relativeOutputPath": "system\\watchdog\\_expiration_state.py", + "templateFile": "system\\watchdog\\_expiration_state.py.mako", }, { "relativeOutputPath": "system\\watchdog.py", diff --git a/src/codegen/templates/system/_watchdog_modules/expiration_state.py.mako b/src/codegen/templates/system/watchdog/_expiration_state.py.mako similarity index 100% rename from src/codegen/templates/system/_watchdog_modules/expiration_state.py.mako rename to src/codegen/templates/system/watchdog/_expiration_state.py.mako diff --git a/src/handwritten/system/_watchdog_modules/__init__.py b/src/handwritten/system/_watchdog_modules/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/handwritten/system/watchdog/__init__.py b/src/handwritten/system/watchdog/__init__.py new file mode 100644 index 000000000..66b45b120 --- /dev/null +++ b/src/handwritten/system/watchdog/__init__.py @@ -0,0 +1,5 @@ + +from nidaqmx.system.watchdog._expiration_state import ExpirationState +from nidaqmx.system.watchdog._expiration_states_collection import ExpirationStatesCollection + +__all__ = ['ExpirationState', 'ExpirationStatesCollection',] \ No newline at end of file diff --git a/src/handwritten/system/_watchdog_modules/expiration_states_collection.py b/src/handwritten/system/watchdog/_expiration_states_collection.py similarity index 94% rename from src/handwritten/system/_watchdog_modules/expiration_states_collection.py rename to src/handwritten/system/watchdog/_expiration_states_collection.py index 5d437ef92..5577606f7 100644 --- a/src/handwritten/system/_watchdog_modules/expiration_states_collection.py +++ b/src/handwritten/system/watchdog/_expiration_states_collection.py @@ -1,5 +1,5 @@ from nidaqmx.errors import DaqError -from nidaqmx.system._watchdog_modules.expiration_state import ExpirationState +from nidaqmx.system.watchdog._expiration_state import ExpirationState class ExpirationStatesCollection: From 590dd0b2f2159d2363095dc45897035f9aacc204 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 19:56:45 -0500 Subject: [PATCH 09/13] update imports and docs --- generated/nidaqmx/system/watchdog.py | 12 ++++++------ .../system/watchdog/_expiration_states_collection.py | 2 +- src/codegen/templates/system/watchdog.py.mako | 12 ++++++------ .../system/watchdog/_expiration_states_collection.py | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/generated/nidaqmx/system/watchdog.py b/generated/nidaqmx/system/watchdog.py index 09e4b8b57..098d9361b 100644 --- a/generated/nidaqmx/system/watchdog.py +++ b/generated/nidaqmx/system/watchdog.py @@ -5,8 +5,8 @@ from nidaqmx import utils from nidaqmx.errors import DaqResourceWarning -from nidaqmx.system._watchdog_modules.expiration_state import ExpirationState -from nidaqmx.system._watchdog_modules.expiration_states_collection import ( +from nidaqmx.system.watchdog._expiration_state import ExpirationState +from nidaqmx.system.watchdog._expiration_states_collection import ( ExpirationStatesCollection) from nidaqmx.utils import flatten_channel_string from nidaqmx.constants import ( @@ -79,7 +79,7 @@ def __exit__(self, type, value, traceback): @property def expiration_states(self): """ - :class:`nidaqmx.system._watchdog_modules.expiration_states_collection.ExpirationStatesCollection`: Gets + :class:`nidaqmx.system.watchdog.ExpirationStatesCollection`: Gets the collection of expiration states for this watchdog task. """ return self._expiration_states @@ -233,7 +233,7 @@ def cfg_watchdog_ao_expir_states(self, expiration_states): output_type (nidaqmx.constants.WatchdogAOExpirState): Specifies the output type of the physical channel. Returns: - List[nidaqmx.system._watchdog_modules.expiration_state.ExpirationState]: + List[nidaqmx.system.watchdog.ExpirationState]: Indicates the list of objects representing the configured expiration states. @@ -267,7 +267,7 @@ def cfg_watchdog_co_expir_states(self, expiration_states): expiration_state (nidaqmx.constants.WatchdogCOExpirState): Specifies the value to set the channel to upon expiration. Returns: - List[nidaqmx.system._watchdog_modules.expiration_state.ExpirationState]: + List[nidaqmx.system.watchdog.ExpirationState]: Indicates the list of objects representing the configured expiration states. @@ -299,7 +299,7 @@ def cfg_watchdog_do_expir_states(self, expiration_states): expiration_state (nidaqmx.constants.Level): Specifies the value to set the channel to upon expiration. Returns: - List[nidaqmx.system._watchdog_modules.expiration_state.ExpirationState]: + List[nidaqmx.system.watchdog.ExpirationState]: Indicates the list of objects representing the configured expiration states. diff --git a/generated/nidaqmx/system/watchdog/_expiration_states_collection.py b/generated/nidaqmx/system/watchdog/_expiration_states_collection.py index 5577606f7..6a49b95ff 100644 --- a/generated/nidaqmx/system/watchdog/_expiration_states_collection.py +++ b/generated/nidaqmx/system/watchdog/_expiration_states_collection.py @@ -31,7 +31,7 @@ def __getitem__(self, index): index (str): Name of the physical channel of which the expiration state to retrieve. Returns: - nidaqmx.system._watchdog_modules.expiration_state.ExpirationState: + nidaqmx.system.watchdog.ExpirationState: The object representing the indexed expiration state. """ diff --git a/src/codegen/templates/system/watchdog.py.mako b/src/codegen/templates/system/watchdog.py.mako index 8bd6edeeb..b02156229 100644 --- a/src/codegen/templates/system/watchdog.py.mako +++ b/src/codegen/templates/system/watchdog.py.mako @@ -11,8 +11,8 @@ import warnings from nidaqmx import utils from nidaqmx.errors import DaqResourceWarning -from nidaqmx.system._watchdog_modules.expiration_state import ExpirationState -from nidaqmx.system._watchdog_modules.expiration_states_collection import ( +from nidaqmx.system.watchdog._expiration_state import ExpirationState +from nidaqmx.system.watchdog._expiration_states_collection import ( ExpirationStatesCollection) from nidaqmx.utils import flatten_channel_string from nidaqmx.constants import ( @@ -85,7 +85,7 @@ class WatchdogTask: @property def expiration_states(self): """ - :class:`nidaqmx.system._watchdog_modules.expiration_states_collection.ExpirationStatesCollection`: Gets + :class:`nidaqmx.system.watchdog.ExpirationStatesCollection`: Gets the collection of expiration states for this watchdog task. """ return self._expiration_states @@ -138,7 +138,7 @@ ${property_template.script_property(attribute)}\ output_type (nidaqmx.constants.WatchdogAOExpirState): Specifies the output type of the physical channel. Returns: - List[nidaqmx.system._watchdog_modules.expiration_state.ExpirationState]: + List[nidaqmx.system.watchdog.ExpirationState]: Indicates the list of objects representing the configured expiration states. @@ -172,7 +172,7 @@ ${property_template.script_property(attribute)}\ expiration_state (nidaqmx.constants.WatchdogCOExpirState): Specifies the value to set the channel to upon expiration. Returns: - List[nidaqmx.system._watchdog_modules.expiration_state.ExpirationState]: + List[nidaqmx.system.watchdog.ExpirationState]: Indicates the list of objects representing the configured expiration states. @@ -204,7 +204,7 @@ ${property_template.script_property(attribute)}\ expiration_state (nidaqmx.constants.Level): Specifies the value to set the channel to upon expiration. Returns: - List[nidaqmx.system._watchdog_modules.expiration_state.ExpirationState]: + List[nidaqmx.system.watchdog.ExpirationState]: Indicates the list of objects representing the configured expiration states. diff --git a/src/handwritten/system/watchdog/_expiration_states_collection.py b/src/handwritten/system/watchdog/_expiration_states_collection.py index 5577606f7..6a49b95ff 100644 --- a/src/handwritten/system/watchdog/_expiration_states_collection.py +++ b/src/handwritten/system/watchdog/_expiration_states_collection.py @@ -31,7 +31,7 @@ def __getitem__(self, index): index (str): Name of the physical channel of which the expiration state to retrieve. Returns: - nidaqmx.system._watchdog_modules.expiration_state.ExpirationState: + nidaqmx.system.watchdog.ExpirationState: The object representing the indexed expiration state. """ From c825470ebf1f67569ae40ea4f7240649d94b9009 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 19:56:57 -0500 Subject: [PATCH 10/13] update watchdog docs --- docs/expiration_state.rst | 6 ------ docs/expiration_states_collection.rst | 6 ------ docs/watchdog.rst | 7 +------ 3 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 docs/expiration_state.rst delete mode 100644 docs/expiration_states_collection.rst diff --git a/docs/expiration_state.rst b/docs/expiration_state.rst deleted file mode 100644 index 4d5ca5c9e..000000000 --- a/docs/expiration_state.rst +++ /dev/null @@ -1,6 +0,0 @@ -nidaqmx.system.expiration_state -=============================== - -.. automodule:: nidaqmx.system._watchdog_modules.expiration_state - :members: - :show-inheritance: diff --git a/docs/expiration_states_collection.rst b/docs/expiration_states_collection.rst deleted file mode 100644 index 9e912ff5b..000000000 --- a/docs/expiration_states_collection.rst +++ /dev/null @@ -1,6 +0,0 @@ -nidaqmx.system.expiration_states_collection -=========================================== - -.. automodule:: nidaqmx.system._watchdog_modules.expiration_states_collection - :members: - :show-inheritance: diff --git a/docs/watchdog.rst b/docs/watchdog.rst index 245448631..d44d23b49 100644 --- a/docs/watchdog.rst +++ b/docs/watchdog.rst @@ -4,9 +4,4 @@ nidaqmx.system.watchdog .. automodule:: nidaqmx.system.watchdog :members: :show-inheritance: - :special-members: - -.. toctree:: - - expiration_state - expiration_states_collection + :member-order: bysource From d382450834e2e01c7e12498f4967a54857e1f883 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 20:52:44 -0500 Subject: [PATCH 11/13] refactor watchdog.py --- generated/nidaqmx/system/__init__.py | 2 -- generated/nidaqmx/system/watchdog/__init__.py | 4 +++- .../nidaqmx/system/{watchdog.py => watchdog/_watchdog.py} | 0 generated/nidaqmx/task/_task.py | 7 +++---- src/codegen/metadata/script_info.py | 4 ++-- .../{watchdog.py.mako => watchdog/_watchdog.py.mako} | 0 src/handwritten/system/__init__.py | 2 -- src/handwritten/system/watchdog/__init__.py | 4 +++- src/handwritten/task/_task.py | 7 +++---- tests/conftest.py | 4 ++-- 10 files changed, 16 insertions(+), 18 deletions(-) rename generated/nidaqmx/system/{watchdog.py => watchdog/_watchdog.py} (100%) rename src/codegen/templates/system/{watchdog.py.mako => watchdog/_watchdog.py.mako} (100%) diff --git a/generated/nidaqmx/system/__init__.py b/generated/nidaqmx/system/__init__.py index 6d57599ca..c2e27f711 100644 --- a/generated/nidaqmx/system/__init__.py +++ b/generated/nidaqmx/system/__init__.py @@ -3,7 +3,5 @@ DOResistorPowerUpState) from nidaqmx.system.device import Device from nidaqmx.system.physical_channel import PhysicalChannel -from nidaqmx.system.watchdog import ( - WatchdogTask, AOExpirationState, COExpirationState, DOExpirationState) __all__ = ['system', 'device', 'physical_channel', 'storage', 'watchdog'] diff --git a/generated/nidaqmx/system/watchdog/__init__.py b/generated/nidaqmx/system/watchdog/__init__.py index 66b45b120..f68408375 100644 --- a/generated/nidaqmx/system/watchdog/__init__.py +++ b/generated/nidaqmx/system/watchdog/__init__.py @@ -1,5 +1,7 @@ from nidaqmx.system.watchdog._expiration_state import ExpirationState from nidaqmx.system.watchdog._expiration_states_collection import ExpirationStatesCollection +from nidaqmx.system.watchdog._watchdog import ( + WatchdogTask, AOExpirationState, COExpirationState, DOExpirationState) -__all__ = ['ExpirationState', 'ExpirationStatesCollection',] \ No newline at end of file +__all__ = ['ExpirationState', 'ExpirationStatesCollection', 'WatchdogTask',] \ No newline at end of file diff --git a/generated/nidaqmx/system/watchdog.py b/generated/nidaqmx/system/watchdog/_watchdog.py similarity index 100% rename from generated/nidaqmx/system/watchdog.py rename to generated/nidaqmx/system/watchdog/_watchdog.py diff --git a/generated/nidaqmx/task/_task.py b/generated/nidaqmx/task/_task.py index b70a51c04..af2b05515 100644 --- a/generated/nidaqmx/task/_task.py +++ b/generated/nidaqmx/task/_task.py @@ -141,11 +141,10 @@ def name(self): return val @property - def channels(self): + def channels(self) -> Channel: """ - :class:`nidaqmx.task.channels.Channel`: Specifies - a channel object that represents the entire list of virtual - channels in this task. + Specifies a channel object that represents the entire list of + virtual channels in this task. """ return Channel._factory( self._handle, flatten_channel_string(self.channel_names), self._interpreter) diff --git a/src/codegen/metadata/script_info.py b/src/codegen/metadata/script_info.py index 660e895ae..f627bb3c3 100644 --- a/src/codegen/metadata/script_info.py +++ b/src/codegen/metadata/script_info.py @@ -33,8 +33,8 @@ "templateFile": "system\\watchdog\\_expiration_state.py.mako", }, { - "relativeOutputPath": "system\\watchdog.py", - "templateFile": "system\\watchdog.py.mako", + "relativeOutputPath": "system\\watchdog\\_watchdog.py", + "templateFile": "system\\watchdog\\_watchdog.py.mako", }, { "relativeOutputPath": "task\\channels\\_ao_channel.py", diff --git a/src/codegen/templates/system/watchdog.py.mako b/src/codegen/templates/system/watchdog/_watchdog.py.mako similarity index 100% rename from src/codegen/templates/system/watchdog.py.mako rename to src/codegen/templates/system/watchdog/_watchdog.py.mako diff --git a/src/handwritten/system/__init__.py b/src/handwritten/system/__init__.py index 6d57599ca..c2e27f711 100644 --- a/src/handwritten/system/__init__.py +++ b/src/handwritten/system/__init__.py @@ -3,7 +3,5 @@ DOResistorPowerUpState) from nidaqmx.system.device import Device from nidaqmx.system.physical_channel import PhysicalChannel -from nidaqmx.system.watchdog import ( - WatchdogTask, AOExpirationState, COExpirationState, DOExpirationState) __all__ = ['system', 'device', 'physical_channel', 'storage', 'watchdog'] diff --git a/src/handwritten/system/watchdog/__init__.py b/src/handwritten/system/watchdog/__init__.py index 66b45b120..f68408375 100644 --- a/src/handwritten/system/watchdog/__init__.py +++ b/src/handwritten/system/watchdog/__init__.py @@ -1,5 +1,7 @@ from nidaqmx.system.watchdog._expiration_state import ExpirationState from nidaqmx.system.watchdog._expiration_states_collection import ExpirationStatesCollection +from nidaqmx.system.watchdog._watchdog import ( + WatchdogTask, AOExpirationState, COExpirationState, DOExpirationState) -__all__ = ['ExpirationState', 'ExpirationStatesCollection',] \ No newline at end of file +__all__ = ['ExpirationState', 'ExpirationStatesCollection', 'WatchdogTask',] \ No newline at end of file diff --git a/src/handwritten/task/_task.py b/src/handwritten/task/_task.py index b70a51c04..af2b05515 100644 --- a/src/handwritten/task/_task.py +++ b/src/handwritten/task/_task.py @@ -141,11 +141,10 @@ def name(self): return val @property - def channels(self): + def channels(self) -> Channel: """ - :class:`nidaqmx.task.channels.Channel`: Specifies - a channel object that represents the entire list of virtual - channels in this task. + Specifies a channel object that represents the entire list of + virtual channels in this task. """ return Channel._factory( self._handle, flatten_channel_string(self.channel_names), self._interpreter) diff --git a/tests/conftest.py b/tests/conftest.py index e4ef333b7..36f117d91 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -507,7 +507,7 @@ def persisted_channel(request, system: nidaqmx.system.System): @pytest.fixture(scope="function") -def watchdog_task(request, sim_6363_device, generate_watchdog_task) -> nidaqmx.system.WatchdogTask: +def watchdog_task(request, sim_6363_device, generate_watchdog_task) -> nidaqmx.system.watchdog.WatchdogTask: """Gets a watchdog task instance.""" # set default values used for the initialization of the task. device_name = _get_marker_value(request, "device_name", sim_6363_device.name) @@ -528,7 +528,7 @@ def generate_watchdog_task(init_kwargs): def _create_task(device_name, task_name="", timeout=0.5): return stack.enter_context( - nidaqmx.system.WatchdogTask(device_name, task_name, timeout, **init_kwargs) + nidaqmx.system.watchdog.WatchdogTask(device_name, task_name, timeout, **init_kwargs) ) yield _create_task From 713ae1e11312d2fbca4a59f39d73f01029cd7e95 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 21:01:21 -0500 Subject: [PATCH 12/13] fix lint --- tests/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 36f117d91..753428a80 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -507,7 +507,9 @@ def persisted_channel(request, system: nidaqmx.system.System): @pytest.fixture(scope="function") -def watchdog_task(request, sim_6363_device, generate_watchdog_task) -> nidaqmx.system.watchdog.WatchdogTask: +def watchdog_task( + request, sim_6363_device, generate_watchdog_task +) -> nidaqmx.system.watchdog.WatchdogTask: """Gets a watchdog task instance.""" # set default values used for the initialization of the task. device_name = _get_marker_value(request, "device_name", sim_6363_device.name) From 4b0800881739b8a4367c79f26f741078b68d5493 Mon Sep 17 00:00:00 2001 From: charitylxy Date: Thu, 21 Mar 2024 21:27:25 -0500 Subject: [PATCH 13/13] revert accidental changes --- generated/nidaqmx/task/_task.py | 7 ++++--- src/handwritten/task/_task.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/generated/nidaqmx/task/_task.py b/generated/nidaqmx/task/_task.py index af2b05515..b70a51c04 100644 --- a/generated/nidaqmx/task/_task.py +++ b/generated/nidaqmx/task/_task.py @@ -141,10 +141,11 @@ def name(self): return val @property - def channels(self) -> Channel: + def channels(self): """ - Specifies a channel object that represents the entire list of - virtual channels in this task. + :class:`nidaqmx.task.channels.Channel`: Specifies + a channel object that represents the entire list of virtual + channels in this task. """ return Channel._factory( self._handle, flatten_channel_string(self.channel_names), self._interpreter) diff --git a/src/handwritten/task/_task.py b/src/handwritten/task/_task.py index af2b05515..b70a51c04 100644 --- a/src/handwritten/task/_task.py +++ b/src/handwritten/task/_task.py @@ -141,10 +141,11 @@ def name(self): return val @property - def channels(self) -> Channel: + def channels(self): """ - Specifies a channel object that represents the entire list of - virtual channels in this task. + :class:`nidaqmx.task.channels.Channel`: Specifies + a channel object that represents the entire list of virtual + channels in this task. """ return Channel._factory( self._handle, flatten_channel_string(self.channel_names), self._interpreter)