alarmkpi 0.1.0__tar.gz

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,10 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .pytest_cache/
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ .coverage
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-11-22
10
+
11
+ ### Added
12
+
13
+ - Alarm journal CSV reader with automatic column, delimiter, encoding and time-format
14
+ detection, state maps and an Ignition preset.
15
+ - ISA-18.2 / EEMUA 191 metrics: alarm rates per operator, peak 10-minute rate, floods,
16
+ bad actors, chattering, fleeting, stale and standing alarms, priority mix, time to acknowledge.
17
+ - `alarmkpi report` with text, HTML (single file, no JavaScript), Markdown and JSON output,
18
+ and `--fail-on` for scheduled checks.
19
+ - `alarmkpi demo`: a realistic one-week sample journal.
alarmkpi-0.1.0/LICENSE ADDED
@@ -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.
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.5
2
+ Name: alarmkpi
3
+ Version: 0.1.0
4
+ Summary: ISA-18.2 / EEMUA 191 alarm performance KPIs and a one-file HTML report from alarm journal exports
5
+ Project-URL: Homepage, https://github.com/DanShinde/alarmkpi
6
+ Project-URL: Documentation, https://github.com/DanShinde/alarmkpi#readme
7
+ Project-URL: Issues, https://github.com/DanShinde/alarmkpi/issues
8
+ Project-URL: Changelog, https://github.com/DanShinde/alarmkpi/blob/main/CHANGELOG.md
9
+ Author: Dan Shinde
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: alarm-flood,alarm-management,automation,chattering-alarms,dcs,eemua-191,hmi,ignition,industrial,isa-18.2,kpi,operator,process-safety,scada
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Manufacturing
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
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: Programming Language :: Python :: 3.14
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
27
+ Classifier: Topic :: Utilities
28
+ Classifier: Typing :: Typed
29
+ Requires-Python: >=3.10
30
+ Description-Content-Type: text/markdown
31
+
32
+ # alarmkpi
33
+
34
+ [![PyPI](https://img.shields.io/pypi/v/alarmkpi.svg)](https://pypi.org/project/alarmkpi/)
35
+ [![CI](https://github.com/DanShinde/alarmkpi/actions/workflows/ci.yml/badge.svg)](https://github.com/DanShinde/alarmkpi/actions/workflows/ci.yml)
36
+ [![Python](https://img.shields.io/pypi/pyversions/alarmkpi.svg)](https://pypi.org/project/alarmkpi/)
37
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
38
+
39
+ **Alarm performance KPIs from your alarm journal, measured against ISA-18.2 and EEMUA 191.**
40
+ Point it at a CSV export from your SCADA, HMI or DCS and get the numbers an alarm
41
+ rationalization starts with, plus a one-file HTML report you can email to the plant manager.
42
+
43
+ ![alarmkpi HTML report: KPI cards and alarms per 10 minutes](https://raw.githubusercontent.com/DanShinde/alarmkpi/main/docs/report.png)
44
+
45
+ ```console
46
+ $ pip install alarmkpi
47
+ $ alarmkpi report alarm_journal.csv --html report.html
48
+ Alarm performance: 984 alarms, 2026-11-16 06:10 to 2026-11-23 05:31 (6 d 23 h)
49
+
50
+ OK Alarms per operator per day 141 target ≈150 acceptable, ≈300 max manageable
51
+ OK Alarms per operator per 10 min 0.98 target ≈1 acceptable, ≈2 max manageable
52
+ BAD Peak alarms in 10 minutes 27 target ≤10
53
+ BAD Top 10 alarms share of total 72.1% target ≈1% to 5% max
54
+ BAD Chattering alarms 2 target 0
55
+ ...
56
+ Overall: POOR
57
+ ```
58
+
59
+ ## What it measures
60
+
61
+ | Metric | Target (one operator position) |
62
+ | --- | --- |
63
+ | Alarms per operator per day / hour / 10 minutes | ≈150 / ≈6 / ≈1 acceptable, ≈300 / ≈12 / ≈2 maximum manageable |
64
+ | Peak alarms in any 10 minutes | ≤10 |
65
+ | % of 10-minute periods in flood, % of hours with >30 alarms, % of time in flood | <1% |
66
+ | **Alarm floods**: start, duration, size, peak and main contributors | flood starts above 10 alarms / 10 min, ends below 5 |
67
+ | **Bad actors**: top 10 alarms and their share of the total load | ≈1% to 5% max |
68
+ | **Chattering** alarms (3+ activations within 60 s) | 0 |
69
+ | **Fleeting** alarms (active for less than 1 s) | 0 |
70
+ | **Stale** alarms (active more than 24 h) and alarms still standing | <5 |
71
+ | **Priority distribution** | ≈80% low / 15% medium / 5% high |
72
+ | Median time to acknowledge | reported when the journal has acknowledgements |
73
+
74
+ Every threshold is a command-line option (`--operators`, `--chatter-count`, `--chatter-window`,
75
+ `--fleeting`, `--stale-hours`, `--top`), because your alarm philosophy document has the final
76
+ say. The targets are the commonly published ISA-18.2 / EEMUA 191 figures and are guidance, not
77
+ a compliance verdict.
78
+
79
+ ## Try it without plant data
80
+
81
+ ```console
82
+ alarmkpi demo -o demo_journal.csv # a realistic week: a flood, a chattering
83
+ alarmkpi report demo_journal.csv --html report.html # level switch, stale alarms, ...
84
+ ```
85
+
86
+ Or open the [sample report](https://htmlpreview.github.io/?https://github.com/DanShinde/alarmkpi/blob/main/docs/demo-report.html)
87
+ made from [`examples/demo_journal.csv`](examples/demo_journal.csv).
88
+
89
+ ## Your alarm journal
90
+
91
+ Any CSV with one row per alarm event works. Columns are found by their usual names
92
+ (`EventTime`/`Timestamp`/`Time`, `Source`/`Tag`/`Alarm`, `EventState`/`State`/`Type`,
93
+ `Priority`/`Severity`, `Message`/`Description`, `Area`/`Unit`), comma, semicolon or tab
94
+ separated, UTF-8 or Windows-1252. When the names differ, say which is which:
95
+
96
+ ```console
97
+ alarmkpi report events.csv --time-col "Date/Time" --tag-col "Point" --state-col "Event" \
98
+ --priority-col "Level" --time-format "%d/%m/%Y %H:%M:%S"
99
+ ```
100
+
101
+ - **State column** values such as `Active`, `Alarm`, `Clear`, `RTN`, `Normal`, `Ack`,
102
+ `Acknowledged` are recognised. Map codes with `--state-map "0=active,1=clear,2=ack"`.
103
+ Without a state column every row counts as one alarm activation (rates, floods, bad actors
104
+ and chattering still work; durations need clear events).
105
+ - **Priorities**: names (`Low`, `Medium`, `High`, `Critical`/`Urgent`) or numbers
106
+ (0 to 4 as in Ignition, or 1 to 1000 severities split in four bands).
107
+ - **Times**: ISO 8601, common US and European formats, epoch seconds or milliseconds.
108
+ Time-zone-aware stamps are converted to UTC.
109
+ - **Ignition**: `--preset ignition` reads the alarm journal export or the `alarm_events`
110
+ table (`eventtype` 0/1/2) and shortens `prov:default:/tag:...:/alm:...` paths.
111
+
112
+ Other useful options: `--operators 3` for several consoles, `--area Boiler` to analyse one
113
+ area, `--start`/`--end` to cut the window, `--markdown`/`--json FILE` for other outputs, and
114
+ `--fail-on poor` to make a scheduled job fail when performance slips.
115
+
116
+ ## Python API
117
+
118
+ ```python
119
+ from alarmkpi import Settings, analyze, read_csv
120
+ from alarmkpi.report import html
121
+
122
+ a = analyze(read_csv("journal.csv"), Settings(operators=2))
123
+ print(a.per_day, a.max_10min, [f.start for f in a.floods])
124
+ open("report.html", "w").write(html(a))
125
+ ```
126
+
127
+ ## Related tools
128
+
129
+ `alarmkpi` is part of a small set of open-source tools for automation engineers:
130
+
131
+ - [tagscope](https://github.com/DanShinde/tagscope): log OPC UA tags to a database, with a dashboard
132
+ - [fakeplc](https://github.com/DanShinde/fakeplc): a fake PLC (OPC UA + Modbus TCP) for tests and demos
133
+ - [tagbridge](https://github.com/DanShinde/tagbridge): Modbus / OPC UA to MQTT Sparkplug B gateway
134
+ - [plcdiff](https://github.com/DanShinde/plcdiff): readable git diffs for PLC program exports
135
+
136
+ ## Contributing
137
+
138
+ Sample exports from other alarm systems (sanitized) are the most valuable contribution: they
139
+ let us add presets. See [CONTRIBUTING.md](CONTRIBUTING.md).
140
+
141
+ ISA-18.2 is a standard of the International Society of Automation; EEMUA 191 is published by
142
+ EEMUA. This project is not affiliated with either.
143
+
144
+ ## License
145
+
146
+ MIT
@@ -0,0 +1,115 @@
1
+ # alarmkpi
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/alarmkpi.svg)](https://pypi.org/project/alarmkpi/)
4
+ [![CI](https://github.com/DanShinde/alarmkpi/actions/workflows/ci.yml/badge.svg)](https://github.com/DanShinde/alarmkpi/actions/workflows/ci.yml)
5
+ [![Python](https://img.shields.io/pypi/pyversions/alarmkpi.svg)](https://pypi.org/project/alarmkpi/)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+
8
+ **Alarm performance KPIs from your alarm journal, measured against ISA-18.2 and EEMUA 191.**
9
+ Point it at a CSV export from your SCADA, HMI or DCS and get the numbers an alarm
10
+ rationalization starts with, plus a one-file HTML report you can email to the plant manager.
11
+
12
+ ![alarmkpi HTML report: KPI cards and alarms per 10 minutes](https://raw.githubusercontent.com/DanShinde/alarmkpi/main/docs/report.png)
13
+
14
+ ```console
15
+ $ pip install alarmkpi
16
+ $ alarmkpi report alarm_journal.csv --html report.html
17
+ Alarm performance: 984 alarms, 2026-11-16 06:10 to 2026-11-23 05:31 (6 d 23 h)
18
+
19
+ OK Alarms per operator per day 141 target ≈150 acceptable, ≈300 max manageable
20
+ OK Alarms per operator per 10 min 0.98 target ≈1 acceptable, ≈2 max manageable
21
+ BAD Peak alarms in 10 minutes 27 target ≤10
22
+ BAD Top 10 alarms share of total 72.1% target ≈1% to 5% max
23
+ BAD Chattering alarms 2 target 0
24
+ ...
25
+ Overall: POOR
26
+ ```
27
+
28
+ ## What it measures
29
+
30
+ | Metric | Target (one operator position) |
31
+ | --- | --- |
32
+ | Alarms per operator per day / hour / 10 minutes | ≈150 / ≈6 / ≈1 acceptable, ≈300 / ≈12 / ≈2 maximum manageable |
33
+ | Peak alarms in any 10 minutes | ≤10 |
34
+ | % of 10-minute periods in flood, % of hours with >30 alarms, % of time in flood | <1% |
35
+ | **Alarm floods**: start, duration, size, peak and main contributors | flood starts above 10 alarms / 10 min, ends below 5 |
36
+ | **Bad actors**: top 10 alarms and their share of the total load | ≈1% to 5% max |
37
+ | **Chattering** alarms (3+ activations within 60 s) | 0 |
38
+ | **Fleeting** alarms (active for less than 1 s) | 0 |
39
+ | **Stale** alarms (active more than 24 h) and alarms still standing | <5 |
40
+ | **Priority distribution** | ≈80% low / 15% medium / 5% high |
41
+ | Median time to acknowledge | reported when the journal has acknowledgements |
42
+
43
+ Every threshold is a command-line option (`--operators`, `--chatter-count`, `--chatter-window`,
44
+ `--fleeting`, `--stale-hours`, `--top`), because your alarm philosophy document has the final
45
+ say. The targets are the commonly published ISA-18.2 / EEMUA 191 figures and are guidance, not
46
+ a compliance verdict.
47
+
48
+ ## Try it without plant data
49
+
50
+ ```console
51
+ alarmkpi demo -o demo_journal.csv # a realistic week: a flood, a chattering
52
+ alarmkpi report demo_journal.csv --html report.html # level switch, stale alarms, ...
53
+ ```
54
+
55
+ Or open the [sample report](https://htmlpreview.github.io/?https://github.com/DanShinde/alarmkpi/blob/main/docs/demo-report.html)
56
+ made from [`examples/demo_journal.csv`](examples/demo_journal.csv).
57
+
58
+ ## Your alarm journal
59
+
60
+ Any CSV with one row per alarm event works. Columns are found by their usual names
61
+ (`EventTime`/`Timestamp`/`Time`, `Source`/`Tag`/`Alarm`, `EventState`/`State`/`Type`,
62
+ `Priority`/`Severity`, `Message`/`Description`, `Area`/`Unit`), comma, semicolon or tab
63
+ separated, UTF-8 or Windows-1252. When the names differ, say which is which:
64
+
65
+ ```console
66
+ alarmkpi report events.csv --time-col "Date/Time" --tag-col "Point" --state-col "Event" \
67
+ --priority-col "Level" --time-format "%d/%m/%Y %H:%M:%S"
68
+ ```
69
+
70
+ - **State column** values such as `Active`, `Alarm`, `Clear`, `RTN`, `Normal`, `Ack`,
71
+ `Acknowledged` are recognised. Map codes with `--state-map "0=active,1=clear,2=ack"`.
72
+ Without a state column every row counts as one alarm activation (rates, floods, bad actors
73
+ and chattering still work; durations need clear events).
74
+ - **Priorities**: names (`Low`, `Medium`, `High`, `Critical`/`Urgent`) or numbers
75
+ (0 to 4 as in Ignition, or 1 to 1000 severities split in four bands).
76
+ - **Times**: ISO 8601, common US and European formats, epoch seconds or milliseconds.
77
+ Time-zone-aware stamps are converted to UTC.
78
+ - **Ignition**: `--preset ignition` reads the alarm journal export or the `alarm_events`
79
+ table (`eventtype` 0/1/2) and shortens `prov:default:/tag:...:/alm:...` paths.
80
+
81
+ Other useful options: `--operators 3` for several consoles, `--area Boiler` to analyse one
82
+ area, `--start`/`--end` to cut the window, `--markdown`/`--json FILE` for other outputs, and
83
+ `--fail-on poor` to make a scheduled job fail when performance slips.
84
+
85
+ ## Python API
86
+
87
+ ```python
88
+ from alarmkpi import Settings, analyze, read_csv
89
+ from alarmkpi.report import html
90
+
91
+ a = analyze(read_csv("journal.csv"), Settings(operators=2))
92
+ print(a.per_day, a.max_10min, [f.start for f in a.floods])
93
+ open("report.html", "w").write(html(a))
94
+ ```
95
+
96
+ ## Related tools
97
+
98
+ `alarmkpi` is part of a small set of open-source tools for automation engineers:
99
+
100
+ - [tagscope](https://github.com/DanShinde/tagscope): log OPC UA tags to a database, with a dashboard
101
+ - [fakeplc](https://github.com/DanShinde/fakeplc): a fake PLC (OPC UA + Modbus TCP) for tests and demos
102
+ - [tagbridge](https://github.com/DanShinde/tagbridge): Modbus / OPC UA to MQTT Sparkplug B gateway
103
+ - [plcdiff](https://github.com/DanShinde/plcdiff): readable git diffs for PLC program exports
104
+
105
+ ## Contributing
106
+
107
+ Sample exports from other alarm systems (sanitized) are the most valuable contribution: they
108
+ let us add presets. See [CONTRIBUTING.md](CONTRIBUTING.md).
109
+
110
+ ISA-18.2 is a standard of the International Society of Automation; EEMUA 191 is published by
111
+ EEMUA. This project is not affiliated with either.
112
+
113
+ ## License
114
+
115
+ MIT
@@ -0,0 +1,74 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "alarmkpi"
7
+ dynamic = ["version"]
8
+ description = "ISA-18.2 / EEMUA 191 alarm performance KPIs and a one-file HTML report from alarm journal exports"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "Dan Shinde" }]
14
+ keywords = [
15
+ "alarm-management", "isa-18.2", "eemua-191", "alarm-flood", "chattering-alarms", "scada",
16
+ "hmi", "dcs", "ignition", "process-safety", "industrial", "automation", "kpi", "operator",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Environment :: Console",
21
+ "Intended Audience :: Developers",
22
+ "Intended Audience :: Manufacturing",
23
+ "Operating System :: OS Independent",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3 :: Only",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Programming Language :: Python :: 3.14",
31
+ "Topic :: Scientific/Engineering :: Information Analysis",
32
+ "Topic :: Scientific/Engineering",
33
+ "Topic :: Utilities",
34
+ "Typing :: Typed",
35
+ ]
36
+ dependencies = []
37
+
38
+ [project.scripts]
39
+ alarmkpi = "alarmkpi.cli:main"
40
+
41
+ [project.urls]
42
+ Homepage = "https://github.com/DanShinde/alarmkpi"
43
+ Documentation = "https://github.com/DanShinde/alarmkpi#readme"
44
+ Issues = "https://github.com/DanShinde/alarmkpi/issues"
45
+ Changelog = "https://github.com/DanShinde/alarmkpi/blob/main/CHANGELOG.md"
46
+
47
+ [dependency-groups]
48
+ dev = ["pytest>=8", "pytest-cov>=5", "ruff>=0.6", "mypy>=1.11"]
49
+
50
+ [tool.hatch.version]
51
+ path = "src/alarmkpi/__init__.py"
52
+
53
+ [tool.hatch.build.targets.sdist]
54
+ include = ["src", "tests", "README.md", "LICENSE", "CHANGELOG.md"]
55
+
56
+ [tool.pytest.ini_options]
57
+ testpaths = ["tests"]
58
+
59
+ [tool.ruff]
60
+ line-length = 100
61
+ target-version = "py310"
62
+
63
+ [tool.ruff.lint]
64
+ select = ["E", "F", "W", "I", "B", "UP", "SIM", "RUF"]
65
+ ignore = ["E501", "RUF001"] # the formatter owns line length; × is intended
66
+
67
+ [tool.mypy]
68
+ python_version = "3.10"
69
+ strict = true
70
+ packages = ["alarmkpi"]
71
+ mypy_path = "src"
72
+
73
+ [tool.ruff.lint.per-file-ignores]
74
+ "tests/*" = ["E501"]
@@ -0,0 +1,18 @@
1
+ """ISA-18.2 / EEMUA 191 alarm performance KPIs from alarm journal exports."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from alarmkpi.analysis import Analysis, Settings, analyze
6
+ from alarmkpi.events import Event, Journal, JournalError, read_csv, read_text
7
+
8
+ __all__ = [
9
+ "Analysis",
10
+ "Event",
11
+ "Journal",
12
+ "JournalError",
13
+ "Settings",
14
+ "__version__",
15
+ "analyze",
16
+ "read_csv",
17
+ "read_text",
18
+ ]
@@ -0,0 +1,3 @@
1
+ from alarmkpi.cli import main
2
+
3
+ raise SystemExit(main())