Data sources

Writing to OPC UA

With the following statement the value of a variable on an OPC UA server may be changed with a script.

-- datasourcename.writevaule(NodeID, Value)
data.opcua.writevalue('ns=3;s="Data_block_2". "IntegersWords". "int1"', toint16(12))

The NodeID can be found in the “NodeID” field of the variable in the browse dialog of the OPC UA data source.

Note

The NodeID can also be created using UaExpert or a similar tool.

For the Peakboard Script Engine all numbers are equivalent. Therefore all numbers are processed as “double”. This means that these numbers cannot be stored on an OPC UA server without further ado.

Note

The Peakboard Script Engine knows only three data types: bool, number and string! Therefore a conversion according to the following table is necessary!

The following table provides an overview of the OPC UA data types and their corresponding conversion functions:

OPC UA Datatype Conversion Function
byte tobyte()
sbyte tosbyte()
float/single tofloat()/tosingle()
int16/short toint16()/toshort()
int32 toint32()
int64/long toint64()/tolong()
uint16/ushort touint16()/toushort()
uint32 touint32()
uint64/ulong touint64()/toulong()
datetime todatetime()
guid toguid()

We are learning from you!

Did you find this article helpful?

Be enlightened!

Do you need more support?

Peakboard Youtube icon Visit our YouTube channel

Our numerous videos for beginners and advanced users explain exactly how to design your dashboard.

Peakboard Templates icon Visit the Peakboard Templates

Download our templates for various use cases for free.

Peakboard icon Visit www.peakboard.com

Find out all about Peakboard and browse our different use cases and success stories.