cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Java SDK for CtrlX?

Java SDK for CtrlX?

cdutz
Long-established Member

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?

10 REPLIES 10

MauroRiboniMX
Contributor

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?

 

cdutz
Long-established Member

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.

Sgilk
Frequent Contributor

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.

Sgilk_0-1698325694961.png

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 

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

cdutz
Long-established Member

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?

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.

MauroRiboniMX_0-1698327921849.png

 

Sgilk
Frequent Contributor

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.

cdutz
Long-established Member

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?

Sgilk
Frequent Contributor

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.

cdutz
Long-established Member

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.


Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist