session.py 文件源码

python
阅读 41 收藏 0 点赞 0 评论 0

项目:nimi-python 作者: ni 项目源码 文件源码
def _write_binary16_waveform_numpy(self, waveform_handle, data):
        '''_write_binary16_waveform

        Writes binary data to the waveform in onboard memory. The waveform
        handle passed must have been created by a call to the
        nifgen_AllocateWaveform or the nifgen_CreateWaveformI16 function.

        By default, the subsequent call to the _write_binary16_waveform
        function continues writing data from the position of the last sample
        written. You can set the write position and offset by calling the
        nifgen_SetWaveformNextWritePosition function. If streaming is enabled,
        you can write more data than the allocated waveform size in onboard
        memory. Refer to the
        `Streaming <REPLACE_DRIVER_SPECIFIC_URL_2(streaming)>`__ topic for more
        information about streaming data.

        Tip:
        This method requires repeated capabilities (usually channels). If called directly on the
        nifgen.Session object, then the method will use all repeated capabilities in the session.
        You can specify a subset of repeated capabilities using the Python index notation on an
        nifgen.Session instance, and calling this method on the result.:

            session['0,1']._write_binary16_waveform(waveform_handle, data)

        Args:
            waveform_handle (int): Specifies the handle of the arbitrary waveform previously allocated with
                the nifgen_AllocateWaveform function.
            data (numpy array of int16): Specifies the array of data to load into the waveform. The array must
                have at least as many elements as the value in **size**. The binary data
                is left-justified.
        '''
        import numpy

        if type(data) is not numpy.ndarray:
            raise TypeError('data must be {0}, is {1}'.format(numpy.ndarray, type(data)))
        if numpy.isfortran(data) is True:
            raise TypeError('data must be in C-order')
        if data.dtype is not numpy.dtype('int16'):
            raise TypeError('data must be numpy.ndarray of dtype=int16, is ' + str(data.dtype))
        vi_ctype = visatype.ViSession(self._vi)  # case 1
        channel_name_ctype = ctypes.create_string_buffer(self._repeated_capability.encode(self._encoding))  # case 2
        waveform_handle_ctype = visatype.ViInt32(waveform_handle)  # case 9
        size_ctype = visatype.ViInt32(0 if data is None else len(data))  # case 6
        data_ctype = numpy.ctypeslib.as_ctypes(data)  # case 13.5
        error_code = self._library.niFgen_WriteBinary16Waveform(vi_ctype, channel_name_ctype, waveform_handle_ctype, size_ctype, data_ctype)
        errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
        return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号