Example Usage with persisted PLC Alias - Manual - PLC Control - The SIMATIC AX tool to manage connections to SIMATIC PLCs and run simple PLC operations. - Connection Sharing And PLC Control Tool,tool

PLC Control CLI Tool (plc-control)

Portfolio
SIMATIC AX
Product
PLC Control
Software version
0.7.128
Edition
10/2024
Language
English (original)
Package Name
@ax/plc-control

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.

  1. 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.yml inside the variables section:

    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').

  2. 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.5
    

    After 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.

  3. 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
    --
    
  4. Close the connection explicitly if needed

    apax plc-control disconnect -t myPlc
    

    Alternatively, if you don't explicitly close the connection, the specified timeout you set when opening the connection will apply.