Exemple #1
0
def test_agilent34410a_r():
    with expected_protocol(ik.agilent.Agilent34410a,
                           ["CONF?", "FORM:DATA REAL,64", "R? 1"], [
                               "VOLT +1.000000E+01,+3.000000E-06",
                               "#18" + "3FF0000000000000".decode("hex")
                           ]) as dmm:
        unit_eq(dmm.r(1), np.array([1]) * pq.volt)
def test_scpi_multimeter_measure():
    with expected_protocol(ik.generic_scpi.SCPIMultimeter, [
            "MEAS:VOLT:DC?",
    ], [
            "+4.23450000E-03",
    ]) as dmm:
        unit_eq(dmm.measure(dmm.Mode.voltage_dc), 4.2345e-03 * pq.volt)
def test_agilent34410a_read_last_data():
    with expected_protocol(ik.agilent.Agilent34410a, [
            "DATA:LAST?",
    ], [
            "+1.73730000E-03 VDC",
    ]) as dmm:
        unit_eq(dmm.read_last_data(), 1.73730000E-03 * u.volt)
def test_cc1_dwell_new_firmware():
    with expected_protocol(ik.qubitekk.CC1,
                           [":ACKN OF", "FIRM?", "DWEL?", ":DWEL 2"],
                           ["", "Firmware v2.010", "8"],
                           sep="\n") as cc:
        unit_eq(cc.dwell_time, pq.Quantity(8, "s"))
        cc.dwell_time = 2
def test_hp6632b_output_protection_delay():
    with expected_protocol(
            ik.hp.HP6632b,
        ["OUTP:PROT:DEL?", "OUTP:PROT:DEL {:e}".format(5e-02)],
        ["8e-02"]) as psu:
        unit_eq(psu.output_protection_delay, 8e-02 * u.second)
        psu.output_protection_delay = 5e-02 * u.second
def test_hp6632b_current_sense_range():
    with expected_protocol(
            ik.hp.HP6632b,
        ["SENS:CURR:RANGE?", "SENS:CURR:RANGE {:e}".format(1)],
        ["0.05"]) as psu:
        unit_eq(psu.current_sense_range, 0.05 * u.amp)
        psu.current_sense_range = 1 * u.amp
def test_cc1_dwell_old_firmware():
    with expected_protocol(ik.qubitekk.CC1,
                           [":ACKN OF", "FIRM?", "DWEL?", ":DWEL 2"],
                           ["Unknown Command", "Firmware v2.001", "8000", ""],
                           sep="\n") as cc:
        unit_eq(cc.dwell_time, pq.Quantity(8, "s"))
        cc.dwell_time = 2
def test_cc1_delay():
    with expected_protocol(ik.qubitekk.CC1,
                           [":ACKN OF", "FIRM?", "DELA?", ":DELA 2"],
                           ["", "Firmware v2.010", "8", ""],
                           sep="\n") as cc:
        unit_eq(cc.delay, pq.Quantity(8, "ns"))
        cc.delay = 2
def test_hp6632b_sense_sweep_interval():
    with expected_protocol(
            ik.hp.HP6632b,
        ["SENS:SWE:TINT?", "SENS:SWE:TINT {:e}".format(1e-05)],
        ["1.56e-05"]) as psu:
        unit_eq(psu.sense_sweep_interval, 1.56e-05 * u.second)
        psu.sense_sweep_interval = 1e-05 * u.second
Exemple #10
0
def test_gpibusbcomm_timeout():
    comm = GPIBCommunicator(mock.MagicMock(), 1)
    comm._version = 5

    unit_eq(comm.timeout, 1000 * pq.millisecond)

    comm.timeout = 5000 * pq.millisecond
    comm._file.sendcmd.assert_called_with("++read_tmo_ms 5000.0")
Exemple #11
0
def test_lcc25_minvoltage():
    with expected_protocol(
        ik.thorlabs.LCC25,
        "min?\rmin=10.0\r",
        "\r>20\r"
    ) as lcc:
        unit_eq(lcc.min_voltage, pq.Quantity(20, "V"))
        lcc.min_voltage = 10.0
Exemple #12
0
def test_lcc25_voltage2():
    with expected_protocol(
        ik.thorlabs.LCC25,
        "volt2?\rvolt2=10.0\r",
        "\r20\r"
    ) as lcc:
        unit_eq(lcc.voltage2, pq.Quantity(20, "V"))
        lcc.voltage2 = 10.0
