Persistent last-value store
This page is for support and IT staff. The settings of the store are in a settings file of the installation, which you change in a text editor started as administrator.
The live data server writes the last value of every signal to disk. When the server starts again, for example after a power failure, the screens open with these values before the drivers have sent anything new. Operators see the last known state of the plant instead of empty screens, marked as not connected.
What the screens show after a restart
When a project starts, its stored values are loaded before the drivers publish. Each loaded value is marked as restored and not current:
| Field | Value |
|---|---|
| Quality | Bad · Not connected: the screen shows the last value in the not-connected style |
| Reason | Stale (last usable) |
| Quality bits | NT (not topical) and an internal bit that marks the value as restored from disk |
| Times | The original device time and arrival time, not the time of the restart |
The first real value from the field replaces the stored value and removes the marking. A value that has already come from the field is never overwritten by a stored one. The alarm service and scripts can tell a restored value from a live one, and because its quality is not good it is not treated as a live value. The usual command rules apply: a command to a signal whose device does not communicate is refused. See Quality.
What is stored
For each signal and each of its values (for example its value, state and limits):
- the value, the quality, the quality reason and the quality bits;
- the device time, the arrival time and the time source;
- the driver and the source of the value (automatic, field manual or SCADA manual).
The state of a command in progress is not stored. The store does not depend on history: signals that are not assigned to an archive table are stored too, and the history database is not used.
How it is written
YTCC marks the signals that change. Every 10 seconds by default, it rewrites the files that contain changed signals; a file holds 1,024 consecutive signals. Files without changes are not touched. Each file is written to a temporary file first and then replaces the old one, so a power failure never leaves a half-written file; at worst the previous version of that file is read. Each file carries a checksum. A damaged file is skipped with a warning in the log, and the other files are loaded.
If the server stops suddenly, the changes of at most the last write interval are lost.
Where the files are
The files are in <data folder>\lastvalue\<project>\, one folder per project. The data folder is the one given by the
environment variable SCADA_DATA_DIR, otherwise C:\YTCC\apps\projects-server\data. When a project is deleted, its
folder is deleted with it.
Settings
The settings are in config\gateway.toml and are read when the live data server starts:
| Setting | Default | Meaning |
|---|---|---|
last_value_flush_s | 10 | Write interval in seconds. A longer interval writes less often to the disk; a shorter one loses fewer changes on a sudden stop. 0 turns the store off: nothing is written and nothing is loaded at start. |
last_value_dir | not set | Another folder for the store, for example on a second disk. A folder given here is not cleaned up when a project is deleted. |
With the store turned off, the live data server logs a warning at start, and after a restart the screens show no values until the drivers send new ones.
Good to know
- The value of a signal that was removed from the configuration stays in its file. It is not shown, because screens only show their own signals.