Ejemplo n.º 1
0
    def is_global(self):
        """
        bool: Indicates whether the channel is a global channel.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetChanIsGlobal
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 2
0
    def ai_power_control_enable(self):
        """
        bool: Specifies whether to turn on the sensor's power supply.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetPhysicalChanAIPowerControlEnable
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 3
0
    def do_samp_clk_supported(self):
        """
        bool: Indicates if the sample clock timing type is supported for
            the digital output physical channel.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetPhysicalChanDOSampClkSupported
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 4
0
    def ao_power_amp_overcurrent(self):
        """
        bool: Indicates if the channel detected an overcurrent
            condition.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetAOPowerAmpOvercurrent
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 5
0
    def dig_edge_dig_fltr_enable(self):
        """
        bool: Specifies whether to apply the pulse width filter to the
            signal.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetDigEdgeArmStartTrigDigFltrEnable
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 6
0
    def ao_power_amp_channel_enable(self):
        """
        bool: Specifies whether to enable or disable a channel for
            amplification. This property can also be used to check if a
            channel is enabled.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetAOPowerAmpChannelEnable
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str, ctypes.POINTER(c_bool32)]

        error_code = cfunc(
            self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 7
0
    def expired(self):
        """
        bool: Indicates if the watchdog timer expired. You can read this
            property only while the task is running.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetWatchdogHasExpired
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 8
0
    def ao_manual_control_short_detected(self):
        """
        bool: Indicates whether the physical channel is currently
            disabled due to a short detected on the channel.
        """
        val = c_bool32()

        cfunc = (lib_importer.windll.
                 DAQmxGetPhysicalChanAOManualControlShortDetected)
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str, ctypes.POINTER(c_bool32)]

        error_code = cfunc(
            self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 9
0
    def allow_interactive_deletion(self):
        """
        bool: Indicates whether the global channel can be deleted
            through MAX.
        """
        val = c_bool32()

        cfunc = (lib_importer.windll.
                 DAQmxGetPersistedChanAllowInteractiveDeletion)
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str, ctypes.POINTER(c_bool32)]

        error_code = cfunc(
            self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 10
0
    def allow_interactive_editing(self):
        """
        bool: Indicates whether the task can be edited in the DAQ
            Assistant.
        """
        val = c_bool32()

        cfunc = (lib_importer.windll.
                 DAQmxGetPersistedTaskAllowInteractiveEditing)
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str, ctypes.POINTER(c_bool32)]

        error_code = cfunc(
            self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 11
0
    def ai_sensor_power_open_chan(self):
        """
        bool: Indicates whether there is an open channel or undercurrent
            condition on the channel.
        """
        val = c_bool32()

        cfunc = (lib_importer.windll.DAQmxGetPhysicalChanAISensorPowerOpenChan)
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 12
0
    def di_change_detect_supported(self):
        """
        bool: Indicates if the change detection timing type is supported
            for the digital input physical channel.
        """
        val = c_bool32()

        cfunc = (lib_importer.windll.
                 DAQmxGetPhysicalChanDIChangeDetectSupported)
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str, ctypes.POINTER(c_bool32)]

        error_code = cfunc(
            self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 13
0
    def timestamp_enable(self):
        """
        bool: Specifies whether the arm start trigger timestamp is
            enabled. If the timestamp is enabled but no resources are
            available, an error will be returned at run time.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetArmStartTrigTimestampEnable
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 14
0
    def sync_unlocked_chans_exist(self):
        """
        bool: Indicates whether the target is currently locked to the
            grand master. Devices may report PLL Unlock either during
            acquisition or after acquisition.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetWriteSyncUnlockedChansExist
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 15
0
    def do_overcurrent_auto_reenable(self):
        """
        bool: Specifies whether to automatically reenable channels after
            they no longer exceed the current limit specified by
            **do_overcurrent_limit**.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetDOOvercurrentAutoReenable
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 16
0
    def dig_edge_dig_sync_enable(self):
        """
        bool: Specifies whether to synchronize recognition of
            transitions in the signal to the internal timebase of the
            device.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetDigEdgeArmStartTrigDigSyncEnable
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 17
0
    def do_tristate(self):
        """
        bool: Specifies whether to stop driving the channel and set it
            to a high-impedance state. You must commit the task for this
            setting to take effect.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetDOTristate
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 18
0
    def do_invert_lines(self):
        """
        bool: Specifies whether to invert the lines in the channel. If
            you set this property to True, the lines are at high logic
            when off and at low logic when on.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetDOInvertLines
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 19
0
    def is_task_done(self):
        """
        Queries the status of the task and indicates if it completed
        execution. Use this function to ensure that the specified
        operation is complete before you stop the task.

        Returns:
            bool:

            Indicates if the measurement or generation completed.
        """
        is_task_done = c_bool32()

        cfunc = lib_importer.windll.DAQmxIsTaskDone
        cfunc.argtypes = [
            lib_importer.task_handle, ctypes.POINTER(c_bool32)]

        error_code = cfunc(
            self._handle, ctypes.byref(is_task_done))
        check_for_error(error_code)

        return is_task_done.value
Ejemplo n.º 20
0
    def ao_manual_control_enable(self):
        """
        bool: Specifies if you can control the physical channel
            externally via a manual control located on the device. You
            cannot simultaneously control a channel manually and with
            NI-DAQmx.
        """
        val = c_bool32()

        cfunc = (lib_importer.windll.
                 DAQmxGetPhysicalChanAOManualControlEnable)
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str, ctypes.POINTER(c_bool32)]

        error_code = cfunc(
            self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 21
0
    def do_use_only_on_brd_mem(self):
        """
        bool: Specifies whether to write samples directly to the onboard
            memory of the device, bypassing the memory buffer.
            Generally, you cannot update onboard memory after you start
            the task. Onboard memory includes data FIFOs.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetDOUseOnlyOnBrdMem
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 22
0
    def di_dig_fltr_enable(self):
        """
        bool: Specifies whether to enable the digital filter for the
            line(s) or port(s). You can enable the filter on a line-by-
            line basis. You do not have to enable the filter for all
            lines in a channel.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetDIDigFltrEnable
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 23
0
    def expir_trig_trig_on_network_conn_loss(self):
        """
        bool: Specifies the watchdog timer behavior when the network
            connection is lost between the host and the chassis. If set
            to true, the watchdog timer expires when the chassis detects
            the loss of network connection.
        """
        val = c_bool32()

        cfunc = (lib_importer.windll.
                 DAQmxGetWatchdogExpirTrigTrigOnNetworkConnLoss)
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes.POINTER(c_bool32)]

        error_code = cfunc(
            self._handle, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 24
0
    def overloaded_chans_exist(self):
        """
        bool: Indicates if the device(s) detected an overload in any
            virtual channel in the task. Reading this property clears
            the overload status for all channels in the task. You must
            read this property before you read **overloaded_chans**.
            Otherwise, you will receive an error.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetWriteOverloadedChansExist
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 25
0
    def di_tristate(self):
        """
        bool: Specifies whether to tristate the lines in the channel. If
            you set this property to True, NI-DAQmx tristates the lines
            in the channel. If you set this property to False, NI-DAQmx
            does not modify the configuration of the lines even if the
            lines were previously tristated. Set this property to False
            to read lines in other tasks or to read output-only lines.
        """
        val = c_bool32()

        cfunc = lib_importer.windll.DAQmxGetDITristate
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes_byte_str,
                        ctypes.POINTER(c_bool32)
                    ]

        error_code = cfunc(self._handle, self._name, ctypes.byref(val))
        check_for_error(error_code)

        return val.value
