I have this code for reading value from the server.
Code: Select all
private void readDataType(NodeId node, out BuiltInType type)
{
type = BuiltInType.Null;
List<ReadValueId> nodesToRead = new List<ReadValueId>();
nodesToRead.Add(new ReadValueId()
{
NodeId = node,
AttributeId = Attributes.DataType
});
List<DataValue> data = opcSession.Read(nodesToRead);
type = TypeUtils.GetBuiltInType((NodeId)data[0].Value);
}
1. At the time of calling Read method, opcSession has sometimes state 'disconnected' and then it throws exception "The operation is not available because the session is in the 'Disconnected' state". I have tried to check if connection is alive, but it's not working always and it's ugly solution as well.
Code: Select all
if (opcSession.ConnectionStatus == ServerConnectionStatus.Disconnected)
{
opcSession.Connect(PropEnpointUrl, SecuritySelection.BestAvailable);
}
I will strongly appreciate any information or heplful tips. Thanks.