FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
10-26-2023 02:48 PM
Hi all,
as the product I'm trying to bring into the CtrlX store is based on java, my colleague who built a first POC had to build 2 apps as snaps wouldn't like starting two processes.
That got me thinking, why not to integrate the webserver needed for the UI into the database application itself. This would simplyfy deployment dramatically.
Unfortunately I see loads of supported languages for SDKs, Java however is not one of them.
Is there simply no Java SDK? If not, will there be one in the future?
Solved! Go to Solution.
10-26-2023 02:58 PM - edited 10-26-2023 02:59 PM
Hello,
You can have 2 "app" running as a daemon in a snap. really no problem. You can have many processes started from the same snap.
The SDK is providing demos to interact with the datalayer, does your app needs to interact with the datalayer? You can do whatever you want with REST-APIs except for privide data (create nodes in the datalayer). For that you need to create a provider or to use the KVD app.
What do you mean with "Database Application" ? the KVD app?
10-26-2023 03:03 PM
Well ....
Timecho provides a Time Series Database (TimechoDB with the open-souce version Apache IoTDB). We want to be able to select datapoints from the datalayer and poll that data and store it in the TSDB in order to allow analysis.
As IoTDB and TimechoDB are both written in Java, it feels natural to build the server-part in Java too. I did read about the REST API, however whenever I tried to hit any of the endpoints, I simply get page-not-found.
10-26-2023 03:13 PM
You can write the app in Java, but won't have access to the SDK datalayer methods in this language.
A great starting point is the API reference built into the ctrlX WebUI. The Swagger documentation is interactive and allows you to play around with pre built REST calls.
Some basic information on the ctrlX REST API can be found in the attached document.
Here is also a How-To on using the REST API: Using-REST-API-of-ctrlX-CORE
10-26-2023 03:20 PM
Hello,
All quote from @Sgilk . Plus: please don't store the data in the internal memory, modify the app to store the data in a removable media.
For that you need the following interface: https://snapcraft.io/docs/removable-media-interface
Is in auto-connecting so you can use it freely.
Mauro
10-26-2023 03:42 PM
Ok ... I'll also look into external storage options ... are there "industrial grade" options for usage with a CtrlX Core device?
Also regarding the PDF you sent me ... I found that myself and already had tried that, unfortunately it seems the API version 1.0 no longer works and the video linked at the end doesn't exist anymore ... but your tip with the (i) menu did help a lot. I think I'll be able to continue from there.
However you mention, that there's no access to the data-layer @Sgilk are you referring to what @MauroRiboniMX mentioned about not being able to create nodes in the data-layer or to write to the datalayer? Because I only want observing (reading) access to that and the API documentaiton does give me the impression that this should be possible using the REST API.
And when using the rest API, is there a way to open the link to the application and pass along a JWT (or whatever token you folks use) so the user can use the app using the access that he has based on his login on the main App?
10-26-2023 03:45 PM - edited 10-26-2023 03:47 PM
Hi,
The Datalayer documentation is covered as well as the Authorization API. Which is what our "Folks" are using 😂. There will be a version with an integrated SSD and by now you can stick industrial grade uSD as well as USB media in the USB port.
10-26-2023 03:49 PM - edited 10-26-2023 03:50 PM
Yes, some of the information is a bit dated, but the process is the same. The most current endpoints will be in the Swagger docs.
What I meant is there is no datalayer access via methods included in the SDK (take a look at this example: Python Datalayer Client). The REST API will be your only means of datalayer access in Java.
Like @MauroRiboniMX says above, you'll use the Authorization and Authentication API to handle access.
10-30-2023 03:50 PM
Soooo ... playing around with the REST API (I managed to get various variants of API clients generated from the swagger spec) ... however I noticed one thing when playing around with the Swagger client:
If I try reading a normal node, I get these permissions:
"operations": { "read": true, "write": false, "create": false, "delete": false, "browse": true },
However as soon as I want to read the state of something on the real-time-layer, I get this:
"operations": { "read": false, "write": false, "create": false, "delete": false, "browse": true },
So it seems as if, even if I get the API client working with OAuth, I would probably not be able to collect the data that I want to connect, is that correct?
10-30-2023 09:17 PM
Sorry, could you please remind me what data you are trying to read? There should be no problem reading either real time or non real time data via REST API with authorization.
10-30-2023 09:37 PM - edited 10-30-2023 09:38 PM
I think I found out what I was doing wrong: I thought I had only 2 options for type: "metadata" or "browse" ... however "--" also seems to do something.
When listing the resources via "nodes/datalayer/nodesrt" one of the entries returned was: "fieldbuses/ethercat/master/instances/ethercatmaster/realtime_data/input" and when trying to read that I only got this when reading "metadata":
{
"type": "object",
"value": {
"nodeClass": "Folder",
"operations": {
"read": false,
"write": false,
"create": false,
"delete": false,
"browse": true }, "description": "",
"descriptionUrl": "",
"displayFormat": "Auto",
"extensions": [],
"references": []
} }
Which lead me to the impression I couldn't read (as "read" was false for all rt variables I had a look at)
However if I run "browse" I get the following:
{
"type": "arstring",
"value": [
"data",
"histogram",
"info",
"map" ] }
So if I append one of these four to my path, I do get sensible data.
I would assume, that "map" tells me which fields are stored where in the byte array returned by "data" and what their names are and how to interpret their value.
I think I'll be able to continue from here 🙂
Thanks and sorry for all these questions recently.