{"id":26742762,"url":"https://github.com/fescron/witrn-ui-bokeh","last_synced_at":"2025-03-28T06:20:01.450Z","repository":{"id":232050327,"uuid":"783198178","full_name":"Fescron/witrn-ui-bokeh","owner":"Fescron","description":"Python Bokeh utility for reading, plotting and storing data from modern WITRN USB-meters using a web-browser","archived":false,"fork":false,"pushed_at":"2024-04-07T16:21:48.000Z","size":3339,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-07T17:29:43.559Z","etag":null,"topics":["aliexpress","bokeh","hid","logging","meter","plotting","python","usb","witrn"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fescron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-04-07T07:55:48.000Z","updated_at":"2024-04-07T17:29:47.213Z","dependencies_parsed_at":"2024-04-07T17:29:47.051Z","dependency_job_id":"afae34d2-5d75-4520-99fc-1bc063d9c369","html_url":"https://github.com/Fescron/witrn-ui-bokeh","commit_stats":null,"previous_names":["fescron/witrn-ui-bokeh"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fescron%2Fwitrn-ui-bokeh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fescron%2Fwitrn-ui-bokeh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fescron%2Fwitrn-ui-bokeh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fescron%2Fwitrn-ui-bokeh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fescron","download_url":"https://codeload.github.com/Fescron/witrn-ui-bokeh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245978672,"owners_count":20703772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aliexpress","bokeh","hid","logging","meter","plotting","python","usb","witrn"],"created_at":"2025-03-28T06:20:00.836Z","updated_at":"2025-03-28T06:20:01.429Z","avatar_url":"https://github.com/Fescron.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WITRN UI BOKEH\n\nThe code on this repository builds upon the existing Python driver-functionality of [witrn-ui](https://github.com/didim99/witrn-ui) by [didim99](https://github.com/didim99), by adding real-time plotting (and logging) functionality using [Bokeh](http://bokeh.org/). The result allows the user to control a WITRN USB-meter to be controlled using a web-browser.\n\nCurrently the code has only been tested using a [Witrn C4](https://aliexpress.com/item/1005004748597690.html).\n\n\u003cbr\u003e\n\n## 1 - Installation\n\n### 1.1 - Install required packages\n\n```bash\npip install -r requirements.txt\n```\n\n**NOTE:** The `requirements.txt` file is generated by running `pipreqs` (`pip install pipreqs`) in the project directory. `~=` means *compatible version*.\n\n\u003cbr\u003e\n\n### 1.2 - Configure platform-dependent functionality\n\n#### 1.2.1 - Linux\n\nCopy the udev-rules-file to the correct location.\n\n```bash\nsudo cp udev/90-usbmeter.rules /etc/udev/rules.d/90-usbmeter.rules\n```\n\n\u003cbr\u003e\n\nRestart the udev management tool.\n\n```bash\nsudo udevadm control --reload-rules\nsudo udevadm trigger\n```\n\n\u003cbr\u003e\n\n#### 1.2.2 - Windows\n\nUse [Zadig](https://zadig.akeo.ie/) to replace Windows's default HID-driver to `libusbK`.\n\n1. Run `zadig-2.8.exe`\n2. Click on `Options` \u003e `List All Devices`\n3. Select the `WITRN.C4` device (in case the [Witrn C4](https://aliexpress.com/item/1005004748597690.html) is used)\n4. Select `libusbK (v3.0.7.0)` above the `Replace Driver` button\n5. Click on `Replace Driver`\n6. Confirm the driver replacement operation, wait for the tool to finish\n\n\u003cbr\u003e\n\n## 2 - Running\n\nRunning `witrn-ui-bokeh.py` *as-is* with Python won't do anything. It is supposed to be launched using [Bokeh server](https://docs.bokeh.org/en/latest/docs/user_guide/server/server_introduction.html#ug-server-introduction) (`bokeh serve`), which creates (and opens, on [http://localhost:5006/witrn-ui-bokeh](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.\n\n```bash\nbokeh serve --show witrn-ui-bokeh.py\n```\n\n\u003cbr\u003e\n\nOnce the web-interface opens, use the following steps.\n\n1. Select a **Device** using the dropdown (`C4` selected by default).\n   - 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.\n2. Click on \u003ckbd\u003eOpen Connection\u003c/kbd\u003e\n   - 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)\n   - Click on \u003ckbd\u003eClear Plot\u003c/kbd\u003e to clear all of the already plotted measurements (the tool only keeps `6000` (configurable, using `MAX_X_POINTS` in [witrn-ui-bokeh.py](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)\n   - Click on an item in the **Legend** to enable or disable the display of certain lines on the plot\n3. Use the tooltips on the side (activated when hovering over the plot) to zoom in or out on the measurements, ...\n4. Change the plot- and file- **Title** and **Log Period \\[ms\\]** using the corresponding fields (if necessary), click on \u003ckbd\u003eStart Logging\u003c/kbd\u003e to start saving values to a `.csv`-file.\n   - 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_\u003cTitle\u003e.csv`\n\n\u003cbr\u003e\n\nUsage sample:\n\n\u003cimg src=\"docs/witrn-ui-bokeh.gif\" alt=\"witrn-ui-bokeh usage example\"\u003e\n\n\u003cbr\u003e\n\n## 3 - TODO\n\n- Add functionality to re-plot stored CSV-data\n- Add functionality to \"download\" offline recordings from the USB-meter\n- Implement U2P functionality (see [this](https://wiki.cuvoodoo.info/doku.php?id=web-u2) and [this](https://git.cuvoodoo.info/kingkevin/web-u2/src/branch/master/u2_usb.c))\n- Implement TC66 functionality (see [this](https://github.com/TheHWcave/TC66/blob/main/TC66C.py))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffescron%2Fwitrn-ui-bokeh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffescron%2Fwitrn-ui-bokeh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffescron%2Fwitrn-ui-bokeh/lists"}