Exemple #13
0
def test_lcc25_frequency():
    with expected_protocol(
        ik.thorlabs.LCC25,
        "freq?\rfreq=10.0\r",
        "\r>20\r"
    ) as lcc:
        unit_eq(lcc.frequency, pq.Quantity(20, "Hz"))
        lcc.frequency = 10.0
Exemple #14
0
def test_sc10_shut_time():
    with expected_protocol(
        ik.thorlabs.SC10,
        "shut?\rshut=10\r",
        "\r20\r>\r"
    ) as sc:
        unit_eq(sc.shut_time, pq.Quantity(20, "ms"))
        sc.shut_time = 10.0
Exemple #15
0
def test_sc10_open_time():
    with expected_protocol(
        ik.thorlabs.SC10,
        "open?\ropen=10\r",
        "\r20\r>\r"
    ) as sc:
        unit_eq(sc.open_time, pq.Quantity(20, "ms"))
        sc.open_time = 10.0
Exemple #16
0
def test_lcc25_increment():
    with expected_protocol(
        ik.thorlabs.LCC25,
        "increment?\rincrement=10.0\r",
        "\r>20\r"
    ) as lcc:
        unit_eq(lcc.increment, pq.Quantity(20, "V"))
        lcc.increment = 10.0
Exemple #17
0
def test_lcc25_dwell():
    with expected_protocol(
        ik.thorlabs.LCC25,
        "dwell?\rdwell=10\r",
        "\r>20\r"
    ) as lcc:
        unit_eq(lcc.dwell, pq.Quantity(20, "ms"))
        lcc.dwell = 10
Exemple #18
0
def test_lcc25_voltage2():
    with expected_protocol(ik.thorlabs.LCC25, [
            "volt2?",
            "volt2=10.0",
    ], ["volt2?", "20", ">volt2=10.0", ">"],
                           sep="\r") as lcc:
        unit_eq(lcc.voltage2, u.Quantity(20, "V"))
        lcc.voltage2 = 10.0
def test_agilent34410a_fetch():
    with expected_protocol(
            ik.agilent.Agilent34410a, ["CONF?", "FETC?"],
        ["VOLT +1.000000E+01,+3.000000E-06", "+4.27150000E-03,5.27150000E-03"
         ]) as dmm:
        data = dmm.fetch()
        unit_eq(data[0], 4.27150000E-03 * u.volt)
        unit_eq(data[1], 5.27150000E-03 * u.volt)
Exemple #20
0
def test_gpibusbcomm_timeout():
    comm = GPIBCommunicator(mock.MagicMock(), 1)
    comm._version = 5

    unit_eq(comm.timeout, 1000 * pq.millisecond)

    comm.timeout = 5000 * pq.millisecond
    comm._file.sendcmd.assert_called_with("++read_tmo_ms 5000.0")
Exemple #21
0
def test_srsdg645_burst_delay():
    """
        SRSDG645: Checks getting/setting of enabling T0 output on first
        in burst mode.
        """
    with expected_protocol(ik.srs.SRSDG645, ["BURD?", "BURD 42"],
                           ["0"]) as ddg:
        unit_eq(ddg.burst_delay, u.Quantity(0, "s"))
        ddg.burst_delay = u.Quantity(42, "s")
Exemple #22
0
def test_srsdg645_burst_period():
    """
        SRSDG645: Checks getting/setting of enabling T0 output on first
        in burst mode.
        """
    with expected_protocol(ik.srs.SRSDG645, ["BURP?", "BURP 13"],
                           ["100E-9"]) as ddg:
        unit_eq(ddg.burst_period, u.Quantity(100, "ns").rescale(u.s))
        ddg.burst_period = u.Quantity(13, "s")
def test_scpi_multimeter_sample_timer():
    with expected_protocol(ik.generic_scpi.SCPIMultimeter, [
            "SAMP:TIM?",
            "SAMP:TIM {:e}".format(1),
    ], [
            "+1",
    ]) as dmm:
        unit_eq(dmm.sample_timer, 1 * pq.second)
        dmm.sample_timer = 1000 * pq.millisecond
