How to set a node_id for a node

Questions regarding the use of the ANSI C SDK for Server or Client development or integration into customer products ...

Moderator: uasdkc

Post Reply
rayraysayshi
Jr. Member
Jr. Member
Posts: 1
Joined: 12 Jun 2014, 20:02

How to set a node_id for a node

Post by rayraysayshi »

I am trying to specify a node id on my server but don't understand the structure that I am supposed to follow. I followed the seemingly simple structure to change the node ID and didn't receive errors or warnings. I was successful in creating the nodes as seen below but not creating a node_id. I thought to add a simple node id I would follow the same structure and add the lines with $$$$ in them;

I am trying to specify a node id on my server but don't understand the structure that I am supposed to follow. I followed the seemingly simple structure to change the node ID and didn't receive errors or warnings. I was successful in creating the nodes as seen below but not creating a node_id. I thought to add a simple node id I would follow the same structure and add the lines with $$$$ in them;



//opcua_server.c

#include "ua_types.h"
#define HANDLE_PDU1 15

const uint8_t EN_DISPLAYNAME_PDU1[] = "PDU1";
const UA_UTF8_string_t ENGLISH_TEXT[] =
{
{ 0, 0 },
{ sizeof(EN_DISPLAYNAME_PDU1)- 1, EN_DISPLAYNAME_PDU1 }
};

void opcua_add_nodes(void)
{
UA_Status_t status = 0;

//Add PDU1 Folder
UA_Folder_t PDU1;
UAServer_Init_config_structure_Folder(&PDU1);
PDU1.node_handle = HANDLE_PDU1;
PDU1.display_name_handle = HANDLE_PDU1;
UA_NodeId_Config_t randomHANDLE; // $$$$ Not creating node id
PDU1.node_id = randomHANDLE; // $$$$ Not creating node id

status = UAServer_Create_Folder(&PDU1);
if (status != 0)
{
UA_SERVER_PRINTF("UAServer_Create_Folder returned: %d\n", (uint16_t)status);

}
status = UAServer_Add_to_folder(folder.node_handle, PDU1.node_handle);
if (status != 0)
{
UA_SERVER_PRINTF("UAServer_Add_to_objects_folder returned: %d\n", (uint16_t)status);
}
}


//ua_types.h
typedef struct
{
/**
* A mandatory unique identifier that identifies the node in the library.
* The value zero is invalid.
*/
uint32_t node_handle;
/**
* A mandatory unique identifier that allows the host to efficiently look up the
* node name text to display in a translate callback. The value zero is invalid.
*/
uint32_t display_name_handle;
/**
* An optional unique identifier that allows the host to efficiently look up the
* node description text to display in a translate callback. The value zero is
* invalid.
*/
uint32_t description_handle;
/**
* An optional visibility mask that restricts the visibility of the node depending
* on which user is logged in. The anonymous user is bit 0 and bits 1 - 15
* represent the corresponding users
*/
uint16_t user_visibility;
/**
* Specifies the namespace index for this node. The UA namespace is 0 and cannot
* be used. The default server namespace is 1. Other namespaces may be added
* to the configuration data structure.
*/
uint16_t namespace_index;
/**
* An optional parameter set that defines the NodeId for the node as a string
* or a GUID. If this parameter is set to default values then the SDK will assign
* an opaque node id to the node. Opaque node ids are easily decoded by the SDK
* and offer the best performance. Only populate this parameter set if your
* application requires it.
*/
UA_NodeId_Config_t node_id;
} UA_Base_t;

/*****************************************************************************/
/** \brief A configuration structure for Folder address space nodes.
*
*/
typedef UA_Base_t UA_Folder_t;

/*****************************************************************************/
/** \brief A configuration structure for View address space nodes.
*
*/
typedef UA_Folder_t UA_View_t;

/*****************************************************************************/
/** \brief A configuration structure for Method address space nodes.
*
*/
typedef struct
{
/**
* Configuration common to all nodes
*/
UA_Base_t base_config;
/**
* The file size in bytes
*/
uint64_t size;
/**
* The file is writable
*/
bool_t writable;
/**
* An optional writable mask that restricts write access of the file depending
* on which user is logged in. The anonymous user is bit 0 and bits 1 - 15
* represent the corresponding users
*/
uint16_t user_writable;
} UA_File_t;

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: How to set a node_id for a node

Post by Support Team »

Hi Rayraysayshi,

the code base you are using is NOT from Unified Automation and does not belong to any of our products. You have used code from an Open Source community project, which is far away from being ready to use and which is far away from being in any way usable for professional product or component development. That code covers only a fraction of the overall OPC UA functionality and by this should not even be used for evaluation, as you may get a wrong impression of the UA technology in general. Of course we can not and will not support this codebbase, especially not within this forum.

We strongly recommend using one of our Toolkits/SDK, which are fully functional and which are the only professionally supported code base:
http://www.unified-automation.com/downl ... pment.html

Best Regards
Support Team

Post Reply