DFA Advanced Operations Module

The module runs configurable "operations" on a schedule (interval) or on tag change (subscribe). Each operation reads input tag(s), computes a value, and writes it to an output tag. There are seven operation types. Common options (all types):

Subscribe to Tag — off = run on the interval; on = recompute when an input changes.
Interval (minutes) — how often to run in interval mode.
Enabled — turn the operation on/off.

On bad quality (writeSentinelOnBad) — ON writes -1 to the output when an input is bad/unreadable; OFF keeps the last good value. Either way the error is reported to the status tag (see “Monitoring”).

Project End of Day Volume

Projects the total gas volume expected by the end of the contract day, assuming the current flow rate continues until the contract hour.

Formula

Current Day Volume + [(% of day remaining until contract hour) × Current Flow Rate]

Example

Contract hour = midnight
Current Day Volume = 946 mcf (at 9:36 PM)
Flow Rate = 1,200 mcf/day

There are 2.4 hours left in the day → 2.4 / 24 = 10%.

So: 946 + (0.10 × 1,200) = 946 + 120 = 1,066 mcf projected.

Inputs

Current Day Volume — tag holding today’s accumulated volume (resets at the contract hour).
Flow Rate — tag holding the current flow rate (mcf/day).
Contract Hour — hour (0–23) when daily volumes roll over.
Output Tag — where the projected end-of-day value is written.

Projected EOD (Rate)

Projects the end-of-day volume based on the current accumulation rate. Instead of using a flow tag, it derives the rate from how much volume has accumulated since the contract hour.

Formula

(MCF Today ÷ Hours Since Contract Hour) × 24

Hours Since Contract Hour is calculated from the MCF Today tag's value timestamp, so the projection reflects when the value was last updated, not when the calculation runs.

Fields

  • MCF Today — tag containing the volume accumulated so far today.
  • Contract Hour — the hour (0–23) when the gas day resets.
  • Output Tag — where the projected value is written.
 
Note: at or very near the contract hour (elapsed time ~0), the calculation cannot produce a meaningful rate and the bad-quality behavior applies.

Net Diff (Proj vs 7-Day Avg)

Calculates the difference between today's projected volume and the 7-day average, showing whether the meter is running above or below its recent trend.

Formula

Projected MCF Today − 7-Day Avg MCF Yesterday

Fields

  • Projected MCF Today — tag with today’s projected volume.
  • 7-Day Avg MCF Yesterday — tag with the 7-day average (provided by an external history script, not computed by this module).
  • Output Tag — where the difference is written. Positive = above average; negative = below.

Multi-Tag Average

Averages the current values of two or more tags into a single output.

Formula

(Tag1 + Tag2 + … + TagN) ÷ N

Fields

  • Tags to Average (1–6) — up to six tag paths. Blank fields are ignored; at least two tags are recommended.
  • Output Tag — where the average is written.
 
If any input tag has bad quality, the operation does not compute a partial average — the bad-quality behavior applies to the whole operation.

Table to Dataset

Replicates a database table into a Dataset tag whenever the table changes.

Formula

(Tag1 + Tag2 + … + TagN) ÷ N

Fields

  • Datasource (gateway DB connection)
  • Table Name
  • Output Tag (Dataset type)
  • Limit Type (ROWS or CELLS)
  • Limit Value
  • Debounce (seconds)

Behavior

Copies the table to the Dataset tag when a change is detected (debounced).

Limit Type ROWS — limit is a maximum row count. CELLS — limit is rows × columns. If the table exceeds the limit, the copy is skipped and the last value is kept (an error is reported to the status tag). It never truncates.

An absolute internal ceiling (100,000 rows) always applies, regardless of the configured limit, to protect gateway memory.

Note on table name: the operations-storage table (module settings) and any table used here may not be named after Ignition system/historian tables (names starting with sqlth, sqlt_, sqla, or sqltags are rejected) — this protects the tag historian.

Rolling Average — Accumulator Rate

Average daily rate derived from a non-resetting accumulated-volume (odometer) tag, over a rolling window. Use this for a totalizer/accumulator that only ever counts up.

Formula

(latest value − earliest value) ÷ elapsed days across the window, pro-rated by the actual timestamps of the data.

Fields

  • Volume tag (the accumulated/odometer tag, history enabled)
  • Window (days)
  • Output Tag

Behavior

Reads the input tag's history over the window (read-only).

Skips the calculation if the meter appears to have reset (latest < earliest).

Requires history enabled on the input tag with retention covering the window; if history is short, it pro-rates over the time actually available.

Reports "no usable history" to the status tag if the window has no data.

Rolling Value Average — Time-Weighted

True time-weighted average of an instantaneous value tag (temperature, pressure, flow rate) over a rolling window.

Use this when you want the average reading, weighted by how long each value held — not a rate.

Formula

time-weighted average of all history values in the window (computed by the tag historian's Average aggregation).

Fields

  • Value tag (the instantaneous tag, history enabled)
  • Window (days)
  • Output Tag.

Behavior

Asks the historian for the time-weighted average over the window and writes that single value — the module never pulls the raw history into memory.

Read-only: it queries history and never writes, deletes, or modifies it.

Requires history enabled on the input tag.

Reports "no history data in window" to the status tag if the window has no data.

Monitoring (status tag)

The module maintains one string tag, [default]DFAOps/operationStatus:

Empty (“”) = all operations healthy.

Non-empty = a |-joined list of currently-failing operations and why (e.g. avgTest: 1 of 1 input tag(s) bad quality | ordersReplica: table exceeds limit).

Put a single alarm on this tag with condition “value is non-empty” — it covers every operation at once, and the string identifies which operation(s) and the reason. The module writes this tag; it must exist (create it as a String memory tag).

Reliability notes

All database and history access is read-only except the module's own operations-config table and the operation output tags. The module has no code that writes or deletes tag history and refuses to operate on historian tables. All database queries have a 30-second timeout; a slow or hung database cannot stall the engine. Failed operations keep their last value, report to the status tag, and recover automatically when the source is available again. Operations are isolated: one failing operation cannot affect the others.