]> git.basschouten.com Git - openhab-addons.git/blob
742a3dbd3ab7454958a11b6e16a34e6814fa06d9
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.message;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.slf4j.Logger;
17
18 /**
19  * The {@link: FMessage} contains information about the Cube NTP Configuration
20  * This is the response to a f: command
21  *
22  * @author Marcel Verpaalen - Initial contribution
23  */
24 @NonNullByDefault
25 public final class FMessage extends Message {
26
27     private String ntpServer1 = "";
28     private String ntpServer2 = "";
29
30     /**
31      * The {@link: FMessage} contains information about the Cube NTP Configuration
32      *
33      * @param raw String with raw message
34      */
35     public FMessage(String raw) {
36         super(raw);
37
38         final String[] servers = this.getPayload().split(",");
39         if (servers.length > 0) {
40             ntpServer1 = servers[0];
41         }
42         if (servers.length > 1) {
43             ntpServer2 = servers[1];
44         }
45     }
46
47     /**
48      * @return the NTP Server1 name
49      */
50     public String getNtpServer1() {
51         return ntpServer1;
52     }
53
54     /**
55      * @return the NTP Server2 name
56      */
57     public String getNtpServer2() {
58         return ntpServer2;
59     }
60
61     @Override
62     public void debug(Logger logger) {
63         logger.debug("=== F Message === ");
64         logger.trace("\tRAW : {}", this.getPayload());
65         logger.debug("\tNTP Server1    : {}", this.ntpServer1);
66         logger.debug("\tNTP Server2    : {}", this.ntpServer2);
67     }
68
69     @Override
70     public MessageType getType() {
71         return MessageType.F;
72     }
73 }