2PLCnext Apps

A PLCnext App (in the following also called "app" for short) is a collection of functionalities bundled into one large file that can be understood and executed by the PLCnext runtime system. Each app may contain multiple different parts, that provide functionalities to the system in their own way. To tell the runtime system how to execute each part, we group them into different types, which we will explore later.

2.1App management

In contrast to a classic package manager which installs the files of the application to be installed directly in the Linux file system, PLCnext Apps are hosted in file containers (like a zip file) and the system references the files in the container. This procedure allows easy installation and residue-free uninstallation of apps and also significantly increases the probability that apps are still executable after a firmware update.

2.2App container

A PLCnext app is stored in a SquashFS container. A SquashFS container stores a folder and file structure in a single compressed file. The SquashFS containers of all installed and activated apps are read-only mounted by the AppManager in the Linux file system at a defined location, i.e. the contents of the container cannot be changed.

The file system within an app container must contain at least the app description file, in which all the necessary information about the app are conveyed to the runtime system. The app description file is a text file in json-notation and the name is app_info.json

/ <- Root node
/app_info.json

Structure of the app_info.json file:

{

   "plcnextapp": {

      "name": "<app name>",

      "identifier": "<App Identifier>",

      "version": "<version>",

      "target": "<target>",

      "minfirmware_version": "<min_firmware>",

      <optional plcnextapp meta data>

   },

   <optional app parts: app dependent data>

}

In generally, there are two classes of app information:

PLCnext App Meta Data:

which are stored in the JSON object "plcnextapp" (Metadata)

Optional information about app parts:

PLCnext Engineer Solution

Command Line Tools

Shared Libraries

Linux Daemons

PLCnext Extensions

Configuration of the PLCnext Runtime Services

File/data storage

2.3Building a PLCnext App

Independent of the amount and types of your app parts the general way to build the app is always identical. The necessary changes you need to include for every app part will be detailed below the general build process. The description of each app part type will contain the following sections:

A general description of the app part type.

The steps to create the app part and to integrate in the your app.

A section about specifications and restrictions for the corresponding app part

A simple demo example of that app part type with a link to its files in the GitHub repository.

If anything about the syntax of the app_info.json is still unclear consider having a look at the completely filled out example: Example of a complete app_info.json

In order to build an app, you will need a SSH-Client (e.g. PUTTY) and a SFTP-Client (e.g. WinSCP) Then you just have to follow the steps below. Most steps can be done with both tools, unless stated otherwise.

1.Connect to your controller with both Clients mentioned above.

2.Create a folder for your app (e.g. /opt/plcnext/myapp)

3.Move every file your app needs to run to this folder. It is a best practice to separate all your app parts into different subfolders. The files you are going to need for each part will be mentioned in the app part type description)

4.Create and fill the app_info.json with:

the format and metadata about your app outlined above

descriptions of your app parts (Specific instructions on how to do this are in each chapter for the different app part type below)

storage and service requirements of the integrated app part types.

5.Execute "plcnextapp create <app directory> <app name> in the SSH client to build <app name>.app file (See “Creation of an app container”)

if plcnextapp is not in your PATH it can be found in "/usr/bin" and executed with "/usr/bin/plcnextapp <appdirectory> <app name>"

6.Move the .app file to your computer with SFTP-Client.

2.4Creation of an app container

The Linux command plcnextapp is available under /usr/bin and is used to create an app container.

The following parameters are supported:

create <APPDIR> <APPNAME>

example

To execute the install/activate/deactivate commands root privileges are required. For the user plcnext_firmware sudo rights are set.

inset_35_32.png 

 

Note:

The tool can handle further commands but except "create" all commands are intended for operation by the AppManager and do not have the desired effect when called via the com­mand line.

inset_36_49.png 

 

Note:

The set access rights to all app files and directories are retained when the container is cre­ated, but the ownership information of these files and directories will be lost/forced on app creation.

2.5Folders and PLCnext environment variables

The following directories with the associated environment variables are required in the system for app administration:

Table 2-1PLCnext environment variables

Environment Variable

Value

Use

ARP_HOME_DIR

/opt/plcnext

Working directory of the PLCnext Runtime

ARP_ACTIVE_APPS_DIR

$ARP_HOME_DIR$/apps

Contains the folders of the mounted app containers.

ARP_APPS_HOME_DIR

$ARP_HOME_DIR$/appshome

All app data such as persistent memory and symlinks to determine binaries are stored here.

ARP_APPS_DATA_DIR

$ARP_APPS_HOME_DIR$/data

Represents the root storage folder for persistent app data.

ARP_APPS_TEMP_DIR

/var/tmp/appsdata

Represents the root storage folder for temporary data of the apps.

ARP_APPS_BIN_DIR

$ARP_APP_HOME_DIR$/bin

Storage directory for the symlinks to the command line tools of the apps. This is entered in the PATH environment variable for all users.

2.6Diagnostic log files

All status and error informations of the app management are saved in the following two log files:

/opt/plcnext/logs/Output.log: All status and error messages of the PLCnext firmware, including those of the app management components

/opt/plcnext/logs/plcnextapps.log: status and error messages of the PLCnextapp command line tool

2.7PLCnext Software Development Kit

Phoenix Contact recommends developing the apps libraries and executable binaries for the different corresponsing app part typed on a separate PC and not directly on the controller. For the development on a separate PC you need a tool chain consisting of an SDK and a cross compiler. One possible tool chain can be downloaded from the "Downloads" section of your PLCnext Controller product page on the Phoenix Contact Website:

Product page of the Controller AXC F 2152

Product page of the Controller RFC 4072S