Giter Site home page Giter Site logo

fescron / witrn-ui-bokeh Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.26 MB

Python Bokeh utility for reading, plotting and storing data from modern WITRN USB-meters using a web-browser

License: MIT License

Python 100.00%
aliexpress bokeh hid logging meter plotting python usb witrn

witrn-ui-bokeh's Introduction

WITRN UI BOKEH

The code on this repository builds upon the existing Python driver-functionality of witrn-ui by didim99, by adding real-time plotting (and logging) functionality using Bokeh. The result allows the user to control a WITRN USB-meter to be controlled using a web-browser.

Currently the code has only been tested using a Witrn C4.


1 - Installation

1.1 - Install required packages

pip install -r requirements.txt

NOTE: The requirements.txt file is generated by running pipreqs (pip install pipreqs) in the project directory. ~= means compatible version.


1.2 - Configure platform-dependent functionality

1.2.1 - Linux

Copy the udev-rules-file to the correct location.

sudo cp udev/90-usbmeter.rules /etc/udev/rules.d/90-usbmeter.rules

Restart the udev management tool.

sudo udevadm control --reload-rules
sudo udevadm trigger

1.2.2 - Windows

Use Zadig to replace Windows's default HID-driver to libusbK.

  1. Run zadig-2.8.exe
  2. Click on Options > List All Devices
  3. Select the WITRN.C4 device (in case the Witrn C4 is used)
  4. Select libusbK (v3.0.7.0) above the Replace Driver button
  5. Click on Replace Driver
  6. Confirm the driver replacement operation, wait for the tool to finish

2 - Running

Running witrn-ui-bokeh.py as-is with Python won't do anything. It is supposed to be launched using Bokeh server (bokeh serve), which creates (and opens, on http://localhost:5006/witrn-ui-bokeh) an interactive web application that connects front-end UI events to running Python code. The correct usage is shown below.

bokeh serve --show witrn-ui-bokeh.py

Once the web-interface opens, use the following steps.

  1. Select a Device using the dropdown (C4 selected by default).
    • Depending on the way the current will flow/flows through the USB-meter, disable (default enabled) the Invert Current Sign logic using the corresponding toggle-switch.
  2. Click on Open Connection
    • Change the Plot Period [ms] to a value greater than 0 if the measurement-throughput is too/unnecessary high (the tool defaults to (try to) plot all incoming measurements, a non-zero value only plots incoming measurements at the defined period)
    • Click on Clear Plot to clear all of the already plotted measurements (the tool only keeps 6000 (configurable, using MAX_X_POINTS in witrn-ui-bokeh.py) data-points on the X-axis (per data-line) before discarding old data, in an attempt to maintain a somewhat responsive real-time application)
    • Click on an item in the Legend to enable or disable the display of certain lines on the plot
  3. Use the tooltips on the side (activated when hovering over the plot) to zoom in or out on the measurements, ...
  4. Change the plot- and file- Title and Log Period [ms] using the corresponding fields (if necessary), click on Start Logging to start saving values to a .csv-file.
    • The generated file has the following syntax (DateTime corresponds to the time at which the button has been pressed): YYYY-MM-DD_HH-MM-SS_<Title>.csv

Usage sample:

witrn-ui-bokeh usage example


3 - TODO

  • Add functionality to re-plot stored CSV-data
  • Add functionality to "download" offline recordings from the USB-meter
  • Implement U2P functionality (see this and this)
  • Implement TC66 functionality (see this)

witrn-ui-bokeh's People

Contributors

fescron avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.