123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- #include "opcua_encodingLayer.h"
- #include "opcua_binaryEncDec.h"
- #include "opcua_types.h"
- #include "opcua_builtInDatatypes.h"
- T_IntegerId convertToIntegerId(char* buf, int pos){
- return convertToUInt32(buf, pos);
- }
- T_DiagnosticInfo convertToDiagnosticInfo(char* buf, int pos){
- T_DiagnosticInfo tmpTDiagnosticInfo;
- int counter = 0;
- tmpTDiagnosticInfo.namespaceUri = convertToInt32(buf, counter);
- counter += sizeof(tmpTDiagnosticInfo.namespaceUri);
- tmpTDiagnosticInfo.symbolicId = convertToInt32(buf, counter);
- counter += sizeof(tmpTDiagnosticInfo.symbolicId);
- tmpTDiagnosticInfo.locale = convertToInt32(buf, counter);
- counter += sizeof(tmpTDiagnosticInfo.locale);
- tmpTDiagnosticInfo.localizesText = convertToInt32(buf, counter);
- counter += sizeof(tmpTDiagnosticInfo.localizesText);
- tmpTDiagnosticInfo.additionalInfo = convertToUAString(buf, counter);
- counter += sizeof(tmpTDiagnosticInfo.additionalInfo);
- tmpTDiagnosticInfo.innerStatusCode = convertToUAStatusCode(buf, pos);
- counter += sizeof(tmpTDiagnosticInfo.innerStatusCode);
-
- if((tmpTDiagnosticInfo.innerStatusCode & DIEMT_INNER_DIAGNOSTIC_INFO) == 1){
- tmpTDiagnosticInfo.innerDiagnosticInfo = convertToTDiagnosticInfo(buf, counter);
- }
- return tmpTDiagnosticInfo;
- }
- T_RequestHeader decodeRequestHeader(char* buf)
- {
- T_RequestHeader tmpRequestHeader;
- int counter = 0;
-
-
- tmpRequestHeader.authenticationToken = convertToUANodeId(buf, counter);
- if (tmpRequestHeader.authenticationToken.EncodingByte == NIEVT_STRING)
- {
- counter =
- sizeof(tmpRequestHeader.authenticationToken.EncodingByte)
- + sizeof(tmpRequestHeader.authenticationToken.Namespace)
- + sizeof(tmpRequestHeader.authenticationToken.Identifier.String.Length)
- + sizeof(tmpRequestHeader.authenticationToken.Identifier.String.Data);
- }
- else
- {
- counter = sizeof(tmpRequestHeader.authenticationToken);
- }
- tmpRequestHeader.timestamp = convertToUADateTime(buf, counter);
- counter += sizeof(tmpRequestHeader.timestamp);
- tmpRequestHeader.requestHandle = convertToTIntegerId(buf, counter);
- counter += sizeof(tmpRequestHeader.requestHandle);
- tmpRequestHeader.returnDiagnostics = convertToUInt32(buf, counter);
- counter += sizeof(tmpRequestHeader.returnDiagnostics);
- tmpRequestHeader.auditEntryId = convertToUAString(buf, counter);
- counter += sizeof(tmpRequestHeader.auditEntryId);
- tmpRequestHeader.timeoutHint = convertToUInt32(buf, counter);
- counter += sizeof(tmpRequestHeader.timeoutHint);
-
- return tmpRequestHeader;
- }
- decodeResponseHeader(const T_ResponseHeader *responseHeader, AD_RawMessage *buf)
- {
- int counter = 0;
- responseHeader->timestamp = convertToUADateTime(buf->message, counter);
- counter += sizeof(responseHeader->timestamp);
- responseHeader->requestHandle = convertToTIntegerId(buf->message, counter);
- counter += sizeof(responseHeader->requestHandle);
- responseHeader->serviceResult = convertToUAStatusCode(buf->message, counter);
- counter += sizeof(responseHeader->serviceResult);
- responseHeader->serviceDiagnostics = convertToTDiagnosticInfo(buf->message, counter);
- }
- void decodeMessage_test()
- {
- char testMessage = {01,0x20,0xbe,0x01,0x20,0x20,0xf2,0xd6,0xd6,0xc9,0x01,0x00,0xbe,0x01,0x00,0x00,0xf2,0xd6,0xd6,0xc9,0x87,0x0b,0xcf,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0xe0,0x93,0x04,0x00,0x,0x};
- AD_RawMessage rawMessage;
- rawMessage.message = testMessage;
- rawMessage.length = 64;
- decodeMessage(testMessage);
- }
- UA_ExtensionObject processMessage(AD_RawMessage *rawMessage)
- {
- UA_NodeId tmpNodeId = convertToUANodeId(rawMessage,0);
-
- }
|