S2OPC OPCUA Toolkit
|
Interface of an example client library supporting the subscription management. More...
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | SOPC_LibSub_Value |
Structure defining the value of a node. More... | |
struct | SOPC_LibSub_StaticCfg |
Static configuration of OPC client library. More... | |
struct | SOPC_LibSub_ConnectionCfg |
Connection configuration to a remote OPC server. More... | |
Typedefs | |
typedef uint32_t | SOPC_StatusCode |
typedef enum SOPC_ReturnStatus | SOPC_ReturnStatus |
typedef char * | SOPC_LibSub_String |
typedef const char * | SOPC_LibSub_CstString |
typedef uint32_t | SOPC_LibSub_ConfigurationId |
typedef uint32_t | SOPC_LibSub_ConnectionId |
typedef uint32_t | SOPC_LibSub_DataId |
typedef uint64_t | SOPC_LibSub_Timestamp |
typedef uint32_t | SOPC_LibSub_AttributeId |
AttributeIds, as defined in the OPC UA Reference, Part 6 Annex A. More... | |
typedef enum SOPC_LibSub_ApplicativeEvent | SOPC_LibSub_ApplicativeEvent |
The event passed to the connection SOPC_LibSub_EventCbk. Either an error or a valid response notification. More... | |
typedef void | SOPC_LibSub_LogCbk(const SOPC_Log_Level log_level, SOPC_LibSub_CstString text) |
Log callback type. More... | |
typedef void | SOPC_LibSub_DisconnectCbk(const SOPC_LibSub_ConnectionId c_id) |
Callback type for disconnect event. More... | |
typedef void | SOPC_LibSub_DataChangeCbk(const SOPC_LibSub_ConnectionId c_id, const SOPC_LibSub_DataId d_id, const SOPC_LibSub_Value *value) |
Callback type for data change event (related to a subscription) More... | |
typedef void | SOPC_LibSub_EventCbk(SOPC_LibSub_ConnectionId c_id, SOPC_LibSub_ApplicativeEvent event, SOPC_StatusCode status, const void *response, uintptr_t responseContext) |
Callback for generic responses to a call to SOPC_LibSub_AsyncSendRequestOnSession(). More... | |
Functions | |
void | SOPC_Sleep (unsigned int milliseconds) |
SOPC_LibSub_CstString | SOPC_LibSub_GetVersion (void) |
Return the current version of the library. More... | |
SOPC_ReturnStatus | SOPC_LibSub_Initialize (const SOPC_LibSub_StaticCfg *pCfg) |
Configure the library. This function shall be called once by the host application before any other service can be used. More... | |
void | SOPC_LibSub_Clear (void) |
Clears the connections, configurations, and clears the Toolkit. More... | |
SOPC_ReturnStatus | SOPC_LibSub_ConfigureConnection (const SOPC_LibSub_ConnectionCfg *pCfg, SOPC_LibSub_ConfigurationId *pCfgId) |
Configure a future connection. This function shall be called once per connection before a call to SOPC_LibSub_Configured(). The given /p pCfgId is later used to create connections. More... | |
SOPC_ReturnStatus | SOPC_LibSub_Configured (void) |
Mark the library as configured. All calls to SOPC_LibSub_ConfigureConnection() shall be done prior to calling this function. All calls to SOPC_LibSub_Connect() shall be done after calling this function. More... | |
SOPC_ReturnStatus | SOPC_LibSub_Connect (const SOPC_LibSub_ConfigurationId cfgId, SOPC_LibSub_ConnectionId *pCliId) |
Creates a new connection to a remote OPC server from configuration id cfg_id. The connection represent the whole client and is later identified by the returned cli_id. A subscription is created and associated with this client. The function waits until the client is effectively connected and the subscription created, or the Toolkit times out. More... | |
SOPC_ReturnStatus | SOPC_LibSub_AddToSubscription (const SOPC_LibSub_ConnectionId cliId, const SOPC_LibSub_CstString *lszNodeId, const SOPC_LibSub_AttributeId *lattrId, int32_t nElements, SOPC_LibSub_DataId *lDataId) |
Add variables to the subscription of the connection. This call is synchroneous: it waits for the server response, or the Toolkit times out. The connection timeout is also used for this function. More... | |
SOPC_ReturnStatus | SOPC_LibSub_AsyncSendRequestOnSession (SOPC_LibSub_ConnectionId cliId, void *requestStruct, uintptr_t requestContext) |
Sends a generic request on the connection. The request must be accepted by the SOPC encoders (OpcUa_<MessageStruct>*) which are defined in "sopc_types.h". Upon response, the SOPC_LibSub_EventCbk callback configured with this connection is called with the OpcUa response. More... | |
SOPC_ReturnStatus | SOPC_LibSub_Disconnect (const SOPC_LibSub_ConnectionId cliId) |
Disconnect from a remote OPC server. The function waits until the client is effectively disconnected, or the Toolkit times out. More... | |
void | Helpers_Log (const SOPC_Log_Level log_level, const char *format,...) |
Buffers a log message, then calls the callback configured with the LibSub. More... | |
void | Helpers_LoggerStdout (const SOPC_Log_Level log_level, const SOPC_LibSub_CstString text) |
Helper logger, prints a log message to stdout, with the following format "# log_level: text\n". More... | |
Interface of an example client library supporting the subscription management.
The functions of this interface are threadsafe, except stated otherwise.
#define SOPC_SecurityPolicy_None_URI "http://opcfoundation.org/UA/SecurityPolicy#None" |
#define SOPC_SecurityPolicy_Basic256_URI "http://opcfoundation.org/UA/SecurityPolicy#Basic256" |
#define SOPC_SecurityPolicy_Basic256Sha256_URI "http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256" |
#define SOPC_SecurityPolicy_Aes128Sha256RsaOaep_URI "http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep" |
#define SOPC_SecurityPolicy_Aes256Sha256RsaPss_URI "http://opcfoundation.org/UA/SecurityPolicy#Aes256_Sha256_RsaPss" |
#define SOPC_LibSub_AttributeId_NodeId 1 |
#define SOPC_LibSub_AttributeId_NodeClass 2 |
#define SOPC_LibSub_AttributeId_BrowseName 3 |
#define SOPC_LibSub_AttributeId_DisplayName 4 |
#define SOPC_LibSub_AttributeId_Description 5 |
#define SOPC_LibSub_AttributeId_WriteMask 6 |
#define SOPC_LibSub_AttributeId_UserWriteMask 7 |
#define SOPC_LibSub_AttributeId_IsAbstract 8 |
#define SOPC_LibSub_AttributeId_Symmetric 9 |
#define SOPC_LibSub_AttributeId_InverseName 10 |
#define SOPC_LibSub_AttributeId_ContainsNoLoops 11 |
#define SOPC_LibSub_AttributeId_EventNotifier 12 |
#define SOPC_LibSub_AttributeId_Value 13 |
#define SOPC_LibSub_AttributeId_DataType 14 |
#define SOPC_LibSub_AttributeId_ValueRank 15 |
#define SOPC_LibSub_AttributeId_ArrayDimensions 16 |
#define SOPC_LibSub_AttributeId_AccessLevel 17 |
#define SOPC_LibSub_AttributeId_UserAccessLevel 18 |
#define SOPC_LibSub_AttributeId_MinimumSamplingInterval 19 |
#define SOPC_LibSub_AttributeId_Historizing 20 |
#define SOPC_LibSub_AttributeId_Executable 21 |
#define SOPC_LibSub_AttributeId_UserExecutable 22 |
typedef uint32_t SOPC_StatusCode |
typedef enum SOPC_ReturnStatus SOPC_ReturnStatus |
typedef char* SOPC_LibSub_String |
typedef const char* SOPC_LibSub_CstString |
typedef uint32_t SOPC_LibSub_ConfigurationId |
typedef uint32_t SOPC_LibSub_ConnectionId |
typedef uint32_t SOPC_LibSub_DataId |
typedef uint64_t SOPC_LibSub_Timestamp |
typedef uint32_t SOPC_LibSub_AttributeId |
AttributeIds, as defined in the OPC UA Reference, Part 6 Annex A.
typedef enum SOPC_LibSub_ApplicativeEvent SOPC_LibSub_ApplicativeEvent |
The event passed to the connection SOPC_LibSub_EventCbk. Either an error or a valid response notification.
typedef void SOPC_LibSub_LogCbk(const SOPC_Log_Level log_level, SOPC_LibSub_CstString text) |
Log callback type.
log_level | The Log level (SOPC_Log_Level). Note: SOPC_log_error shall be non-returning. |
text | The text string to log (shall not be null) |
typedef void SOPC_LibSub_DisconnectCbk(const SOPC_LibSub_ConnectionId c_id) |
Callback type for disconnect event.
c_id | The connection id that has been disconnected |
typedef void SOPC_LibSub_DataChangeCbk(const SOPC_LibSub_ConnectionId c_id, const SOPC_LibSub_DataId d_id, const SOPC_LibSub_Value *value) |
Callback type for data change event (related to a subscription)
c_id | The connection id on which the datachange happened |
d_id | The data id of the monitored item (see SOPC_LibSub_AddToSubscription()) |
value | The new value. Its content is freed by the LibSub after this function has been called, hence the callback must copy it if it should be used outside the callback. The NULL pointer is given to the callback when the SOPC_DataValue could not be converted to a SOPC_LibSub_Value, or the malloc failed. |
typedef void SOPC_LibSub_EventCbk(SOPC_LibSub_ConnectionId c_id, SOPC_LibSub_ApplicativeEvent event, SOPC_StatusCode status, const void *response, uintptr_t responseContext) |
Callback for generic responses to a call to SOPC_LibSub_AsyncSendRequestOnSession().
c_id | The connection id on which the event happened |
event | The type of the event:
|
status | The status code for the event |
response | An (OpcUa_<MessageStruct>*) pointing to the OPC-UA response structure. This message is freed by the caller and should not be modified by the callback function. |
responseContext | The requestContext given in SOPC_LibSub_AsyncSendRequestOnSession(). |
enum SOPC_ReturnStatus |
enum SOPC_Log_Level |
enum SOPC_UserPolicyId |
enum SOPC_LibSub_DataType |
void SOPC_Sleep | ( | unsigned int | milliseconds | ) |
SOPC_LibSub_CstString SOPC_LibSub_GetVersion | ( | void | ) |
Return the current version of the library.
SOPC_ReturnStatus SOPC_LibSub_Initialize | ( | const SOPC_LibSub_StaticCfg * | pCfg | ) |
Configure the library. This function shall be called once by the host application before any other service can be used.
pCfg | Non null pointer to the static configuration. The content of the configuration is copied and the object pointed by /p pCfg can be freed by the caller. |
void SOPC_LibSub_Clear | ( | void | ) |
Clears the connections, configurations, and clears the Toolkit.
SOPC_ReturnStatus SOPC_LibSub_ConfigureConnection | ( | const SOPC_LibSub_ConnectionCfg * | pCfg, |
SOPC_LibSub_ConfigurationId * | pCfgId | ||
) |
Configure a future connection. This function shall be called once per connection before a call to SOPC_LibSub_Configured(). The given /p pCfgId is later used to create connections.
pCfg | Non null pointer to the connection configuration. The content of the configuration is copied and the object pointed by /p pCfg can be freed by the caller. | |
[out] | pCfgId | The configuration connection id. Set when the value returned is "SOPC_STATUS_OK". |
SOPC_ReturnStatus SOPC_LibSub_Configured | ( | void | ) |
Mark the library as configured. All calls to SOPC_LibSub_ConfigureConnection() shall be done prior to calling this function. All calls to SOPC_LibSub_Connect() shall be done after calling this function.
SOPC_ReturnStatus SOPC_LibSub_Connect | ( | const SOPC_LibSub_ConfigurationId | cfgId, |
SOPC_LibSub_ConnectionId * | pCliId | ||
) |
Creates a new connection to a remote OPC server from configuration id cfg_id. The connection represent the whole client and is later identified by the returned cli_id. A subscription is created and associated with this client. The function waits until the client is effectively connected and the subscription created, or the Toolkit times out.
cfgId | The parameters of the connection to create, return by SOPC_LibSub_ConfigureConnection(). | |
[out] | pCliId | The connection id of the newly created client, set when return is SOPC_STATUS_OK. |
SOPC_ReturnStatus SOPC_LibSub_AddToSubscription | ( | const SOPC_LibSub_ConnectionId | cliId, |
const SOPC_LibSub_CstString * | lszNodeId, | ||
const SOPC_LibSub_AttributeId * | lattrId, | ||
int32_t | nElements, | ||
SOPC_LibSub_DataId * | lDataId | ||
) |
Add variables to the subscription of the connection. This call is synchroneous: it waits for the server response, or the Toolkit times out. The connection timeout is also used for this function.
cliId | The connection id. | |
lszNodeId | An array of zero-terminated strings describing the NodeIds to add. It should be at least nElements long. | |
lattrId | An array of attributes id. The subscription is created for the attribute lAttrId[i] for the node id lszNodeId[i]. It should be at least nElements long. | |
nElements | The number of elements in previous arrays. | |
[out] | lDataId | A pre-allocated array to the output unique variable data identifiers. It should be at least nElements long. The values will be used in call to data_change_callback. |
SOPC_ReturnStatus SOPC_LibSub_AsyncSendRequestOnSession | ( | SOPC_LibSub_ConnectionId | cliId, |
void * | requestStruct, | ||
uintptr_t | requestContext | ||
) |
Sends a generic request on the connection. The request must be accepted by the SOPC encoders (OpcUa_<MessageStruct>*) which are defined in "sopc_types.h". Upon response, the SOPC_LibSub_EventCbk callback configured with this connection is called with the OpcUa response.
cliId | The connection id. |
requestStruct | OPC UA message payload structure pointer (OpcUa_<MessageStruct>*). Deallocated by toolkit. |
requestContext | A context value, it will be provided in the callback alongside the corresponding response. |
SOPC_ReturnStatus SOPC_LibSub_Disconnect | ( | const SOPC_LibSub_ConnectionId | cliId | ) |
Disconnect from a remote OPC server. The function waits until the client is effectively disconnected, or the Toolkit times out.
cliId | The connection id to disconnect |
void Helpers_Log | ( | const SOPC_Log_Level | log_level, |
const char * | format, | ||
... | |||
) |
Buffers a log message, then calls the callback configured with the LibSub.
void Helpers_LoggerStdout | ( | const SOPC_Log_Level | log_level, |
const SOPC_LibSub_CstString | text | ||
) |
Helper logger, prints a log message to stdout, with the following format "# log_level: text\n".