]> git.basschouten.com Git - openhab-addons.git/blob
5c1c606f4402181ce9a5bb5d110eb71d38b3341b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.dsmr.internal.device.connector;
14
15 import java.util.Locale;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * Error events from a connector.
21  *
22  * @author M. Volaart - Initial contribution
23  * @author Hilbrand Bouwkamp - Refactored all error into one enum
24  */
25 @NonNullByDefault
26 public enum DSMRErrorStatus {
27     /**
28      * The smarty telegram was successfully received but could not be decoded because of an invalid decryption key.
29      */
30     INVALID_DECRYPTION_KEY(false),
31     /**
32      * Serial port could not be found.
33      */
34     PORT_DONT_EXISTS(true),
35     /**
36      * Serial port is already in use by another application.
37      */
38     PORT_IN_USE(true),
39     /**
40      * Internal error in the serial port communication.
41      */
42     PORT_INTERNAL_ERROR(true),
43     /**
44      * Serial port doesn't support the configured settings.
45      */
46     PORT_NOT_COMPATIBLE(true),
47     /**
48      * Reading data from the serial port failed.
49      */
50     SERIAL_DATA_READ_ERROR(false),
51     /**
52      * The telegram CRC16 checksum failed (only DSMR V4 and up).
53      */
54     TELEGRAM_CRC_ERROR(false),
55     /**
56      * The P1 telegram has syntax errors.
57      */
58     TELEGRAM_DATA_CORRUPTION(false),
59     /**
60      * Received telegram data, but after parsing no data is present. Possibly all data corrupted.
61      */
62     TELEGRAM_NO_DATA(false);
63
64     private final boolean fatal;
65
66     private DSMRErrorStatus(final boolean fatal) {
67         this.fatal = fatal;
68     }
69
70     /**
71      * @return Returns true if this error is not something possible temporary, but something that can't be recovered
72      *         from.
73      */
74     public boolean isFatal() {
75         return fatal;
76     }
77
78     /**
79      * @return the event details
80      */
81     public String getEventDetails() {
82         return "@text/addon.dsmr.error.status." + name().toLowerCase(Locale.ROOT);
83     }
84 }