create image

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
Stefan_L_01
Sr. Member
Sr. Member
Posts: 18
Joined: 18 Nov 2016, 20:17

create image

Post by Stefan_L_01 »

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

User avatar
Support Team
Hero Member
Hero Member
Posts: 3068
Joined: 18 Mar 2011, 15:09

Re: create image

Post by Support Team »

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.

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

Post Reply