Closed techvoipit closed 1 year ago
Is this not working for you?
var val = result.GetValueOrDefault<bool>();
In fact, in 3.1.1 at least, the GetValueOrDefault requires a type parameter (?).
Thank you very much is working!! Can you share me where I can find some documentation about which type I can use for GetValueOrDefault
You are welcome, glad to help.
The GetValueOrDefault
I think you are really asking for OPC-UA types, that you can see here: OPC UA Built-in Data Types
Also, you can find a typical mapping from these data types to C# .NET counterparts here (warning: this is NOT official documentation from this library, take this only as an example): Quick OPC Data Types in OPC-UA
I would like to read a value variable with this code but I can't isolate it: var readRequest = new ReadRequest { // set the NodesToRead to an array of ReadValueIds. NodesToRead = new[] { // construct a ReadValueId from a NodeId and AttributeId. new ReadValueId { // you can parse the nodeId from a string. NodeId = NodeId.Parse("ns=2;s=Target01.PLC.Memory_Bits.AGITATORE_FERMO"), //NodeId = NodeId.Parse(VariableIds.Server_ServerStatus), // variable class nodes have a Value attribute. AttributeId = AttributeIds.Value } } }; // send the ReadRequest to the server. var readResult = await channel.ReadAsync(readRequest); foreach (var result in readResult.Results) { Console.WriteLine(result); var val = result.GetValueOrDefault();
Console.WriteLine("Value: " + val.Value);
return True; status: 0x00000000; ts: 28/06/2023 16:43:19
How I can get only true ? attached the node structure