Furnace Monitor and Control System

Python

Oracle

Docker

PyQt5

Overview

FMCS (Furnace Monitor and Control System) is a Windows desktop application I designed and built during my placement at CERN. It runs in production in Building 163, automating the heat treatment of superconducting magnet cable across six furnaces.

Before FMCS, an operator had to read each heat treatment program from Oracle and key it into the furnace controller by hand, and there was no continuous record of what a furnace was doing during a run. FMCS sits between the CERN Oracle database and the Eurotherm furnace controllers: it retrieves programs, transfers them to the controllers, starts them, collects live data over OPC DA, and syncs measurements back to Oracle for full traceability. Operators only step in to assign an order or stop a program.

FMCS application running, showing live furnace data and system tray icons


Architecture

FMCS is deliberately a single multi-threaded process rather than a distributed system. Each control-room workstation runs one independent instance talking directly to the local OPC servers and the shared Oracle database, so resilience is per-machine and there's nothing to cluster or load-balance.

Data collection

The Data Collection thread owns all OPC DA connections. Rather than polling each tag, it subscribes to OPC groups and receives OnDataChange COM events, filtering out duplicates so the cache only updates when a value, quality or timestamp actually changes. OPC quality codes are mapped to GOOD/BAD, and readings matching OPC's "no data" sentinels (NaN, Inf, near-float32-max) are rejected regardless of their reported quality.

Protocols sit behind a pluggable adapter interface, so OPC UA or Modbus could be added without touching the service layer.

Detecting dead connections

A dead OPC link can leave the COM objects perfectly intact while no real data flows, so "connected" isn't enough. A source is treated as stale, and automatically reconnected, if any of these hold for longer than a configurable threshold:

  • no event has arrived at all
  • it has never produced a single reading since connecting (the local COM calls can succeed even when the server can't reach the device)
  • every subscribed tag is reporting BAD quality (e.g. a sensor unplugged while the server keeps sending events)

Aggregation and adaptive sync

Rather than writing every OPC reading to Oracle, FMCS aggregates in memory and persists just two rows per parameter per sync period, one at the start and one at the end. This keeps the buffer bounded to roughly the number of parameters, while preserving enough of the time series for traceability. The GUI still sees every reading live.

Each parameter carries its own run and idle logging intervals, chosen automatically from the furnace's live state. A furnace mid-treatment gets fine-grained writes, while an idle one syncs far less often, with no global setting changes.

Program transfer and start

Sending a program is a verified two-step sequence:

  1. Transfer: FMCS generates a UIP program file and shells out to Eurotherm's S2KPE.exe to write it to the controller, detecting failures from S2KPE's error log rather than trusting its exit code. It then reads the program name back from the controller to catch a transfer that silently landed the wrong program.
  2. Start: it selects the program slot on the controller, reads the selection back to confirm it, and only then writes the RUN command.

Furnace state machine

A FurnaceStateManager maps Eurotherm's integer program status codes (1=RESET, 2=RUN, 4=HOLD, 8=HOLDBACK, 16=END) through a protocol-independent mapper into furnace states: UNKNOWN, IDLE, IDLE_HOT, RUNNING and START_FAILED. State changes are emitted as Qt signals.

Telling IDLE from IDLE_HOT depends on furnace temperature, which is computed defensively. It only averages parameters explicitly typed as actual temperatures, uses only readings in the majority unit (so one sensor misconfigured in °F can't skew a set of °C readings), and ignores readings older than 30 seconds so a single stuck sensor can't misreport a furnace that has genuinely cooled.

Concurrency

All threads share each furnace's in-memory state behind a lock, with snapshot copies handed out so no caller iterates data another thread is mutating. Background threads never touch Qt widgets; updates reach the GUI only through queued Qt signals. Work flowing the other way, such as subscribing newly configured parameters, goes through a thread-safe queue that the collection thread drains, because OPC's COM objects are only safe to use from the thread that created them.


Authentication and Security

Operators log in via CERN SSO (Keycloak OIDC) using the OAuth 2.0 Device Authorization Grant: the user completes login in a browser while the desktop app polls for the token. A valid CERN login isn't sufficient on its own, though. The username is also checked against an authorisation function in the furnace database, so permission to operate furnaces is controlled centrally. Tokens live only in memory.

Oracle credentials are never stored in plain text; they're kept in the Windows Credential Manager via keyring, separate from non-secret preferences.


User Interface

The GUI is built with PyQt5 and styled with qtmodern.

  • Tabbed furnace views: one tab per furnace, showing live parameter readings, status, and the active HT order.
  • System tray icons: per-furnace icons showing the furnace number and active order ID. They appear only for states that need attention, and clicking one jumps to that furnace's tab.
  • HT Program Editor: a visual editor for heat treatment profiles with a segment graph and plateau table, supporting per-furnace templates.
  • Settings panel: collapsible sections for sync intervals, Oracle connection, database status, parameter types and file paths.
  • Live log viewer: a docked panel with real-time application logs.

Packaging, CI and Testing

FMCS ships as a self-contained Windows installer (PyInstaller + Inno Setup) that bundles the Python runtime and a 32-bit Oracle Instant Client, so end users need no separate Oracle install.

A GitLab CI pipeline runs linting, a compile check, pytest with coverage, and secret detection on every commit, and creates a GitLab Release when a version is tagged. Tests target the pure-logic modules (data models, the Eurotherm file adapters) with Qt, Oracle and Windows COM stubbed out. The installer itself is built on a dedicated Windows machine, since its 32-bit COM toolchain doesn't fit CERN's shared Linux runners.


Key Outcomes

  • In production in CERN Building 163, running heat treatment for six furnaces
  • Manual program entry at the furnace eliminated, with transfer and start verified by controller readback
  • Automatic detection and recovery from dead OPC connections for unattended operation
  • Oracle write load proportional to furnace activity through aggregation and adaptive sync
  • Zero-dependency Windows installer with bundled Oracle Instant Client

On this page

OverviewArchitectureData collectionDetecting dead connectionsAggregation and adaptive syncProgram transfer and startFurnace state machineConcurrencyAuthentication and SecurityUser InterfacePackaging, CI and TestingKey Outcomes

Links

Gitlab (Restricted Access to CERN Members)