ACF (Application Component Framework)

The ACF (Application Component Framework) is the foundation for the PLCnext Technology platform architecture. The ACF is a framework that enables component-based platform development and the configurative composition of the firmware for the devices. It can configuratively distribute the firmware to one or more processes. The ACF enables the configurative integration of user functions into the system. This way, you can extend PLCnext Technology devices with your own functions. 

The ACF loads the various shared object files, and starts and manages the components contained therein in the desired sequence. In PLCnext Technology, components are instantiated as classes so that several instances of one component type can coexist in the same project. The instantiation is performed via configuration files for the ACF. 

Functions

The ACF takes on the role of creating, configuring, and destroying ACF components.  The application components are controlled as follows:

Action Calling of an IComponent
Start firmware
  • void Initialize()
  • void SubscribeServices()
  • void LoadSettings(Const string & stettingsPath)
  • void SetupSettings()
  • void LoadConfig()
  • void SetupConfig()
Shut down firmware
  • void ResetConfig()
  • void Dispose()
Note: The void PublishServices() function is reserved for firmware components only and therefore not usable by user components.

Configuration

ACF components are loaded and instantiated during startup of the firmware based on configuration by *.acf.config files. This configuration lasts as long as the firmware is runnning. A changed configuration becomes effective by restarting the firmware.

As there is just one mechanism for the dynamic integration of components, the ACF configuration contains both the firmware settings and the project configuration for the user components. The difference is in the storage location. The respective *.acf.config file is either in the directory for the system settings or for the project configuration.

For more information in the configuration files, see Configuration files.

ACF libraries

ACF libraries are loaded dynamically via configuration by the ACF. They serve as the configurative extension of the system by means of platform or user functions. The ACF libraries must be available as dynamic libraries ("shared object" = *.so file) and contain one or more ACF components. This enables the user to construct the firmware configuratively and add functions.

ACF libraries must be implemented in accordance with a particular template. The specified template is necessary to enable the ACF to access the code dynamically. Implementation consists of the following elements:

  • Library class (derived from LibraryBase), implemented as a singleton. A library singleton is an instance or function that exists exactly once per library
  • At least one component class that implements the IComponent interface.
  • ComponentFactory

See ILibrary and LibraryBase  and IComponent and IProgram.

Loading libraries

The configuration document that adds a library to the ACF configuration is created automatically by the PLCnext Engineer as shown in the following example:

<?xml version="1.0" encoding="utf-8"?>
<AcfConfigurationDocument    
   xmlns="http://phoenixcontact.com/schema/acfconfig"    
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
   xsi:schemaLocation="http://www.phoenixcontact.com/schema/acfconfig"schemaVersion="1.0" > 
                                
   <Libraries>         
      <Library name="MyLibraryACF"      
       binaryPath="$ARP_PROJECTS_DIR$/MyLibrary/libs/libMyLibraryACF.so" />
   </Libraries>
    
</AcfConfigurationDocument>


The following table lists explanations of the individual attributes:

XML element Description
<Libraries> List of libraries. Here, libraries are listed that are to be loaded to create components.
<Library> Definition of a library.
name Name of the library referenced in a component configuration.
binaryPath Path of the library's binary (*.so) that is to be loaded.

ACF components

Components are classes in the sense of object-oriented programming. They are a part of a library and provide a public interface to the library. They therefore facilitate access to libraries with coherent functionality, and can be instantiated once or several times.

ACF components enable the PLCnext Technology platform to be extended configuratively. The ACF components must be implemented in accordance with a particular template. The ACF components must register with the ComponentFactory of the library. Furthermore, they must implement the IComponent interface in order for the ACF to dynamically integrate them into the firmware (see IComponent and IProgram).

ACF components are instantiated once or several times. They are assigned with a system-wide unique instance name.

Adding a component instance

Component instances are added to the ACF configuration as shown in the following example:

<?xml version="1.0" encoding="utf-8"?>
<AcfConfigurationDocument
   xmlns="http://phoenixcontact.com/schema/acfconfig"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.phoenixcontact.com/schema/acfconfig"
   schemaVersion="1.0" >
   <!-- Components included into /opt/plcnext/projects/Default/*.acf.config
        are managed by ACF
        while components included into /opt/plcnext/projects/Default/Plc/Plm/*.plm.config
        are managed by PLM
   -->
   <Components>
      <Component name="ACFDemo" type="MyLibraryACF.MyComponentACF" library="MyLibraryACF">
         <Settings path="/opt/plcnext/projects/MyLibrary/ACFDemoSettings.xml" />
      </Component>
   </Components>
</AcfConfigurationDocument>

The following table lists explanations of the individual attributes:

XML element Description
<Components> List of the components that are to be created.
<Component> Definition of a component instance.
name Name of the component instance. It must be unique throughout the entire system because all resources in the system are addressed via the components name.
type

Type name of the component. The name is composed of <namespace>.<class>.
A library can provide several component types. Typically, C++ type names are used here. The name is used in the code to register components with the ComponentFactory. This is the only dependency between the system configuration and the source code.

library Name of the library that contains the component and was defined under <Libraries>.
<Settings path> Path to the component settings file.
If the component requires a project configuration, the path to the component-specific project configuration must be specified in the settings file. This settings file is especially useful if two or more component instances of the same type shall be used.

 

 


• Published/reviewed: 2024-09-24   ☀  Revision 073 •