def test_agilent34410a_read_data():
    with expected_protocol(
            ik.agilent.Agilent34410a,
        ["CONF?", "FORM:DATA ASC", "DATA:REM? 2"],
        ["VOLT +1.000000E+01,+3.000000E-06", "+4.27150000E-03,5.27150000E-03"
         ]) as dmm:
        data = dmm.read_data(2)
        unit_eq(data[0], 4.27150000E-03 * u.volt)
        unit_eq(data[1], 5.27150000E-03 * u.volt)
def test_agilent34410a_read_data_nvmem():
    with expected_protocol(ik.agilent.Agilent34410a, [
            "CONF?",
            "DATA:DATA? NVMEM",
    ], ["VOLT +1.000000E+01,+3.000000E-06", "+4.27150000E-03,5.27150000E-03"
        ]) as dmm:
        data = dmm.read_data_nvmem()
        unit_eq(data[0], 4.27150000E-03 * u.volt)
        unit_eq(data[1], 5.27150000E-03 * u.volt)
def test_scpi_multimeter_trigger_delay():
    with expected_protocol(ik.generic_scpi.SCPIMultimeter, [
            "TRIG:DEL?",
            "TRIG:DEL {:e}".format(1),
    ], [
            "+1",
    ]) as dmm:
        unit_eq(dmm.trigger_delay, 1 * pq.second)
        dmm.trigger_delay = 1000 * pq.millisecond
Exemple #27
0
def test_gpibusbcomm_init_correct_values_new_firmware():
    mock_gpib = mock.MagicMock()
    mock_gpib.query.return_value = "5"
    comm = GPIBCommunicator(mock_gpib, 1)

    eq_(comm._terminator, "\n")
    eq_(comm._version, 5)
    eq_(comm._eos, "\n")
    eq_(comm._eoi, True)
    unit_eq(comm._timeout, 1000 * pq.millisecond)
Exemple #28
0
def test_hp6632b_voltage_sense():
    with expected_protocol(
        ik.hp.HP6632b,
        [
            "MEAS:VOLT?",
        ] , [
            "10.0"
        ]
    ) as psu:
        unit_eq(psu.voltage_sense, 10*pq.volt)
def test_gpibusbcomm_init_correct_values_new_firmware():
    mock_gpib = mock.MagicMock()
    mock_gpib.query.return_value = "5"
    comm = GPIBCommunicator(mock_gpib, 1)

    assert comm._terminator == "\n"
    assert comm._version == 5
    assert comm._eos == "\n"
    assert comm._eoi is True
    unit_eq(comm._timeout, 1000 * pq.millisecond)
Exemple #30
0
def test_agilent34410a_read_last_data():
    with expected_protocol(
        ik.agilent.Agilent34410a,
        [
            "DATA:LAST?",
        ] , [
            "+1.73730000E-03 VDC",
        ]
    ) as dmm:
        unit_eq(dmm.read_last_data(), 1.73730000E-03 * pq.volt)
Exemple #31
0
def test_gpibusbcomm_init_correct_values_new_firmware():
    mock_gpib = mock.MagicMock()
    mock_gpib.query.return_value = "5"
    comm = GPIBCommunicator(mock_gpib, 1)

    eq_(comm._terminator, "\n")
    eq_(comm._version, 5)
    eq_(comm._eos, "\n")
    eq_(comm._eoi, True)
    unit_eq(comm._timeout, 1000 * pq.millisecond)
def test_agilent34410a_r():
    with expected_protocol(
            ik.agilent.Agilent34410a,
        ["CONF?", "FORM:DATA REAL,64", "R? 1"],
        [
            "VOLT +1.000000E+01,+3.000000E-06",
            # pylint: disable=no-member
            b"#18" + bytes.fromhex("3FF0000000000000")
        ]) as dmm:
        unit_eq(dmm.r(1), np.array([1]) * u.volt)
def test_cc1_window():
    with expected_protocol(ik.qubitekk.CC1,
                           [":ACKN OF", "FIRM?", "WIND?", ":WIND 7"], [
                               "",
                               "Firmware v2.010",
                               "2",
                           ],
                           sep="\n") as cc:
        unit_eq(cc.window, pq.Quantity(2, "ns"))
        cc.window = 7
Exemple #34
0
def test_hp6632b_current_sense():
    with expected_protocol(
        ik.hp.HP6632b,
        [
            "MEAS:CURR?",
        ] , [
            "10.0"
        ]
    ) as psu:
        unit_eq(psu.current_sense, 10*pq.amp)
