#include "custom_datatypes.hpp"
int main() {
const auto& dataTypePoint = getPointDataType();
const auto& dataTypeMeasurements = getMeasurementsDataType();
const auto& dataTypeOpt = getOptDataType();
const auto& dataTypeUni = getUniDataType();
const auto& dataTypeColor = getColorDataType();
dataTypePoint,
dataTypeMeasurements,
dataTypeOpt,
dataTypeUni,
dataTypeColor,
});
structureDataTypeNode.
addDataType(dataTypePoint.getTypeId(),
"PointDataType");
structureDataTypeNode.
addDataType(dataTypeMeasurements.getTypeId(),
"MeasurementsDataType");
structureDataTypeNode.
addDataType(dataTypeOpt.getTypeId(),
"OptDataType");
structureDataTypeNode.
addDataType(dataTypeUni.getTypeId(),
"UniDataType");
enumerationDataTypeNode.
addDataType(dataTypeColor.getTypeId(),
"Color")
{0, 0},
"EnumValues",
.setArrayDimensions({0})
{0, {"", "Red"}, {}},
{1, {"", "Green"}, {}},
{2, {"", "Yellow"}, {}},
})
)
{1, 4243},
"PointType",
.setValueScalar(Point{1, 2, 3}, dataTypePoint)
);
auto variableTypeMeasurementNode = baseDataVariableTypeNode.
addVariableType(
{1, 4444},
"MeasurementsType",
.setValueScalar(Measurements{}, dataTypeMeasurements)
);
{1, 4645},
"OptType",
.setValueScalar(Opt{}, dataTypeOpt)
);
{1, 4846},
"UniType",
.setValueScalar(Uni{}, dataTypeUni)
);
const Point point{3.0, 4.0, 5.0};
{1, "Point"},
"Point",
.setValueScalar(point, dataTypePoint),
variableTypePointNode.id()
);
const std::vector<Point> pointVec{{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}};
{1, "PointVec"},
"PointVec",
.setArrayDimensions({0})
.setValueArray(pointVec, dataTypePoint),
variableTypePointNode.id()
);
std::vector<float> measurementsValues{19.1F, 20.2F, 19.7F};
const Measurements measurements{
measurementsValues.size(),
measurementsValues.data(),
};
{1, "Measurements"},
"Measurements",
.setValueScalar(measurements, dataTypeMeasurements),
variableTypeMeasurementNode.id()
);
float optC = 10.10F;
const Opt opt{3, nullptr, &optC};
{1, "Opt"},
"Opt",
.setValueScalar(opt, dataTypeOpt),
variableTypeOptNode.id()
);
Uni uni{};
uni.switchField = UniSwitch::OptionB;
{1, "Uni"},
"Uni",
.setValueScalar(uni, dataTypeUni),
variableTypeUniNode.id()
);
{1, "Color"},
"Color",
.setValueScalar(Color::Green, dataTypeColor)
);
}
UA_EnumValueType wrapper class.
High-level node class to access node attribute, browse and populate address space.
Node & addModellingRule(ModellingRule rule)
Add modelling rule.
Node addProperty(const NodeId &id, std::string_view browseName, const VariableAttributes &attributes={})
Add property.
Node addDataType(const NodeId &id, std::string_view browseName, const DataTypeAttributes &attributes={}, const NodeId &referenceType=ReferenceTypeId::HasSubtype)
Add data type.
Node addVariableType(const NodeId &id, std::string_view browseName, const VariableTypeAttributes &attributes={}, const NodeId &variableType=VariableTypeId::BaseDataVariableType, const NodeId &referenceType=ReferenceTypeId::HasSubtype)
Add variable type.
Node addVariable(const NodeId &id, std::string_view browseName, const VariableAttributes &attributes={}, const NodeId &variableType=VariableTypeId::BaseDataVariableType, const NodeId &referenceType=ReferenceTypeId::HasComponent)
Add variable.
void setCustomDataTypes(Span< const DataType > dataTypes)
Set custom data types.
void run()
Run the server's main loop. This method will block until Server::stop is called.
View to a contiguous sequence of objects, similar to std::span in C++20.
UA_VariableAttributes wrapper class.
auto & setDataType(const NodeId &dataType)
UA_VariableAttributes wrapper class.
auto & setDataType(const NodeId &dataType)
#define UA_STRING_STATIC(CHARS)