in_a_nutshell.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. .. _introduction:
  2. Introduction to OPC UA
  3. ======================
  4. OPC UA, a collection of services
  5. --------------------------------
  6. In OPC UA, all communication is based on service calls, each consisting of a request and a response
  7. message. Be careful to note the difference between services and methods. Services are pre-defined in
  8. the standard and cannot be changed. But you can use the *Call* service to invoke user-defined
  9. methods on the server.
  10. For completeness, the following tables contain all services defined in the standard. Do not bother
  11. with their details yet. We will introduce the different services later in the text. In open62541,
  12. each service is implemented in a single function. See the \ref services section for details.
  13. **Establishing communication**
  14. +-----------------------------+-----------------------------+------------------------------+
  15. | Discovery Service Set | SecureChannel Service Set | Session Service Set |
  16. +=============================+=============================+==============================+
  17. | FindServers | OpenSecureChannel | CreateSession |
  18. +-----------------------------+-----------------------------+------------------------------+
  19. | GetEndpoints | CloseSecureChannel | ActivateSession |
  20. +-----------------------------+-----------------------------+------------------------------+
  21. | RegisterServer | | CloseSession |
  22. +-----------------------------+-----------------------------+------------------------------+
  23. | | | Cancel |
  24. +-----------------------------+-----------------------------+------------------------------+
  25. **Interaction with the information model**
  26. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  27. | Attribute Service Set | View Service Set | Method Service Set | NodeManagement Service Set | Query Service Set |
  28. +=============================+===============================+==============================+==============================+======================+
  29. | Read | Browse | Call | AddNodes | QueryFirst |
  30. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  31. | HistoryRead | BrowseNext | | AddReferences | QueryNext |
  32. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  33. | Write | TranslateBrowsePathsToNodeids | | DeleteNodes | |
  34. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  35. | HistoryUpdate | RegisterNodes | | DeleteReferences | |
  36. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  37. | | UnregisterNodes | | | |
  38. +-----------------------------+-------------------------------+------------------------------+------------------------------+----------------------+
  39. **Notifications**
  40. +-----------------------------+-------------------------------+
  41. | MonitoredItem Service Set | Subscription Service Set |
  42. +=============================+===============================+
  43. | CreateMonitoredItems | CreateSubscription |
  44. +-----------------------------+-------------------------------+
  45. | ModifyMonitoreditems | ModifySubscription |
  46. +-----------------------------+-------------------------------+
  47. | SetMonitoringMode | SetPublishingMode |
  48. +-----------------------------+-------------------------------+
  49. | SetTriggering | Publish |
  50. +-----------------------------+-------------------------------+
  51. | DeleteMonitoredItems | Republish |
  52. +-----------------------------+-------------------------------+
  53. | | TransferSubscription |
  54. +-----------------------------+-------------------------------+
  55. | | DeleteSubscription |
  56. +-----------------------------+-------------------------------+
  57. OPC UA, a web of nodes
  58. ----------------------
  59. The information model in each OPC UA server is a web of interconnected nodes.
  60. There are eight different types of nodes.
  61. +-----------------------+-------------------+
  62. | ReferenceTypeNode | MethodNode |
  63. +-----------------------+-------------------+
  64. | DataTypeNode | ObjectTypeNode |
  65. +-----------------------+-------------------+
  66. | VariableTypeNode | ObjectNode |
  67. +-----------------------+-------------------+
  68. | VariableNode | ViewNode |
  69. +-----------------------+-------------------+
  70. Depending on its type, every node contains different attributes. Some
  71. attributes, are contained in all node types:
  72. +----------------+---------------+
  73. | Name | Type |
  74. +================+===============+
  75. | nodeID | NodeId |
  76. +----------------+---------------+
  77. | nodeClass | NodeClass |
  78. +----------------+---------------+
  79. | browseName | QualifiedName |
  80. +----------------+---------------+
  81. | displayName | LocalizedText |
  82. +----------------+---------------+
  83. | description | LocalizedText |
  84. +----------------+---------------+
  85. | writeMask | UInt32 |
  86. +----------------+---------------+
  87. | userWriteMask | UInt32 |
  88. +----------------+---------------+
  89. | referencesSize | Int32 |
  90. +----------------+---------------+
  91. | references |ReferenceNode[]|
  92. +----------------+---------------+
  93. Nodes are interconnected by directed reference-triples of the form ``(nodeid,
  94. referencetype, target-nodeid)``. Therefore an OPC UA information model is
  95. easiest imagined as a *web of nodes*. Reference types can be
  96. - standard- or user-defined and
  97. - either non-hierarchical (e.g., indicating the type of a variable-node) or
  98. hierarchical (e.g., indicating a parent-child relationship).
  99. OPC UA, a protocol
  100. ------------------
  101. The OPC UA protocol (both binary and XML-based) is based on 25 *built-in*
  102. datatypes. In open62541, these are defined in ua_types.h.
  103. The builtin datatypes are combined to more complex structures. When the structure contains an array,
  104. then the size of the array is stored in an Int32 value just before the array itself. A size of -1
  105. indicates an undefined array. Positive sizes (and zero) have the usual semantics.
  106. Most importantly, every service has a request and a response message defined as such a data
  107. structure. The entire OPC UA protocol revolves around the exchange of these request and response
  108. messages. Their exact definitions can be looked up here:
  109. https://opcfoundation.org/UA/schemas/Opc.Ua.Types.bsd.xml. In open62541, we autogenerate the
  110. C-structs to handle the standard-defined structures automatically. See ua_types_generated.h for
  111. comparison.