diff --git a/h-opc/Da/DaClient.cs b/h-opc/Da/DaClient.cs index 3f829e5..f0e4476 100644 --- a/h-opc/Da/DaClient.cs +++ b/h-opc/Da/DaClient.cs @@ -76,7 +76,7 @@ public T Read(string tag) var item = new OpcDa.Item { ItemName = tag }; var result = _server.Read(new[] { item })[0]; - CheckResult(result); + CheckResult(result, tag); return (T)result.Value; } @@ -96,7 +96,7 @@ public void Write(string tag, T item) Value = item }; var result = _server.Write(new[] { itmVal })[0]; - CheckResult(result); + CheckResult(result, tag); } /// @@ -143,7 +143,7 @@ public DaNode FindNode(string tag) // try to find the tag otherwise var item = new OpcDa.Item { ItemName = tag }; var result = _server.Read(new[] { item })[0]; - CheckResult(result); + CheckResult(result, tag); var node = new DaNode(this, item.ItemName, item.ItemName, RootNode); AddNodeToCache(node); return node; @@ -179,7 +179,6 @@ public IEnumerable ExploreFolder(string tag) /// public void Dispose() { - _server.Disconnect(); _server.Dispose(); GC.SuppressFinalize(this); } @@ -196,12 +195,12 @@ private void AddNodeToCache(DaNode node) _nodesCache.Add(node.Tag, node); } - private static void CheckResult(IResult result) + private static void CheckResult(IResult result, string tag) { if (result == null) throw new OpcException("The server replied with an empty response"); if (result.ResultID.ToString() != "S_OK") - throw new OpcException(string.Format("Invalid response from the server. (Response Status: {0})", result.ResultID)); + throw new OpcException(string.Format("Invalid response from the server. (Response Status: {0}, Opc Tag: {1})", result.ResultID, tag)); } } }