How bronkhorst-developer/bronkhorst-propar works
Project Type and Purpose
• This is an open-source Python library (“bronkhorst-propar”) that provides a Propar master implementation for communicating with Bronkhorst flow and pressure instruments over RS232/RS485 and FLOW-BUS.
• It is not a full-stack web app but a hardware-communication SDK/library intended for embedding in user scripts or applications.
File Structure Overview
• Top-level:
• setup.py, setup.cfg, MANIFEST.in, LICENSE, README.md – packaging and metadata
• .readthedocs.yml – ReadTheDocs configuration
• docs/ – Sphinx documentation source (RST files, Makefiles, images)
• propar/ – library code (package init + parameters module)
• test/ – automated test suite (unit and integration tests)
• build.bat, upload.bat – Windows scripts for build/upload tasks
• Key patterns:
• Small, single package “propar”
• Sphinx-driven docs, pytest/unittest tests
• Serial communication dependency (pyserial)
README Insights
• Core functionality: open serial port, send/receive Propar protocol frames, support single or multi-instrument FLOW-BUS.
• External dependency: pyserial.
• Cross-platform: Windows & Linux.
• Documentation hosted on ReadTheDocs.
a. Main components
1. User Application (any Python script or service using bronkhorst-propar)
2. bronkhorst-propar Library
– propar package (classes for connection, framing, parameter handling)
3. pyserial (external dependency providing SerialPort abstraction)
4. OS Serial Driver / RS232/RS485 Interface
5. FLOW-BUS Network (optional multi-drop bus)
6. Physical Instruments (flow meters, controllers, pressure devices)
7. Build/CI Components
– setup.py, pytest, build scripts, ReadTheDocs
b. Interactions
– pyserial invokes OS serial driver → physical wires (RS232/485)
– If FLOW-BUS mode: messages are broadcast to multiple instruments on the bus
– Instruments respond back through same path, data flows upstream into library
– Library decodes frames into parameter objects and returns to User App
– Build/CI flows: source → setup.py → package on PyPI; tests run via pytest; docs built via Sphinx → ReadTheDocs
c. Architectural Patterns and Design Principles
– Layered design: Application layer → Protocol library → Transport layer → Hardware
– Single Responsibility: propar.parameters handles parameter definitions, separate from serial framing
– Dependency Injection: library expects any SerialPort-compatible object (for mocking in tests)
– Test isolation: serial port injection in tests, use of mock ILogger for broadcast_logger
d. Key Technologies and Frameworks
– Python 3.x
– pyserial for serial I/O
– pytest/unittest for testing
– Sphinx for documentation
– ReadTheDocs for hosted docs
– setuptools for packaging
Capturing Essential Details
• Both single-device mode and FLOW-BUS multi-drop mode branching from pyserial.
• Packaging flow: source → setup.py → PyPI → pip install.