tagscope 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.5
2
+ Name: tagscope
3
+ Version: 0.1.0
4
+ Summary: Log OPC UA tags to SQLite or PostgreSQL and watch them live in a fast, modern web dashboard.
5
+ Project-URL: Homepage, https://github.com/DanShinde/tagscope
6
+ Project-URL: Issues, https://github.com/DanShinde/tagscope/issues
7
+ Project-URL: Changelog, https://github.com/DanShinde/tagscope/blob/main/CHANGELOG.md
8
+ Author: Dan Shinde
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: dashboard,data-logger,historian,iiot,industrial,opc-ua,opcua,plc,scada,siemens
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Web Environment
14
+ Classifier: Framework :: AsyncIO
15
+ Classifier: Framework :: FastAPI
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Manufacturing
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
25
+ Classifier: Topic :: System :: Monitoring
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: asyncua>=1.1
28
+ Requires-Dist: fastapi>=0.110
29
+ Requires-Dist: pyyaml>=6.0
30
+ Requires-Dist: sqlalchemy>=2.0
31
+ Requires-Dist: uvicorn>=0.29
32
+ Requires-Dist: websockets>=12
33
+ Provides-Extra: dev
34
+ Requires-Dist: build; extra == 'dev'
35
+ Requires-Dist: httpx>=0.27; extra == 'dev'
36
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
37
+ Requires-Dist: pytest>=8; extra == 'dev'
38
+ Requires-Dist: ruff>=0.5; extra == 'dev'
39
+ Provides-Extra: postgres
40
+ Requires-Dist: psycopg[binary]>=3.1; extra == 'postgres'
41
+ Description-Content-Type: text/markdown
42
+
43
+ <div align="center">
44
+
45
+ # TagScope
46
+
47
+ **Log OPC UA tags to a database and watch them live in your browser.**
48
+
49
+ A lightweight historian for PLCs and industrial equipment: subscribe to any OPC UA server
50
+ (Siemens S7-1500, Beckhoff, B&R, Kepware, Ignition, Prosys…), store every change in SQLite or
51
+ PostgreSQL, and get a fast, modern dashboard with live values, trends, alarms and CSV export.
52
+ One `pip install`, one YAML file, no cloud.
53
+
54
+ [![CI](https://github.com/DanShinde/tagscope/actions/workflows/ci.yml/badge.svg)](https://github.com/DanShinde/tagscope/actions/workflows/ci.yml)
55
+ [![PyPI](https://img.shields.io/pypi/v/tagscope.svg)](https://pypi.org/project/tagscope/)
56
+ [![Python](https://img.shields.io/pypi/pyversions/tagscope.svg)](https://pypi.org/project/tagscope/)
57
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
58
+
59
+ <img src="docs/demo.gif" alt="TagScope dashboard showing live tag cards, a multi-tag trend and the OPC UA address space browser" width="900">
60
+
61
+ </div>
62
+
63
+ ## Try it in 10 seconds
64
+
65
+ ```bash
66
+ pip install tagscope
67
+ tagscope demo
68
+ ```
69
+
70
+ `demo` starts a small simulated plant (a buffer tank, a transfer pump that trips now and then,
71
+ a reactor and a filler) as an OPC UA server, logs it to `tagscope-demo.db` and opens the dashboard
72
+ at <http://localhost:8000>. It even pre-fills 30 minutes of history, so the trends look alive
73
+ from the first second.
74
+
75
+ ## Why
76
+
77
+ Getting PLC data into a database usually means a commercial historian, a Node-RED flow you have
78
+ to babysit, or a one-off script without a UI. TagScope sits in between:
79
+
80
+ - **Small**: a single Python process, no broker, no separate front-end build.
81
+ - **Honest storage**: plain SQL tables you can query from Grafana, Power BI, Excel or pandas.
82
+ - **Made for the plant floor**: limits and alarms, deadbands, reconnects that just work,
83
+ and a dashboard that follows ISA-101 ideas (calm grey, colour only when something is wrong).
84
+
85
+ ## Features
86
+
87
+ | | |
88
+ |---|---|
89
+ | **Collect** | OPC UA subscriptions (not polling) for many servers at once, username/password login, automatic reconnect with back-off, per-tag deadband |
90
+ | **Store** | SQLite out of the box, PostgreSQL / TimescaleDB via `tagscope[postgres]`, retention clean-up, quality flag per sample |
91
+ | **See** | Live value cards with sparklines and limit bars, multi-tag trends with zoom (5 min to 24 h, downsampled server side), event log, dark and light themes, works on a phone |
92
+ | **Alarm** | High / low limits per tag, alarm and clear events with timestamps, active alarm counter |
93
+ | **Explore** | Built-in address space browser: click through the server and copy node ids into your config |
94
+ | **Export** | One click CSV from the dashboard, `tagscope export` from the shell, REST API with OpenAPI docs at `/api/docs`, WebSocket feed at `/ws` |
95
+
96
+ ## Use it with your PLC
97
+
98
+ ```bash
99
+ tagscope init # writes an example tagscope.yaml
100
+ tagscope browse opc.tcp://192.168.0.1:4840 # find the node ids you need
101
+ tagscope run tagscope.yaml --open
102
+ ```
103
+
104
+ ```yaml
105
+ storage: sqlite:///line1.db # or postgresql+psycopg://user:${DB_PASSWORD}@host/db
106
+ retention_days: 90
107
+
108
+ servers:
109
+ - name: line1-plc
110
+ endpoint: opc.tcp://192.168.0.1:4840
111
+ username: ${PLC_USER:-} # values can come from the environment
112
+ password: ${PLC_PASSWORD:-}
113
+ publishing_interval_ms: 500
114
+ tags:
115
+ - name: Mixer/Temperature
116
+ node: ns=3;s="DB_Mixer"."Temperature"
117
+ unit: °C
118
+ low: 20
119
+ high: 85
120
+ deadband: 0.1 # store only changes bigger than this
121
+ - name: Mixer/Running
122
+ node: ns=3;s="DB_Mixer"."Running"
123
+ - ns=3;s="DB_Counters"."Good" # short form: the node id is the name
124
+ ```
125
+
126
+ More in [`examples/`](examples), including a Siemens S7-1500 setup and PostgreSQL.
127
+
128
+ > **Siemens tip:** enable the OPC UA server in the PLC properties in TIA Portal and tick
129
+ > *Accessible from HMI/OPC UA* on the data blocks you want to log. Node ids then look like
130
+ > `ns=3;s="DB_Name"."Member"`.
131
+
132
+ ## Command line
133
+
134
+ | Command | What it does |
135
+ |---|---|
136
+ | `tagscope demo` | Simulated plant + logger + dashboard, nothing to configure |
137
+ | `tagscope run CONFIG` | Log the servers and tags in a YAML file and serve the dashboard |
138
+ | `tagscope init [PATH]` | Write an example config |
139
+ | `tagscope browse ENDPOINT [NODE]` | List the nodes of a server, with current values |
140
+ | `tagscope export CONFIG --minutes 60 -o out.csv` | Export logged samples |
141
+
142
+ ## Data model
143
+
144
+ Three tables, easy to query from anything that speaks SQL:
145
+
146
+ ```sql
147
+ SELECT t.name, s.ts, s.value
148
+ FROM tagscope_samples s JOIN tagscope_tags t ON t.id = s.tag_id
149
+ WHERE t.name = 'Mixer/Temperature' AND s.ts > CAST(strftime('%s', 'now', '-1 hour') AS REAL);
150
+ ```
151
+
152
+ | Table | Columns |
153
+ |---|---|
154
+ | `tagscope_tags` | `id, name, server, node, unit, description, low, high` |
155
+ | `tagscope_samples` | `tag_id, ts (epoch seconds), value, quality (0 good, 1 uncertain, 2 bad)` |
156
+ | `tagscope_events` | `id, ts, tag, kind (alarm, cleared, info, warning, error), message` |
157
+
158
+ ## How it works
159
+
160
+ ```mermaid
161
+ flowchart LR
162
+ PLC1[PLC / OPC UA server] -- subscriptions --> C[Collector]
163
+ PLC2[More servers] -- subscriptions --> C
164
+ C --> H[(Live state + alarms)]
165
+ H -- batched writes --> DB[(SQLite / PostgreSQL)]
166
+ H -- WebSocket --> UI[Dashboard]
167
+ DB -- history, CSV --> API[REST API] --> UI
168
+ ```
169
+
170
+ Everything runs on one asyncio event loop: asyncua subscriptions feed an in-memory hub,
171
+ which applies deadbands and limits, pushes updates to browsers over a WebSocket and hands
172
+ batches to a writer that flushes to the database once a second.
173
+
174
+ ## Docker
175
+
176
+ ```bash
177
+ docker build -t tagscope .
178
+ docker run -p 8000:8000 tagscope demo --host 0.0.0.0 --no-browser
179
+ docker run -p 8000:8000 -v $PWD:/data tagscope # uses ./tagscope.yaml
180
+ ```
181
+
182
+ ## Development
183
+
184
+ ```bash
185
+ git clone https://github.com/DanShinde/tagscope && cd tagscope
186
+ python -m venv .venv && source .venv/bin/activate
187
+ pip install -e ".[dev]"
188
+ pytest # includes end-to-end tests against the simulated OPC UA server
189
+ ruff check . && ruff format --check .
190
+ ```
191
+
192
+ The dashboard is plain HTML, CSS and JavaScript in `src/tagscope/static`, no build step.
193
+ Charts use [uPlot](https://github.com/leeoniya/uPlot) (MIT), bundled for offline use.
194
+
195
+ ## Roadmap
196
+
197
+ - Write values back to the PLC from the dashboard (opt-in, with confirmation)
198
+ - Add tags from the address space browser without editing YAML
199
+ - Modbus TCP and Siemens S7 (snap7) sources
200
+ - MQTT / Sparkplug B output
201
+ - Desktop build (single executable for Windows engineering laptops)
202
+
203
+ Ideas and pull requests are welcome, see the [issues](https://github.com/DanShinde/tagscope/issues).
204
+
205
+ ## License
206
+
207
+ [MIT](LICENSE) © Dan Shinde
@@ -0,0 +1,20 @@
1
+ tagscope/__init__.py,sha256=S9jY_NL8Ib5ZXlEF8p3BpHqtL6OlDzPKMonLSdC0jRM,133
2
+ tagscope/__main__.py,sha256=k1ocEWawweo1qCJWNFAAvyxz3tcY13dzvCenHszij30,48
3
+ tagscope/cli.py,sha256=7MWDSWCRJHU4dDhkJdzHh93PmKTT9mZTHG3DFUDN6OA,8129
4
+ tagscope/collector.py,sha256=VEh1m2aJgP5HahfMZiztyWAlOkJV_wIklJwjiEFuidY,5935
5
+ tagscope/config.py,sha256=8z2tWfYX5iY-ESZOh53KJqaFOmBEk-xFipQm0ayyjuo,5125
6
+ tagscope/hub.py,sha256=W75HwjJDbEghMk6wdRgTphKdLX5QyorxYckeusfcCfw,5605
7
+ tagscope/simulator.py,sha256=ZGqudC25VoHppxKEx9OEsGJtwUJ_i13Zyr2SBPxdVcw,7163
8
+ tagscope/storage.py,sha256=mc35pUh5RClRzWSjtlyGMj755tGQJt-KHidc-fRJmi4,10533
9
+ tagscope/web.py,sha256=da8-leObE2MbKxbJ_S1CqKZSXQLKj6bz7gYtB3hqNTY,4263
10
+ tagscope/static/app.css,sha256=eUMoSvt5r-9yLhltY0IouexQYOUxskg9u5lVGBTSWzM,14026
11
+ tagscope/static/app.js,sha256=limpKC1PYLhjqCKaVYgRhnm01HQpoUb9c8_O_E3iEY8,24294
12
+ tagscope/static/index.html,sha256=u_HrGy7hW0nu9rGavjgMaPDuU9XTg99pXieMM9vwNbQ,4147
13
+ tagscope/static/vendor/uPlot.LICENSE,sha256=j5iSKWmbT-LxoEMtDp7cM4qKkR4lDi0bAezXcKX1sb0,1078
14
+ tagscope/static/vendor/uPlot.iife.min.js,sha256=LSforT0igWRSXOIT-dxxbzm0467gzHc_s0kcls9JIaI,50312
15
+ tagscope/static/vendor/uPlot.min.css,sha256=32MMao1vjur_JktQ9zzlsRT2Rv_ZoLt08EmwoAE1-gQ,1857
16
+ tagscope-0.1.0.dist-info/METADATA,sha256=_7ZD56A-Ksi1910LjIqAbttDHxRhOK2jOy-vN1AiQ24,8443
17
+ tagscope-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
+ tagscope-0.1.0.dist-info/entry_points.txt,sha256=5tcu2xHZ6DcCmOgfKlQzS-zPlTcRt0102XeRtLQFvTA,47
19
+ tagscope-0.1.0.dist-info/licenses/LICENSE,sha256=8V3_LiY7wYDT-PZsKk8zKEqWZAq-Mb0Ua_Qoddhsx3k,1067
20
+ tagscope-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ tagscope = tagscope.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dan Shinde
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.