calimero-project / calimero-core

Core library for KNX network access and management
Other
129 stars 65 forks source link

added getUnit() and base-class getNumericValue() #17

Closed owagner closed 9 years ago

owagner commented 9 years ago

-- added DTPXlator.getUnit() to get the string denoting the DPT's unit of measurement individually (even if appendUnit is set to false).

Rationale: Useful if value and unit are handled independently. No impact on existing API.

-- added a double getNumericValue() method in DPTXlator, which returns a numeric representation of the first value, if possible. Throws KNXFormatException if no numeric representation is available.

Rationale: Currently, there is no base-class method to get the numeric representation of a DPT value, although most of them actually deal with numeric values. There is getValueFloat(), getValueSigned(), getValueUnsigned() etc. in the individual subclasses, but no common base-class method which can be called without prior type identification and casting. Useful when using the unspecialized DPTxlator base class. No impact on existing APIs.

owagner commented 9 years ago

The rationale for getNumericValue() remains valid, I think, though? If I simply want to convert into a numeric value from a generic DPTXlator instance, I still have to do type-based branching...

bmalinowsky commented 9 years ago

Yes, it does. My comment was only for that one particular method.