]> git.basschouten.com Git - openhab-addons.git/blob
9663c261d1832bff7f9c91504a4cd22fadbe3677
[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 lastReadingDate time of last reading as ZonedDateTime
36      * @param lastRefreshTime time of last refresh as ZonedDateTime
37      */
38     public MeterState(ReadingInstance reading) {
39         this.readingValue = reading.getValue();
40         this.lastReadingDate = new DateTimeType(reading.getReadingDate());
41         this.lastRefreshTime = new DateTimeType();
42     }
43
44     /**
45      * @return returns the current reading value
46      */
47     public double getReadingValue() {
48         return readingValue;
49     }
50
51     /**
52      * @return returns the last time that the meter has been read into pixometer
53      */
54     public DateTimeType getLastReadingDate() {
55         return lastReadingDate;
56     }
57
58     /**
59      * @return returns the last time, the item has been refreshed
60      */
61     public DateTimeType getLastRefreshTime() {
62         return lastRefreshTime;
63     }
64 }