Skip to content

Online changes to data structures

eaxPLCExplanationFreeProView as Markdown

You add a member to a structure while the PLC runs a recipe array of fifty of them. Most controller suites refuse that change online, or reset every instance to its initial values. eaxPLC copies the members you kept from the old storage to the new one at the switch, so every recipe keeps its values and the new member starts at its initial value.

This page explains how that works during an online edit (Make online edits) and a deploy, and where it stops.

A variable whose type changed always gets new storage, as before. The old storage is never written by the new program: storage is never reused while both programs are resident. That is what makes an untest safe.

Data flowA changed type: new storage, then a copy in the first cycle
A changed type: new storage, then a copy in the first cycleA test or a deploy switches to a program in which a type changed. While the PLC runs, the switch is refused when it would copy more bytes than the cap. Otherwise the changed variable gets new storage with its initial values, and in the first cycle of the new program, before any task, each member is copied from the old storage, initialised or dropped. The old storage is not written.Test or deploya type changedCopy within the cap?1 MB unless set higherRefusedmigration_too_large:nothing was changedOld storageof the running program,read and never writtenNew storagegets its initial valuesFirst cyclebefore any task: memberby memberCopiedsame shape: byte for byte;widened: converted;enumeration: by value nameInitialisednew member, narrowed orchanged kind, UNIONDroppedmember removed: valuelost, and reportedno, PLCrunningyes, or PLC pausedthenvalues of thekept members
The old storage is only read. That is why an untest brings back the values from when the test started.
  • Service or process
  • Data store
  • Check or decision
  • Data or telemetry
  • Refusal
Read as text

A test or a deploy switches to a program in which a type changed. While the PLC runs, the switch is refused when it would copy more bytes than the cap. Otherwise the changed variable gets new storage with its initial values, and in the first cycle of the new program, before any task, each member is copied from the old storage, initialised or dropped. The old storage is not written.

Parts

  • Test or deploy (service or process): a type changed
  • Copy within the cap? (check or decision): 1 MB unless set higher
  • Refused (outcome): migration_too_large: nothing was changed
  • Old storage (data store): of the running program, read and never written
  • New storage (data store): gets its initial values
  • First cycle (service or process): before any task: member by member
  • Copied (outcome): same shape: byte for byte; widened: converted; enumeration: by value name
  • Initialised (outcome): new member, narrowed or changed kind, UNION
  • Dropped (outcome): member removed: value lost, and reported

Connections

  • Start → Test or deploy (next step)
  • Test or deploy → Copy within the cap? (next step)
  • Copy within the cap? → Refused (refusal): no, PLC running. Asked only while the PLC runs: with the PLC paused no cycle runs, so the switch goes through whatever its size.
  • Copy within the cap? → New storage (next step): yes, or PLC paused
  • New storage → First cycle (next step): then
  • Old storage → First cycle (data or telemetry): values of the kept members
  • First cycle → Copied (next step)
  • First cycle → Initialised (next step)
  • First cycle → Dropped (next step)

What is new is the copy. When the old and the new type still share members, the new program copies them from the old storage in its first cycle, after its new storage got its initial values and before any task runs. Every member is handled one of three ways, and the impact report’s Storage tab lists each one under Members of migrated variables:

Member What happens Examples
Same path, same shape copied byte for byte Temp_SP : REAL kept in ST_Recipe
Same path, widened without loss copied, converted INT to DINT, REAL to LREAL, STRING[10] to STRING[20]
Same path, enumeration copied, mapped by value name: an old value whose name still exists gets the new number of that name; a name that is gone gets the initial value E_State renumbered
New member initialised to its initial value Hold_s : DINT := 30 added
Same path, narrowed or changed kind initialised DINT to INT, REAL to DINT
A UNION initialised (a union is never migrated)
Member removed dropped, and reported: Recipes: migrated to its new type; dropped (their values are lost): …

It works for every instance of the type: globals, program variables, members of function blocks, arrays of instances and nested structures. Array elements are matched by index: when bounds change, the elements both bounds hold are copied and the others initialised. A plain variable whose type widens (INT to DINT) is converted the same way. A live value is never reinterpreted as another type: a copy is either byte for byte between storage of one shape, or a load of the old type and a store of the new one.

The impact report’s Storage tab shows these variables with the kind Migrated and the bytes the switch will copy.

The same migration runs on a plain Build & Deploy, so a deploy no longer resets a structure array whose type grew.

TimelineWhich storage runs: test, untest, test again, accept
Which storage runs: test, untest, test again, acceptA variable whose type changed has one storage in the accepted program and a new one in each test. The program runs on one of them at a time. A test copies the kept members into its new storage and leaves the old one as it was; an untest goes back to the old one; an accept keeps the new one and releases the old one. Cancel edits during a test ends like an untest: the accepted program keeps its storage and values.ACCEPTEDFIRST TESTACCEPTEDSECOND TESTACCEPTEDTestUntestTest againAcceptACCEPTED PROGRAMOld storagethe type before the changereleasedTEST PROGRAMSNew storage, first testkept members copied indroppedNew storage, second testbecomes the accepted one
The accepted program's storage is never written by a test, so an untest finds the values from when the test started.
  • Data or telemetry
  • The program runs on it
  • Kept, not written
  • Released or dropped
