]> git.basschouten.com Git - openhab-addons.git/blob
3cf9f31b0b4e96447dfa08573f39f725d8765ea5
[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.plclogo.internal.config;
14
15 import static org.openhab.binding.plclogo.internal.PLCLogoBindingConstants.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * The {@link PLCDigitalConfiguration} is a base class for configuration
21  * of Siemens LOGO! PLC digital input/outputs blocks.
22  *
23  * @author Alexander Falkenstern - Initial contribution
24  */
25 @NonNullByDefault
26 public class PLCDigitalConfiguration extends PLCCommonConfiguration {
27
28     private String kind = "";
29
30     @Override
31     public String getBlockKind() {
32         return kind;
33     }
34
35     /**
36      * Set Siemens LOGO! blocks kind.
37      * Can be I, Q, M, NI or NQ for digital blocks and
38      * AI, AM, AQ, NAI or NAQ for analog
39      *
40      * @param kind Siemens LOGO! blocks kind
41      */
42     public void setBlockKind(final String kind) {
43         this.kind = kind.trim();
44     }
45
46     @Override
47     public String getChannelType() {
48         boolean isInput = kind.equalsIgnoreCase(I_DIGITAL) || kind.equalsIgnoreCase(NI_DIGITAL);
49         return isInput ? DIGITAL_INPUT_ITEM : DIGITAL_OUTPUT_ITEM;
50     }
51 }