I Wonder why did you use description of units as Unit?
namespace Gurux.DLMS.Enums
{
/// <summary>
/// Unit describes available COSEM unit types.
/// </summary>
public enum Unit : int
{
...
/// <summary>
/// Unit is Active power P watt W = J/s.
/// </summary>
[XmlEnum("27")]
ActivePower,
/// <summary>
/// Unit is Apparent power S.
/// </summary>
[XmlEnum("28")]
ApparentPower,
/// <summary>
/// Unit is Reactive power Q.
/// </summary>
[XmlEnum("29")]
ReactivePower,
/// <summary>
/// Unit is Active energy W*60*60s.
/// </summary>
[XmlEnum("30")]
ActiveEnergy,
/// <summary>
/// Unit is Apparent energy VA*60*60s.
/// </summary>
[XmlEnum("31")]
ApparentEnergy,
...
It translates as Enum string instead ... W, VA, var, Wh, VAh ...
Table 4. in BlueBook has 5 columns
unit ::= enum; Unit; Quantity; Unit name; SI definition (comment).
GXDLMSConverter.GetUnit is used to get unit description. It's more textual description and we might change it later (localize, etc).
We must return plain Unit on GetValues because some of our clients are saving this info to the DB and it's localized from there.
I suggest that you check if object is Register and get description later if you want.
This might cause problems if we change descriptions and you are comparing using this info.
Catch 22
OK, I've found the catch
In COSEM IC you never call GetUnit, so we get only description without the unit
/// <inheritdoc cref="GXDLMSObject.GetValues"/>
public override object[] GetValues()
{
//return new object[] { LogicalName, Value, "Scaler: " + Scaler + " Unit: " + Unit };
//my mod
return new object[] { LogicalName, Value, "Scaler: " + Scaler + " Unit: " + GXDLMSConverter.GetUnit(Unit) };
}
Unit
Hi,
GXDLMSConverter.GetUnit is used to get unit description. It's more textual description and we might change it later (localize, etc).
We must return plain Unit on GetValues because some of our clients are saving this info to the DB and it's localized from there.
I suggest that you check if object is Register and get description later if you want.
This might cause problems if we change descriptions and you are comparing using this info.
BR,
Mikko
Unit
Yes, I've figured out that.
I'll create additional resource or enum attribute decoration with additional info about unit or something.