コード例 #1
0
ファイル: test_visa.py プロジェクト: jenshnielsen/Qcodes
    def write(self, cmd):
        if self.closed:
            raise RuntimeError("Trying to write to a closed instrument")
        num = float(cmd.split(':')[-1])
        self.state = num

        if num < 0:
            raise ValueError('be more positive!')

        if num == 0:
            raise visa.VisaIOError(visa.constants.VI_ERROR_TMO)

        return len(cmd)
コード例 #2
0
ファイル: visa.py プロジェクト: mizkulg/Qcodes
    def check_error(self, ret_code: int) -> None:
        """
        Default error checking, raises an error if return code ``!=0``.
        Does not differentiate between warnings or specific error messages.
        Override this function in your driver if you want to add specific
        error messages.

        Args:
            ret_code: A Visa error code. See eg:
                https://github.com/hgrecco/pyvisa/blob/master/pyvisa/errors.py

        Raises:
            visa.VisaIOError: if ``ret_code`` indicates a communication
                problem.
        """
        if ret_code != 0:
            raise visa.VisaIOError(ret_code)