SetupDataLogger()

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

Moderator: uasdkc

Post Reply
macsurfer
Full Member
Full Member
Posts: 8
Joined: 09 Aug 2013, 12:26

SetupDataLogger()

Post by macsurfer »

Modeler_Struktur.JPG
How could I get the NodeId of my variables to add them to the DataLogger.
I want to use the UaProvider_Helper_HistorizeItem(OpcUa_NodeId *pId) Method with the Model I created, see picture above.

Code: Select all

/* add Temperature to data logging  */
    UaProvider_Helper_HistorizeItem(&g_pMyCustomMachine->pTemperatureSensor->nodeId);

macsurfer
Full Member
Full Member
Posts: 8
Joined: 09 Aug 2013, 12:26

Re: SetupDataLogger()

Post by macsurfer »

Hello Forum,

I spent some time now to get a server running which just contains one variable. Because I wanted to understand which files the modeller creates and where I have to put my code to datalog my variable.
It worked quite good so far but I cannot get the SetupDataLogger() work properly because I am using the wrong pointer/ NodeId.

I tried to copy the NodeId to a global variable of type OpcUa_NodeId* using a modified GetNode() just after the CreateNode- Call:
GetNode_Screen.jpg

Code: Select all

...
/* MeineVariable, PropertyOf MeinBasisObjekt */
    referenceTypeId.Identifier.Numeric = OpcUaId_HasProperty;

	/****************************************************************************************/
	/*	The next node is created, which is a child of "MeinBasisObjekt". The type is 
		property type and so a simple variable.	*/
	/****************************************************************************************/

    UaServer_CreateNumericNodeIdEx(&parentNodeId, NurEinKnoten_Objects_MeinBasisObjekt, g_UaProviderNurEinKnoten_uNamespaceIndex1);
    UaServer_GetNode(pAddressSpace,
                    &parentNodeId,
                    &pParent);

	/* I tried to copy the Node to the global variable g_pMeineVariableNodeId */
	UaServer_GetNode(pAddressSpace,
                &parentNodeId,
                &g_pMeineVariableNodeId);

    UaServer_CreateNumericNodeIdEx(&nodeInfo.TypeDefinition, OpcUaId_PropertyType, 0);
...
This is the modified SetupDataLogger() which creates a folder "newhistorian" and a tagconfig.txt-file in the folder containing only "00000001"

Code: Select all

void NurEinKnoten_SetupDataLogger()
{
    /* create file logger */
#if HAVE_DATA_LOGGER_FILE_BACKEND
    g_hDataLogger = UaServer_FileLogger_Create( "newhistorian" );
#endif
    if (g_hDataLogger < 0) return;

    /* start historian data logging */
    UaServer_DataLogger_Start( g_hDataLogger );
    
    /* add MeineVariable to data logging  */
    UaProvider_Helper_HistorizeItem(&g_pMeineVariableNodeId);
}
#endif /* HAVE_DATA_LOGGER */
Modeller_Screen.jpg
The UAExpert looks like this:
Expert_Screen.jpg

I hope you can help me, thanks in advance!

By the way, my name´s Michael

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

Re: SetupDataLogger()

Post by Support Team »

Hello Michael,

the method 'UaProvider_Helper_HistorizeItem' expects a pointer to a OpcUa_NodeId as a parameter, instead you are passing the pointer to a OpcUa_BaseNode, that's why it won't work.

Inside of 'NurEinKnoten_SetupDataLogger' you roughly should do following:

Code: Select all

    OpcUa_NodeId parentNodeId;
    OpcUa_NodeId_Initialize(&parentNodeId);

    UaServer_CreateNumericNodeIdEx(&parentNodeId, NurEinKnoten_Objects_MeinBasisObjekt, g_UaProviderNurEinKnoten_uNamespaceIndex1);

    /* add MeineVariable to data logging  */
    UaProvider_Helper_HistorizeItem(&parentNodeId);
Best regards,
Unified Automation Support Team

Post Reply