To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 11147ec0 authored by mikolajr's avatar mikolajr
Browse files

In PSI9000 device: wait time config opts, refactor config errors tests, fixed...

In PSI9000 device: wait time config opts, refactor config errors tests, fixed type check errors, format (black), and copyright notice
parent 76d21c07
Pipeline #53089 passed with stages
in 3 minutes and 26 seconds
......@@ -39,7 +39,7 @@ class PSI9000VisaCommunicationConfig(VisaCommunicationConfig):
interface_type: Union[
str, VisaCommunicationConfig.InterfaceType
] = VisaCommunicationConfig.InterfaceType.TCPIP_SOCKET
] = VisaCommunicationConfig.InterfaceType.TCPIP_SOCKET # type: ignore
class PSI9000VisaCommunication(VisaCommunication):
......@@ -80,6 +80,10 @@ class PSI9000Config(VisaDeviceConfig):
#: Upper current limit in A, depending on the experimental setup.
current_upper_limit: Number = 2040.0
wait_sec_system_lock: Number = 0.5
wait_sec_settings_effect: Number = 1
wait_sec_initialisation: Number = 2
# limit with 63 A grid connection, absolute limit, never ever change this value
_POWER_GRID_LIMIT: ClassVar = 43500
......@@ -126,6 +130,18 @@ class PSI9000Config(VisaDeviceConfig):
or self.current_upper_limit > self._CURRENT_UPPER_LIMIT
):
raise ValueError("Upper current limit out of range.")
if self.wait_sec_system_lock <= 0:
raise ValueError(
"Wait time for system lock must be a positive value (in seconds)."
)
if self.wait_sec_settings_effect <= 0:
raise ValueError(
"Wait time for settings effect must be a positive value (in seconds)."
)
if self.wait_sec_initialisation <= 0:
raise ValueError(
"Wait time after initialisation must be a positive value (in seconds)."
)
class PSI9000(VisaDevice):
......@@ -173,9 +189,9 @@ class PSI9000(VisaDevice):
if current_lock and self.get_output():
# locked and output on
self.set_voltage_current(0, 0)
time.sleep(1)
time.sleep(self.config.wait_sec_settings_effect)
self.set_output(False)
time.sleep(1)
time.sleep(self.config.wait_sec_settings_effect)
if current_lock:
# locked
......@@ -204,7 +220,7 @@ class PSI9000(VisaDevice):
if lock:
# we want to lock the system
self.com.write("SYSTem:LOCK ON")
time.sleep(0.5)
time.sleep(self.config.wait_sec_system_lock)
new_system_lock = self.get_system_lock()
if not new_system_lock:
......@@ -230,7 +246,7 @@ class PSI9000(VisaDevice):
raise PSI9000Error(err_msg)
self.com.write("SYSTem:LOCK OFF")
time.sleep(0.5)
time.sleep(self.config.wait_sec_system_lock)
new_system_lock = self.get_system_lock()
if new_system_lock:
......@@ -308,8 +324,9 @@ class PSI9000(VisaDevice):
"""
list_ret = self.com.query("MEASure:VOLTage?", "MEASure:CURRent?")
return self._remove_units(list_ret)
assert len(list_ret) == 2
ret = self._remove_units(list_ret)
return ret[0], ret[1]
def set_voltage_current(self, volt: float, current: float) -> None:
"""
......@@ -356,8 +373,9 @@ class PSI9000(VisaDevice):
"""
list_ret = self.com.query("SOURce:VOLTage?", "SOURce:CURRent?")
return self._remove_units(list_ret)
assert len(list_ret) == 2
ret = self._remove_units(list_ret)
return ret[0], ret[1]
def set_upper_limits(
self,
......@@ -410,7 +428,7 @@ class PSI9000(VisaDevice):
)
# wait until settings are made
time.sleep(0.5)
time.sleep(self.config.wait_sec_settings_effect)
v_higher, i_higher, p_higher = self.get_uip_upper_limits()
......@@ -489,8 +507,9 @@ class PSI9000(VisaDevice):
list_ret = self.com.query(
"SOURce:VOLTage:LIMit:LOW?", "SOURce:CURRent:LIMit:LOW?"
)
return self._remove_units(list_ret)
assert len(list_ret) == 2
ret = self._remove_units(list_ret)
return ret[0], ret[1]
def get_uip_upper_limits(self) -> Tuple[float, float, float]:
"""
......@@ -504,8 +523,9 @@ class PSI9000(VisaDevice):
"SOURce:CURRent:LIMit:HIGH?",
"SOURce:POWer:LIMit:HIGH?",
)
return self._remove_units(list_ret)
assert len(list_ret) == 3
ret = self._remove_units(list_ret)
return ret[0], ret[1], ret[2]
def check_master_slave_config(self) -> None:
"""
......@@ -526,7 +546,7 @@ class PSI9000(VisaDevice):
# begin initialization
self.com.write("SYSTem:MS:INITialisation")
time.sleep(2)
time.sleep(self.config.wait_sec_initialisation)
# check for correct init
if self.com.query("SYSTem:MS:CONDition?") != "INIT":
......@@ -554,7 +574,7 @@ class PSI9000(VisaDevice):
logging.info("Initialization of Master/Slave successful")
@staticmethod
def _remove_units(list_with_strings: Iterable[str]) -> Tuple:
def _remove_units(list_with_strings: Iterable[str]) -> Tuple[float, ...]:
"""
Removes the last two characters of each string in the list and
convert it to float (is only working for units with one character e.g. V, A, W)
......
# Copyright (c) 2019 ETH Zurich, SIS ID and HVL D-ITET
#
"""
Tests for the Elektro Automatik PSI 9000 power supply device classes.
"""
......@@ -8,26 +10,29 @@ from hvl_ccb.dev import (
PSI9000,
PSI9000Error,
PSI9000VisaCommunicationConfig,
PSI9000Config
PSI9000Config,
)
from tests.masked_comm import MaskedVisaCommunication
@pytest.fixture(scope='module')
@pytest.fixture(scope="module")
def com_config():
return {
'interface_type': PSI9000VisaCommunicationConfig.InterfaceType.TCPIP_SOCKET,
'host': '127.0.0.1',
'open_timeout': 10,
'timeout': 50,
"interface_type": PSI9000VisaCommunicationConfig.InterfaceType.TCPIP_SOCKET,
"host": "127.0.0.1",
"open_timeout": 10,
"timeout": 50,
}
@pytest.fixture(scope='module')
@pytest.fixture(scope="module")
def dev_config():
return {
'spoll_interval': 0.01,
'spoll_start_delay': 0,
"spoll_interval": 0.01,
"spoll_start_delay": 0,
"wait_sec_system_lock": 0.01,
"wait_sec_settings_effect": 0.01,
"wait_sec_initialisation": 0.01,
}
......@@ -38,26 +43,36 @@ def testdev(com_config, dev_config):
return dev
def test_psi9000_config():
def test_psi9000_config(dev_config):
# currently there are no non-default config values
PSI9000Config()
PSI9000Config(**dev_config)
@pytest.mark.parametrize(
"wrong_config_dict",
[
{"power_limit": -1.0},
{"voltage_lower_limit": 20, "voltage_upper_limit": 19.0},
{
"voltage_lower_limit": 4,
"voltage_upper_limit": PSI9000Config._VOLTAGE_UPPER_LIMIT + 1,
},
{"current_lower_limit": -1.0},
{
"current_lower_limit": 4,
"current_upper_limit": PSI9000Config._CURRENT_UPPER_LIMIT + 1,
},
{"wait_sec_system_lock": 0},
{"wait_sec_system_lock": -1},
{"wait_sec_settings_effect": 0},
{"wait_sec_initialisation": 0},
],
)
def test_psi9000_config_wrong_value(wrong_config_dict):
with pytest.raises(ValueError):
PSI9000Config(power_limit=-1.0)
with pytest.raises(ValueError):
PSI9000Config(voltage_lower_limit=20, voltage_upper_limit=19.0)
with pytest.raises(ValueError):
PSI9000Config(voltage_lower_limit=4,
voltage_upper_limit=PSI9000Config._VOLTAGE_UPPER_LIMIT + 1)
with pytest.raises(ValueError):
PSI9000Config(current_lower_limit=-1.0)
with pytest.raises(ValueError):
PSI9000Config(current_lower_limit=4,
current_upper_limit=PSI9000Config._CURRENT_UPPER_LIMIT + 1)
PSI9000Config(**wrong_config_dict)
def test_instantiation(com_config):
......@@ -72,17 +87,17 @@ def test_start_stop(testdev: PSI9000):
power_supply.start()
# stop successful
test_com.put_name('SYSTem:LOCK:OWNer?', 'NONE')
test_com.put_name('OUTput?', 'OFF')
test_com.put_name("SYSTem:LOCK:OWNer?", "NONE")
test_com.put_name("OUTput?", "OFF")
power_supply.stop()
# stop successful: output and lock on
test_com.put_name('SYSTem:LOCK:OWNer?', 'REMOTE')
test_com.put_name('OUTPut?', 'ON')
test_com.put_name('SOURce:VOLTage?', '0 V')
test_com.put_name('SOURce:CURRent?', '0 A')
test_com.put_name('OUTPut?', 'OFF')
test_com.put_name('SYSTem:LOCK:OWNer?', 'NONE')
test_com.put_name("SYSTem:LOCK:OWNer?", "REMOTE")
test_com.put_name("OUTPut?", "ON")
test_com.put_name("SOURce:VOLTage?", "0 V")
test_com.put_name("SOURce:CURRent?", "0 A")
test_com.put_name("OUTPut?", "OFF")
test_com.put_name("SYSTem:LOCK:OWNer?", "NONE")
power_supply.stop()
......@@ -91,45 +106,45 @@ def test_locking(testdev: PSI9000):
test_com = power_supply.com
# lock failed
test_com.put_name('SYSTem:LOCK:OWNer?', 'NONE')
test_com.put_name('SYSTem:LOCK:OWNer?', 'NONE')
test_com.put_name("SYSTem:LOCK:OWNer?", "NONE")
test_com.put_name("SYSTem:LOCK:OWNer?", "NONE")
with pytest.raises(PSI9000Error):
power_supply.set_system_lock(True)
assert test_com.get_written() == 'SYSTem:LOCK ON'
assert test_com.get_written() == "SYSTem:LOCK ON"
# lock successful
test_com.put_name('SYSTem:LOCK:OWNer?', 'NONE')
test_com.put_name('SYSTem:LOCK:OWNer?', 'REMOTE')
test_com.put_name("SYSTem:LOCK:OWNer?", "NONE")
test_com.put_name("SYSTem:LOCK:OWNer?", "REMOTE")
power_supply.set_system_lock(True)
assert test_com.get_written() == 'SYSTem:LOCK ON'
assert test_com.get_written() == "SYSTem:LOCK ON"
# unlock failed due to still on current
test_com.put_name('SYSTem:LOCK:OWNer?', 'REMOTE')
test_com.put_name('MEASure:VOLTage?', '20 V')
test_com.put_name('MEASure:CURRent?', '100 A')
test_com.put_name("SYSTem:LOCK:OWNer?", "REMOTE")
test_com.put_name("MEASure:VOLTage?", "20 V")
test_com.put_name("MEASure:CURRent?", "100 A")
with pytest.raises(PSI9000Error):
power_supply.set_system_lock(False)
assert test_com.get_written() is None
# unlock failed
test_com.put_name('SYSTem:LOCK:OWNer?', 'REMOTE')
test_com.put_name('MEASure:VOLTage?', '0 V')
test_com.put_name('MEASure:CURRent?', '0 A')
test_com.put_name('SYSTem:LOCK:OWNer?', 'REMOTE')
test_com.put_name("SYSTem:LOCK:OWNer?", "REMOTE")
test_com.put_name("MEASure:VOLTage?", "0 V")
test_com.put_name("MEASure:CURRent?", "0 A")
test_com.put_name("SYSTem:LOCK:OWNer?", "REMOTE")
with pytest.raises(PSI9000Error):
power_supply.set_system_lock(False)
assert test_com.get_written() == 'SYSTem:LOCK OFF'
assert test_com.get_written() == "SYSTem:LOCK OFF"
# unlock successful
test_com.put_name('SYSTem:LOCK:OWNer?', 'REMOTE')
test_com.put_name('MEASure:VOLTage?', '0 V')
test_com.put_name('MEASure:CURRent?', '0 A')
test_com.put_name('SYSTem:LOCK:OWNer?', 'NONE')
test_com.put_name("SYSTem:LOCK:OWNer?", "REMOTE")
test_com.put_name("MEASure:VOLTage?", "0 V")
test_com.put_name("MEASure:CURRent?", "0 A")
test_com.put_name("SYSTem:LOCK:OWNer?", "NONE")
power_supply.set_system_lock(False)
assert test_com.get_written() == 'SYSTem:LOCK OFF'
assert test_com.get_written() == "SYSTem:LOCK OFF"
# illegal answer
test_com.put_name('SYSTem:LOCK:OWNer?', 'bla')
test_com.put_name("SYSTem:LOCK:OWNer?", "bla")
with pytest.raises(PSI9000Error):
power_supply.get_system_lock()
......@@ -138,43 +153,43 @@ def test_output(testdev: PSI9000):
power_supply = testdev
test_com = power_supply.com
test_com.put_name('OUTPut?', 'ON')
test_com.put_name("OUTPut?", "ON")
assert power_supply.get_output()
test_com.put_name('OUTPut?', 'OFF')
test_com.put_name("OUTPut?", "OFF")
assert not power_supply.get_output()
test_com.put_name('OUTPut?', 'bla')
test_com.put_name("OUTPut?", "bla")
with pytest.raises(PSI9000Error):
power_supply.get_output()
# setting output
test_com.put_name('OUTPut?', 'ON')
test_com.put_name("OUTPut?", "ON")
power_supply.set_output(True)
assert test_com.get_written() == 'OUTPut ON'
assert test_com.get_written() == "OUTPut ON"
test_com.put_name('OUTPut?', 'OFF')
test_com.put_name("OUTPut?", "OFF")
power_supply.set_output(False)
assert test_com.get_written() == 'OUTPut OFF'
assert test_com.get_written() == "OUTPut OFF"
test_com.put_name('OUTPut?', 'ON')
test_com.put_name("OUTPut?", "ON")
with pytest.raises(PSI9000Error):
power_supply.set_output(False)
assert test_com.get_written() == 'OUTPut OFF'
assert test_com.get_written() == "OUTPut OFF"
test_com.put_name('OUTPut?', 'OFF')
test_com.put_name("OUTPut?", "OFF")
with pytest.raises(PSI9000Error):
power_supply.set_output(True)
assert test_com.get_written() == 'OUTPut ON'
assert test_com.get_written() == "OUTPut ON"
def test_get_uip_upper_limits(testdev: PSI9000):
test_com = testdev.com
# get upper limits
test_com.put_name('SOURce:VOLTage:LIMit:HIGH?', '80 V')
test_com.put_name('SOURce:CURRent:LIMit:HIGH?', '1000 A')
test_com.put_name('SOURce:POWer:LIMit:HIGH?', '10000 W')
test_com.put_name("SOURce:VOLTage:LIMit:HIGH?", "80 V")
test_com.put_name("SOURce:CURRent:LIMit:HIGH?", "1000 A")
test_com.put_name("SOURce:POWer:LIMit:HIGH?", "10000 W")
assert testdev.get_uip_upper_limits() == (80, 1000, 10000)
......@@ -182,8 +197,8 @@ def test_get_ui_lower_limits(testdev: PSI9000):
test_com = testdev.com
# get lower limits
test_com.put_name('SOURce:VOLTage:LIMit:LOW?', '2 V')
test_com.put_name('SOURce:CURRent:LIMit:LOW?', '5 A')
test_com.put_name("SOURce:VOLTage:LIMit:LOW?", "2 V")
test_com.put_name("SOURce:CURRent:LIMit:LOW?", "5 A")
assert testdev.get_ui_lower_limits() == (2, 5)
......@@ -191,31 +206,31 @@ def test_set_upper_limits(testdev: PSI9000):
test_com = testdev.com
# set upper limits, success
test_com.put_name('SOURce:VOLTage:LIMit:LOW?', '2 V')
test_com.put_name('SOURce:CURRent:LIMit:LOW?', '5 A')
test_com.put_name('SOURce:VOLTage:LIMit:HIGH?', '10 V')
test_com.put_name('SOURce:CURRent:LIMit:HIGH?', '20 A')
test_com.put_name('SOURce:POWer:LIMit:HIGH?', '10000 W')
test_com.put_name("SOURce:VOLTage:LIMit:LOW?", "2 V")
test_com.put_name("SOURce:CURRent:LIMit:LOW?", "5 A")
test_com.put_name("SOURce:VOLTage:LIMit:HIGH?", "10 V")
test_com.put_name("SOURce:CURRent:LIMit:HIGH?", "20 A")
test_com.put_name("SOURce:POWer:LIMit:HIGH?", "10000 W")
testdev.set_upper_limits(10, 20, 10000)
assert test_com.get_written() == 'SOURce:VOLTage:LIMit:HIGH 10'
assert test_com.get_written() == 'SOURce:CURRent:LIMit:HIGH 20'
assert test_com.get_written() == 'SOURce:POWer:LIMit:HIGH 10000'
assert test_com.get_written() == "SOURce:VOLTage:LIMit:HIGH 10"
assert test_com.get_written() == "SOURce:CURRent:LIMit:HIGH 20"
assert test_com.get_written() == "SOURce:POWer:LIMit:HIGH 10000"
# set upper limits, set fail
test_com.put_name('SOURce:VOLTage:LIMit:LOW?', '2 V')
test_com.put_name('SOURce:CURRent:LIMit:LOW?', '5 A')
test_com.put_name('SOURce:VOLTage:LIMit:HIGH?', '10 V')
test_com.put_name('SOURce:CURRent:LIMit:HIGH?', '200 A')
test_com.put_name('SOURce:POWer:LIMit:HIGH?', '10000 W')
test_com.put_name("SOURce:VOLTage:LIMit:LOW?", "2 V")
test_com.put_name("SOURce:CURRent:LIMit:LOW?", "5 A")
test_com.put_name("SOURce:VOLTage:LIMit:HIGH?", "10 V")
test_com.put_name("SOURce:CURRent:LIMit:HIGH?", "200 A")
test_com.put_name("SOURce:POWer:LIMit:HIGH?", "10000 W")
with pytest.raises(PSI9000Error):
testdev.set_upper_limits(10, 20, 10000)
assert test_com.get_written() == 'SOURce:VOLTage:LIMit:HIGH 10'
assert test_com.get_written() == 'SOURce:CURRent:LIMit:HIGH 20'
assert test_com.get_written() == 'SOURce:POWer:LIMit:HIGH 10000'
assert test_com.get_written() == "SOURce:VOLTage:LIMit:HIGH 10"
assert test_com.get_written() == "SOURce:CURRent:LIMit:HIGH 20"
assert test_com.get_written() == "SOURce:POWer:LIMit:HIGH 10000"
# set upper limits, limit fail
test_com.put_name('SOURce:VOLTage:LIMit:LOW?', '20 V')
test_com.put_name('SOURce:CURRent:LIMit:LOW?', '5 A')
test_com.put_name("SOURce:VOLTage:LIMit:LOW?", "20 V")
test_com.put_name("SOURce:CURRent:LIMit:LOW?", "5 A")
with pytest.raises(ValueError):
testdev.set_upper_limits(10, 20, 10000)
assert test_com.get_written() is None
......@@ -225,30 +240,30 @@ def test_set_lower_limits(testdev: PSI9000):
test_com = testdev.com
# set lower limits, success
test_com.put_name('SOURce:VOLTage:LIMit:HIGH?', '80 V')
test_com.put_name('SOURce:CURRent:LIMit:HIGH?', '2000 A')
test_com.put_name('SOURce:POWer:LIMit:HIGH?', '10000 W')
test_com.put_name('SOURce:VOLTage:LIMit:LOW?', '2 V')
test_com.put_name('SOURce:CURRent:LIMit:LOW?', '5.2 A')
test_com.put_name("SOURce:VOLTage:LIMit:HIGH?", "80 V")
test_com.put_name("SOURce:CURRent:LIMit:HIGH?", "2000 A")
test_com.put_name("SOURce:POWer:LIMit:HIGH?", "10000 W")
test_com.put_name("SOURce:VOLTage:LIMit:LOW?", "2 V")
test_com.put_name("SOURce:CURRent:LIMit:LOW?", "5.2 A")
testdev.set_lower_limits(2, 5.2)
assert test_com.get_written() == 'SOURce:VOLTage:LIMit:LOW 2'
assert test_com.get_written() == 'SOURce:CURRent:LIMit:LOW 5.2'
assert test_com.get_written() == "SOURce:VOLTage:LIMit:LOW 2"
assert test_com.get_written() == "SOURce:CURRent:LIMit:LOW 5.2"
# set lower limits, set fail
test_com.put_name('SOURce:VOLTage:LIMit:HIGH?', '80 V')
test_com.put_name('SOURce:CURRent:LIMit:HIGH?', '2000 A')
test_com.put_name('SOURce:POWer:LIMit:HIGH?', '10000 W')
test_com.put_name('SOURce:VOLTage:LIMit:LOW?', '2 V')
test_com.put_name('SOURce:CURRent:LIMit:LOW?', '50 A')
test_com.put_name("SOURce:VOLTage:LIMit:HIGH?", "80 V")
test_com.put_name("SOURce:CURRent:LIMit:HIGH?", "2000 A")
test_com.put_name("SOURce:POWer:LIMit:HIGH?", "10000 W")
test_com.put_name("SOURce:VOLTage:LIMit:LOW?", "2 V")
test_com.put_name("SOURce:CURRent:LIMit:LOW?", "50 A")
with pytest.raises(PSI9000Error):
testdev.set_lower_limits(2, 5)
assert test_com.get_written() == 'SOURce:VOLTage:LIMit:LOW 2'
assert test_com.get_written() == 'SOURce:CURRent:LIMit:LOW 5'
assert test_com.get_written() == "SOURce:VOLTage:LIMit:LOW 2"
assert test_com.get_written() == "SOURce:CURRent:LIMit:LOW 5"
# set lower limits, limit fail
test_com.put_name('SOURce:VOLTage:LIMit:HIGH?', '1 V')
test_com.put_name('SOURce:CURRent:LIMit:HIGH?', '20 A')
test_com.put_name('SOURce:POWer:LIMit:HIGH?', '10000 W')
test_com.put_name("SOURce:VOLTage:LIMit:HIGH?", "1 V")
test_com.put_name("SOURce:CURRent:LIMit:HIGH?", "20 A")
test_com.put_name("SOURce:POWer:LIMit:HIGH?", "10000 W")
with pytest.raises(ValueError):
testdev.set_lower_limits(0.5, 500)
assert test_com.get_written() is None
......@@ -258,23 +273,23 @@ def test_set_voltage_current(testdev: PSI9000):
power_supply = testdev
test_com = power_supply.com
test_com.put_name('SOURce:VOLTage?', '20.2 V')
test_com.put_name('SOURce:CURRent?', '123.4 A')
test_com.put_name("SOURce:VOLTage?", "20.2 V")
test_com.put_name("SOURce:CURRent?", "123.4 A")
power_supply.set_voltage_current(20.2, 123.4)
assert test_com.get_written() == 'SOURce:VOLTage 20.200000'
assert test_com.get_written() == 'SOURce:CURRent 123.400000'
test_com.put_name('SOURce:VOLTage?', '20.2 V')
test_com.put_name('SOURce:CURRent?', '10 A')
test_com.put_name('SOURce:VOLTage:LIMit:HIGH?', '20 V')
test_com.put_name('SOURce:CURRent:LIMit:HIGH?', '2000 A')
test_com.put_name('SOURce:POWer:LIMit:HIGH?', '10000 W')
test_com.put_name('SOURce:VOLTage:LIMit:LOW?', '1 V')
test_com.put_name('SOURce:CURRent:LIMit:LOW?', '5 A')
assert test_com.get_written() == "SOURce:VOLTage 20.200000"
assert test_com.get_written() == "SOURce:CURRent 123.400000"
test_com.put_name("SOURce:VOLTage?", "20.2 V")
test_com.put_name("SOURce:CURRent?", "10 A")
test_com.put_name("SOURce:VOLTage:LIMit:HIGH?", "20 V")
test_com.put_name("SOURce:CURRent:LIMit:HIGH?", "2000 A")
test_com.put_name("SOURce:POWer:LIMit:HIGH?", "10000 W")
test_com.put_name("SOURce:VOLTage:LIMit:LOW?", "1 V")
test_com.put_name("SOURce:CURRent:LIMit:LOW?", "5 A")
with pytest.raises(PSI9000Error):
power_supply.set_voltage_current(20.2, 123.4)
assert test_com.get_written() == 'SOURce:VOLTage 20.200000'
assert test_com.get_written() == 'SOURce:CURRent 123.400000'
assert test_com.get_written() == "SOURce:VOLTage 20.200000"
assert test_com.get_written() == "SOURce:CURRent 123.400000"
def test_check_master_slave_config(testdev: PSI9000):
......@@ -282,46 +297,50 @@ def test_check_master_slave_config(testdev: PSI9000):
test_com = power_supply.com
# MS disabled
test_com.put_name('SYSTem:MS:ENABle?', 'OFF')
test_com.put_name("SYSTem:MS:ENABle?", "OFF")
with pytest.raises(PSI9000Error):
power_supply.check_master_slave_config()
assert test_com.get_written() is None
# device is not MASTER
test_com.put_name('SYSTem:MS:ENABle?', 'ON')
test_com.put_name('SYSTem:MS:LINK?', 'SLAVE')
test_com.put_name("SYSTem:MS:ENABle?", "ON")
test_com.put_name("SYSTem:MS:LINK?", "SLAVE")
with pytest.raises(PSI9000Error):
power_supply.check_master_slave_config()
assert test_com.get_written() is None
# initialization failed
test_com.put_name('SYSTem:MS:ENABle?', 'ON')
test_com.put_name('SYSTem:MS:LINK?', 'MASTER')
test_com.put_name('SYSTem:MS:CONDition?', 'NOT_INIT')
test_com.put_name("SYSTem:MS:ENABle?", "ON")
test_com.put_name("SYSTem:MS:LINK?", "MASTER")
test_com.put_name("SYSTem:MS:CONDition?", "NOT_INIT")
with pytest.raises(PSI9000Error):
power_supply.check_master_slave_config()
assert test_com.get_written() == 'SYSTem:MS:INITialisation'
assert test_com.get_written() == "SYSTem:MS:INITialisation"
# wrong expected voltage, current nominal values
test_com.put_name('SYSTem:MS:ENABle?', 'ON')
test_com.put_name('SYSTem:MS:LINK?', 'MASTER')
test_com.put_name('SYSTem:MS:CONDition?', 'INIT')
test_com.put_name('SYSTem:MS:NOMinal:VOLTage?', '{} V'.format(
PSI9000.MS_NOMINAL_VOLTAGE))
test_com.put_name('SYSTem:MS:NOMinal:CURRent?', '{} A'.format(
PSI9000.MS_NOMINAL_CURRENT - 1))
test_com.put_name("SYSTem:MS:ENABle?", "ON")
test_com.put_name("SYSTem:MS:LINK?", "MASTER")
test_com.put_name("SYSTem:MS:CONDition?", "INIT")
test_com.put_name(
"SYSTem:MS:NOMinal:VOLTage?", "{} V".format(PSI9000.MS_NOMINAL_VOLTAGE)
)
test_com.put_name(
"SYSTem:MS:NOMinal:CURRent?", "{} A".format(PSI9000.MS_NOMINAL_CURRENT - 1)
)
with pytest.raises(PSI9000Error):
power_supply.check_master_slave_config()
assert test_com.get_written() == 'SYSTem:MS:INITialisation'
assert test_com.get_written() == "SYSTem:MS:INITialisation"
# all right
# wrong expected voltage, current nominal values
test_com.put_name('SYSTem:MS:ENABle?', 'ON')
test_com.put_name('SYSTem:MS:LINK?', 'MASTER')
test_com.put_name('SYSTem:MS:CONDition?', 'INIT')
test_com.put_name('SYSTem:MS:NOMinal:VOLTage?', '{} V'.format(
PSI9000.MS_NOMINAL_VOLTAGE))
test_com.put_name('SYSTem:MS:NOMinal:CURRent?', '{} A'.format(
PSI9000.MS_NOMINAL_CURRENT))