FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We are updating our platform to a new
system.
Read more: Important
information on the platform change.
10-13-2023 05:49 PM
I am trying to create a data layer node with a python script that I uploaded to the application data folder (i.e., /solutions/webdav/appdata).
When I execute my script with a simple print("Hello world") it works. However, using the datalayer API I get an error. I created the python instance over nodered with the examples provided here.
This is the contents of the python script
datalayer.create("/test_path",123)
I tried adding user permission to create, modify,delete,update datalayer but the same error occured.
Solved! Go to Solution.
10-13-2023 06:13 PM
Hello,
Is the script working if launched in the build environment or in the IDE app? I have not enough info to understand if is a script or app problem.
10-16-2023 07:57 AM
Please check on the data layer "script/instances/<name of instance>/diag" for further information about the script error. In your case I would expect an access error.
It is not possible to create a node only by using the "create" command via REST api. It is meant to execute functionality of a provider, what create is the technical name for. In the example you mentioned the script handler is issued to create new nodes below its path.
Other way around, you will always need a data provider that adds nodes to the data layer, as itself does not hold this data but is publishing it as a broker.
10-16-2023 10:34 AM - edited 10-16-2023 10:44 AM
The diagnostic message I got is the following
"RuntimeError(\"0x80f2000 c270208: 'Data Layer' returned errorDL_INVALID_ADDRESS!\")"
@CodeShepherd wrote:Other way around, you will always need a data provider that adds nodes to the data layer, as itself does not hold this data but is publishing it as a broker.
Is it possible to add a node to the datalayer programatically with the python runtime environment ?
I saw this example in the sdk
samples-python/datalayer.provider/main.py
but it seems I need to build a snap with the Bosch SDK to have access to the python API to create a node. Can I instead do this instead just by uploading a script over WebDAV and using the REST API?
10-16-2023 10:57 AM
Hello,
I try myself and then i give you a feedback 🙂
Mauro
10-16-2023 11:15 AM
Well, I searched more about this in the forum and found this by @CodeShepherd
So I need to use the SDK and build a snap to create a datalayer node.
10-16-2023 11:26 AM
May I suggest that in the documentation this is explicitly mentioned. It was not clear to me that nodes cannot be created with the python interpreter
In specific in the document application manual: Ctrl X Core Runtime, section 4.5 Script parser/interpreter (Python)
10-16-2023 11:51 AM - edited 10-16-2023 11:51 AM
I agree that it can be misunderstood. I will talk to the documentation department.
Function datalayer.create(<path>, <value>):
The function creates an element with the specified value in the Data Layer. Only simple types are supported.
Like mentioned create is the technical name for the convention to execute a function of a data provider. It can but must not add nodes.
If you are using the KVD (Key Value Database) app, there it works like you expect in the dynamic path. But this is all handled by the app. The data layer itself does not do it.