opcua_encodingLayer.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * opcua_encodingLayer.c
  3. *
  4. * Created on: Jan 14, 2014
  5. * Author: opcua
  6. */
  7. #include "opcua_encodingLayer.h"
  8. #include "opcua_binaryEncDec.h"
  9. #include "opcua_types.h"
  10. #include "opcua_builtInDatatypes.h"
  11. /**
  12. * IntegerId
  13. * Part: 4
  14. * Chapter: 7.13
  15. * Page: 118
  16. */
  17. T_IntegerId convertToIntegerId(char* buf, Int32 *pos)
  18. {
  19. return convertToUInt32(buf, pos);
  20. }
  21. /**
  22. * DiagnosticInfo
  23. * Part: 4
  24. * Chapter: 7.9
  25. * Page: 116
  26. */
  27. Int32 convertToDiagnosticInfo(char* buf, Int32 *pos, T_DiagnosticInfo* dstDiagnosticInfo)
  28. {
  29. dstDiagnosticInfo->namespaceUri = convertToInt32(buf,pos);
  30. dstDiagnosticInfo->symbolicId = convertToInt32(buf, pos);
  31. dstDiagnosticInfo->locale = convertToInt32(buf, pos);
  32. dstDiagnosticInfo->localizesText = convertToInt32(buf, pos);
  33. convertToUAByteString(buf, pos, dstDiagnosticInfo->additionalInfo);
  34. dstDiagnosticInfo->innerStatusCode = convertToUAStatusCode(buf, pos);
  35. //If the Flag InnerDiagnosticInfo is set, then the DiagnosticInfo will be encoded
  36. if ((dstDiagnosticInfo->innerStatusCode & DIEMT_INNER_DIAGNOSTIC_INFO) == 1)
  37. {
  38. dstDiagnosticInfo->innerDiagnosticInfo = convertToTDiagnosticInfo(buf,
  39. pos);
  40. }
  41. return 0;
  42. }
  43. /**
  44. * RequestHeader
  45. * Part: 4
  46. * Chapter: 7.26
  47. * Page: 132
  48. */
  49. /** \copydoc decodeRequestHeader */
  50. Int32 decodeRequestHeader(const AD_RawMessage *srcRaw, Int32 *pos,
  51. T_RequestHeader *dstRequestHeader)
  52. {
  53. convertToUANodeId(srcRaw->message, pos,&(dstRequestHeader->authenticationToken));
  54. dstRequestHeader->timestamp = convertToUADateTime(srcRaw->message, pos);
  55. dstRequestHeader->requestHandle = convertToIntegerId(srcRaw->message, pos);
  56. dstRequestHeader->returnDiagnostics = convertToUInt32(srcRaw->message, pos);
  57. convertToUAString(srcRaw->message, pos, &dstRequestHeader->auditEntryId);
  58. dstRequestHeader->timeoutHint = convertToUInt32(srcRaw->message, pos);
  59. // AdditionalHeader will stay empty, need to be changed if there is relevant information
  60. return 0;
  61. }
  62. /**
  63. * ResponseHeader
  64. * Part: 4
  65. * Chapter: 7.27
  66. * Page: 133
  67. */
  68. /** \copydoc encodeResponseHeader */
  69. Int32 encodeResponseHeader(const T_ResponseHeader *responseHeader, Int32 *pos, AD_RawMessage *dstBuf)
  70. {
  71. return 0;
  72. }