2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.smartmeter.connectors;
15 import java.io.IOException;
16 import java.time.Duration;
17 import java.util.concurrent.ExecutorService;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.reactivestreams.Publisher;
24 * Specifies the generic method to retrieve values from a device
26 * @author Matthias Steigenberger - Initial contribution
27 * @author Mathias Gilhuber - Also-By
30 public interface IMeterReaderConnector<T> {
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
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.
40 Publisher<T> getMeterValues(byte @Nullable [] initMessage, Duration period, ExecutorService executor);
43 * Opens the connection to the serial port.
45 * @throws IOException Whenever something goes wrong while opening the connection.
48 void openConnection() throws IOException;
51 * Closes the connection to the serial port.
54 void closeConnection();