Writing a single value to an array with the .NET SDK|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Writing a single value to an array with the .NET SDK
Avatar
Kiril Ralinovski_2
New Member
Members
Forum Posts: 1
Member Since:
10/28/2021
sp_UserOfflineSmall Offline
1
10/28/2021 - 06:40
sp_Permalink sp_Print

Hello,

I am trying to write a single value in an array of booleans. My code looks as follows:

WriteValueCollection nodesToWrite = new WriteValueCollection();
WriteValue writeVal = new WriteValue();

writeVal.NodeId = new NodeId(nodeID);
writeVal.AttributeId = Attributes.Value;

writeVal.Value = new DataValue(new Variant(true));
writeVal.IndexRange = "1";

nodesToWrite.Add(writeVal);

StatusCodeCollection results = null;
DiagnosticInfoCollection diagnosticInfos;

session.Write(null,
nodesToWrite,
out results,
out diagnosticInfos);

Unfortunately I get a BadWriteNotSupported as a reply. I've tried setting writeVal.Value.Value to the following:

Boolean[] toWrite = { true };
Variant[] toWrite2 = { new Variant(true) };
Boolean[,] toWrite3 = { { true } };

And unfortunately I get the same error. It's possible to write single values by using ua Expert, so I am sure that the server allows writing single values. 

I have been able to subscribe to the properties and read them, but not write to them. Any help would be greatly appreciated! 

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
10/28/2021 - 09:09
sp_Permalink sp_Print sp_EditHistory

Servers may not support index writes for every variable (some servers front end other systems which do not support the feature).

A WriteFullArrayOnly bit has been added to the AccessLevel to allow Servers to indicate when writes are not supported:
https://reference.opcfoundatio.....art3/8.58/

For servers that do not support the bit, the BadWriteNotSupported code tells that client that index writes are not supported for the variable.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 25
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855