def test_srsdg645_output_offset():
    """
    SRSDG645: Checks getting/setting unitful output offset.
    """
    with expected_protocol(ik.srs.SRSDG645, [
            "LOFF? 1",
            "LOFF 1,2.0",
    ], ["1.2"]) as ddg:
        unit_eq(ddg.output["AB"].level_offset, u.Quantity(1.2, "V"))
        ddg.output["AB"].level_offset = 2.0
def test_srsdg645_output_level():
    """
    SRSDG645: Checks getting/setting unitful output level.
    """
    with expected_protocol(ik.srs.SRSDG645, [
            "LAMP? 1",
            "LAMP 1,4.0",
    ], ["3.2"]) as ddg:
        unit_eq(ddg.output["AB"].level_amplitude, u.Quantity(3.2, "V"))
        ddg.output["AB"].level_amplitude = 4.0
Exemple #37
0
def test_scpi_multimeter_measure():
    with expected_protocol(
        ik.generic_scpi.SCPIMultimeter,
        [
            "MEAS:VOLT:DC?",
        ] , [
            "+4.23450000E-03",
        ]
    ) as dmm:
        unit_eq(dmm.measure(dmm.Mode.voltage_dc), 4.2345e-03 * pq.volt)
Exemple #38
0
def test_scpi_multimeter_sample_timer():
    with expected_protocol(
        ik.generic_scpi.SCPIMultimeter,
        [
            "SAMP:TIM?",
            "SAMP:TIM {:e}".format(1),
        ] , [
            "+1",
        ]
    ) as dmm:
        unit_eq(dmm.sample_timer, 1 * pq.second)
        dmm.sample_timer = 1000 * pq.millisecond
Exemple #39
0
def test_hp6632b_current_sense_range():
    with expected_protocol(
        ik.hp.HP6632b,
        [
            "SENS:CURR:RANGE?",
            "SENS:CURR:RANGE {:e}".format(1)
        ] , [
            "0.05"
        ]
    ) as psu:
        unit_eq(psu.current_sense_range, 0.05*pq.amp)
        psu.current_sense_range = 1 * pq.amp
Exemple #40
0
def test_hp6632b_sense_sweep_interval():
    with expected_protocol(
        ik.hp.HP6632b,
        [
            "SENS:SWE:TINT?",
            "SENS:SWE:TINT {:e}".format(1e-05)
        ] , [
            "1.56e-05"
        ]
    ) as psu:
        unit_eq(psu.sense_sweep_interval, 1.56e-05 * pq.second)
        psu.sense_sweep_interval = 1e-05 * pq.second
Exemple #41
0
def test_hp6632b_output_protection_delay():
    with expected_protocol(
        ik.hp.HP6632b,
        [
            "OUTP:PROT:DEL?",
            "OUTP:PROT:DEL {:e}".format(5e-02)
        ] , [
            "8e-02"
        ]
    ) as psu:
        unit_eq(psu.output_protection_delay, 8e-02 * pq.second)
        psu.output_protection_delay = 5e-02 * pq.second
Exemple #42
0
def test_hp6632b_current_trigger():
    with expected_protocol(
        ik.hp.HP6632b,
        [
            "CURR:TRIG?",
            "CURR:TRIG {:e}".format(0.1)
        ] , [
            "1e-01"
        ]
    ) as psu:
        unit_eq(psu.current_trigger, 0.1 * pq.amp)
        psu.current_trigger = 0.1 * pq.amp
Exemple #43
0
def test_hp6632b_voltage_trigger():
    with expected_protocol(
        ik.hp.HP6632b,
        [
            "VOLT:TRIG?",
            "VOLT:TRIG {:e}".format(1)
        ] , [
            "1e+0"
        ]
    ) as psu:
        unit_eq(psu.voltage_trigger, 1 * pq.volt)
        psu.voltage_trigger = 1 * pq.volt
Exemple #44
0
def test_scpi_multimeter_trigger_delay():
    with expected_protocol(
        ik.generic_scpi.SCPIMultimeter,
        [
            "TRIG:DEL?",
            "TRIG:DEL {:e}".format(1),
        ] , [
            "+1",
        ]
    ) as dmm:
        unit_eq(dmm.trigger_delay, 1 * pq.second)
        dmm.trigger_delay = 1000 * pq.millisecond
