To simplify the usage of connections you can define an alias for a PLC with the plc-control tool and use the PLC Alias name in all SIMATIC AX online tools supporting Connection Sharing.
The PLC alias name simplifies each call of the connect command and of all other SIMATIC AX tools because you do not need to enter the target IP address and all other options again and again.
-
Define an alias name for an IP address and certificate (optionally).
apax add --dev @ax/plc-control apax plc-control add myPlc 192.168.0.1 -u myUserName -C ./cert.cer -d "the PLC of machine A"Caution
The PLC alias name (e.g. 'myPlc') must start with a letter and can contain letters, digits and the '_' character to apply the rules of Apax variables. It is case insensitive on command line level, BUT not inside Apax scripts.
The PLC alias data is stored in the
apax.ymlinside thevariablessection:variables: - myPlc_IPADDRESS: 192.168.0.1 - myPlc_USERNAME: myUserName - myPlc_CERT: aSDcdafvsASDFJAUF7afcijajkajckjdjasiuu8e723082 - myPlc_DESC: "the PLC of machine A"Note
The PLC alias name can be adjusted later by changing the prefix of all associated variable names (e.g. 'myPlc_IPADDRESS' > 'myPlc2_IPADDRESS').
-
Connect to the PLC via PLC alias name and password, in addition a timeout of 2.5 hours
apax plc-control connect -t myPlc -p aSecurePassword -T 2.5After the specified time elapses, the connection will be automatically closed. Instead of a timeout you can also set an exact end-time like '17:30'. Long running operations like MON or TRACE will be terminated when the specified time expires. Other operations like SW download (SLD) will not be aborted immediately. The connection is closed afterwards.
-
Run the tools you need for your task
If only a single PLC alias is configured, you can directly run the tools without specifying the target:
apax sld load --accept-security-disclaimer apax plc-control run apax plc-control diag apax plc-control stop ...If you have two or more PLC aliases configured, you can still use the --target option to specify the target PLC for each tool:
apax sld load -t myPLC_1 --accept-security-disclaimer apax plc-control run -t myPLC_2 -- -
Close the connection explicitly if needed
apax plc-control disconnect -t myPlcAlternatively, if you don't explicitly close the connection, the specified timeout you set when opening the connection will apply.