Skip to content

guardianofetherra/CppExamples

 
 

PLCnext Technology - CppExamples

Feature Requests Bugs License Web Community

The CppExamples repository is a collection of various sample code for PLCnext Technology controllers. It is assumed that the reader has basic know-how of C++ programming and has read the key parts of the PLCnext Info Center.
Each example explains one or more topics on how to use C++11 with PLCnext Technology. Explanations are given in the README.md document and via comments in the example code. Each example holds separate user components which can be instantiated on a PLCnext Control.

This project aims to supply, over time, examples and best practices of PLCnext Technology functions regarding C++11.

Table of Contents

# Topic Content SourceCode
01 Program Component Interaction This example shows two PLCnext programs interacting with a PLCnext component by getting or setting variables through reference. SourceCode
02 Data Type Exchange Example This example shows how to transfer data from a C++ project to the GDS. Variables published to the GDS can be accessed by other programs (IEC/C++/Simulink/C#) or the IOs SourceCode
03 Include an Open Source Library This describes how to use a third-party open-source library in a C++ project that is built for PLCnext Control using Eclipse
04 Thread Example This describes how to implement Threads in a component of C++ project. SourceCode
05 Notification Example This describes how to use the Notification Manager. SourceCode
06 E-Learning: InternalFunctionExtensions This describes how to use the Internal Function Extensions. SourceCode

Getting started

Compiling an example

There are different ways how to build your code:

Compile the code with the PLCnext CLI

  1. Install Eclipse IDE, CLI, SDK and Eclipse Add-in (how-to guide: see links in the "Getting started" section above)
  2. Clone this repository
  3. Navigate to the project you want to test, e.g. cd Examples/ProgramComponentInteraction
  4. Execute plcncli new project -c DummyC -p DummyP && ls -la src && rm src/Dummy*
  5. Execute plcncli set target --add --name AXCF2152 --version 2020.6 to specify details of the build target
  6. Execute plcncli generate all to generate intermediate code and Config files
  7. Execute plcncli build to build the code.
  8. Execute plcncli deploy to generate a .pcwlx file that can be included in PLCnext Engineer

Compile using the Eclipse Add-in

  1. Create a new empty project named like the example you want to test
  2. Remove the source files located at ProjectName/src
  3. Move the source files from the example you want to use into your workspace at ProjectName/src
  4. Build the project

Compile using build-local.sh script

  1. Clone this Repository
  2. Modify the build-local.sh script to fit your needs
    1. select Hardware
    2. select Project
  3. Make sure it is executable for example with chmod +x tools/build-local.sh
  4. Execute the script ./tools/build-local.sh or sh tools/build-local.sh

Contributing

You can participate in this project by submitting bugs and feature requests.
Furthermore you can help us by discussing issues and letting us know where you have problems or where others could struggle.

Feedback

License

Copyright (c) Phoenix Contact GmbH & Co KG. All rights reserved.

Licensed under the MIT License.

About

Collection of various C++ sample code for PLCnext Technology controllers.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 56.4%
  • C++ 29.4%
  • CMake 14.2%