]> git.basschouten.com Git - openhab-addons.git/blob
e1ad58fca3de939af21057a1c45bfc6b8a2dbe0b
[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.modbus.internal;
14
15 import static org.openhab.binding.modbus.ModbusBindingConstants.BINDING_ID;
16
17 import java.util.HashMap;
18 import java.util.Map;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.core.io.transport.modbus.ModbusReadFunctionCode;
22 import org.openhab.core.thing.ThingTypeUID;
23
24 /**
25  * The {@link ModbusBindingConstantsInternal} class defines common constants, which are
26  * used across the whole binding.
27  *
28  * @author Sami Salonen - Initial contribution
29  */
30 @NonNullByDefault
31 public class ModbusBindingConstantsInternal {
32
33     // List of all Thing Type UIDs
34     public static final ThingTypeUID THING_TYPE_MODBUS_TCP = new ThingTypeUID(BINDING_ID, "tcp");
35     public static final ThingTypeUID THING_TYPE_MODBUS_SERIAL = new ThingTypeUID(BINDING_ID, "serial");
36     public static final ThingTypeUID THING_TYPE_MODBUS_POLLER = new ThingTypeUID(BINDING_ID, "poller");
37     public static final ThingTypeUID THING_TYPE_MODBUS_DATA = new ThingTypeUID(BINDING_ID, "data");
38
39     // List of all Channel ids
40     public static final String CHANNEL_SWITCH = "switch";
41     public static final String CHANNEL_CONTACT = "contact";
42     public static final String CHANNEL_DATETIME = "datetime";
43     public static final String CHANNEL_DIMMER = "dimmer";
44     public static final String CHANNEL_NUMBER = "number";
45     public static final String CHANNEL_STRING = "string";
46     public static final String CHANNEL_ROLLERSHUTTER = "rollershutter";
47     public static final String CHANNEL_LAST_READ_SUCCESS = "lastReadSuccess";
48     public static final String CHANNEL_LAST_READ_ERROR = "lastReadError";
49     public static final String CHANNEL_LAST_WRITE_SUCCESS = "lastWriteSuccess";
50     public static final String CHANNEL_LAST_WRITE_ERROR = "lastWriteError";
51
52     public static final String[] DATA_CHANNELS = { CHANNEL_SWITCH, CHANNEL_CONTACT, CHANNEL_DATETIME, CHANNEL_DIMMER,
53             CHANNEL_NUMBER, CHANNEL_STRING, CHANNEL_ROLLERSHUTTER };
54
55     public static final String[] DATA_CHANNELS_TO_COPY_FROM_READ_TO_READWRITE = { CHANNEL_SWITCH, CHANNEL_CONTACT,
56             CHANNEL_DATETIME, CHANNEL_DIMMER, CHANNEL_NUMBER, CHANNEL_STRING, CHANNEL_ROLLERSHUTTER,
57             CHANNEL_LAST_READ_SUCCESS, CHANNEL_LAST_READ_ERROR };
58
59     public static final String[] DATA_CHANNELS_TO_DELEGATE_COMMAND_FROM_READWRITE_TO_WRITE = { CHANNEL_SWITCH,
60             CHANNEL_CONTACT, CHANNEL_DATETIME, CHANNEL_DIMMER, CHANNEL_NUMBER, CHANNEL_STRING, CHANNEL_ROLLERSHUTTER };
61
62     public static final String WRITE_TYPE_COIL = "coil";
63     public static final String WRITE_TYPE_HOLDING = "holding";
64
65     public static final String READ_TYPE_COIL = "coil";
66     public static final String READ_TYPE_HOLDING_REGISTER = "holding";
67     public static final String READ_TYPE_DISCRETE_INPUT = "discrete";
68     public static final String READ_TYPE_INPUT_REGISTER = "input";
69
70     public static final Map<String, ModbusReadFunctionCode> READ_FUNCTION_CODES = new HashMap<>();
71     static {
72         READ_FUNCTION_CODES.put(READ_TYPE_COIL, ModbusReadFunctionCode.READ_COILS);
73         READ_FUNCTION_CODES.put(READ_TYPE_DISCRETE_INPUT, ModbusReadFunctionCode.READ_INPUT_DISCRETES);
74         READ_FUNCTION_CODES.put(READ_TYPE_INPUT_REGISTER, ModbusReadFunctionCode.READ_INPUT_REGISTERS);
75         READ_FUNCTION_CODES.put(READ_TYPE_HOLDING_REGISTER, ModbusReadFunctionCode.READ_MULTIPLE_REGISTERS);
76     }
77 }