]> git.basschouten.com Git - openhab-addons.git/blob
01763c0b08ac2f01b47f55fb7246a8c0060afae2
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.tacmi.internal.schema;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.thing.Channel;
18 import org.openhab.core.types.State;
19
20 /**
21  * The {@link ApiPageEntry} class contains mapping information for an entry of
22  * the API page.
23  *
24  * @author Christian Niessner - Initial contribution
25  */
26 @NonNullByDefault
27 public class ApiPageEntry {
28
29     enum Type {
30         READ_ONLY_SWITCH(true),
31         READ_ONLY_NUMERIC(true),
32         NUMERIC_FORM(false),
33         SWITCH_BUTTON(false),
34         SWITCH_FORM(false),
35         READ_ONLY_STATE(true),
36         STATE_FORM(false);
37
38         public final boolean readOnly;
39
40         private Type(boolean readOnly) {
41             this.readOnly = readOnly;
42         }
43     }
44
45     /**
46      * type of this entry
47      */
48     public final Type type;
49
50     /**
51      * The channel for this entry
52      */
53     public final Channel channel;
54
55     /**
56      * internal address for this channel
57      */
58     public final @Nullable String address;
59
60     /**
61      * data for handle 'changerx2' form fields
62      */
63     public final @Nullable ChangerX2Entry changerX2Entry;
64
65     /**
66      * The last known state for this item...
67      */
68     private State lastState;
69
70     /**
71      * Timestamp (epoch ms) when last 'outgoing' command was sent.
72      * Required for de-bounce overlapping effects when status-poll's and updates overlap.
73      */
74     private long lastCommandTS;
75
76     protected ApiPageEntry(final Type type, final Channel channel, @Nullable final String address,
77             @Nullable ChangerX2Entry changerX2Entry, State lastState) {
78         this.type = type;
79         this.channel = channel;
80         this.address = address;
81         this.changerX2Entry = changerX2Entry;
82         this.lastState = lastState;
83     }
84
85     public void setLastState(State lastState) {
86         this.lastState = lastState;
87     }
88
89     public State getLastState() {
90         return lastState;
91     }
92
93     public long getLastCommandTS() {
94         return lastCommandTS;
95     }
96
97     public void setLastCommandTS(long lastCommandTS) {
98         this.lastCommandTS = lastCommandTS;
99     }
100 }