How to use the pyvisa.resources.resource.Resource.register function in PyVISA

To help you get started, we’ve selected a few PyVISA examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyvisa / pyvisa / pyvisa / resources / gpib.py View on Github external
while True:
            if timeout is None:
                adjusted_timeout = constants.VI_TMO_INFINITE
            else:
                adjusted_timeout = int((starting_time + timeout/1e3 - time.clock())*1e3)
                if adjusted_timeout < 0:
                    adjusted_timeout = 0

            self.wait_on_event(constants.VI_EVENT_SERVICE_REQ, adjusted_timeout)
            if self.stb & 0x40:
                break

        self.discard_events(constants.VI_EVENT_SERVICE_REQ, constants.VI_QUEUE)


@Resource.register(constants.InterfaceType.gpib, 'INTFC')
class GPIBInterface(_GPIBMixin, Resource):
    """Communicates with to devices of type GPIB::INTFC

    More complex resource names can be specified with the following grammar:
        GPIB[board]::INTFC

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """

    def group_execute_trigger(self, *resources):

        for resource in resources:
            if not isinstance(resource, GPIBInstrument):
                raise ValueError('%r is not a GPIBInstrument', resource)

            # TODO: check that all resources are in the same board.
github pyvisa / pyvisa / pyvisa / resources / tcpip.py View on Github external
from .resource import Resource
from .messagebased import MessageBasedResource, ControlRenMixin


@Resource.register(constants.InterfaceType.tcpip, 'INSTR')
class TCPIPInstrument(ControlRenMixin, MessageBasedResource):
    """Communicates with to devices of type TCPIP::host address[::INSTR]

    More complex resource names can be specified with the following grammar:
        TCPIP[board]::host address[::LAN device name][::INSTR]

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """


@Resource.register(constants.InterfaceType.tcpip, 'SOCKET')
class TCPIPSocket(MessageBasedResource):
    """Communicates with to devices of type TCPIP::host address::port::SOCKET
github pyvisa / pyvisa / pyvisa / resources / pxi.py View on Github external
This file is part of PyVISA.

    :copyright: 2014 by PyVISA Authors, see AUTHORS for more details.
    :license: MIT, see LICENSE for more details.
"""

from __future__ import division, unicode_literals, print_function, absolute_import

from .. import constants

from .resource import Resource
from .registerbased import RegisterBasedResource


@Resource.register(constants.InterfaceType.pxi, 'INSTR')
class PXIInstrument(RegisterBasedResource):
    """Communicates with to devices of type PXI::[::INSTR]

    More complex resource names can be specified with the following grammar:
        PXI[bus]::device[::function][::INSTR]
    or:
        PXI[interface]::bus-device[.function][::INSTR]
    or:
        PXI[interface]::CHASSISchassis number::SLOTslot number[::FUNCfunction][::INSTR]

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """


@Resource.register(constants.InterfaceType.pxi, 'MEMACC')
class PXIMemory(RegisterBasedResource):
github pyvisa / pyvisa / pyvisa / resources / tcpip.py View on Github external
This file is part of PyVISA.

    :copyright: 2014 by PyVISA Authors, see AUTHORS for more details.
    :license: MIT, see LICENSE for more details.
"""

from __future__ import division, unicode_literals, print_function, absolute_import

from .. import constants

from .resource import Resource
from .messagebased import MessageBasedResource, ControlRenMixin


@Resource.register(constants.InterfaceType.tcpip, 'INSTR')
class TCPIPInstrument(ControlRenMixin, MessageBasedResource):
    """Communicates with to devices of type TCPIP::host address[::INSTR]

    More complex resource names can be specified with the following grammar:
        TCPIP[board]::host address[::LAN device name][::INSTR]

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """


@Resource.register(constants.InterfaceType.tcpip, 'SOCKET')
class TCPIPSocket(MessageBasedResource):
    """Communicates with to devices of type TCPIP::host address::port::SOCKET
