How to Add objects in address space?

I created an OPC server using iiot contrib nodes. There are predefined objects inside it. How can I create my own objects and add it in the OPC server. I've tried the following.

  1. I'm able to create folders and collection using IIOT-Server-ASO-node. But I'm not able to create the final data. I tried lots of Object type options but it only creates an empty collection.
  2. I also tried creating Flex server because the definition says that one can create his own address space model. But ASO contrib is not working with this.
    I'm able to read and write pre existing data but unable to create my own data in address space.

Did you use node-red-contrib-iiot-opcua? It has a lot of samples ready to import from node-red -menu - import

Maybe one of those can point you in the right direction?

you can use node-red-contrib-opcua-server to define your object,for example:

let GatewayInfo = namespace.addObject({
browseName: "GatewayInfo",
description: "GatewayInfo",
organizedBy: addressSpace.rootFolder.objects,
nodeId:"s=GatewayInfo",
notifierOf: addressSpace.rootFolder.objects.server
});
if you have any question,send me a message

Can you tell me where do I define this ? Is it somewhere inside the opcua contrib or do i define it in a function contrib outside?
I was able to add the basic nodes with the help of an example but it uses very few basic data types like int, bool, string, Json etc. The use case is that I want to send an array of struct called rivets.
The structure has two string variables showing Group and Index and three double variables showing X,Y & Z coordinates. At the moment I'm not sure how can I define this structure in node red.

The type of data that opcua already provides should be satisfied, which requires viewing the data types supported in the xml configuration, or you can wrap array with String.

I tried with standard data types for e.g. Range. It is a structure defined in standard opc data types having two values Low: xxx, High: xxx. I'm not able to transfer data to this because payload is only string, bool, int, json etc. How do i define the values for this structure and send it to the server?

you can define one object(namespace.addObject),and define two value under this object(namespace.addVariable).so you can send two value to this server object.

1 Like

Where should I define this object? In a function node after the inject node ? Do u have an example?
Also the classes do not show its supported functions and variables automatically as in other languages like c++, java etc. e.g. I'm expecting that all the functions for namespace should come when I type namespace. xxx. I can then see add object there and use it but that is not happening in node red. So is there a lib where I can get the for available functions for all objects node red uses?

you can have an example in node-red-contrib-opcua-server,the "server with context" could help you.we can define object in address space.other,In node-red,pyhon & java have function node to define function.

Thanks for your reply. It works in a sense but I want to implement it in a different way.
I created a new namespace called Rivets and added three objects X,Y,&Z of type double.
In UA expert I saw the rivets has a type definition of "BaseObjectType" & X,Y,Z of "PropertyType" (added screenshot for the same).
I want to create rivet also as a variable like a Struct and add X,Y,Z in it.
At the moment I'm not able to call rivet to see its values. The value attribute is missing (maybe because it is a namespace object). In the end I want to call rivets directly and see X,Y&Z values from it. I don't want to call X,Y,Z explicitly.


Is it possible to create a structure like that in node red?