def do_generate_on(self):
        """
        :class:`nidaqmx.constants.ActiveOrInactiveEdgeSelection`:
            Specifies on which edge of the sample clock to generate
            samples.
        """
        val = ctypes.c_int()

        cfunc = lib_importer.windll.DAQmxGetDOGenerateOn
        cfunc.argtypes = [
            lib_importer.task_handle, ctypes_byte_str,
            ctypes.POINTER(ctypes.c_int)
        ]

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

        return ActiveOrInactiveEdgeSelection(val.value)
Beispiel #2
0
    def __init__(self, device_name, task_name='', timeout=10):
        """
        Creates and configures a task that controls the watchdog timer of a
        device. The timer activates when you start the task.

        Use the DAQmx Configure Watchdog Expiration States functions to
        configure channel expiration states. This class does not program
        the watchdog timer on a real-time controller.

        Args:
            device_name (str): Specifies is the name as configured in MAX of
                the device to which this operation applies.
            task_name (str): Specifies the name to assign to the task. If you
                use this constructor in a loop and specify a name for the task,
                you must use the DAQmx Clear Task method within the loop after
                you are finished with the task. Otherwise, NI-DAQmx attempts to
                create multiple tasks with the same name, which results in an
                error.
            timeout (float): Specifies the amount of time in seconds until the
                watchdog timer expires. A value of -1 means the internal timer
                never expires. Set this input to -1 if you use an Expiration
                Trigger to expire the watchdog task. If this time elapses, the
                device sets the physical channels to the states you specify
                with the digital physical channel expiration states input.
        """
        self._handle = lib_importer.task_handle(0)

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

        error_code = cfunc(
            device_name, task_name, ctypes.byref(self._handle), timeout)
        check_for_error(error_code)

        # Saved name is used in self.close() to throw graceful error on
        # double closes.
        self._saved_name = self.name
        self._expiration_states = ExpirationStatesCollection(self._handle)
    def add_do_chan(
            self, lines, name_to_assign_to_lines="",
            line_grouping=LineGrouping.CHAN_FOR_ALL_LINES):
        """
        Creates channel(s) to generate digital signals. You can group
        digital lines into one digital channel or separate them into
        multiple digital channels. If you specify one or more entire
        ports in **lines** input by using port physical channel names,
        you cannot separate the ports into multiple channels. To
        separate ports into multiple channels, use this function
        multiple times with a different port each time.

        Args:
            lines (str): Specifies the names of the digital lines or
                ports to use to create virtual channels. The DAQmx
                physical channel constant lists all lines and ports for
                devices installed in the system.
            name_to_assign_to_lines (Optional[str]): Specifies a name to
                assign to the virtual channel this function creates. If
                you do not specify a value for this input, NI-DAQmx uses
                the physical channel name as the virtual channel name.
            line_grouping (Optional[nidaqmx.constants.LineGrouping]): 
                Specifies how to group digital lines into one or more
                virtual channels. If you specify one or more entire
                ports with the **lines** input, you must set this input
                to **one channel for all lines**.
        Returns:
            nidaqmx._task_modules.channels.do_channel.DOChannel:
            
            Indicates the newly created channel object.
        """
        cfunc = lib_importer.windll.DAQmxCreateDOChan
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [
                        lib_importer.task_handle, ctypes_byte_str,
                        ctypes_byte_str, ctypes.c_int]

        error_code = cfunc(
            self._handle, lines, name_to_assign_to_lines, line_grouping.value)
        check_for_error(error_code)

        return self._create_chan(lines, line_grouping, name_to_assign_to_lines)
Beispiel #4
0
    def expir_trig_dig_edge_edge(self):
        """
        :class:`nidaqmx.constants.Edge`: Specifies on which edge of a
            digital signal to expire the watchdog task.
        """
        val = ctypes.c_int()

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

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

        return Edge(val.value)
    def timeout(self):
        """
        float: Specifies in seconds the amount of time until the
            watchdog timer expires. A value of -1 means the internal
            timer never expires. Set this input to -1 if you use an
            Expiration Trigger to expire the watchdog task.
        """
        val = ctypes.c_double()

        cfunc = lib_importer.windll.DAQmxGetWatchdogTimeout
        cfunc.argtypes = [
            lib_importer.task_handle,
            ctypes.POINTER(ctypes.c_double)
        ]

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

        return val.value
Beispiel #6
0
    def di_num_lines(self):
        """
        int: Indicates the number of digital lines in the channel.
        """
        val = ctypes.c_uint()

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

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

        return val.value
Beispiel #7
0
    def _minor_version(self):
        """
        int: Indicates the minor portion of the installed version of NI-
            DAQmx, such as 0 for version 7.0.
        """
        val = ctypes.c_uint()

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

        error_code = cfunc(
            ctypes.byref(val))
        check_for_error(error_code)

        return val.value
    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 = ctypes.c_bool()

        cfunc = lib_importer.windll.DAQmxGetDIDigFltrEnable
        cfunc.argtypes = [
            lib_importer.task_handle, ctypes_byte_str,
            ctypes.POINTER(ctypes.c_bool)]

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

        return val.value
    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 = ctypes.c_bool()

        cfunc = (lib_importer.windll.
                 DAQmxGetPhysicalChanAOManualControlEnable)
        cfunc.argtypes = [
            ctypes_byte_str, ctypes.POINTER(ctypes.c_bool)]

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

        return val.value
Beispiel #10
0
    def allow_interactive_deletion(self):
        """
        bool: Indicates whether the task can be deleted through MAX.
        """
        val = c_bool32()

        cfunc = (lib_importer.windll.
                 DAQmxGetPersistedTaskAllowInteractiveDeletion)
        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
Beispiel #11
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
Beispiel #12
0
    def scale_type(self):
        """
        :class:`nidaqmx.constants.ScaleType`: Indicates the method or
            equation form that the custom scale uses.
        """
        val = ctypes.c_int()

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

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

        return ScaleType(val.value)
Beispiel #13
0
    def dig_edge_dig_fltr_timebase_rate(self):
        """
        float: Specifies in hertz the rate of the pulse width filter
            timebase. NI-DAQmx uses this value to compute settings for
            the filter.
        """
        val = ctypes.c_double()

        cfunc = (
            lib_importer.windll.DAQmxGetDigEdgeArmStartTrigDigFltrTimebaseRate)
        cfunc.argtypes = [
            lib_importer.task_handle,
            ctypes.POINTER(ctypes.c_double)
        ]

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

        return val.value
Beispiel #14
0
    def pre_scaled_units(self):
        """
        :class:`nidaqmx.constants.UnitsPreScaled`: Specifies the units
            of the values that you want to scale.
        """
        val = ctypes.c_int()

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

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

        return UnitsPreScaled(val.value)
Beispiel #15
0
    def map_pre_scaled_min(self):
        """
        float: Specifies the smallest value in the range of pre-scaled
            values. NI-DAQmx maps this value to **map_scaled_min**.
        """
        val = ctypes.c_double()

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

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

        return val.value
Beispiel #16
0
    def expir_states_ao_type(self):
        """
        :class:`nidaqmx.constants.WatchdogAOExpirState`: Specifies the
            output type of the analog output physical channels when the
            watchdog task expires.
        """
        val = ctypes.c_int()

        cfunc = lib_importer.windll.DAQmxGetWatchdogAOOutputType
        cfunc.argtypes = [
            lib_importer.task_handle, ctypes_byte_str,
            ctypes.POINTER(ctypes.c_int)
        ]

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

        return WatchdogAOExpirState(val.value)
Beispiel #17
0
    def is_global(self):
        """
        bool: Indicates whether the channel is a global channel.
        """
        val = ctypes.c_bool()

        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(ctypes.c_bool)
                    ]

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

        return val.value
Beispiel #18
0
def _read_ctr_freq_scalar(task_handle, timeout):
    freq = ctypes.c_double()
    duty_cycle = ctypes.c_double()

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

    error_code = cfunc(task_handle, timeout, ctypes.byref(freq),
                       ctypes.byref(duty_cycle), None)
    check_for_error(error_code)

    value = CtrFreq(freq.value, duty_cycle.value)

    return value
Beispiel #19
0
    def ao_manual_control_freq(self):
        """
        float: Indicates the current value of the front panel frequency
            control for the physical channel in hertz.
        """
        val = ctypes.c_double()

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

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

        return val.value
Beispiel #20
0
def _read_ctr_time_scalar(task_handle, timeout):
    high_time = ctypes.c_double()
    low_time = ctypes.c_double()

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

    error_code = cfunc(task_handle, timeout, ctypes.byref(high_time),
                       ctypes.byref(low_time), None)
    check_for_error(error_code)

    value = CtrTime(high_time.value, low_time.value)

    return value
Beispiel #21
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
    def ao_power_amp_offset(self):
        """
        float: Indicates the calibrated offset of the channel in volts.
        """
        val = ctypes.c_double()

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

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

        return val.value
Beispiel #23
0
    def relative_to(self):
        """
        :class:`nidaqmx.constants.WriteRelativeTo`: Specifies the point
            in the buffer at which to write data. If you also specify an
            offset with **offset**, the write operation begins at that
            offset relative to this point you select with this property.
        """
        val = ctypes.c_int()

        cfunc = lib_importer.windll.DAQmxGetRelativeTo
        cfunc.argtypes = [
            lib_importer.task_handle,
            ctypes.POINTER(ctypes.c_int)
        ]

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

        return WriteRelativeTo(val.value)
    def do_port_width(self):
        """
        int: Indicates in bits the width of digital output port.
        """
        val = ctypes.c_uint()

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

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

        return val.value
Beispiel #25
0
    def lin_slope(self):
        """
        float: Specifies the slope, m, in the equation y=mx+b.
        """
        val = ctypes.c_double()

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

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

        return val.value
Beispiel #26
0
    def expir_trig_trig_type(self):
        """
        :class:`nidaqmx.constants.TriggerType`: Specifies the type of
            trigger to use to expire a watchdog task.
        """
        val = ctypes.c_int()

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

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

        return TriggerType(val.value)
Beispiel #27
0
    def _control_watchdog_task(self, action):
        """
        Controls the watchdog timer task according to the action you
        specify. This function does not program the watchdog timer on a
        real-time controller. Use the Real-Time Watchdog VIs to program
        the watchdog timer on a real-time controller.

        Args:
            action (nidaqmx.constants.WDTTaskAction): Specifies how to
                control the watchdog timer task.
        """
        cfunc = lib_importer.windll.DAQmxControlWatchdogTask
        if cfunc.argtypes is None:
            with cfunc.arglock:
                if cfunc.argtypes is None:
                    cfunc.argtypes = [lib_importer.task_handle, ctypes.c_int]

        error_code = cfunc(self._handle, action.value)
        check_for_error(error_code)
    def teds_version_num(self):
        """
        int: Indicates the version number of the sensor.
        """
        val = ctypes.c_uint()

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

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

        return val.value
    def teds_mfg_id(self):
        """
        int: Indicates the manufacturer ID of the sensor.
        """
        val = ctypes.c_uint()

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

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

        return val.value
Beispiel #30
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