Hello Forum,
thanks for that quick reply.
I assume you meant the following code line in example 7:
Code: Select all
TemperatureSensor *pTemperatureSensor = (TemperatureSensor*) OpcUa_BaseNode_GetUserData(pNode);
When the node is created I have to use the OpcUa_BaseNode_SetUserData()- Fct to assign the UserData, not?
In another thread I asked if in that example 7 not only the temperature but also the heater switch could be historized, therefore a colleague changed that line to:
Code: Select all
pUserData = (UserDataCommon*)OpcUa_BaseNode_GetUserData(pNode);
The UserDataCommon struct now contains:
Code: Select all
struct _UserDataCommon
{
UserDataType Type;
/* Data logging information */
OpcUa_NodeId nodeId; /* nodeid of variable */
OpcUa_Int hDataLogItem; /* handle of datalogitem */
};
typedef struct _UserDataCommon UserDataCommon;
My question has to do with the "counterpart" of GetUserData() which I find in custom_provider.c, but these lines I don´t understand:
Code: Select all
...
OpcUa_NodeId_Initialize(&pNewSensor->nodeId);
OpcUa_NodeId_CopyTo(a_pStartingNodeId, &pNewSensor->nodeId);
OpcUa_BaseNode_SetUserData(pVariable, pNewSensor);
*a_ppNewTemperatureSensor = pNewSensor;
I assume that pNewSensor is the UserData- Pointer but why is it assigned to *a_ppNewTemperatureSensor?
Is this only needed in the example?
In my adapted example with only one basenode and one variable the "CreateNode"- part looks like this:
Code: Select all
UaServer_CreateNumericNodeIdEx(&parentNodeId, NurEinKnoten_Objects_MeinBasisObjekt,
g_UaProviderNurEinKnoten_uNamespaceIndex1);
UaServer_GetNode(pAddressSpace,
&parentNodeId,
&pParent);
UaServer_CreateNumericNodeIdEx(&nodeInfo.TypeDefinition, OpcUaId_PropertyType, 0);
UaServer_CreateNumericNodeIdEx(&nodeInfo.NodeId, NurEinKnoten_Objects_MeinBasisObjekt_MeineVariable,
g_UaProviderNurEinKnoten_uNamespaceIndex1);
nodeInfo.NodeClass = OpcUa_NodeClass_Variable;
UaServer_CreateLocalizedText(&nodeInfo.sDisplayName, g_NurEinKnotenStringTable1[4], g_NurEinKnotenStringTable1[3]);
UaServer_CreateQualifiedNameEx(&nodeInfo.sBrowseName, g_NurEinKnotenStringTable1[3],
g_UaProviderNurEinKnoten_uNamespaceIndex1);
UaServer_CreateLocalizedText(&nodeInfo.sDescription, g_NurEinKnotenStringTable1[4], g_NurEinKnotenStringTable1[0]);
uStatus = UaProvider_NurEinKnoten_CreateNode(pAddressSpace,
&pNode,
pParent,
&referenceTypeId,
&nodeInfo);
// This part I tried to adapt like here with a new pointer
/* Set new struct as user data of the new node and store it in the global variable*/
//OpcUa_BaseNode_SetUserData(pNode, g_pMeineVariable);
But how is the right way to do it?
Thanks,
Michael