github pyvisa / pyvisa / pyvisa / resources / resource.py View on Github external
The returned context is the access_key if applicable.

        """
        if requested_key == 'exclusive':
            self.lock_excl(timeout)
            access_key = None
        else:
            access_key = self.lock(timeout, requested_key)
        try:
            yield access_key
        finally:
            self.unlock()


Resource.register(constants.InterfaceType.unknown, '')(Resource)
github pyvisa / pyvisa / pyvisa / resources / gpib.py View on Github external
:rtype: VISAStatus
        """
        return self.visalib.gpib_pass_control(self.session, primary_address, secondary_address)

    def send_ifc(self):
        """Pulse the interface clear line (IFC) for at least 100 microseconds.

        Corresponds to viGpibSendIFC function of the VISA library.

        :return: return value of the library call.
        :rtype: VISAStatus
        """
        return self.visalib.gpib_send_ifc(self.session)


@Resource.register(constants.InterfaceType.gpib, 'INSTR')
class GPIBInstrument(_GPIBMixin, MessageBasedResource):
    """Communicates with to devices of type GPIB::[::INSTR]

    More complex resource names can be specified with the following grammar:
        GPIB[board]::primary address[::secondary address][::INSTR]

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """

    def wait_for_srq(self, timeout=25000):
        """Wait for a serial request (SRQ) coming from the instrument.

        Note that this method is not ended when *another* instrument signals an
        SRQ, only *this* instrument.

        :param timeout: the maximum waiting time in milliseconds.
github pyvisa / pyvisa / pyvisa / resources / vxi.py View on Github external
from .resource import Resource
from .registerbased import RegisterBasedResource


@Resource.register(constants.InterfaceType.vxi, 'BACKPLANE')
class VXIBackplane(Resource):
    """Communicates with to devices of type VXI::BACKPLANE

    More complex resource names can be specified with the following grammar:
        VXI[board][::VXI logical address]::BACKPLANE

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """


@Resource.register(constants.InterfaceType.vxi, 'INSTR')
class VXIInstrument(Resource):
    """Communicates with to devices of type VXI::VXI logical address[::INSTR]

    More complex resource names can be specified with the following grammar:
        VXI[board]::VXI logical address[::INSTR]

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """


@Resource.register(constants.InterfaceType.vxi, 'MEMACC')
class VXIMemory(RegisterBasedResource):
    """Communicates with to devices of type VXI[board]::MEMACC
github pyvisa / pyvisa / pyvisa / resources / vxi.py View on Github external
This file is part of PyVISA.

    :copyright: 2014 by PyVISA Authors, see AUTHORS for more details.
    :license: MIT, see LICENSE for more details.
"""

from __future__ import division, unicode_literals, print_function, absolute_import

from .. import constants

from .resource import Resource
from .registerbased import RegisterBasedResource


@Resource.register(constants.InterfaceType.vxi, 'BACKPLANE')
class VXIBackplane(Resource):
    """Communicates with to devices of type VXI::BACKPLANE

    More complex resource names can be specified with the following grammar:
        VXI[board][::VXI logical address]::BACKPLANE

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """


@Resource.register(constants.InterfaceType.vxi, 'INSTR')
class VXIInstrument(Resource):
    """Communicates with to devices of type VXI::VXI logical address[::INSTR]

    More complex resource names can be specified with the following grammar:
        VXI[board]::VXI logical address[::INSTR]
github pyvisa / pyvisa / pyvisa / resources / vxi.py View on Github external
Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """


@Resource.register(constants.InterfaceType.vxi, 'INSTR')
class VXIInstrument(Resource):
    """Communicates with to devices of type VXI::VXI logical address[::INSTR]

    More complex resource names can be specified with the following grammar:
        VXI[board]::VXI logical address[::INSTR]

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """


@Resource.register(constants.InterfaceType.vxi, 'MEMACC')
class VXIMemory(RegisterBasedResource):
    """Communicates with to devices of type VXI[board]::MEMACC
github pyvisa / pyvisa / pyvisa / resources / pxi.py View on Github external
@Resource.register(constants.InterfaceType.pxi, 'INSTR')
class PXIInstrument(RegisterBasedResource):
    """Communicates with to devices of type PXI::[::INSTR]

    More complex resource names can be specified with the following grammar:
        PXI[bus]::device[::function][::INSTR]
    or:
        PXI[interface]::bus-device[.function][::INSTR]
    or:
        PXI[interface]::CHASSISchassis number::SLOTslot number[::FUNCfunction][::INSTR]

    Do not instantiate directly, use :meth:`pyvisa.highlevel.ResourceManager.open_resource`.
    """


@Resource.register(constants.InterfaceType.pxi, 'MEMACC')
class PXIMemory(RegisterBasedResource):
    """Communicates with to devices of type PXI[interface]::MEMACC