Online Change
From TwinCAT 3.1 Build 4024.0 The functionality described here is available from TwinCAT 3.1. 4024.0. |
TwinCAT 3.1 supports the exchange of C++ modules at runtime, i.e. without interrupting the real-time program.
For this purpose, different versions of a TwinCAT Executable (TMX) are stored on the target system, as already described here.
For all module instances from a TMX, a switchover between the versions can be initiated by the engineering.
The procedure is roughly sketched:
- Online Change capable module in TMX
- 1. TwinCAT instantiates the new module. The old module is still called cyclically by the task.
- 2. TwinCAT calls ITcOnlineChange::PrepareOnlineChange() of the new module.
This call can access the old module and accept data that does not change due to the cyclic calls of the module - for example parameter values. - 3. TwinCAT calls ITcOnlineChange::PerformOnlineChange() of the new module.
This call can access the old module and take over data which have changed cyclically before. This call is executed if no cyclic call is made by a task. The old module is not called again by the task, but the new module is called. The PerformOnlineChange() method should use as little computing time as possible so that this switchover can take place from one task cycle to the other. - 4. After completion, the task will call the new module cyclically.
The Online Change can be carried out through this dialog in engineering.
When dealing with the Online Change, there are therefore some aspects to consider:
- The project must provide a revision control.
- The DataAreas for these modules are kept outside the TcCOM module and made available to the modules. This means that they do not need to consider the data or the mapping of the symbols in the DataAreas.
- The DataAreas of the module must not change.
- References to internal data structures must not be passed on. Access must always take place via interfaces that are retrieved via the TcQueryInterface, since these references are updated during an Online Change.
After a restart, TwinCAT will start the driver in the initial version of the modules.