#include <iostream>
int main() {
int counter = 0;
server,
{1, 1000},
"Counter",
.setDataType<int>()
.setValueScalar(counter),
).value();
counter++;
if (timestamp) {
}
std::cout << "Read counter from data source: " << counter << "\n";
};
std::cout << "Write counter to data source: " << counter << "\n";
};
}
UA_DataValue wrapper class.
void setSourceTimestamp(DateTime sourceTimestamp) noexcept
Set source timestamp for the value.
Variant & getValue() &noexcept
Get value.
static DateTime now() noexcept
Get current DateTime.
Numeric range to indicate subsets of (multidimensional) arrays.
void setVariableNodeValueBackend(const NodeId &id, ValueBackendDataSource backend)
Set data source backend for variable node.
void run()
Run the server's main loop. This method will block until Server::stop is called.
UA_VariableAttributes wrapper class.
auto & setAccessLevel(Bitmask< AccessLevel > accessLevel) noexcept
T getScalarCopy() const
Get copy of scalar value with given template type.
void setScalarCopy(const T &value)
Copy scalar value to variant.
#define UA_ACCESSLEVELMASK_READ
#define UA_ACCESSLEVELMASK_WRITE
Result< NodeId > addVariable(T &connection, const NodeId &parentId, const NodeId &id, std::string_view browseName, const VariableAttributes &attributes, const NodeId &variableType, const NodeId &referenceType) noexcept
Add variable.
#define UA_STATUSCODE_GOOD
Data source backend for variable nodes.
std::function< StatusCode(DataValue &value, const NumericRange &range, bool timestamp)> read
Callback to set the read value, the result status and optionally a source timestamp.
std::function< StatusCode(const DataValue &value, const NumericRange &range)> write
Callback to write the value into a data source.