exOS Component GeneratorExtension to create exOS components for B&R Automation Studio. Create packagesThis VsCode plugin creates exOS components (code templates) via the context menu of / right clicking on a The purpose of the templates is to give an easy start for application development. Here, a base frame of Automation Runtime and Linux code is created for the application, and the build instructions for the component are configured to create Debian packages with the exOS build-chain in Automation Studio. If the .typ file is located within an Automation Studio project (part of the Package.pkg definition), the .typ file is replaced by an exOS package and moved in to a suitable object, like a dynamic library or a program. Update packagesFor all templates except the The update of a package is performed via the context menu of / right clicking on the There are four options to update a template package
Export binary packagesAll exOS packages created with the A package can be exported to a binary format via the context menu of / right clicking on the Folder containing the Use exOS Debug ConsoleIn the editor title menu, under "More Actions...", the exOS Debug Console terminal can be started. This console connects to the IP address of the PLC, and captures all internal logging available to the system. This is mainly useful for debugging purposes, where all other exOS diagnostic functionalities fall short. Update WSL build environmentIn order to update the WSL build environment for a new exOS TP version, the exos-data-eth package needs to be installed that the new headerfiles are used when compiling Linux sources.
This function has been build in by richt-clicking on the Run exOS data connectionWhen developing the Linux code of an exOS component within an AS project, it can be useful to debug the Linux sources locally (either via the command prompt or via an IDE). This can be done in combination with ARsim without activating Deployment using the "Run exOS data connection". This starts the Linux DMR which allows to manually run programs/scripts in Linux/WSL in order to connect to the AR side of the exOS component, and test the code that will eventually be deployed to the target for the production environment.
This function has been build in by richt-clicking on the ExampleThe Code generator uses a top-level structure of a given In this case Mouse is the datamodel (main structure) which contains datasets (structure members) that are either published or subscribed to (from the AR perspective). It has three datasets (
Template variantsTemplate variants are selected individually for Automation Runtime and Linux. In other words, the used template only has impact on the look-and feel of the local system implementation, not on the data-connection performance or functionality between Automation Runtime and Linux. Automation RuntimeEven though the exOS API can be integrated at various levels of an application, all templates generated with the exOS-Components Generator create a dynamic Automation Studio Library and a Structured Text IEC "user" Task. This setup allows the creator of the exOS Package to export the low-level exOS-API parts of the solution in a binary format, that it can be used in situations where no build environment is existing. The Datatype which is used to generate the template (and represents the exOS datamodel) is attached to the library as an external PV, which allows the user to use this structure as a local or a global PV in the AS project. C APIThe dynamic library (which has the name of the Datatype) has the possiblity to instantiate its function blocks, that local copies of the datatype can be used throughout the application. The exos-api functions are implemented directly in the Library, meaning it is rather simple for the user to add special features of the application using the C-API. Updating the package using the "Update All" option might add additional dataset declarations, but remove user-specific features. C InterfaceHere a dynamic library is created as a datamodel proxy, providing a singleton structure representing the datamodel. The interface includes the most common exos-api functions, and can be regenerated by the Update functionality. The benefit of this approach is that the main source in the library is decoupled from the exos-api (simplifying the code), and only needs to access simplified datamodel functions to read and write values, and that this interface can be changed by Updating the package. The drawback of this template is that it only allows the usage of a single datamodel within one application, that is, the library does not allow more than one instance of the generated function block. C++ ClassThis template variant creates a dynamic library with an internal C++ Class as the interface of the datamodel. As the complete functionality is encapsulated within an OO class, the template has the benefit that the resulting function block can be used in several instances in the Automation Studio environment. The class interface can be regenerated by Updating the package.
LinuxC APIHere a C-executable is created together with a cmake instruction. Like the Automation Runtime library, the exos-api functions are used directly in the code, making it simple for the user to add special communication features. Updating the package using the "Update All" option might add additional dataset declarations, but remove user-specific features. C InterfaceHere a static datamodel interface library is created together with a C-executable that accesses a singleton structure. This gives a simpler interface than the C API, and has the benefit that the static datamodel interface library can be updated. It does however only allow accessing a single instance of the datamodel per executable. C++ ClassThis template variant creates a C-executable with an internal C++ Class as the interface of the datamodel. As the complete functionality is encapsulated within an OO class, the template has the benefit that the C++ class can be instantiated in the application. The class interface can be regenerated by Updating the package. JavaScript ModuleThis template uses the n-api (Node-API) to generate a complete nodejs object of the provided datamodel and The template supports arrays and callbacks, as well as any newer nodejs versions, and provides an extensive functionality very close to the native exos-api.
Python ModuleThe SWIG library takes the C Interface as a template for a library that creates a python module representing the datamodel. Along with the python module, a "main" python script is generated that automatically connects the datamodel to AR. The Linux application consists of a shared library, a python module, and a
InstallationWSLexOS works best with WSL as a build environment for the components that are to be deployed on a Linux target system, as WSL executes a full-fledged Debian Linux in the background containing all needed packages for the exOS components to be compiled. The For installing a WSL build system as well as a simulated WSL target environment, please see exOS-WSL on github. The provided images come with python, nodejs and SWIG preinstalled. PythonOne important topic when creating Python-based exOS packages is to compile the package with the same Python version that is installed on the target. Python 2One easy solution for this is to use Python2.7. Old as it is, it is still same-for-all
In the CMakeLists.txt:
Python 3When it comes to using Python 3, it should be noted that different Debian
distributions will install different Python versions when installing Python via Here is a list of distributions together with supported Python versions https://wiki.debian.org/Python
As long as the same distribution is used for target and build-environment, the installation of Python3 is as simple as Python2.7
In the CMakeLists.txt:
If the application requires a different python version than is offered by the default apt mechanism in the distribution, python needs to be intalled by other means than
The following article gives a good intro to pyenv: https://realpython.com/intro-to-pyenv/ In short, a few packages need to be installed in the build-environment before using
When
NodeJSSimilar to using Python3, nodejs comes in different versions in different distributions when using apt. https://packages.debian.org/nodejs
One important topic when creating NodeJS-based exOS packages is to compile the package with the same NodeJS version that is installed on the target. As long as the same distribution is used for the build environment as the target, apt can be used to easily install nodejs.
For the build environment, npm (the node package manager) should be installed to obtain additional node modules during build and include these in the generated package.
Whereas, if the target and build environment should use different distros, the best option is to use nodesource for both platforms. If theres a previous version of nodejs already installed, this should be removed, as it might result in conflicting dependencies or linkable .so files, even if the same version is in use (the apt setup uses a sligthly different setup of packages and linkable files the nodesource setup).
The nodesource installation instructions can be found here: https://github.com/nodesource/distributions/blob/master/README.md Whereas installing NodeJS version 10 is recommended, as SWIG currently does not support newer versions.
In some cases the build environment might need to have several node versions installed. NVM is a tool to handle this. SWIGUnlike Python and NodeJS, SWIG is a mere code generator and only needs to be installed in the development environment. This means, there are no requirements to keep target and development versions synchronized.
There is still a difference of SWIG versions dependent on the used distribution, see https://packages.debian.org/swig
If newer versions are needed, the source pacakges can be downloaded via http://www.swig.org/download.html |