PLCnext CLI

Concept

The PLCnext CLI (PLCnext Command Line Interface) provides the entire toolchain for C++ programming on the PLCnext Technology platform as well as a template system for creating projects. Based on the templates, you can develop your applications. Use the PLCnext CLI to unpack and manage the SDKs. CMake is contained as the build environment and each SDK has its own configuration. A parser integrated in PLCnext CLI creates the metadata required for PLCnext Technology. The LibraryBuilder contained in PLCnext CLI creates a PLCnext Engineer li­brary from the project.

PLCnext CLI command structure

  • Use the Command Line Interface to call functions by means of simple commands.
  • Activate the PLCnext CLI by calling the plcncli.exe via the shell, e.g.:
  • C:\Program Files\PHOENIX CONTACT\PLCnCLI 2020.0 LTS\plcncli.exe.
  • If you added it to your system "PATH" variable, you can simply use plcncli as a command everywhere in the console.

 

There is a long and a short form for the commands, which you can use as you like:

Long form for the commands

To add the parameters, prefix --.

E.g.: new project --name MyProject1 

CLI_NewProject.png

Short form for the commands

To add the parameters, prefix -.

E.g.: new project -n MyProject1

CLI_NewProjectshort.png
 

Command details

The functions are structured hierarchically. For each command, there is another level of commands that specifies the desired function in more detail. Use the --help command to call a description of the individual functions.
E.g.: new project --help
 
PLCnCLI_Help.PNG

If you do not specify all the parameters, the system will use default parameters. The values will be displayed after the command was executed.
For example, if you do not specify a directory path via the --output option for a new project, a subfolder is created and used in the current directory.

How to

PLCnext CLI command overview

The PLCnext CLI provides the following commands, which you can use to execute the corresponding functions.

Command Meaning
build Compile a project
generate Generate configuration and code files
get Query information about projects, controllers, settings, etc.
set Change settings, e.g. set a project controller
update Update of controllers in the current project
install Install an SDK
new Create new files/projects
deploy Deploy files for production.
help Call additional information about a specific command
version Show version information

Each command can be specified using additional parameters. Commands consist of the fol­lowing:

PLCnext CLI call

Level 1

Level 2

Level 3

plcncli

new

project

-n or --name

If you require information on parameters or additional command levels, you can request them for each level by means of the --help command.

CLI template system:

With the plcncli new command it is possible to add new files or start new projects. These are based on templates, and they are adapted to the current project or pre-configured by additional parameters.

Currently available is the PLM program project template (via plcncli new project) which can be extended by additional programs (via plcncli new program) and components (via plcncli new component).

A second option is the ACF project template (via plcncli new acfproject), and additional ACF components can be added via plcncli new acfcomponents.

For more Information about the project types, please read this.

Example how to configure a project with the PLCnext CLIClick to see an example how to configure a project with the PLCnext CLI

The following example shows an option of how to configure a project up to the complete PLCnext library using the PLCnext CLI:

  • Open a project folder of your choice:
    e.g., C:\Users\<username>\Documents\CLI Projects.

  • Generate a new project with the project name Project1:
    plcncli new project –n Project1  

  • Go to the Project1 project folder:
    cd Project1

  • Select the desired controller for the project (e.g., AXC F 2152):
    plcncli set targets --add -n AXCF2152

  • Use the following command to generate the necessary metafiles for the project:
    plcncli generate config

  • Use the following command to generate the necessary code files for the project:
    plcncli generate code

  • You can also generate metafiles and code files in only one step:
    plcncli generate all

  • Compile the project.:
    plcncli build

  • Generate a library:
    plcncli generate library

The library and the .so files are located in the bin folder of the project.

Importing the library

You can then import the generated library into PLCnext Engineer. Click here for a description how to import libraries in PLCnext Engineer.