private int coding ( final String unit ) throws KNXFormatException { expUnitAdjustment = 0 ; // @formatter:off switch ( unit ) { case "Wh" : return 0b00000000 ; case "MWh" : expUnitAdjustment = 6 ; return 0b10000000 ; case "kJ" : expUnitAdjustment = 3 ; return 0b00001000 ; case "GJ" : expUnitAdjustment = 9 ; return 0b10001000 ; case "l" : expUnitAdjustment = - 3 ; return 0b00010000 ; case "kg" : return 0b00011000 ; case "W" : return 0b00101000 ; case "MW" : expUnitAdjustment = 6 ; return 0b10101000 ; case "kJ/h" : expUnitAdjustment = 3 ; return 0b00110000 ; case "GJ/h" : expUnitAdjustment = 9 ; return 0b10110000 ; case "l/h" : expUnitAdjustment = - 3 ; return 0b00111000 ; case "l/min" : expUnitAdjustment = - 3 ; return 0b01000000 ; case "ml/s" : expUnitAdjustment = - 6 ; return 0b01001000 ; case "kg/h" : return 0b01010000 ; // case "": return 0b01101110; // 'units for HCA', we will opt for 'dimensionless counter' case "" : return dimensionlessCounter ; default : throw newException ( "unsupported unit" , unit ) ; } // @formatter:on }
try to find the coding based on unit