| 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 |
import pytest |
| 26 |
|
| 27 |
from pymeasure.test import expected_protocol |
| 28 |
|
| 29 |
from pymeasure.instruments.novanta import Fpu60 |
| 30 |
|
| 31 |
|
| 32 |
def test_disable_emission(): |
| 33 |
with expected_protocol(Fpu60, |
| 34 |
[("LASER=OFF", ""), ("LASER=ON", "")], |
| 35 |
) as inst: |
| 36 |
inst.disable_emission() |
| 37 |
|
| 38 |
|
| 39 |
@pytest.mark.parametrize("string, value", (("ENABLED", True), ("DISABLED", False))) |
| 40 |
def test_emission_enabled(string, value): |
| 41 |
with expected_protocol(Fpu60, |
| 42 |
[("STATUS?", string)], |
| 43 |
) as inst: |
| 44 |
assert inst.emission_enabled is value |
| 45 |
|
| 46 |
|
| 47 |
def test_power(): |
| 48 |
with expected_protocol(Fpu60, |
| 49 |
[("POWER?", " 12.345W")], |
| 50 |
) as inst: |
| 51 |
assert inst.power == 12.345 |
| 52 |
|
| 53 |
|
| 54 |
def test_power_setpoint(): |
| 55 |
with expected_protocol(Fpu60, |
| 56 |
[("POWER=12.345", ""), ("SETPOWER?", " 12.345W")], |
| 57 |
) as inst: |
| 58 |
inst.power_setpoint = 12.345 |
| 59 |
assert inst.power_setpoint == 12.345 |
| 60 |
|
| 61 |
|
| 62 |
def test_shutter_open(): |
| 63 |
with expected_protocol(Fpu60, |
| 64 |
[("SHUTTER OPEN", ""), ("SHUTTER?", "SHUTTER OPEN")], |
| 65 |
) as inst: |
| 66 |
inst.shutter_open = True |
| 67 |
assert inst.shutter_open is True |
| 68 |
|
| 69 |
|
| 70 |
def test_shutter_close(): |
| 71 |
with expected_protocol(Fpu60, |
| 72 |
[("SHUTTER CLOSE", ""), ("SHUTTER?", "SHUTTER CLOSED")], |
| 73 |
) as inst: |
| 74 |
inst.shutter_open = False |
| 75 |
assert inst.shutter_open is False |
| 76 |
|
| 77 |
|
| 78 |
def test_shutter_close_read(): |
| 79 |
with expected_protocol(Fpu60, |
| 80 |
[("SHUTTER?", "SHUTTER CLOSED")], |
| 81 |
) as inst: |
| 82 |
assert inst.shutter_open is False |
| 83 |
|
| 84 |
|
| 85 |
@pytest.mark.parametrize("string, value", (("ENABLED", True), ("DISABLED", False))) |
| 86 |
def test_interlock(string, value): |
| 87 |
with expected_protocol(Fpu60, |
| 88 |
[("INTERLOCK?", string)], |
| 89 |
) as inst: |
| 90 |
assert inst.interlock_enabled is value |
| 91 |
|
| 92 |
|
| 93 |
def test_head_temperature(): |
| 94 |
with expected_protocol(Fpu60, |
| 95 |
[("HTEMP?", " 12.345C")], |
| 96 |
) as inst: |
| 97 |
assert inst.head_temperature == 12.345 |
| 98 |
|
| 99 |
|
| 100 |
def test_psu_temperature(): |
| 101 |
with expected_protocol(Fpu60, |
| 102 |
[("PSUTEMP?", " 12.345C")], |
| 103 |
) as inst: |
| 104 |
assert inst.psu_temperature == 12.345 |
| 105 |
|
| 106 |
|
| 107 |
def test_get_operation_times(): |
| 108 |
with expected_protocol( |
| 109 |
Fpu60, |
| 110 |
[("TIMERS?", "PSU Time = 00594820 Mins"), |
| 111 |
(None, "Laser Enabled Time = 00196700 Mins"), |
| 112 |
(None, "Laser Threshold Time = 00196500 Mins"), |
| 113 |
(None, "")], |
| 114 |
) as inst: |
| 115 |
assert inst.get_operation_times() == {'psu': 594820, |
| 116 |
'laser': 196700, |
| 117 |
'laser_above_1A': 196500} |
| 118 |
|
| 119 |
|
| 120 |
def test_current(): |
| 121 |
with expected_protocol(Fpu60, |
| 122 |
[("CURRENT?", " 12.3%")], |
| 123 |
) as inst: |
| 124 |
assert inst.current == 12.3 |
| 125 |
|
| 126 |
|
| 127 |
def test_serial_number(): |
| 128 |
with expected_protocol(Fpu60, |
| 129 |
[("SERIAL?", "1234567")], |
| 130 |
) as inst: |
| 131 |
assert inst.serial_number == "1234567" |