Read as text

A variable whose type changed has one storage in the accepted program and a new one in each test. The program runs on one of them at a time. A test copies the kept members into its new storage and leaves the old one as it was; an untest goes back to the old one; an accept keeps the new one and releases the old one. Cancel edits during a test ends like an untest: the accepted program keeps its storage and values.

Time runs left to right: accepted, then first test, then accepted, then second test, then accepted. Each switch happens at a cycle boundary; the times between them are not to scale.

Accepted program

  • Old storage: the type before the change (released). While a test runs the old storage is kept and not written. At the untest the program runs on it again, with the values it had when the test started. At the accept the previous accepted program is dropped and its storage is no longer kept.

Test programs

  • New storage, first test: kept members copied in (dropped). What the test wrote to it is not carried back at the untest, and this storage is not handed out again.
  • New storage, second test: becomes the accepted one. The accept does not compile and does not switch: the program under test goes on running on this storage and is the accepted program from then on.

Connections

  • Old storage → New storage, first test (data or telemetry). In the first test cycle, before any task: the kept members are copied from the accepted program's storage, the new members get their initial values.
  • Old storage → New storage, second test (data or telemetry). The copy comes from the storage of the program running at that moment: here the accepted program, after the untest. A test started while another test runs copies from that test's storage.
Step What the migrated variable holds
Test The test program’s new storage: kept members copied from the running (accepted) program in the first test cycle, new members initialised.
Untest The accepted program runs again on its own storage, which the test never wrote. The variable comes back with the values it had when the test started: anything the test wrote to the new storage is not carried back.
Test again (after more edits) The copy comes from the storage of the program running at that moment: the accepted program after an untest, or the current test program when you re-test while testing.
Accept The test program becomes the accepted one; the old storage is released.
Cancel edits The accepted program keeps its storage and values.

The cap, and why the PLC refuses while running

Section titled “The cap, and why the PLC refuses while running”

The copy runs inside one cycle. A large copy stretches that cycle, and the fastest task with it. So the bytes copied by one switch are capped: 1 MB by default, set per project up to 16 MB with Values copied per switch, at most in the Program settings card (migrate_cap_bytes; see Set the project compile settings). As an order of magnitude, a 1 MB copy takes roughly 0.1 ms.

Above the cap:

  • Test edits is blocked: the impact report shows the blocking item migration_too_large with the bytes and the cap (the switch would copy N bytes of migrated members, above the cap of M bytes (project setting migrate_cap_bytes): deploy with the PLC stopped, or split the change). Even if the dialog were bypassed, the PLC refuses the test (409 migration_too_large) and nothing changes.
  • Build & Deploy on a running PLC is refused (409 migration_too_large, audited as a refused deploy) with the same message and nothing was changed: the running program, its storage and its version stay as they were.
  • With the PLC paused (Pause), the deploy goes through: no cycle runs, so no task waits for the copy.

To stay under the cap while running, split the change (for example, change one array at a time), or raise the cap if your fastest task can absorb the copy.

A rename is a new name, and a new name gets new storage with its initial value. To carry the value across, name the old variable on the new declaration:

VAR_GLOBAL
{attribute 'was' := 'Line2.Speed'}
Speed : REAL;
END_VAR

The new variable migrates from the storage the old name has in the running program, member by member as above. The old name is a storage key in any scope: Line2.Speed (a variable of program Line2), Speed or PLC_PRG.Speed (the main program’s), GVL_Line.Speed (a global, by its list).

was goes on a global or a program variable. On a member of a structure or function block it is a compile error (… attribute ‘was’ is not applied on … (a member) …): a member is matched by its name inside the migrated variable.

The attribute only acts while it has something to do. Otherwise it is an information message, never an error:

Situation Message
The old name is not in the running program (for example after the accept that migrated it) info: Speed: attribute ‘was’ := ‘Line2.Speed’: no variable Line2.Speed in the running program: nothing to migrate (the attribute can be removed)
The old name is still declared info: …: Line2.Speed is still declared: ignored
The new variable is located (AT %MW...) info: …: a located variable keeps its address: ignored

Remove the attribute once the change is accepted. Promote to global in the tag database writes it for you when it moves variables of a program other than main (main-program variables keep their storage and need none).

  • The old storage is covered by a located variable or a direct address of the new program. Its initial value would be written there before the copy, so the copy would read the wrong bytes. The variable is initialised, with the warning X: not migrated, initialised: its old storage (bytes a..b) is covered by a located variable or direct address of the new program (bytes c..d), so its values cannot be copied. Choose another address, or accept the reset.
  • The old variable was located (AT %M..., %Q...): only automatically placed storage is migrated.
  • A located variable or direct address moved onto automatic storage. The variable it displaces moves to a new offset and is reset: X moved to a new offset: a located variable or direct address now uses its memory; its value is reset.
  • A cold reset reinitialises everything, as before. There is no persistent RETAIN yet: see Data model.

An alias whose target changed is Repointed: no storage moves, and the impact report’s Writers tab shows the target’s old and new writers. A force made through an alias is held on the target’s storage. An AI-made text that re-points an alias of a safety target is refused (ai_repoints_safety_alias), and one that widens the access of a safety target is refused (ai_widens_access): otherwise an edit could move a protected name onto harmless storage.