]> git.basschouten.com Git - openhab-addons.git/blob
e104e13f35f40b1ed1ed009714b4088a81751cd4
[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.pixometer.internal.data;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.pixometer.internal.config.ReadingInstance;
17 import org.openhab.core.library.types.DateTimeType;
18
19 /**
20  * Abstract data class to store shared/common meter state values
21  *
22  * @author Jerome Luckenbach - Initial contribution
23  *
24  */
25 @NonNullByDefault
26 public class MeterState {
27
28     private final DateTimeType lastReadingDate;
29     private final DateTimeType lastRefreshTime;
30     private final double readingValue;
31
32     /**
33      * Initialize times from the given timestamps
34      *
35      * @param reading last reading
36      */
37     public MeterState(ReadingInstance reading) {
38         this.readingValue = reading.getValue();
39         this.lastReadingDate = new DateTimeType(reading.getReadingDate());
40         this.lastRefreshTime = new DateTimeType();
41     }
42
43     /**
44      * @return returns the current reading value
45      */
46     public double getReadingValue() {
47         return readingValue;
48     }
49
50     /**
51      * @return returns the last time that the meter has been read into pixometer
52      */
53     public DateTimeType getLastReadingDate() {
54         return lastReadingDate;
55     }
56
57     /**
58      * @return returns the last time, the item has been refreshed
59      */
60     public DateTimeType getLastRefreshTime() {
61         return lastRefreshTime;
62     }
63 }