Skip to content

Commit

Permalink
Merge pull request #2 from numat/master
Browse files Browse the repository at this point in the history
merge master
  • Loading branch information
alexrudd2 authored Oct 8, 2024
2 parents e100a64 + 38547bb commit 7b449db
Show file tree
Hide file tree
Showing 18 changed files with 1,368 additions and 555 deletions.
27 changes: 27 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"timezone": "America/Chicago",
"pre-commit": {
"enabled": true
},
"packageRules": [
{
"matchManagers": ["github-actions"],
"automerge": true
},
{
"matchPackagePatterns": ["mypy", "pre-commit", "ruff"],
"automerge": true
},
{
"matchPackagePatterns": ["ruff"],
"groupName": "ruff",
"schedule": [
"on the first day of the month"
]
}
]
}
40 changes: 40 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: ismatec

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
allow-prereleases: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install '.[test]'
- name: Lint with ruff
run: |
ruff .
- name: Check types with mypy
run: |
mypy ismatec
- name: Pytest
run: |
pytest
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
__pycache__/
.DS_Store
*.pyc
build
dist
*egg-info
*.pyc
*.egg-info
.vscode
.coverage
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-json
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.7
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include LICENSE
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
TODO:
* the Moxa interface (implement SocketCommunicator)
ismatec
=======

Python ≥3.8 driver and command-line tool for Masterflex® Ismatec® Reglo ICC Digital Pumps.

![](https://us.vwr.com/stibo/bigweb/std.lang.all/21/78/38732178.jpg)

Installation
============

```
pip install ismatec
```

Usage
=====

## Command Line

```
$ ismatec /dev/ttyUSB0 --channel 1
$ ismatec <serial-to-ethernet-ip>:<port> --channel 2
```

This will print the current flow rate for the selected channel, using either the serial port or an ethernet-to-serial adapter.

## Python

This uses Python ≥3.5's async/await syntax to asynchronously communicate with a Ismatec® Reglo ICC pump. For example:

```python
import asyncio
from ismatec import Pump

async def get():
async with Pump('/dev/ttyUSB0') as pump:
print(await pump.get_pump_version())

asyncio.run(get())
```

Acknowledgements
================

©2022 Alexander Ruddick

[Original project](https://github.com/alexbjorling/lib-maxiv-regloicc) ©2017 Alexander Bjoerling

No affiliation to [the Hein group](https://gitlab.com/heingroup/ismatec). As of 2023, that project appears to have been abandoned.
36 changes: 36 additions & 0 deletions ismatec/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Python driver for Ismatec Reglo ICC peristaltic pump.
Distributed under the GNU General Public License v3
Copyright (C) 2022 NuMat Technologies
"""
from ismatec.driver import Pump


def command_line(args=None):
"""Command-line tool for reading Ismatec Reglo ICC pumps."""
import argparse
import asyncio
import json

parser = argparse.ArgumentParser(description="Control a RegloICC pump"
"from the command line.")
parser.add_argument('address', nargs='?', default='/dev/ttyUSB0', help="The "
"target serial port or TCP address:port. Default "
"'/dev/ttyUSB0'.")
parser.add_argument('--channel', '-c', default=None, type=int,
help="Specify channel in case of multi-channel pump.")
args = parser.parse_args(args)

async def run():
async with Pump(address=(args.address), timeout=.2) as pump:
d = await pump.get_flow_rate(args.channel)
print(json.dumps(d, indent=4))

loop = asyncio.new_event_loop()
loop.run_until_complete(run())
loop.close()
return


if __name__ == '__main__':
command_line()
Loading

0 comments on commit 7b449db

Please sign in to comment.