# OEE and downtime

> How eaxScada (Pro and Enterprise) works out machine states, downtime events and OEE from the historian - the four state classes, the six time categories and their order, planned and unplanned downtime, micro-stops, availability, performance, quality and OEE as the server computes them, coverage and the quality of a result, counts and their checks, final and provisional rows (settle, write interval), backfill and recompute, high availability and failover, retention, and why the module never writes to a machine.

Product: eaxScada · Type: Explanation · Editions: Pro, Enterprise
Source: https://eaxware.com/docs/eaxscada/explanation/oee-and-downtime/
Verified against commit 667babf.

OEE and downtime turns what the historian logged for a machine (its state, its counts, optionally its fault code and product) into **states over time**, **downtime events** with the reason an operator gave, and **OEE** per hour, shift, day or any period. It is part of eaxScada **Pro and Enterprise**; it is not in Starter and not in Free (not even its evaluation sessions). To set it up, see [Set up OEE and downtime](/docs/eaxscada/how-to/set-up-oee-and-downtime/); the facts in one place are in the [OEE and downtime reference](/docs/eaxscada/reference/oee-and-downtime/).

## It only reads

**OEE and downtime never writes to equipment.** It writes no tag, sends no command, acknowledges or shelves no alarm and changes no recipe. It reads the historian. Its only writes are:

- the human inputs (downtime reasons, planned stops, count adjustments), each stored as a record of the audit trail;
- its configuration (machines, reason codes, plans, ideal cycles, settings), which is project content;
- its own results, in `data/production/production.duckdb`;
- historian logging rules, and only when an engineer applies them for a machine's source tags;
- the server's own condition tag `System/Production/CapturePaused`, which drives the system alarm `ALM-SYS-PRODUCTION`. It is a tag of the server, never of a machine.

Entering a reason in the downtime panel is not a command to the machine, and the screen action **Open downtime panel** only opens the panel.

## One source of truth for each kind of data

- **Tag samples**: the historian. Machine states and counts are computed from what the historian logged, with the quality each sample had.
- **Human inputs**: the audit trail. A reason entry *is* an audit record: the request is answered only after the record is written; if the trail cannot write, the answer is `503 AUDIT_NOT_WRITTEN` and nothing changes.
- **Configuration**: the project. It is replicated to the HA standby and kept in project checkpoints.

