]> git.basschouten.com Git - openhab-addons.git/blob
08763f0d371fbc9109d472a64158fe74c7072043
[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.max.internal.command;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 /**
19  * The {@link F_CubeCommand} is used to query and update the NTP servers used by the Cube.
20  *
21  * @author Marcel Verpaalen - Initial Contribution
22  */
23 @NonNullByDefault
24 public class FCommand extends CubeCommand {
25
26     private String ntpServer1 = "";
27     private String ntpServer2 = "";
28
29     /**
30      * Queries the Cube for the NTP info
31      */
32     public FCommand() {
33     }
34
35     /**
36      * Updates the Cube the NTP info
37      */
38     public FCommand(@Nullable String ntpServer1, @Nullable String ntpServer2) {
39         this.ntpServer1 = ntpServer1 != null ? ntpServer1 : "";
40         this.ntpServer2 = ntpServer2 != null ? ntpServer2 : "";
41     }
42
43     @Override
44     public String getCommandString() {
45         final String servers;
46         if (ntpServer1.length() > 0 && ntpServer2.length() > 0) {
47             servers = ntpServer1 + "," + ntpServer2;
48         } else {
49             servers = ntpServer1 + ntpServer2;
50         }
51         return "f:" + servers + '\r' + '\n';
52     }
53
54     @Override
55     public String getReturnStrings() {
56         return "F:";
57     }
58 }