Using the PLCnext Technology Toolchain and the PLCnext CLI
What is the PLCnext CLI
The PLCnext Command Line Interface (PLCnext CLI) provides an entire toolchain for C++ programming on the PLCnext Technology platform as well as a template system for creating projects.
- Based on the C++ specific templates, you can develop your applications.
- You can use the PLCnext CLI to unpack and manage the SDKs.
- CMake is contained as the build environment, and each SDK brings its own configuration.
- A parser integrated in PLCnext CLI creates the metadata required for PLCnext Engineer to inform it about data types, components, programs and ports.
- The LibraryBuilder contained in PLCnext CLI creates a PLCnext Engineer library from the project.
If you are working with Eclipse® or Visual Studio® and installed the PLCnext IDE tools, the PLCnext CLI is called by means of that IDE user interface to perform some steps.
How to use the PLCnext CLI
Example workflow
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 target --add -n AXCF2152 - Generate metafiles and code files:
plcncli generate all
Generating metafiles and code files separatelyGenerating metafiles and code files separately...Use the following command to generate only the necessary metafiles for the project:
plcncli generate configUse the following command to generate only the necessary code files for the project:
plcncli generate code - Compile the project.:
plcncli build - Generate a library for PLCnext Engineer:
plcncli deploy
↪ The library and the .so files are located in the bin folder of the project. - Import the generated library into PLCnext Engineer.
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 the plcncli.exe to your PATH
environment variables during installation (see PLCnext toolchain installation), you can simply use plcncli
as a command 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 long-form parameters, use --
as the prefix, e.g.:
C:\Workspace>plcncli new project --name MyProject1
Successfully created template 'project' in C:\Workspace\MyProject1
Short form for the commands
To add short-form parameters, use prefix -
as the prefix, e.g.:
C:\Workspace>plcncli new project -n MyProject1
Successfully created template 'project' in C:\Workspace\MyProject1
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.: plcncli new project --help
.
plcncli 20.0.0.243 RC1 (20.0.0.243)
Copyright (c) 2018 Phoenix Contact GmbH & Co. KG
-c, --component The name of the component which will be automatically
created.
-p, --program The name of the program which will be automatically
created.
-s, --namespace The root namespace for the project. It is used to resolve
the initial component and program namespace.
-n, --name Name of the project.
-o, --output Absolute path or relative path to the directory of the
project.
-f, --force Overrides existing files when encountered.
--verbose Enables verbose output.
--quiet Suppresses all output.
--help Display this help screen.
If you do not specify all the parameters, the system will also display the help or 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.
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 |
show-log |
Opens the location of the CLI log files. |
migrate-old-cli |
Migrates all caches and user settings from an old CLI installation. Note: Use this command, if you had a previous installation of the PLCnext CLI and your settings or already installed SDKs are missing after an update of the PLCnext CLI. |
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 following:
PLCnext CLI call |
Level 1 |
Level 2 |
Level 3 |
|
|
|
|
If you require information on parameters or additional command levels, you can request them for each level by means of the --help
command.
PLCnext 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.
First, there 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
). For more information about the PLM program project type, refer to the Structure of a C++ program.
A second option is the ACF project template (via plcncli new acfproject
), and additional ACF components can be added via plcncli new acfcomponents
. To distinguish the core differences between PLM and ACF projects, refer to their PLM and ACF delimitation.
From firmware releases 2021.0 LTS or newer, the third option is a template for a Shared library (via plcncli new consumablelibrary
) which can be used in other PLCnext C++ projects. For more on this useful template type, see the Consumable library description.