| 1 |
# |
| 2 |
# This file is part of the PyMeasure package. |
| 3 |
# |
| 4 |
# Copyright (c) 2013-2024 PyMeasure Developers |
| 5 |
# |
| 6 |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 |
# of this software and associated documentation files (the "Software"), to deal |
| 8 |
# in the Software without restriction, including without limitation the rights |
| 9 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 |
# copies of the Software, and to permit persons to whom the Software is |
| 11 |
# furnished to do so, subject to the following conditions: |
| 12 |
# |
| 13 |
# The above copyright notice and this permission notice shall be included in |
| 14 |
# all copies or substantial portions of the Software. |
| 15 |
# |
| 16 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 |
# THE SOFTWARE. |
| 23 |
# |
| 24 |
|
| 25 |
from pymeasure.test import expected_protocol |
| 26 |
from pymeasure.instruments.teledyne.teledyneT3AFG import TeledyneT3AFG |
| 27 |
|
| 28 |
|
| 29 |
def test_output_enabled(): |
| 30 |
"""Verify the output enable setter and getter.""" |
| 31 |
with expected_protocol( |
| 32 |
TeledyneT3AFG, |
| 33 |
[("C1:OUTPut ON", None), |
| 34 |
("C1:OUTPut?", "C1:OUTP OFF,LOAD,HZ,PLRT,NOR")], |
| 35 |
) as inst: |
| 36 |
inst.ch_1.output_enabled = True |
| 37 |
assert inst.ch_1.output_enabled is False |
| 38 |
|
| 39 |
|
| 40 |
def test_wavetype(): |
| 41 |
"""Verify the wavetype setter and getter for ramp or sine wavetype.""" |
| 42 |
with expected_protocol( |
| 43 |
TeledyneT3AFG, |
| 44 |
[("C1:BSWV WVTP,RAMP", None), |
| 45 |
("C1:BSWV?", "C1:BSWV WVTP,SINE,FRQ,0.3HZ,PERI,3.33333S,AMP,0.08V," |
| 46 |
"AMPVRMS,0.02828Vrms,MAX_OUTPUT_AMP,4.6V,OFST,-2V,HLEV,-1.96V,LLEV,-2.04V,PHSE,0")], |
| 47 |
) as inst: |
| 48 |
inst.ch_1.wavetype = 'RAMP' |
| 49 |
assert inst.ch_1.wavetype == "SINE" |
| 50 |
|
| 51 |
|
| 52 |
def test_frequency(): |
| 53 |
"""Verify the frequency setter and getter for ramp or sine wavetype.""" |
| 54 |
with expected_protocol( |
| 55 |
TeledyneT3AFG, |
| 56 |
[("C1:BSWV FRQ,1000", None), |
| 57 |
("SYST:ERR?", "-0, No errors"), |
| 58 |
("C1:BSWV?", "C1:BSWV WVTP,SINE,FRQ,0.3HZ,PERI,3.33333S,AMP,0.08V," |
| 59 |
"AMPVRMS,0.02828Vrms,MAX_OUTPUT_AMP,4.6V,OFST,-2V,HLEV,-1.96V,LLEV,-2.04V,PHSE,0")], |
| 60 |
) as inst: |
| 61 |
inst.ch_1.frequency = 1000 |
| 62 |
assert inst.ch_1.frequency == 0.3 |
| 63 |
|
| 64 |
|
| 65 |
def test_frequency_getter_error(): |
| 66 |
"""Verify the frequency getter for DC wavetype with no frequency value.""" |
| 67 |
with expected_protocol( |
| 68 |
TeledyneT3AFG, |
| 69 |
[("C1:BSWV?", "C1:BSWV WVTP,DC,MAX_OUT_AMP,4.6V,OFST,0V")], |
| 70 |
) as inst: |
| 71 |
assert inst.ch_1.frequency is None |
| 72 |
|
| 73 |
|
| 74 |
def test_amplitude(): |
| 75 |
"""Verify the amplitude setter and getter for ramp or sine wavetype.""" |
| 76 |
with expected_protocol( |
| 77 |
TeledyneT3AFG, |
| 78 |
[("C1:BSWV AMP,1", None), |
| 79 |
("SYST:ERR?", "-0, No errors"), |
| 80 |
("C1:BSWV?", "C1:BSWV WVTP,SINE,FRQ,0.3HZ,PERI,3.33333S,AMP,0.08V," |
| 81 |
"AMPVRMS,0.02828Vrms,MAX_OUTPUT_AMP,4.6V,OFST,-2V,HLEV,-1.96V,LLEV,-2.04V,PHSE,0")], |
| 82 |
) as inst: |
| 83 |
inst.ch_1.amplitude = 1 |
| 84 |
assert inst.ch_1.amplitude == 0.08 |
| 85 |
|
| 86 |
|
| 87 |
def test_offset(): |
| 88 |
"""Verify the offset setter and getter for DC wavetype.""" |
| 89 |
with expected_protocol( |
| 90 |
TeledyneT3AFG, |
| 91 |
[("C1:BSWV OFST,1", None), |
| 92 |
("SYST:ERR?", "-0, No errors"), |
| 93 |
("C1:BSWV?", "C1:BSWV WVTP,DC,MAX_OUT_AMP,4.6V,OFST,0V")], |
| 94 |
) as inst: |
| 95 |
inst.ch_1.offset = 1 |
| 96 |
assert inst.ch_1.offset == 0 |