FullClient DEMO solution: code missing

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

Moderator: uasdknet

Post Reply
FabioLantek
Full Member
Full Member
Posts: 5
Joined: 04 Dec 2020, 10:23

FullClient DEMO solution: code missing

Post by FabioLantek »

Hi Guys,
i found that in the FullClient.Net45 solution provided as demo, there is a problem in the code in the Write section which deals with Arrays.

Actually the code provided for OneDimensional Arrays -> DOESN'T WORK, since is the same code provided for Scalar values.
Copy/Paste problem i guess. But i really need the code to write arrays.

Image

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

Re: FullClient DEMO solution: code missing

Post by Support Team »

Hello Fabio,

the code in his base is correct. Writing an array doesn´t differ from writing a scalar value. But we see the problem in the interface which can´t handle array input properly.
To write an array you just need to fill the WriteValue with an array of the right datatype.

In case to write an Int32 array:

Fist, create the array :

Code: Select all

int[] newRawValue = { 1, 2 };
Second, convert the array into a Variant:

Code: Select all

Variant newValue = new Variant(newRawValue);
Last, create an DataValue and fill it with the Variant:

Code: Select all

                                DataValue dataValue = new DataValue()
                                {
                                    Value = newValue
                                };
Now you can fill the WriteValue with the DataValue

Code: Select all

                                nodesToWrite.Add(new WriteValue()
                                {
                                    NodeId = writeValInfo.NodeId,
                                    Value = dataValue,
                                    AttributeId = Attributes.Value
                                });
Best regards
Unified Automation Support Team

Post Reply