diff --git a/README.md b/README.md index 10046b8..721837c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # vsr53 -This is a Python library to communicate with Thyracont's VSR53USB pressure -gauge. It should also work with the VSR53DL model (over RS485) but I haven't -tested it. +[![Build and Test](https://github.com/lobis/vsr53/actions/workflows/build.yaml/badge.svg)](https://github.com/lobis/vsr53/actions/workflows/build.yaml) + +This is a Python library to communicate with +[Thyracont](https://thyracont-vacuum.com/en/)'s VSR53USB pressure gauge. It +should also work with the VSR53DL model (over RS485) but I haven't tested it as +I don't have access to one. This library is a fork of [this repository](https://github.com/IFAEControl/pyvsr53dl). All credits go to @@ -13,4 +16,20 @@ of the box for the USB version of this sensor, however, with some minor modifications such as allowing the user to set the baudrate and updating the default value (to 9600 instead of 115200) it works perfectly. -I also updated the packaging to the latest standards and published it to PyPi. +## Installation + +```bash +pip install vsr53 +``` + +## Usage + +```python +from vsr53 import VSR53USB + +port = "/dev/ttyUSB0" # replace with the device port of your gauge +with VSR53USB(port) as gauge: + print(gauge.get_device_type()) + print(gauge.get_product_name()) + print(gauge.get_measurement_value()) +``` diff --git a/examples/vsr53dl.py b/examples/vsr53dl.py index 1e0f10c..b037428 100644 --- a/examples/vsr53dl.py +++ b/examples/vsr53dl.py @@ -13,23 +13,23 @@ log.setLevel(logging.INFO) sensor_address = 1 - with VSR53DL(dev_tty, address=sensor_address) as vacuum_sense: - vacuum_sense.get_device_type() - vacuum_sense.get_product_name() - vacuum_sense.get_serial_number_device() - vacuum_sense.get_serial_number_head() - vacuum_sense.get_response_delay() - vacuum_sense.get_device_version() - vacuum_sense.get_firmware_version() - vacuum_sense.get_bootloader_version() - vacuum_sense.get_measurement_range() - vacuum_sense.get_measurement_value() - vacuum_sense.get_measurement_value_piezo() - vacuum_sense.get_measurement_value_pirani() - vacuum_sense.set_display_unit(Units.MBAR) - vacuum_sense.get_display_unit() - vacuum_sense.set_display_orientation(Orientation.NORMAL) - vacuum_sense.get_display_orientation() - vacuum_sense.get_relay_1_status() - vacuum_sense.get_relay_2_status() - vacuum_sense.get_operating_hours() + with VSR53DL(dev_tty, address=sensor_address) as gauge: + gauge.get_device_type() + gauge.get_product_name() + gauge.get_serial_number_device() + gauge.get_serial_number_head() + gauge.get_response_delay() + gauge.get_device_version() + gauge.get_firmware_version() + gauge.get_bootloader_version() + gauge.get_measurement_range() + gauge.get_measurement_value() + gauge.get_measurement_value_piezo() + gauge.get_measurement_value_pirani() + gauge.set_display_unit(Units.MBAR) + gauge.get_display_unit() + gauge.set_display_orientation(Orientation.NORMAL) + gauge.get_display_orientation() + gauge.get_relay_1_status() + gauge.get_relay_2_status() + gauge.get_operating_hours() diff --git a/examples/vsr53usb.py b/examples/vsr53usb.py index f580876..a35fc11 100644 --- a/examples/vsr53usb.py +++ b/examples/vsr53usb.py @@ -11,13 +11,13 @@ log.setLevel(logging.INFO) sensor_address = 1 - with VSR53USB(dev_tty, address=sensor_address) as vacuum_sense: - vacuum_sense.get_device_type() - vacuum_sense.get_product_name() - vacuum_sense.get_serial_number_device() - vacuum_sense.get_serial_number_head() - vacuum_sense.get_device_version() - vacuum_sense.get_firmware_version() - vacuum_sense.get_measurement_value() - vacuum_sense.get_measurement_value_piezo() - vacuum_sense.get_measurement_value_pirani() + with VSR53USB(dev_tty, address=sensor_address) as gauge: + gauge.get_device_type() + gauge.get_product_name() + gauge.get_serial_number_device() + gauge.get_serial_number_head() + gauge.get_device_version() + gauge.get_firmware_version() + gauge.get_measurement_value() + gauge.get_measurement_value_piezo() + gauge.get_measurement_value_pirani() diff --git a/test/test_stress.py b/test/test_stress.py index b7cbc33..d6c26bc 100644 --- a/test/test_stress.py +++ b/test/test_stress.py @@ -33,15 +33,10 @@ def stress_test(): from vsr53.sys import dev_tty sensor_address = 1 - vacuum_sense = VSR53DL(dev_tty, address=sensor_address) - vacuum_sense.open_communication() - - filename = f"./results/Stress_test_results_{get_now_timestamp_str()}.csv" - writer = open_file(filename) - - perform_measurement(vacuum_sense, writer) - - vacuum_sense.close_communication() + with VSR53DL(dev_tty, address=sensor_address) as gauge: + filename = f"./results/Stress_test_results_{get_now_timestamp_str()}.csv" + writer = open_file(filename) + perform_measurement(gauge, writer) if __name__ == "__main__": diff --git a/test/test_vsr53dl.py b/test/test_vsr53dl.py index 6609c16..c4af7be 100644 --- a/test/test_vsr53dl.py +++ b/test/test_vsr53dl.py @@ -17,15 +17,15 @@ def vacuum_sensor(): def test_device_query(vacuum_sensor): - vacuum_sense = vacuum_sensor - - assert vacuum_sense.get_device_type() == "VSR205" - assert vacuum_sense.get_product_name() == "VSR53DL" - assert vacuum_sense.get_serial_number_device() == "20002583" - assert vacuum_sense.get_serial_number_head() == "20002583" - assert vacuum_sense.get_device_version() == 2.0 - assert vacuum_sense.get_firmware_version() == "0215" - assert vacuum_sense.get_bootloader_version() == 2.0 - - vacuum_sense.set_display_unit(Units.MBAR) - assert vacuum_sense.get_display_unit() == Units.MBAR + gauge = vacuum_sensor + + assert gauge.get_device_type() == "VSR205" + assert gauge.get_product_name() == "VSR53DL" + assert gauge.get_serial_number_device() == "20002583" + assert gauge.get_serial_number_head() == "20002583" + assert gauge.get_device_version() == 2.0 + assert gauge.get_firmware_version() == "0215" + assert gauge.get_bootloader_version() == 2.0 + + gauge.set_display_unit(Units.MBAR) + assert gauge.get_display_unit() == Units.MBAR diff --git a/test/test_vsr53usb.py b/test/test_vsr53usb.py index 3d8d7c5..46b13eb 100644 --- a/test/test_vsr53usb.py +++ b/test/test_vsr53usb.py @@ -16,11 +16,11 @@ def vacuum_sensor(): def test_device_query(vacuum_sensor): - vacuum_sense = vacuum_sensor + gauge = vacuum_sensor - assert vacuum_sense.get_device_type() == "VSR213" - assert vacuum_sense.get_product_name() == "VSR53USB" - assert vacuum_sense.get_serial_number_device() == "22002816" - assert vacuum_sense.get_serial_number_head() == "22002816" - assert vacuum_sense.get_device_version() == 2.0 - assert vacuum_sense.get_firmware_version() == "0003" + assert gauge.get_device_type() == "VSR213" + assert gauge.get_product_name() == "VSR53USB" + assert gauge.get_serial_number_device() == "22002816" + assert gauge.get_serial_number_head() == "22002816" + assert gauge.get_device_version() == 2.0 + assert gauge.get_firmware_version() == "0003"