View Javadoc
1   package net.sf.mbus4j.dataframes.datablocks.vif;
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   *
33   * @author arnep@users.sourceforge.net
34   * @version $Id: VifeError.java 159 2016-05-13 08:33:29Z arnep $
35   */
36  public enum VifeError implements Vife {
37  
38      NO_ERROR("No error"),
39      TOO_MANY_DIFES("Too many DIFE's"),
40      STORAGE_NUMBER_NOT_IMPLEMENTED("Storage number not implemented"),
41      UNIT_NUMBER_NOT_IMPLEMENTED("Unit number not implemented"),
42      TARIFF_NUMBER_NOT_IMPLEMENTED("Tariff number not implemented"),
43      FUNCTION_NOT_IMPLEMENTED("Function not implemented"),
44      DATA_CLASS_NOT_IMPLEMENTED("Data class not implemented"),
45      DATA_SIZE_NOT_IMPLEMENTED("Data size not implemented"),
46      DIF_ERROR_RESERVED_0X08("DIF Error Reserved 0x08"),
47      DIF_ERROR_RESERVED_0X09("DIF Error Reserved 0x09"),
48      DIF_ERROR_RESERVED_0X0A("DIF Error Reserved 0x0A"),
49      TOO_MANY_VIFES("Too many VIFE's"),
50      ILLEGAL_VIF_GROUP("Illegal VIF-Group"),
51      ILLEGAL_VIF_EXPONENT("Illegal VIF-Exponent"),
52      VIF_DIF_MISMATCH("VIF/DIF mismatch"),
53      UNIMPLEMENTED_ACTION("Unimplemented action"),
54      VIF_ERROR_RESERVED_0X10("VIF Error Reserved 0x10"),
55      VIF_ERROR_RESERVED_0X11("VIF Error Reserved 0x11"),
56      VIF_ERROR_RESERVED_0X12("VIF Error Reserved 0x12"),
57      VIF_ERROR_RESERVED_0X13("VIF Error Reserved 0x13"),
58      VIF_ERROR_RESERVED_0X14("VIF Error Reserved 0x14"),
59      NO_DATA_AVAILABLE("No data available (undefined value)"),
60      DATA_OVERFLOW("Data overflow"),
61      DATA_UNDERFLOW(" Data underflow"),
62      DATA_ERROR(" Data error"),
63      DATA_ERROR_RESERVED_0X19("Data Error Reserved 0x19"),
64      DATA_ERROR_RESERVED_0X1A("Data Error Reserved 0x1A"),
65      DATA_ERROR_RESERVED_0X1B("Data Error Reserved 0x1B"),
66      PREMATURE_END_OF_RECORD("Premature end of record"),
67      OTHER_ERROR_RESERVED_0X1D("Other Error Reserved 0x1D"),
68      OTHER_ERROR_RESERVED_0X1E("Other Error Reserved 0x1E"),
69      OTHER_ERROR_RESERVED_0X1F("Other Error Reserved 0x1F");
70  
71      private final String label;
72      private final static VifeError[] map = values();
73  
74      public final static VifeError valueOfTableIndex(byte ordinal) {
75          return map[ordinal];
76      }
77  
78      private VifeError(String label) {
79          this.label = label;
80      }
81  
82      public byte getTableIndex() {
83          return (byte) ordinal();
84      }
85  
86      @Override
87      public String toString() {
88          return label;
89      }
90  
91      @Override
92      public String getLabel() {
93          return label;
94      }
95  
96      @Override
97      public VifeTypes getVifeType() {
98          return VifeTypes.ERROR;
99      }
100 
101     public static VifeError fromLabel(String label) {
102         for (VifeError value : map) {
103             if (value.getLabel().equals(label)) {
104                 return value;
105             }
106         }
107         return valueOf(label);
108     }
109 
110 }