Skip to content

Commit

Permalink
Merge branch 'lupien-move_control_ren2'
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed May 19, 2015
2 parents 8fc41ff + 1a0de8f commit 22a9228
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
17 changes: 2 additions & 15 deletions pyvisa/resources/gpib.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

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


class _GPIBMixin(object):
class _GPIBMixin(ControlRenMixin):
"""Common attributes and methods of GPIB Instr and Interface.
"""

Expand Down Expand Up @@ -48,19 +48,6 @@ def control_atn(self, mode):
"""
return self.visalib.gpib_control_atn(self.session, mode)

def control_ren(self, mode):
"""Controls the state of the GPIB Remote Enable (REN) interface line, and optionally the remote/local
state of the device.
Corresponds to viGpibControlREN function of the VISA library.
:param mode: Specifies the state of the REN line and optionally the device remote/local state.
(Constants.GPIB_REN*)
:return: return value of the library call.
:rtype: VISAStatus
"""
return self.visalib.gpib_control_ren(self.session, mode)

def pass_control(self, primary_address, secondary_address):
"""Tell the GPIB device at the specified address to become controller in charge (CIC).
Expand Down
20 changes: 20 additions & 0 deletions pyvisa/resources/messagebased.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ def use_binary(self, datatype, is_big_endian, container=list, header_fmt='ieee')
self.header_fmt = header_fmt


class ControlRenMixin(object):
"""Common controlt_ren method of some messaged based resources.
"""
# It should work for GPIB, USB and some TCPIP
# For TCPIP I found some (all?) NI's VISA library do not handle control_ren, but
# it works for Agilent's VISA library (at least some of them)
def control_ren(self, mode):
"""Controls the state of the GPIB Remote Enable (REN) interface line, and optionally the remote/local
state of the device.
Corresponds to viGpibControlREN function of the VISA library.
:param mode: Specifies the state of the REN line and optionally the device remote/local state.
(Constants.GPIB_REN*)
:return: return value of the library call.
:rtype: VISAStatus
"""
return self.visalib.gpib_control_ren(self.session, mode)


class MessageBasedResource(Resource):
"""Base class for resources that use message based communication.
"""
Expand Down
4 changes: 2 additions & 2 deletions pyvisa/resources/tcpip.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
from .. import constants

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


@Resource.register(constants.InterfaceType.tcpip, 'INSTR')
class TCPIPInstrument(MessageBasedResource):
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:
Expand Down
4 changes: 2 additions & 2 deletions pyvisa/resources/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
from __future__ import division, unicode_literals, print_function, absolute_import

from .. import constants
from .messagebased import MessageBasedResource
from .messagebased import MessageBasedResource, ControlRenMixin


@MessageBasedResource.register(constants.InterfaceType.usb, 'INSTR')
class USBInstrument(MessageBasedResource):
class USBInstrument(ControlRenMixin, MessageBasedResource):
"""Communicates with devices of type USB::manufacturer ID::model code::serial number
More complex resource names can be specified with the following grammar:
Expand Down

0 comments on commit 22a9228

Please sign in to comment.