How riclolsen/oshmi works
1. OSHMI is a substation/industrial HMI platform, not just a single app. The repo contains the core runtime, browser UI, protocol clients, database scripts, graphics authoring assets, and installation/OS integration for Windows and Linux deployments.
2. The central architecture is a data-acquisition-and-presentation pipeline: field protocols and helper clients feed point values, alarms, events, and histories into the backend; the backend persists selected data in SQLite/PostgreSQL; browser clients read it through HTTP/JSON/PHP endpoints and render SVG/HTML5 views, trends, tables, alarms, and events.
3. The main server-side engine lives in webserver/. This is the core native C++ application and its UI/dialog modules. It embeds a lightweight HTTP server, JSON handling, SQLite, Lua, and crypto helpers, and is responsible for serving the HMI services, historian access, event/alarm logic, and server-side automation hooks.
4. The htdocs/ tree is the browser-facing application layer. It contains the HMI pages (screen.html, trend.html, events.html, tabular.html, etc.), PHP endpoints (json.php, pntserver.php, eventserver.php, sqlite_oshmi.php, pgsql_* scripts), and a large JavaScript/CSS library stack for SVG, jQuery UI, Flot, D3, Vega/Vega-Lite, Tableau WDC, and custom HMI widgets.
5. Data persistence is split by use case. The db/ folder contains SQLite-oriented processing and maintenance scripts for dump/history/SOE tables, while PostgreSQL/ and the pgsql_* endpoints support a PostgreSQL-backed variant for reporting and larger deployments. The repository also includes MongoDB helper scripts, showing that archival/export can be swapped or extended.
6. Protocol integration is decomposed into separate driver/client projects rather than a single monolith. Notable acquisition/control components are DNP3/, modbus/, iec61850_client/, opc_client/, s7client/, qtester104/, and mon_proc/. These are the boundaries where OSHMI talks to external automation systems and feeds the core HMI point model.
7. The README makes an important architectural distinction: OSHMI is an HMI and automation presentation system, not a protocol gateway by itself. In practice, external devices and protocol drivers supply data into OSHMI; OSHMI then visualizes, logs, correlates, alarms, and optionally issues commands or scripted actions.
8. Automation and business logic can be pushed into Lua. The webserver/luasrc/ subtree and config templates like conf_templates/script.lua indicate a server-side scripting layer used for custom logic such as restoration sequences, tap control, point calculations, and other site-specific workflows.
9. Configuration is intentionally file-driven. The repo is full of templates and .ini/.conf/.js/.txt files under conf_templates/, plus protocol-specific configs in each client folder. That means most system wiring is done by deployment-time text configuration rather than hardcoded application state.
10. The graphics pipeline is a major subsystem. inkscape_sage_src/ contains custom Inkscape/“SAGE” extensions for building animated SVG screens, while svg/, icons/, charts/, and the htdocs screen files support the runtime rendering side. This is the UX layer for lossless zooming, mimics, and live process visualization.
11. Operational control and shell replacement are handled separately from the HMI itself. hmishell/ is a dedicated Windows shell application, and bin/, etc/, and linux/ contain start/stop/reboot/logout scripts, service registration, and platform-specific launch automation. This is the boundary where OSHMI integrates with the host OS and kiosk-like deployments.
12. Reporting and analytics are first-class integrations. The repo includes a Power BI sample, Tableau WDC assets, OData/JSON endpoints, and Grafana packaging. These pieces let external BI tools query historian and point data without going through the live HMI UI.
13. Deployment is cross-platform but weighted toward Windows station/SCADA installations. There are Windows batch files, .reg files, and installer assets in installer/, plus Linux web stack assets in linux/, nginx_php/, and conf_templates/. The runtime is therefore a mix of native binaries, browser assets, and web middleware rather than a single server executable.
14. For an architecture diagram, the key boundaries are: field protocol clients on the left; core OSHMI backend in the center; SQLite/PostgreSQL/MongoDB/Grafana/BI/reporting on the right; and browser or shell-based operator clients on the top. The notable internal cross-cutting concerns are Lua scripting, configuration files, and SVG-based screen assets.
Main entry points: webserver Webserver · htdocs Browser app · json.php Data endpoints · installer Installer
Components 23
Field clients
Protocol adapters and helper clients that acquire process data from external automation systems.
- DNP3 · C++ acquisition client for DNP3 field data and SOE handling.
DNP3 - Modbus · Modbus helper client for polling and point acquisition.
modbus - IEC 61850 · .NET client for IEC 61850 integration.
iec61850_client - OPC client · OPC client integration for external automation systems.
opc_client - S7 client · Siemens S7 acquisition client and helper logic.
s7client - Mon proc · Process monitoring helper used to feed or supervise point data.
mon_proc
Core runtime
Native backend engine, embedded HTTP, JSON, historian, alarms, and scripting.
- Webserver · Native runtime that serves HMI services, historian access, alarms, events, JSON, and scripting.
webserver - HTTP/JSON · Embedded web server and request handling exposed by the backend.
webserver/httpd_u.cpp - Hist & alarms · Historian, event, alarm, SOE, and point-processing logic.
webserver/historico_u.cpp - Lua hooks · Server-side scripting and site-specific automation hooks.
webserver/luasrc - Screen runtime · Server-side screen list and HMI presentation model used by the backend.
webserver/screen_list_u.cpp
Operator UI
Browser-facing HMI pages, endpoints, and client-side visualization stack.
- Browser app · Browser-facing HTML, PHP, JavaScript, and CSS application layer.
htdocs - Data endpoints · PHP endpoints for JSON, point, event, tabular, trend, and OData access.
htdocs/json.php - UI libraries · JavaScript and CSS libraries for charts, dialogs, tables, and SVG widgets.
htdocs/lib
Persistence & analytics
Local databases, reporting integrations, and archival/export helpers.
- SQLite scripts · SQLite-oriented dump, historian, SOE, and maintenance scripts.
db - PostgreSQL · PostgreSQL-backed reporting and archival variant.
PostgreSQL - Mongo helpers · MongoDB helper scripts for alternate archival or export workflows.
mongodb - BI exports · Power BI, Tableau WDC, OData, and Grafana integration assets.
PowerBI
Deployment
OS integration, launch scripts, installers, and platform-specific packaging.
- HMI shell · Dedicated operator shell and kiosk-style Windows shell application.
hmishell - OS scripts · Start/stop, service registration, reboot/logout, and platform launch scripts.
bin - Installer · Windows installer and packaging assets for deployment.
installer - Linux stack · Linux web stack, PHP, nginx, and autostart/service integration.
linux
Graphics pipeline
Authoring and runtime assets for SVG-based process screens and mimics.
- SVG assets · Inkscape SAGE extensions, screen authoring assets, icons, charts, and SVG runtime support.
inkscape_sage_src
Connections 23
- DNP3 → Webserver: points/SOE · Protocol data flows into the core backend point model.
- Modbus → Webserver: points · Modbus values are ingested by the backend.
- IEC 61850 → Webserver: points · IEC 61850 data feeds the backend.
- OPC client → Webserver: points · OPC data feeds the backend.
- S7 client → Webserver: points · S7 data feeds the backend.
- Mon proc → Webserver: monitoring · Monitoring helper supplies process-related data.
- Webserver → HTTP/JSON: serves · The backend exposes its services over embedded HTTP.
- Webserver → Hist & alarms: coordinates · Core runtime manages historian, alarms, events, and point processing.
- Webserver → Lua hooks: hooks · Automation logic is extended through Lua scripting.
- Webserver → Screen runtime: screen model · Backend maintains the screen list and presentation model.
- HTTP/JSON → Browser app: delivers · Browser application assets are served to clients.
- Browser app → Data endpoints: calls · Web pages consume PHP and JSON endpoints.
- Browser app → UI libraries: renders with · The HMI UI is built on client-side libraries and widgets.
- Data endpoints → SQLite scripts: reads/writes · Endpoints access SQLite-backed historian and point data.
- Data endpoints → PostgreSQL: reports · PostgreSQL endpoints support larger reporting deployments.
- Data endpoints → Mongo helpers: exports · Alternate archival/export paths can target MongoDB helpers.
- Data endpoints → BI exports: feeds · BI tools consume historian data through reporting integrations.
- SVG assets → Browser app: screens · Authoring assets support browser-rendered HMI graphics.
- OS scripts → Webserver: launches · Scripts start and stop the core runtime and services.
- HMI shell → Browser app: hosts UI · The shell provides an operator-facing desktop wrapper for the HMI.
- Linux stack → Browser app: web stack · Linux packaging supports the browser application deployment.
- Installer → Webserver: packages · Installer bundles backend and deployment components.
- Installer → Browser app: packages · Installer bundles browser assets and supporting files.