Sending the AdditionalInfo through the UaStatus from server to client

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

Moderator: uasdkcpp

Post Reply
Rajendra
Jr. Member
Jr. Member
Posts: 4
Joined: 27 Jul 2011, 06:50

Sending the AdditionalInfo through the UaStatus from server to client

Post by Rajendra »

We have to send the UAStatus (is a method return type) from the server to the client with additional diagnostic information , and part of this UAStatus is the UADiagnosticInfo in which we updated AdditionInfo (AdditionInfo is a uastring and we update it using the uastatus.SetAdditionalInfo and also tried with SetStatus).

Please see the following server and client code snippet
//ServerSide code
UaStatus ControllerObject::beginCall(
MethodManagerCallback* pCallback,
const ServiceContext& serviceContext,
OpcUa_UInt32 callbackHandle,
MethodHandle* pMethodHandle,
const UaVariantArray& inputArguments)
{
UaStatus ret;
UaVariantArray outputArguments;
UaStatusCodeArray inputArgumentResults;
UaDiagnosticInfos inputArgumentDiag;
MethodHandleUaNode* pMethodHandleUaNode = static_cast(pMethodHandle);
UaMethod* pMethod = NULL;

if(pMethodHandleUaNode)
{
pMethod = pMethodHandleUaNode->pUaMethod();

if(pMethod)
{
// Check if we have the start method
if ( pMethod->nodeId() == m_pMethodStart->nodeId())
{
ret.setStatus(1024,UaString("Error: DiagnoticInfo" ));
//ret.setAdditionalInfo(UaString("Error: DiagnoticInfo" ));
}
}
}
pCallback->finishCall(
callbackHandle,
inputArgumentResults,
inputArgumentDiag,
outputArguments,
ret);

ret = OpcUa_Good;
}

//Client side code
/*********************************************************************
Call Method
**********************************************************************/
status = g_pUaSession->call(
serviceSettings, // Use default settings
callRequest, // In parameters and settings for the method call
callResult); // Out parameters and results returned from the method call
/*********************************************************************/
if ( status.isBad() )
{
printf("** Error: UaSession::call failed [ret=%s] *********n", status.toString().toUtf8());
UaDiagnosticInfo* pDiagnosticInfo = status .pDiagnosticInfo();
//Showing the garbage value}
else
{
printf("** Error: UaSession::call succeeded!n" );
}
Client is receiving the error code but not able to get the UADiagnosticInfo.

Please let me know how to get the diagnosticInfo on the client side.

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

Re:Sending the AdditionalInfo through the UaStatus from server to client

Post by Support Team »

Hello Rajendra,

We verified your example and the server side works fine but there are different things to consider on the client side.

(1) DiagnosticInformation is optional
DiagnosticInformation must be requested by the client to be delivered when it is available in the server.
The server is not required to provide DiagnosticInformation.

Since your server is providing this information, you must request it from the client side. This is dont through the parameter returnDiagnostics of the ServiceSettings. This parameter is a bit mask to request different available parts of the diagnostic information.

Here is an extract from the SDK documentation
Bit Value --- Diagnostics to return -------------- Define
0x0000 0001 - ServiceLevel / SymbolicId ---------- OpcUa_DiagnosticsMasks_ServiceSymbolicId
0x0000 0002 - ServiceLevel / LocalizedText ------- OpcUa_DiagnosticsMasks_ServiceLocalizedText
0x0000 0004 - ServiceLevel / AdditionalInfo ------ OpcUa_DiagnosticsMasks_ServiceAdditionalInfo
0x0000 0008 - ServiceLevel / Inner StatusCode ---- OpcUa_DiagnosticsMasks_ServiceInnerStatusCode
0x0000 0010 - ServiceLevel / Inner Diagnostics --- OpcUa_DiagnosticsMasks_ServiceInnerDiagnostics
0x0000 0020 - OperationLevel / SymbolicId -------- OpcUa_DiagnosticsMasks_OperationSymbolicId
0x0000 0040 - OperationLevel / LocalizedText ----- OpcUa_DiagnosticsMasks_OperationLocalizedText
0x0000 0080 - OperationLevel / AdditionalInfo ---- OpcUa_DiagnosticsMasks_OperationAdditionalInfo
0x0000 0100 - OperationLevel / Inner StatusCode -- OpcUa_DiagnosticsMasks_OperationInnerStatusCode
0x0000 0200 - OperationLevel / Inner Diagnostics - OpcUa_DiagnosticsMasks_OperationInnerDiagnostics

You must extend your sample code with the following setting:
/*********************************************************************
Call Method
**********************************************************************/
// Request additional information in the diagnistic information
serviceSettings.returnDiagnostics = OpcUa_DiagnosticsMasks_OperationAdditionalInfo;

status = g_pUaSession->call(
serviceSettings, // Use default settings
callRequest, // In parameters and settings for the method call
callResult); // Out parameters and results returned from the method call
/*********************************************************************/

(2) Access to DiagnosticInformation if delivered
DiagnosticInformation is normally delivered in an parallel array to the StatusCode/result array. But several string fields of the DiagnosticInformation structure are not directly embedded in the structure. They just contain an index into a string table contained in the ServiceSettings object after the service call. It is contained in ServiceSettings:: stringTable.

AdditionalInformation (used in your example) is directly embedded in the DiagnosticInformation structure. But if you request other parts, and you get an array of DiagnosticInformation structures, you must extract the string form ServiceSettings:: stringTable using the index in the strucure.
!!!!
Be careful, the index is -1 if no string is provided.
!!!!

(3) DiagnosticInformation as part of UaStatus
Since the DiagnosticInformation is optional, you should not access the DiagnosticInformation pointer provided by the UaStatus class without checking for NULL. The pointer is NULL if no diagnostic information is available.

The assignment for the diagnostic information provided by the server for the call operation is missing in the UaSession::call implementation. This will be fixed for the next version or service release.
If you use the method UaSession::callList, you will get the additional info through the out parameter diagnosticInfos.

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

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

Re:Sending the AdditionalInfo through the UaStatus from server to client

Post by Support Team »

Hi,

The new service release for the C++ SDK (V1.3.2) is now available for download

http://www.unified-automation.com/opc-ua-servers/

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

Post Reply