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.
FullClient DEMO solution: code missing
Moderator: uasdknet
-
- Full Member
- Posts: 5
- Joined: 04 Dec 2020, 10:23
- Support Team
- Hero Member
- Posts: 3068
- Joined: 18 Mar 2011, 15:09
Re: FullClient DEMO solution: code missing
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 :
Second, convert the array into a Variant:
Last, create an DataValue and fill it with the Variant:
Now you can fill the WriteValue with the DataValue
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 };
Code: Select all
Variant newValue = new Variant(newRawValue);
Code: Select all
DataValue dataValue = new DataValue()
{
Value = newValue
};
Code: Select all
nodesToWrite.Add(new WriteValue()
{
NodeId = writeValInfo.NodeId,
Value = dataValue,
AttributeId = Attributes.Value
});
Best regards
Unified Automation Support Team
Unified Automation Support Team