ifw-core 5.0.1
|
#include <open62541.hpp>
Public Member Functions | |
Open62541 () | |
virtual | ~Open62541 () |
virtual void | Connect (const std::string &device, const std::string &address) |
Establish the connection to the OPCUA server. | |
virtual void | Read (protocol::base::VectorVariant ¶ms) override |
Performs a Read operation. | |
virtual void | Write (const protocol::base::VectorVariant ¶ms) override |
Performs a Write operation. | |
virtual void | Rpc (const std::string &obj, const std::string &proc, const protocol::base::VectorVariant ¶ms, protocol::base::Variant &result) override |
Executes a RPC. | |
UA_StatusCode | ResumeSubscriptions () |
Resume subscriptions for all connections. | |
virtual void | StartMonitorItem (const std::string &item) override |
Start monitoring an attribute. | |
virtual void | StartMonitorItems (const std::vector< std::string > &item_vector) override |
Start monitoring a vector of attributes. | |
virtual void | StopMonitorItem (const std::string &item) override |
Stop monitoring an attribute. | |
virtual void | Disconnect () |
Disconnects from the server. | |
virtual void | RegisterCB (protocol::base::Dispatcher< protocol::base::VectorVariant & > &dispatcher, protocol::base::Dispatcher<> &failure, protocol::base::Dispatcher<> &normal) |
Registers internal and external callbacks. | |
void | SetEndpoint (const std::string &endpoint) |
Set endpoint to the connection. | |
std::string | GetEndpoint () const |
Get endpoint of the connection. | |
virtual void | HandleDataChange (const std::shared_ptr< MonitoredItem > monitor_item, UA_DataValue *value) |
Handle data changes. | |
virtual void | HandleSessionChanges (bool status) |
Handle changes in the OPCUA session. | |
void | UpdateState (UA_SecureChannelState channel_state, UA_SessionState session_state, UA_StatusCode recovery_status) |
Update connection state. | |
![]() | |
virtual void | Connect (const std::string &device, const std::string &address)=0 |
virtual void | Read (VectorVariant ¶ms)=0 |
virtual void | Write (const VectorVariant ¶ms)=0 |
virtual void | Rpc (const std::string &obj, const std::string &proc, const VectorVariant ¶ms, Variant &result)=0 |
virtual void | Disconnect ()=0 |
virtual void | StartMonitorItem (const std::string &item)=0 |
virtual void | StartMonitorItems (const std::vector< std::string > &item_vector)=0 |
virtual void | StopMonitorItem (const std::string &item)=0 |
virtual void | RegisterCB (protocol::base::Dispatcher< protocol::base::VectorVariant & > &dispatcher, protocol::base::Dispatcher<> &failure, protocol::base::Dispatcher<> &normal)=0 |
virtual | ~IComm () |
![]() | |
virtual | ~IDataChangeHandler () |
~IDataChangeHandler | |
virtual void | HandleDataChange (const std::shared_ptr< MonitoredItem > monitor_item, UA_DataValue *value)=0 |
HandleDataChanges. | |
Static Public Attributes | |
static std::map< std::string, std::shared_ptr< OpcuaConnection > > | m_connection_map |
The Open62541 class.
This class encapsulates the Open62541 OPCUA functions used by ICS FW devices. Each device shall create one instance of this class. If a device is running in the same server as another existing device, then this connection will be reused avoiding creating multiple connections for the same server.
protocol::opcua::Open62541::Open62541 | ( | ) |
|
virtual |
|
virtual |
Establish the connection to the OPCUA server.
device | Name of the device |
address | Address of the OPCUA Server |
Implements protocol::base::IComm.
|
virtual |
Disconnects from the server.
exceptions | for error cases. |
Implements protocol::base::IComm.
std::string protocol::opcua::Open62541::GetEndpoint | ( | ) | const |
Get endpoint of the connection.
|
virtual |
Handle data changes.
monitored_item | Pointer to the monitored item generating the change. |
value | Vector containing the values of the data changes. |
Implements protocol::opcua::IDataChangeHandler.
|
virtual |
Handle changes in the OPCUA session.
status | Status of the session. |
|
overridevirtual |
Performs a Read operation.
params | Vector of attributes to be read. |
exceptions | for error cases. |
Implements protocol::base::IComm.
|
virtual |
Registers internal and external callbacks.
dispatcher | Vector of device callbacks. |
failure | Callback for session problems. |
normal | Callback for session recovery. |
exceptions | for error cases. |
Implements protocol::base::IComm.
UA_StatusCode protocol::opcua::Open62541::ResumeSubscriptions | ( | ) |
Resume subscriptions for all connections.
This method shall be called only to recover subscriptions after loosing the session, e.g. for a connection lost.
|
overridevirtual |
Executes a RPC.
obj | of attributes to write. |
proc | Vector of attributes to write. |
params | Vector of pameters to the RPC to be executed. |
result | resulting value given by the RPC. |
exceptions | for error cases. |
Implements protocol::base::IComm.
void protocol::opcua::Open62541::SetEndpoint | ( | const std::string & | endpoint | ) |
Set endpoint to the connection.
|
overridevirtual |
Start monitoring an attribute.
item | Attribute to be monitored. |
The format expected is <namespace, name> e.g. 4, PLC1.Lamp1.stat.nState
The above means, the library only supports string based names.
exceptions | for error cases. |
Implements protocol::base::IComm.
|
overridevirtual |
Start monitoring a vector of attributes.
item_vector | Vector of attributes to be monitored. |
Each attribute in the vector is expected to have the format <namespace, name> e.g. 4, PLC1.Lamp1.stat.nState
The above means, the library only supports string based names.
exceptions | for error cases. |
Implements protocol::base::IComm.
|
overridevirtual |
Stop monitoring an attribute.
item | Attribute to be removed. |
exceptions | for error cases. |
Implements protocol::base::IComm.
void protocol::opcua::Open62541::UpdateState | ( | UA_SecureChannelState | channel_state, |
UA_SessionState | session_state, | ||
UA_StatusCode | recovery_status | ||
) |
Update connection state.
|
overridevirtual |
Performs a Write operation.
params | Vector of attributes to write. |
exceptions | for error cases. |
Implements protocol::base::IComm.
|
inlinestatic |
static map of connections. Multiples objects of this class may share the same connection. This is a typical case when several controllers are handled by one PLC.