You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

#ifndef OPCUA_CLIENT_H
#define OPCUA_CLIENT_H
#include <open62541/client_config_default.h>
#include <open62541/client_highlevel.h>
#include <string>
#include <vector>
#include <iostream>
// Structure for storing node information for the browser
struct OpcNodeInfo {
std::string name;
uint16_t nsIndex;
uint32_t numericId;
std::string stringId;
bool isStringId;
uint32_t nodeClass; // e.g. UA_NODECLASS_VARIABLE or UA_NODECLASS_OBJECT
};
class OPCUAClient {
public:
OPCUAClient();
~OPCUAClient();
// Establishes a connection to the server
bool Connect(const std::string& endpointUrl);
// Lists the child nodes of a specific node (default: Objects folder)
std::vector<OpcNodeInfo> GenList(uint16_t namespaceIndex = 0, uint32_t numericNodeId = 85);
// Reads the value of a string-based node
std::string ReadString(uint16_t namespaceIndex, const std::string& stringNodeId);
// Reads the value of a numeric node (new for the browser)
std::string ReadNumeric(uint16_t namespaceIndex, uint32_t numericNodeId);
// Closes the connection
void Close();
private:
UA_Client* client;
bool isConnected;
};
#endif // OPCUA_CLIENT_H