]> git.basschouten.com Git - openhab-addons.git/blob
c6ff776287f9873568cd48f46a910e3a5af88513
[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 initMessage
37      * @param period hint for the connector to emit items in this time intervals.
38      * @param executor
39      * @return native encoded SML informations from a device.
40      */
41     Publisher<T> getMeterValues(byte @Nullable [] initMessage, Duration period, ExecutorService executor);
42
43     /**
44      * Opens the connection to the serial port.
45      *
46      * @throws IOException Whenever something goes wrong while opening the connection.
47      *
48      */
49     void openConnection() throws IOException;
50
51     /**
52      * Closes the connection to the serial port.
53      *
54      */
55     void closeConnection();
56 }