Can you support me with an example?
In servermain.c I have real world data (boolean, double,...).
In uaprovider_xxx_nodes_1.c my nodes designed with UaModeler are described.
For my variable nodes, initial values are set, e.g.: value.Value.Double = (OpcUa_Double) 0.0;.
I want to use an expression like this in servermain.c. But you suggest OpcUa_Variable_SetValue().
I have checked the documentation of OpcUa_Variable_SetValue(): a pointer referencing the variable and the value as a variant to be set are required.
How can I get these?
In my opinion, I have to use unique identifiers for the variables from uaprovider_xxx_nodes_1.c. Is it correct?
I have tried to use:
Code: Select all
OpcUa_Variable_SetValue(xxx_Objects_TestObjekt1_TestVariable1,di2)
where di2 is a variant and di2.value contains the real world value, but it doesnt't work, because xxx_Objects_TestObjekt1_TestVariable1is not known by the compiler.
This is the variable i want to set with real world data:
Code: Select all
/* TestVariable1, ComponentOf TestObjekt1 */
referenceTypeId.Identifier.Numeric = OpcUaId_HasComponent;
UaBase_CreateNumericNodeIdEx(&parentNodeId, xxx_Objects_TestObjekt1, g_UaProviderxxx_uNamespaceIndex1);
UaServer_GetNode(pAddressSpace,
&parentNodeId,
&pParent);
UaBase_CreateNumericNodeIdEx(&nodeInfo.TypeDefinition, OpcUaId_BaseDataVariableType, 0);
UaBase_CreateNumericNodeIdEx(&nodeInfo.NodeId, xxx_Objects_TestObjekt1_TestVariable1, g_UaProviderxxx_uNamespaceIndex1);
nodeInfo.NodeClass = OpcUa_NodeClass_Variable;
UaBase_CreateLocalizedText(&nodeInfo.sDisplayName, g_xxxStringTable1[14], g_xxxStringTable1[3]);
UaBase_CreateQualifiedNameEx(&nodeInfo.sBrowseName, g_xxxStringTable1[3], g_UaProviderxxx_uNamespaceIndex1);
UaBase_CreateLocalizedText(&nodeInfo.sDescription, g_xxxStringTable1[14], g_xxxStringTable1[4]);
uStatus = UaProvider_xxx_CreateNode(pAddressSpace,
&pNode,
pParent,
&referenceTypeId,
&nodeInfo);
OpcUa_GotoErrorIfBad(uStatus);
OpcUa_Variable_SetAccessLevel(pNode, OpcUa_AccessLevels_CurrentReadOrWrite);
#if UASERVER_SUPPORT_AUTHORIZATION == OPCUA_CONFIG_NO
OpcUa_Variable_SetUserAccessLevel(pNode, OpcUa_AccessLevels_CurrentReadOrWrite);
#endif
OpcUa_Variable_SetDataType_Numeric(pNode, OpcUaId_Double, 0);
OpcUa_Variable_SetHistorizing(pNode, OpcUa_False);
OpcUa_Variable_SetMinimumSamplingInterval(pNode, 0);
OpcUa_Variable_SetValueRank(pNode, OpcUa_ValueRanks_Scalar);
OpcUa_Variant_Initialize(&value);
value.Value.Double = (OpcUa_Double) 0.0;
value.Datatype = OpcUaType_Double;
value.ArrayType = OpcUa_VariantArrayType_Scalar;
OpcUa_Variable_AttachValue(pNode, &value);