View Javadoc
1   package net.sf.mbus4j.dataframes.datablocks.dif;
2   
3   /*
4    * #%L
5    * mbus4j-core
6    * %%
7    * Copyright (C) 2009 - 2014 MBus4J
8    * %%
9    * mbus4j - Drivers for the M-Bus protocol - http://mbus4j.sourceforge.net/
10   * Copyright (C) 2009-2014, mbus4j.sf.net, and individual contributors as indicated
11   * by the @authors tag. See the copyright.txt in the distribution for a
12   * full listing of individual contributors.
13   * 
14   * This is free software; you can redistribute it and/or modify it
15   * under the terms of the GNU General Public License as
16   * published by the Free Software Foundation; either version 3 of
17   * the License, or (at your option) any later version.
18   * 
19   * This software is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22   * Lesser General Public License for more details.
23   * 
24   * You should have received a copy of the GNU Lesser General Public
25   * License along with this software; if not, write to the Free
26   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
28   * #L%
29   */
30  /**
31   *
32   * @author arnep@users.sourceforge.net
33   * @version $Id: DataFieldCode.java 104 2014-02-21 09:31:17Z arnep $
34   */
35  public enum DataFieldCode {
36  
37      NO_DATA(0x00, "No Data"),
38      _8_BIT_INTEGER(0x01, "8 Bit Integer"),
39      _16_BIT_INTEGER(0x02, "16 Bit Integer"),
40      _24_BIT_INTEGER(0x03, "24 Bit Integer"),
41      _32_BIT_INTEGER(0x04, "32 Bit Integer"),
42      _32_BIT_REAL(0x05, "32 Bit Real"),
43      _48_BIT_INTEGER(0x06, "48 Bit Integer"),
44      _64_BIT_INTEGER(0x07, "64 Bit Integer"),
45      SELECTION_FOR_READOUT(0x08, "Selection for readout"),
46      _2_DIGIT_BCD(0x09, "2 digit BCD"),
47      _4_DIGIT_BCD(0x0a, "4 digit BCD"),
48      _6_DIGIT_BCD(0x0b, "6 digit BCD"),
49      _8_DIGIT_BCD(0x0c, "8 digit BCD"),
50      VARIABLE_LENGTH(0x0d, "variable length"),
51      _12_DIGIT_BCD(0x0e, "12 digit BCD"),
52      SPECIAL_FUNCTION_MAN_SPEC_DATA_LAST_PACKET(0x0f, "Special Function Manufacturer specific data"),
53      SPECIAL_FUNCTION_MAN_SPEC_DATA_PACKETS_FOLLOWS(0x1f, "Special Function Manufacturer specific data more records follow in next telegram"),
54      SPECIAL_FUNCTION_IDLE_FILLER(0x2f, "Special Function Idle filler"),
55      // 3,4,5,6 reserved
56      SPECIAL_FUNCTION_GLOBAL_READOUT_REQUEST(0x7f, "Special Function Global readout request");
57      private final String label;
58      public final byte code;
59  
60      private DataFieldCode(int code, String name) {
61          this.label = name;
62          this.code = (byte) code;
63      }
64  
65      @Override
66      public String toString() {
67          return label;
68      }
69  
70      public String getLabel() {
71          return label;
72      }
73  
74      public static DataFieldCode fromLabel(String label) {
75          for (DataFieldCode value : values()) {
76              if (value.getLabel().equals(label)) {
77                  return value;
78              }
79          }
80          return valueOf(label);
81      }
82  }