2 * Copyright (c) 2010-2020 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.io.transport.modbus;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
17 import net.wimpi.modbus.Modbus;
20 * Base interface for Modbus write requests
22 * @author Sami Salonen - Initial contribution
26 public abstract class ModbusWriteRequestBlueprint {
29 * Returns the protocol identifier of this
30 * <tt>ModbusMessage</tt> as <tt>int</tt>.<br>
31 * The identifier is a 2-byte (short) non negative
32 * integer value valid in the range of 0-65535.
35 * @return the protocol identifier as <tt>int</tt>.
37 public int getProtocolID() {
38 return Modbus.DEFAULT_PROTOCOL_ID;
42 * Returns the reference of the register/coil/discrete input to to start
43 * writing with this request
46 * @return the reference of the register
47 * to start reading from as <tt>int</tt>.
49 public abstract int getReference();
52 * Returns the unit identifier of this
53 * <tt>ModbusMessage</tt> as <tt>int</tt>.<br>
54 * The identifier is a 1-byte non negative
55 * integer value valid in the range of 0-255.
58 * @return the unit identifier as <tt>int</tt>.
60 public abstract int getUnitID();
63 * Returns the function code of this
64 * <tt>ModbusMessage</tt> as <tt>int</tt>.<br>
65 * The function code is a 1-byte non negative
66 * integer value valid in the range of 0-127.<br>
67 * Function codes are ordered in conformance
68 * classes their values are specified in
69 * <tt>net.wimpi.modbus.Modbus</tt>.
72 * @return the function code as <tt>int</tt>.
74 * @see net.wimpi.modbus.Modbus
76 public abstract ModbusWriteFunctionCode getFunctionCode();
79 * Get maximum number of tries, in case errors occur. Should be at least 1.
81 public abstract int getMaxTries();
88 public abstract void accept(ModbusWriteRequestBlueprintVisitor visitor);