Skip to content

Commit

Permalink
improve readme, normalize usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Feb 21, 2024
1 parent 9bbc404 commit a25f648
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 62 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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())
```
40 changes: 20 additions & 20 deletions examples/vsr53dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
20 changes: 10 additions & 10 deletions examples/vsr53usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
13 changes: 4 additions & 9 deletions test/test_stress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
24 changes: 12 additions & 12 deletions test/test_vsr53dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions test/test_vsr53usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit a25f648

Please sign in to comment.