Everything else (states, events, OEE sums) is derived and can be rebuilt from these three by a [recompute](#recompute).

## States

Each instant of a machine has exactly one **state class**:

| Class | Meaning |
|---|---|
| `run` | The machine produces. |
| `stop` | It does not produce, and nothing says the stop is planned. It becomes unplanned downtime or a micro-stop, unless a planned reason is given later. |
| `planned_stop` | The state itself says the stop is planned (for example a changeover declared by the controller, or a PackML unit mode other than Production). |
| `unknown` | No usable data: the sample is Bad, the tag has logged nothing for longer than the machine's gap limit, or the server was not recording. |

A state also has a **label** (Producing, Starved, Fault...) and an **external** flag for stops caused upstream or downstream (starved, blocked). External stops are kept for the Pareto; they are not a different time category.

The state is read in one of four ways, all declarative (no script runs per sample):

- **State code tag** (`map`): one integer tag, its codes mapped to classes and labels. A code that is not in the map is a stop by default, or a planned stop or unknown if you say so. **It is never run.**
- **PackML state** (`packml`): the PackML state tag with the standard map: Execute is run, every other state is a stop (Suspended, Suspending and Unsuspending marked external). With a unit mode tag, a mode other than the production modes (default mode 1) is a planned stop, and a Bad mode is unknown.
- **Conditions on tags** (`conditions`): 2 to 32 rules over at most 8 tags, the first rule that holds decides, the last rule is "Otherwise" (and is never run). A rule whose input is Bad or missing decides nothing, and later rules are not tried: the state is unknown.
- **From the counter** (`counter_activity`): for a machine with only a count. It is running while the total counter moved within `k` times the ideal cycle (default 5), else stopped. Every result marks such a state as inferred (`state_source` = `inferred`; a state read from tags is `tag`).

**A Bad sample is never "run".** A Bad state sample makes the state unknown from that sample until the next Good or Uncertain one, even if the last good value was "run". An Uncertain sample is used, and the time is marked uncertain.

**A value holds for at most the gap limit** (`gap_limit_s`, default 120 s). After that without a new point the input is missing and the state is unknown. Nothing is interpolated across a server outage: the first points after a restart open a new interval.

## Time categories

Every second of a machine's timeline falls into exactly one category, decided in this order:

1. **Run**: the state is run. Also outside the plan and inside a break: the machine produced, so breaks never hide production. Running outside the plan is also counted as `run_unscheduled_s` (part of the run time).
2. **Not scheduled**: outside the plan, and not running.
3. **Planned stop**: inside a break or a planned-stop record, or the state is `planned_stop`, or the state is a stop and the reason in force for that stop is a planned reason. Missing data inside a break or a planned-stop record is still planned stop time. A planned reason does not cover unknown time.
4. **Unknown**: the state is unknown.
5. **Micro-stop**: the time of a stop that is shorter than the machine's micro-stop threshold.
6. **Unplanned stop**: any other stop time, with or without a reason yet.

The six categories always add up to the length of the period.

### Planned and unplanned downtime

A stop is **planned** when it falls in a break of the production plan, in a planned stop a supervisor recorded, when the machine's state says so (`planned_stop`), or when the reason it was given is a reason code marked **Planned**. Everything else is **unplanned**, including a stop that has no reason yet. Planned stop time is not part of planned production time, so it does not lower availability.

A machine without a plan is scheduled around the clock (every shift of its calendar). A plan lists the shifts scheduled on each weekday (all seven days must be given; an empty day is not scheduled), breaks for every scheduled day, and date exceptions. A shift belongs to the date on which it starts, on the site's clock.

### Downtime events and micro-stops

A **downtime event** runs from the first scheduled instant the machine leaves run to the instant it returns to run. Its duration counts only the stop time inside scheduled time, outside breaks and planned-stop records; unknown time never counts. An event that crosses a shift boundary stays one event, split into shift pieces for the accounting; one reason covers all of it.

An event shorter than the micro-stop threshold (`micro_stop_s`, default 120 s, at most 3,600 s) is a **micro-stop**: no reason is asked, it is not listed in the downtime panel, and its time is counted as micro-stop time and its number in `micro_stop_count`. The threshold applies to the whole event, so an event is micro or not, never half. An event that runs over a configuration change, or whose reason is planned, is never a micro-stop. While a short stop is still going, it is shown as unplanned until it ends.

Each event has an id built from the machine and its start (`dt_<machine>_<start>`), so the same event has the same id on both HA servers and after a recompute that does not move its start.

### Reasons and suggestions

When a stop starts, the server suggests a reason: the fault code tag's value at the start of the stop, mapped through the machine's fault code map, else the first alarm of the machine's alarm scope that became active between 5 s before and 2 s after the start, else the first mapped fault code logged in the 2 s after the start while the stop lasts (for a PLC that writes its fault code a moment after the state). A suggestion is only a suggestion: the operator taps it. Only when **Use the machine's suggestion as the reason without an operator's confirmation** is set for the machine does it become the reason in force (`reason_source` `auto`), and only for a fault code or alarm found at the start: a code from the 2 s after the start always stays a suggestion, because the stop's time categories are fixed at its start. Default: off.

The reason in force on an event comes from an operator entry (`operator`), a planned-stop record (`plan`), the planned state of the machine (`state`, only for events with no unplanned stop time), the suggestion when accepted automatically (`auto`), or nothing (`none`).

### When a shift closes for reasons

A shift is **closed for reasons** at its end plus the grace set under **Settings** (`reason_grace_h`, default 8 hours, at most 168). Before that, entering or changing a reason needs `production_reason`. After it, a change, and also the first entry of a missing reason, needs `production_reason_closed` **and the signed-in user's e-signature** with the meaning "Changed after shift close": by then the shift's numbers may be in signed reports. A shift whose calendar cannot be read counts as closed (the stricter rule).

## The formulas

The server stores **seconds and counts**, never ratios. Every ratio is computed from the sums over the requested period and machines, so a shift, a day, a week or a year all divide the same way and a ratio is never averaged.

```
planned production time   planned_s   = run_s + micro_stop_s + unplanned_stop_s
run time                  operating_s = run_s + micro_stop_s
ideal time                ideal_s     = sum over the slices of (counted units x ideal cycle of the slice's product)

Availability   A = operating_s / planned_s
Performance    P = ideal_s / (operating_s - run time without an ideal cycle)
Quality        Q = good / (total - units not classified)
OEE              = A x P x Q
Coverage         = planned_s / (planned_s + unknown_s)
```

In plain words:

- **Availability** is the share of planned production time the machine was running. Unplanned stops lower it; planned stops, time outside the plan and time without data do not.
- **Performance** is how much the machine made, in ideal time, compared with the time it was running. **Micro-stops are inside the run time**, so they lower performance, not availability. Run time for which no ideal cycle is known is left out, and the row warns `ideal_cycle_missing`.
- **Quality** is the share of good units among the units classified good or reject. Units whose class is not known (for example when the reject counter was Bad) are left out and counted as `unclassified`.
- **OEE** is the product of the three.
- **Coverage** is the share of the time that would be planned production time for which there was data. Time without data (`unknown`) is never counted as running or as a stop: it lowers coverage instead.

**A ratio that cannot be computed is "No data", never 0 % and never 100 %.** No planned time: availability is unknown. No run time: performance is unknown. No classified unit: quality is unknown. OEE is unknown when any factor is. The API answers `null` for an unknown ratio and the datasets answer SQL `NULL`.

**Performance is not capped.** Above 100 % the row warns `ideal_cycle_too_slow`, because a capped value would hide a wrong ideal cycle. Units counted with no run time give the warning `counts_without_run`.

With one product, OEE equals good units x ideal cycle / planned production time. With products of different ideal cycles that identity is only approximate; the datasets also return `fully_productive_s` (good units x ideal cycle) for sites that prefer that definition. For a group of machines the same sums are taken over all of them (an area roll-up); the **line OEE** of a group is the OEE of its constraint machine, chosen under **Settings**.

### Ideal cycle

A machine has a default ideal cycle (seconds per unit). With a **product tag**, the per-product rows of **Ideal cycles** apply instead, each from its start time, and the default is never used: a product without a row, or a Bad product value, has an unknown performance for that time, never 100 %.

### The quality of a result

Every OEE row carries its quality:

- **good**: coverage 100 %, and every state and count sample behind it Good;
- **uncertain**: any Uncertain time or count, or coverage below 100 % but at least the coverage threshold (`coverage_min`, default 95 %);
- **bad**, shown as **Incomplete data**: coverage below the threshold, any factor unknown, no slice at all, or any Bad state or count.

A report or a tile shows a value with non-good inputs with its badge, and a value that cannot be computed as "No data".

## Counts

A machine has exactly two of the three counts total, good and reject; the third is worked out. Each count comes from:

| Source | How units are counted |
|---|---|
| Counter tag | The difference between two Good readings of a cumulative counter. A decrease is a rollover when **Rolls over after** is set and the old value was above 90 % of it (delta = rollover - old + new + 1); otherwise it is a reset (delta = the new value), marked uncertain. The first reading counts nothing (nothing to count against). |
| Increment tag | Each logged sample is a number of new parts. A Bad sample's parts are lost (`count_lost`). |
| Genealogy station | One unit per operation of the station in [part and lot genealogy](/docs/eaxscada/explanation/genealogy/); results in the reject set are rejects. |
| Manual adjustments only | Only supervisors' adjustments. The total is never manual. |

**A Bad counter reading is not a reading.** The next Good reading's difference is taken against the last Good one, attributed at the recovery, and marked uncertain. A jump larger than twice the plausible rate times the elapsed time (the rate is the machine's **Highest plausible rate**, or 1 / ideal cycle) is not counted and is listed as an implausible count; the slice's count quality is then Bad. If the reject (or good) count is Bad or missing while the total is Good, good is **unknown** for that time, not equal to the total. A non-integer counter value is not a reading. Every such case is noted in the dataset relation `count_notes`.