Exemple #45
0
def test_hp6632b_overvoltage():
    with expected_protocol(
        ik.hp.HP6632b,
        [
            "VOLT:PROT?",
            "VOLT:PROT {:e}".format(1)
        ] , [
            "10.0"
        ]
    ) as psu:
        unit_eq(psu.overvoltage, 10*pq.volt)
        psu.overvoltage = 1.0 * pq.volt
Exemple #46
0
def test_agilent34410a_read():
    with expected_protocol(
        ik.agilent.Agilent34410a,
        [
            "CONF?",
            "READ?"
        ] , [
            "VOLT +1.000000E+01,+3.000000E-06",
            "+1.86850000E-03"
        ]
    ) as dmm:
        unit_eq(dmm.read(), +1.86850000E-03 * pq.volt)
Exemple #47
0
def test_hp6632b_current():
    with expected_protocol(
        ik.hp.HP6632b,
        [
            "CURR?",
            "CURR {:e}".format(1)
        ] , [
            "10.0"
        ]
    ) as psu:
        unit_eq(psu.current, 10*pq.amp)
        psu.current = 1.0 * pq.amp
Exemple #48
0
def test_agilent34410a_r():
    with expected_protocol(
        ik.agilent.Agilent34410a,
        [
            "CONF?",
            "FORM:DATA REAL,64",
            "R? 1"
        ] , [
            "VOLT +1.000000E+01,+3.000000E-06",
            "#18"+"3FF0000000000000".decode("hex")
        ]
    ) as dmm:
        unit_eq(dmm.r(1), np.array([1]) * pq.volt)
Exemple #49
0
def test_socketcomm_timeout():
    comm = SocketCommunicator(socket.socket())
    comm._conn = mock.MagicMock()
    comm._conn.gettimeout.return_value = 1.234

    unit_eq(comm.timeout, 1.234 * pq.second)
    comm._conn.gettimeout.assert_called_with()

    comm.timeout = 10
    comm._conn.settimeout.assert_called_with(10)

    comm.timeout = 1000 * pq.millisecond
    comm._conn.settimeout.assert_called_with(1)
Exemple #50
0
def test_agilent34410a_fetch():
    with expected_protocol(
        ik.agilent.Agilent34410a,
        [
            "CONF?",
            "FETC?"
        ] , [
            "VOLT +1.000000E+01,+3.000000E-06",
            "+4.27150000E-03,5.27150000E-03"
        ]
    ) as dmm:
        data = dmm.fetch()
        unit_eq(data[0], 4.27150000E-03 * pq.volt)
        unit_eq(data[1], 5.27150000E-03 * pq.volt)
Exemple #51
0
def test_agilent34410a_read_data_nvmem():
    with expected_protocol(
        ik.agilent.Agilent34410a,
        [
            "CONF?",
            "DATA:DATA? NVMEM",
        ] , [
            "VOLT +1.000000E+01,+3.000000E-06",
            "+4.27150000E-03,5.27150000E-03"
        ]
    ) as dmm:
        data = dmm.read_data_NVMEM()
        unit_eq(data[0], 4.27150000E-03 * pq.volt)
        unit_eq(data[1], 5.27150000E-03 * pq.volt)
Exemple #52
0
def test_usbtmccomm_timeout(mock_usbtmc):
    comm = USBTMCCommunicator()

    timeout = mock.PropertyMock(return_value=1)
    type(comm._filelike).timeout = timeout

    unit_eq(comm.timeout, 1 * pq.second)
    timeout.assert_called_with()

    comm.timeout = 10
    timeout.assert_called_with(array(10000.0))

    comm.timeout = 1000 * pq.millisecond
    timeout.assert_called_with(array(1000.0))
Exemple #53
0
def test_srsdg645_output_level():
    """
    SRSDG645: Checks getting/setting unitful ouput level.
    """
    with expected_protocol(ik.srs.SRSDG645,
            [
                "LAMP? 1",
                "LAMP 1,4.0",
            ], [
                "3.2"
            ]
    ) as ddg:
        unit_eq(ddg.output['AB'].level_amplitude, pq.Quantity(3.2, "V"))
        ddg.output['AB'].level_amplitude = 4.0