]> git.basschouten.com Git - openhab-addons.git/blob
99aa15a3dd60fba8081538cf8aa1f46f0c936ea3
[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.urtsi.internal.mapping;
14
15 /**
16  * The {@code UrtsiChannelMapping} is responsible for mapping the channel you select at the URTSI II device to the
17  * channel which is transmitted via the serial port.
18  *
19  * @author Oliver Libutzki - Initial contribution
20  *
21  */
22 public class UrtsiChannelMapping {
23
24     /**
25      * Returns the mapped channel which is used to communicate with the URTSI II device. Returns null if the given
26      * channel is not valid.
27      *
28      * @param configuredChannel the channel selected at the URTSI II device
29      * @return returns the mapped channel, returns null is the given channel is not valid.
30      */
31     public static String getMappedChannel(String configuredChannel) {
32         int channel = Integer.parseInt(configuredChannel, 16);
33         if (channel == 0) {
34             channel = 16;
35         }
36         if (channel < 1 || channel > 16) {
37             return null;
38         }
39         return String.format("%02d", channel);
40     }
41 }