A **count adjustment** by a supervisor moves units from good to reject in the slice holding its time. It is refused if it would make that slice's good count negative.

## Final and provisional rows

The service receives every point the historian logs for a source tag, takes them in every 100 ms, and keeps one calculation per machine. Rows are **final** up to the machine's settled time: now minus `production.settle` (default 2 s), held back to a tag's last point when a tag with a heartbeat is overdue (by at most the gap limit). After that, the current state and the ongoing stop are **provisional**: the API returns them with `provisional: true` when asked with `live`, and the panel says "Provisional" while the shift runs. Final rows are written to `production.duckdb` every `production.write_interval` (default 10 s).

The source tags must be logged by the historian the way OEE needs: every change (on change, deadband 0, no minimum interval; a counter may have a minimum interval of at most 1 s), with a heartbeat of half the gap limit for state, mode, condition, fault code and product tags (60 s by default) and 60 s for counters, and no heartbeat for increment tags (a repeated increment would count twice). The Studio marks a machine whose tags are not logged that way and applies the rules for you ([step 6 of the set-up](/docs/eaxscada/how-to/set-up-oee-and-downtime/#6-apply-the-historian-logging)). Without it, a quiet tag is held only for the gap limit and then reads as missing, and changes inside a deadband are never seen.

**Late data.** A point older than what was already computed (store-and-forward from an edge, a history import, a point the historian reported it lost) marks the machine dirty from that time, and the service recomputes that range from the historian; the rows of the range are replaced in one transaction. When the hook's buffer is full (`production.hook_queue`, default 65,536 points), the machines of the points not kept are recomputed the same way: the historian's logging never waits for OEE.

## Backfill

A machine that has no stored rows yet is computed from history going back `production.backfill_days` (default 30, 0 to 400). Time before its source tags were logged the right way reads as unknown.

## Recompute

A configuration change applies from its **Applies from** time (`effective_from`, default: when you save); earlier results keep the configuration they were computed with. To apply a change, a corrected history or a calculation fix to the past, a person with `production_recompute` **recomputes** machines from a time: a preview first, which writes nothing and lists the slices that would change with their old and new sums and the reasons that would move or detach; then the request, recorded first in the audit trail (`RECOMPUTE_REQUESTED`) with its reason; when it is written the server records `RECOMPUTE_COMPLETED` with the rows and the sums before and after per shift (`RECOMPUTE_FAILED` if it fails first). A request is refused without its preview. Each machine is recomputed from its stored state at or before that time up to now. Archived reports keep their bytes.

After a recompute that moves events, a recorded reason attaches to the event that contains its start, or to the one that overlaps it most (`REASON_REATTACHED`); if no event does, it is **detached** (`REASON_DETACHED`) and listed under **Reasons to review**. Records are never edited or deleted.

## High availability

- **Only the primary with quorum computes.** The standby never computes: the two servers' historians do not hold exactly the same samples (each polls the devices with its own clock), so each would get slightly different numbers.
- **The primary's results are replicated.** Every committed write of the primary's store (final rows, checkpoints, watermarks, retention) goes to the standby over the HA stream, and the standby applies each one whole, in one transaction, or not at all. A standby that falls too far behind is resynchronised from the primary's snapshot. On the standby the API and the datasets therefore return the primary's numbers.
- **Writes go to the primary.** Reasons, planned stops, count adjustments, configuration changes, the logging apply and recompute requests are refused on a standby (`409 ha_standby`) and on a primary without quorum (`503 ha_no_quorum`). Reasons and the other human inputs reach the standby as audit records.
- **Failover.** A server that becomes primary first applies what the stream still holds, then resumes each machine from the last replicated point using its **own** historian. The first slice after the takeover carries the warning `ha_failover`. The rows before that point stay the old primary's: recomputing them reads the new primary's historian, so it needs an explicit confirmation and records which server's rows were replaced (`source_node`, `rows_from_node`). It never happens on its own.
- **Historian logging rules are per server.** An apply changes the rules of the server it runs on; the other HA server applies the same rules from the replicated record.

Replication counters and lag are on `/metrics` ([reference](/docs/eaxscada/reference/oee-and-downtime/#metrics)).

## Retention

`production.retention.intervals` (default 400 days, at least 1 day) is how long the **state intervals** (the state timeline) are kept. Once a day the older intervals and count notes are deleted. **Downtime events and the OEE slices are kept**, so OEE and downtime of any past period stay available. Reasons, planned stops and count adjustments are audit records and follow the audit trail.

The derived results are not part of the server backup: they are rebuilt from the historian by a recompute, as far back as the historian holds data. The configuration is in project checkpoints and in the server backup; the human inputs are in the audit trail, which the backup includes.

## When the licence changes

The server decides at start: the module runs when `production.enabled` is `true`, the licence includes OEE and downtime, the `production:` configuration is valid and the historian has its columnar store. A licence installed while the server runs takes effect at the next restart.

After a downgrade or an expiry while it runs, **capture pauses**: nothing is computed and every write is refused (`403 EDITION`), but everything recorded stays readable. The system alarm **ALM-SYS-PRODUCTION** ("OEE and downtime capture paused") is raised and `CAPTURE_PAUSED` recorded. With the licence back, capture resumes, the gap is recomputed from the historian, the alarm clears and `CAPTURE_RESUMED` is recorded. Reasons for stops in the gap are missing and shown as such.

## Who sees which machine

A machine is shown to a person only when they hold `production_view` **and** their tag read rights allow **every** source tag of the machine (state, mode, condition inputs, fault code, product, counters). A machine whose numbers come from a tag you may not read is hidden completely, in the API, the panel, the datasets and archived reports, never partly shown. A machine you may not read answers exactly like one that does not exist. Writing for a machine (a reason, a planned stop, a count adjustment, its configuration) needs the same read access. The rights are listed in the [reference](/docs/eaxscada/reference/oee-and-downtime/#rights).
