]> git.basschouten.com Git - openhab-addons.git/blob
76b7720b2c11724e6edaf67ccd362ef5b1607ddc
[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.smartmeter.connectors;
14
15 import java.io.IOException;
16 import java.time.Duration;
17 import java.util.concurrent.ExecutorService;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.reactivestreams.Publisher;
22
23 /**
24  * Specifies the generic method to retrieve values from a device
25  *
26  * @author Matthias Steigenberger - Initial contribution
27  * @author Mathias Gilhuber - Also-By
28  */
29 @NonNullByDefault
30 public interface IMeterReaderConnector<T> {
31
32     /**
33      * Establishes the connection against the device and reads native encoded SML informations.
34      * Ensures that a connection is opened and notifies any attached listeners
35      *
36      * @param serialParmeter
37      * @param period hint for the connector to emit items in this time intervals.
38      * @return native encoded SML informations from a device.
39      */
40     Publisher<T> getMeterValues(byte @Nullable [] initMessage, Duration period, ExecutorService executor);
41
42     /**
43      * Opens the connection to the serial port.
44      *
45      * @throws IOException Whenever something goes wrong while opening the connection.
46      *
47      */
48     void openConnection() throws IOException;
49
50     /**
51      * Closes the connection to the serial port.
52      *
53      */
54     void closeConnection();
55 }