Ejemplo n.º 26
0
    def are_configured_cdaq_sync_ports_disconnected(
            self, chassis_devices_ports="", timeout=WAIT_INFINITELY):
        """
        Verifies configured cDAQ Sync connections between devices.
        Failures generally indicate a wiring issue or that a device has
        been powered off or removed. Stop all NI-DAQmx tasks running on
        the devices prior to running this function because any running
        tasks cause the verification process to fail.

        Args:
            chassis_devices_ports (Optional[str]): Specifies the names
                of the CompactDAQ chassis, C Series modules, or cDAQ
                Sync ports in comma separated form to search. If no
                names are specified, all cDAQ Sync ports on connected,
                non-simulated devices are scanned.
            timeout (Optional[float]): Specifies the time in seconds to
                wait for the device to respond before timing out.
        Returns:
            List[nidaqmx.types.CDAQSyncConnection]:

            Returns the port-to-port connections that failed verification.
        """
        disconnected_ports_exist = c_bool32()

        cfunc = lib_importer.windll.DAQmxAreConfiguredCDAQSyncPortsDisconnected
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes_byte_str, ctypes.c_double,
                        ctypes.POINTER(c_bool32)]

        error_code = cfunc(
            chassis_devices_ports, timeout,
            ctypes.byref(disconnected_ports_exist))
        check_for_error(error_code)

        cfunc = lib_importer.windll.DAQmxGetDisconnectedCDAQSyncPorts
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint)]

        port_list_size = ctypes.c_uint()

        while True:
            size_or_code = cfunc(
                None, ctypes.byref(port_list_size))

            if size_or_code < 0:
                break

            port_list = ctypes.create_string_buffer(size_or_code)

            size_or_code = cfunc(
                port_list, ctypes.byref(port_list_size))

            if is_string_buffer_too_small(size_or_code):
                # Buffer size must have changed between calls; check again.
                continue
            else:
                break

        check_for_error(size_or_code)

        ports = unflatten_channel_string(port_list.value.decode('ascii'))
        output_ports = ports[::2]
        input_ports = ports[1::2]

        connections = []
        for output_port, input_port in zip(output_ports, input_ports):
            connections.append(
                CDAQSyncConnection(output_port=output_port,
                                   input_port=input_port))

        return connections