示例#1
0
文件: visa.py 项目: rasmusto/pyvisa
    def wait_for_srq(self, timeout=25):
        """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.

        Parameters:
        timeout -- (optional) the maximal waiting time in seconds.  The default
            value is 25 (seconds).  "None" means waiting forever if necessary.

        """
        vpp43.enable_event(self.vi, VI_EVENT_SERVICE_REQ, VI_QUEUE)
        if timeout and not(0 <= timeout <= 4294967):
            raise ValueError, "timeout value is invalid"
        starting_time = time.clock()
        while True:
            if timeout is None:
                adjusted_timeout = VI_TMO_INFINITE
            else:
                adjusted_timeout = int((starting_time + timeout - time.clock())
                                       * 1000)
                if adjusted_timeout < 0:
                    adjusted_timeout = 0
            event_type, context = \
                vpp43.wait_on_event(self.vi, VI_EVENT_SERVICE_REQ,
                                    adjusted_timeout)
            vpp43.close(context)
            if self.stb & 0x40:
                break
        vpp43.discard_events(self.vi, VI_EVENT_SERVICE_REQ, VI_QUEUE)
示例#2
0
文件: visa.py 项目: rasmusto/pyvisa
    def __init__(self, gpib_identifier, board_number=0, **keyw):
        """Class constructor.

        parameters:
        gpib_identifier -- if it's a string, it is interpreted as the
            instrument's VISA resource name.  If it's a number, it's the
            instrument's GPIB number.
        board_number -- (default: 0) the number of the GPIB bus.

        Further keyword arguments are passed to the constructor of class
        Instrument.

        """
        _warn_for_invalid_keyword_arguments(keyw, ("timeout", "term_chars",
                                                   "chunk_size", "lock",
                                                   "delay", "send_end",
                                                   "values_format"))
        if isinstance(gpib_identifier, int):
            resource_name = "GPIB%d::%d" % (board_number, gpib_identifier)
        else:
            resource_name = gpib_identifier
        Instrument.__init__(self, resource_name, **keyw)
        # Now check whether the instrument is really valid
        if self.interface_type != VI_INTF_GPIB:
            raise ValueError, "device is not a GPIB instrument"
        vpp43.enable_event(self.vi, VI_EVENT_SERVICE_REQ, VI_QUEUE)
示例#3
0
    def wait_for_srq(self, timeout=25):
        """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.

        Parameters:
        timeout -- (optional) the maximal waiting time in seconds.  The default
            value is 25 (seconds).  "None" means waiting forever if necessary.

        """
        vpp43.enable_event(self.vi, VI_EVENT_SERVICE_REQ, VI_QUEUE)
        if timeout and not(0 <= timeout <= 4294967):
            raise ValueError, "timeout value is invalid"
        starting_time = time.clock()
        while True:
            if timeout is None:
                adjusted_timeout = VI_TMO_INFINITE
            else:
                adjusted_timeout = int((starting_time + timeout - time.clock())
                                       * 1000)
                if adjusted_timeout < 0:
                    adjusted_timeout = 0
            event_type, context = \
                vpp43.wait_on_event(self.vi, VI_EVENT_SERVICE_REQ,
                                    adjusted_timeout)
            vpp43.close(context)
            if self.stb & 0x40:
                break
        vpp43.discard_events(self.vi, VI_EVENT_SERVICE_REQ, VI_QUEUE)
示例#4
0
    def __init__(self, gpib_identifier, board_number=0, **keyw):
        """Class constructor.

        parameters:
        gpib_identifier -- if it's a string, it is interpreted as the
            instrument's VISA resource name.  If it's a number, it's the
            instrument's GPIB number.
        board_number -- (default: 0) the number of the GPIB bus.

        Further keyword arguments are passed to the constructor of class
        Instrument.

        """
        _warn_for_invalid_keyword_arguments(keyw, ("timeout", "term_chars",
                                                   "chunk_size", "lock",
                                                   "delay", "send_end",
                                                   "values_format"))
        if isinstance(gpib_identifier, int):
            resource_name = "GPIB%d::%d" % (board_number, gpib_identifier)
        else:
            resource_name = gpib_identifier
        Instrument.__init__(self, resource_name, **keyw)
        # Now check whether the instrument is really valid
        if self.interface_type != VI_INTF_GPIB:
            raise ValueError, "device is not a GPIB instrument"
        vpp43.enable_event(self.vi, VI_EVENT_SERVICE_REQ, VI_QUEUE)
示例#5
0
 def __init__(self, gpib_identifier, board_number=0, **keyw):
     _warn_for_invalid_keyword_arguments(keyw, ("timeout", "term_chars",
                                                "chunk_size", "lock",
                                                "delay", "send_end",
                                                "values_format"))
     if isinstance(gpib_identifier, int):
         resource_name = "GPIB%d::%d" % (board_number, gpib_identifier)
     else:
         resource_name = gpib_identifier
     Instrument.__init__(self, resource_name, **keyw)
     # Now check whether the instrument is really valid
     if self.interface_type != VI_INTF_GPIB:
         raise ValueError("device is not a GPIB instrument")
     vpp43.enable_event(self.vi, VI_EVENT_SERVICE_REQ, VI_QUEUE)