Hello
I Need help: How is an Image (type 30) or bmp, jpg image variable created, without constructor of BaseDataVariableType using the XmlUaNodeFactoryManager param (Server example) ?
I do not succeed in creating the Image object as it gets the type of the inital value which is a bytestream (15), even if typeDefinitionId() returns OpcUaId_Image
Thank you for help
Best regards
Stefan
create image
Moderator: uasdkcpp
- Support Team
- Hero Member
- Posts: 3068
- Joined: 18 Mar 2011, 15:09
Re: create image
Hello Stefan,
just create an instance of BaseDataVariableType, set the image data as ByteString and then explicitly set the DataType (e.g. to ImagePNG).
Note that all Image DataTypes are subtypes of ByteString - so on the network the value is just a ByteString.
just create an instance of BaseDataVariableType, set the image data as ByteString and then explicitly set the DataType (e.g. to ImagePNG).
Note that all Image DataTypes are subtypes of ByteString - so on the network the value is just a ByteString.
Code: Select all
// Create a Variable of DataType Image
UaByteString imageData;
// ... get the content from somewhere
UaVariant varValue;
varValue.setByteString(imageData, OpcUa_True);
OpcUa::BaseDataVariableType* pVariable = new OpcUa::BaseDataVariableType(
UaNodeId("Nodes.Images.ImagePNG", getTypeNamespace()),
"ImagePNG",
getNameSpaceIndex(),
varValue,
OpcUa_AccessLevels_CurrentRead,
this,
m_pSharedNodeMutex);
pVariable->setDataType(OpcUaId_ImagePNG);
addResult = addNodeAndReference(pParentNode->getUaReferenceLists(), pVariable, OpcUaId_Organizes);
Best regards
Unified Automation Support Team
Unified Automation Support Team