]> git.basschouten.com Git - openhab-addons.git/blob
d35194d5765b1b45d2abf8dfe249681937d5b7de
[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.lcn.internal.connection;
14
15 import java.time.Instant;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.lcn.internal.common.LcnAddr;
19
20 /**
21  * Holds data of one PCK command with the target address and the date when the item has been enqueued.
22  *
23  * @author Fabian Wolter - Initial Contribution
24  */
25 @NonNullByDefault
26 public class PckQueueItem {
27     private final Instant enqueued;
28     private final LcnAddr addr;
29     private final boolean wantsAck;
30     private final byte[] data;
31
32     public PckQueueItem(LcnAddr addr, boolean wantsAck, byte[] data) {
33         this.enqueued = Instant.now();
34         this.addr = addr;
35         this.wantsAck = wantsAck;
36         this.data = data;
37     }
38
39     /**
40      * Gets the time when this message has been enqueued.
41      *
42      * @return the Instant
43      */
44     public Instant getEnqueued() {
45         return enqueued;
46     }
47
48     /**
49      * Gets the address of the destination LCN module.
50      *
51      * @return the address
52      */
53     public LcnAddr getAddr() {
54         return addr;
55     }
56
57     /**
58      * Checks whether an Ack is requested.
59      *
60      * @return true, if an Ack is requested
61      */
62     public boolean isWantsAck() {
63         return wantsAck;
64     }
65
66     /**
67      * Gets the raw PCK message to be sent.
68      *
69      * @return message as ByteBuffer
70      */
71     public byte[] getData() {
72         return data;
73     }
74 }