FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
07-05-2021 04:31 PM
I tried to store a simple txt file into configuration using hello-plc C++ example from SDK 1.8, but it doesn´t work.
1. I added the plug as described:
2. I tried to store the txt file to the following paths I found in some community posts, but none of them worked for me:
- /var/snap/rexroth-solutions/common/solutions/activeConfiguration/helloplc
- /var/snap/rexroth-solutions/common/solutions/DefaultSolutions/configurations/Default/helloplc
- filepath: $SNAP_COMMON + /solutions/activeConfiguration/helloplc
Via configurations (web interface) I see also no configuration for my helloplc snap. 😞
Could you send me a small code example which explains how to add a file (txt or json) from hello plc C++ snap to configuration?
Thank you very much!!
Solved! Go to Solution.
07-06-2021 11:52 AM - edited 07-06-2021 01:36 PM
To simply store a file in the active configuration add the plug to your .yaml file:
plugs:
active-solution:
interface: content
content: solutions
target: $SNAP_COMMON/solutions
And then use following code:
#include <fstream>
///// test /////
path = "/var/snap/rexroth-solutions/common/solutions/activeConfiguration/test.txt";
std::cout << "write " << path << std::endl;
std::ofstream outfile (path);
if (outfile.is_open()){
std::cout << "opened: "<< path << std::endl;
outfile << "Test txt with some words\nand two lines\n" << path;
outfile.close();
}
else{
std::cout << "error: " << path << std::endl;
}
If you like to be part of the automatic save and load process of the configuration some more steps have to be done. To get more information please get in contact with your ctrlX World contact person.
11-08-2021 12:40 PM