hylasoft-usa / h-opc

OPC client made simpler, for UA and DA
MIT License
300 stars 144 forks source link

Is there a way to retrieve the engineering unit from the tags? #58

Open bajcmartinez opened 7 years ago

bajcmartinez commented 7 years ago

For example in the case of a temperature sensor, I can get the value, but how can I get the if that value is being measured on Farenheit, Kelvong, etc?

Thanks!

bajcmartinez commented 7 years ago

For DA I could create the following method:

///

/// Gets the engineering unit of an OPC tag /// /// Tag to get enginneering unit of /// String public String GetEngineeringUnit(string tag) { var item = new OpcDa.Item { ItemName = tag }; OpcDa.ItemProperty result; try { var propertyCollection = _server.GetProperties(new[] { item }, new[] { OpcDa.Property.ENGINEERINGUINTS }, false)[0]; result = propertyCollection[0]; } catch (NullReferenceException) { throw new OpcException("Could not find node because server not connected."); } return result.Value.ToString(); }

which returns what I need, but I can't find the same property for UA, do you know how to retrieve it?

Thanks!