S2OPC OPCUA Toolkit
|
High level interface to run an OPC UA server. More...
Go to the source code of this file.
Typedefs | |
typedef void | SOPC_ServerStopped_Fct(SOPC_ReturnStatus status) |
Type of callback called when server stopped. More... | |
Functions | |
SOPC_ReturnStatus | SOPC_ServerHelper_StartServer (SOPC_ServerStopped_Fct *stoppedCb) |
Starts the server asynchronously. Server information node is updated and endpoints are asynchronously requested to be opened. More... | |
SOPC_ReturnStatus | SOPC_ServerHelper_StopServer (void) |
Call to stop the server started with SOPC_ServerHelper_StartServer. If server started with SOPC_ServerHelper_StartServer, this call is blocking during shutdown phase and SOPC_ServerStopped_Fct is called on actual shutdown. Caller is responsible to wait for SOPC_ServerStopped_Fct call prior to use any SOPC_ServerConfigHelper_Clear function. If server started with SOPC_ServerHelper_Serve, this call is asynchronous and server is actually stopped on SOPC_ServerHelper_Serve return (after shutdown phase). More... | |
SOPC_ReturnStatus | SOPC_ServerHelper_Serve (bool catchSigStop) |
Runs the server synchronously (alternative to SOPC_ServerHelper_StartServer) Server information node is updated and endpoints are opened. Run until requested to stop (call to SOPC_ServerHelper_StopServer or signal stop if active) or on endpoint opening error. More... | |
SOPC_ReturnStatus | SOPC_ServerHelper_LocalServiceAsync (void *request, uintptr_t userContext) |
Executes a local OPC UA service on server (read, write, browse or discovery service) asynchronously. On local service response callback configured through SOPC_ServerConfigHelper_SetLocalServiceAsyncResponse will be called. More... | |
SOPC_ReturnStatus | SOPC_ServerHelper_LocalServiceSync (void *request, void **response) |
Executes a local OPC UA service on server (read, write, browse or discovery service) synchronously. More... | |
SOPC_ReturnStatus | SOPC_ServerHelper_CreateEvent (const SOPC_NodeId *eventTypeId, SOPC_Event **event) |
Creates an event instance for the given event type referenced. The EventId value is set to a unique value by this function prior to returning the new event instance. Caller is responsible for event deallocation. More... | |
SOPC_ReturnStatus | SOPC_ServerHelper_TriggerEvent (const SOPC_NodeId *notifierNodeId, SOPC_Event *event, uint32_t optSubscriptionId, uint32_t optMonitoredItemId) |
Triggers the given event from the given node as notifier. More... | |
High level interface to run an OPC UA server.
Once the server is configured using functions of libs2opc_server_config.h, the server should be started using SOPC_ServerHelper_StartServer (or SOPC_ServerHelper_Serve). Until it is stopped by call to SOPC_ServerHelper_StopServer or due to an error (listening address busy, etc.), the server is then accessible for connections by OPC UA client applications and local access/modification of address space content by server application itself. This is done using same OPC UA services client are using but in a local way called "local services" in this server API trough SOPC_ServerHelper_LocalServiceAsync (or SOPC_ServerHelper_LocalServiceSync)
typedef void SOPC_ServerStopped_Fct(SOPC_ReturnStatus status) |
Type of callback called when server stopped.
status | Indicates the return status of server, SOPC_STATUS_OK if stopped on purpose. |
SOPC_ReturnStatus SOPC_ServerHelper_StartServer | ( | SOPC_ServerStopped_Fct * | stoppedCb | ) |
Starts the server asynchronously. Server information node is updated and endpoints are asynchronously requested to be opened.
stoppedCb | callback called when server will stop (on purpose or due to endpoint opening isssue), it is mandatory to define it and to wait it is called after call to SOPC_ServerHelper_StopServer. |
SOPC_ReturnStatus SOPC_ServerHelper_StopServer | ( | void | ) |
Call to stop the server started with SOPC_ServerHelper_StartServer. If server started with SOPC_ServerHelper_StartServer, this call is blocking during shutdown phase and SOPC_ServerStopped_Fct is called on actual shutdown. Caller is responsible to wait for SOPC_ServerStopped_Fct call prior to use any SOPC_ServerConfigHelper_Clear function. If server started with SOPC_ServerHelper_Serve, this call is asynchronous and server is actually stopped on SOPC_ServerHelper_Serve return (after shutdown phase).
SOPC_ReturnStatus SOPC_ServerHelper_Serve | ( | bool | catchSigStop | ) |
Runs the server synchronously (alternative to SOPC_ServerHelper_StartServer) Server information node is updated and endpoints are opened. Run until requested to stop (call to SOPC_ServerHelper_StopServer or signal stop if active) or on endpoint opening error.
catchSigStop | If set to true, the stop signal (Ctrl+C) is caught and server shutdown initiated. When flag is set the server will stop on first event occurring between stop signal and call to SOPC_ServerHelper_StopServer. |
SOPC_ReturnStatus SOPC_ServerHelper_LocalServiceAsync | ( | void * | request, |
uintptr_t | userContext | ||
) |
Executes a local OPC UA service on server (read, write, browse or discovery service) asynchronously. On local service response callback configured through SOPC_ServerConfigHelper_SetLocalServiceAsyncResponse will be called.
request | An instance of the following OPC UA requests: |
The request messages can be built using the helper functions of libs2opc_request_builder.h (e.g.: SOPC_ReadRequest_Create, SOPC_ReadRequest_SetReadValue, etc.).
userContext | User defined context that will be provided with the corresponding response in SOPC_LocalServiceAsyncResp_Fct |
SOPC_ReturnStatus SOPC_ServerHelper_LocalServiceSync | ( | void * | request, |
void ** | response | ||
) |
Executes a local OPC UA service on server (read, write, browse or discovery service) synchronously.
request | An instance of on of the following OPC UA request: |
The request messages can be built using the helper functions of libs2opc_request_builder.h (e.g.: SOPC_ReadRequest_Create, SOPC_ReadRequest_SetReadValue, etc.). Note: it shall be allocated on heap since it will be freed by S2OPC library during treatment.
[out] | response | Pointer into which instance of response complying with the OPC UA request is provided:
response.encodeableType points to OpcUa_ServiceFault_EncodeableType and SOPC_IsGoodStatus(response.ResponseHeader.ServiceResult ) is false . |
SOPC_ReturnStatus SOPC_ServerHelper_CreateEvent | ( | const SOPC_NodeId * | eventTypeId, |
SOPC_Event ** | event | ||
) |
Creates an event instance for the given event type referenced. The EventId value is set to a unique value by this function prior to returning the new event instance. Caller is responsible for event deallocation.
eventTypeId | The NodeId of the event type to instantiate | |
[out] | event | A pointer set to the newly allocated event instance |
SOPC_ReturnStatus SOPC_ServerHelper_TriggerEvent | ( | const SOPC_NodeId * | notifierNodeId, |
SOPC_Event * | event, | ||
uint32_t | optSubscriptionId, | ||
uint32_t | optMonitoredItemId | ||
) |
Triggers the given event from the given node as notifier.
notifierNodeId | NodeId of the node notifier for the triggered event |
event | The event to be triggered |
optSubscriptionId | (optional) The subscriptionId for which the event is triggered or 0. |
optMonitoredItemId | (optional) The monitored item Id for which the event is triggered or 0. |
Note: the provided event and its content are automatically deallocated by callee