In combination with the attribute symbol, the pragma {attribute namespace} allows you to redefine the namespace of project variables. You can apply it on complete POUs, like GVLs or programs, but not on particular variables. The concerned variables will be exported with the new namespace definition to a symbol file and after a download of this file be available on the controller.
This also allows you to access variables from POUs or visualizations which originally have got different namespaces. For example, it allows you to run a previous EcoStruxure Machine Expert visualization also in a later EcoStruxure Machine Expert environment.
For further information, refer to the description of the symbol configuration. A new symbol file will be created at a download or online change of the project. It is downloaded to the controller together with the application.
{attribute 'namespace' := '<namespace>'}
Example of a Namespace Replacement for the Variables of a Program
{attribute 'namespace':='prog'}
PROGRAM PLC_PRG
VAR
{attribute 'symbol' := 'readwrite'}
iVar:INT;
bVar:BOOL;
END_VAR
If iVar, for example, was accessed by App1.PLC_PRG.ivar before, now it is accessible via prog.ivar.
Original Namespace |
Variable |
Namespace Replacement |
Access on the Variable Within the Current Project |
---|---|---|---|
App1.Lib2.GVL2 |
Var07 |
{attribute 'namespace':=''} |
.Var07 |
App1.GVL2 |
Var02 |
{attribute 'namespace':='Ext''} |
Ext.Var02 |
App1.GVL2.FB1 |
Var02 |
{attribute 'namespace':='App1.GVL2''} |
App1.GVL2.Var02 |
The replacements shown in the table result in the following entries in the symbol file:
<NodeList>
<Node name="">
<Node name="Var07" type="T_INT" access="ReadWrite">
</Node>
</NodeList>
<NodeList>
<Node name="Ext">
<Node name="Var02 " type="T_INT" access="ReadWrite"></Node>
</Node>
</NodeList>
<NodeList>
<Node name="App1">
<Node name="GVL2">
<Node name="Var02 " type="T_INT" access="ReadWrite"></Node>
</Node>
</Node>
</NodeList>