]> git.basschouten.com Git - openhab-addons.git/blob
5cab106286150703e4feded60372df61573222b3
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.io.transport.modbus;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 import net.wimpi.modbus.Modbus;
18
19 /**
20  * Base interface for Modbus write requests
21  *
22  * @author Sami Salonen - Initial contribution
23  *
24  */
25 @NonNullByDefault
26 public abstract class ModbusWriteRequestBlueprint {
27
28     /**
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.
33      * <p>
34      *
35      * @return the protocol identifier as <tt>int</tt>.
36      */
37     public int getProtocolID() {
38         return Modbus.DEFAULT_PROTOCOL_ID;
39     }
40
41     /**
42      * Returns the reference of the register/coil/discrete input to to start
43      * writing with this request
44      * <p>
45      *
46      * @return the reference of the register
47      *         to start reading from as <tt>int</tt>.
48      */
49     public abstract int getReference();
50
51     /**
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.
56      * <p>
57      *
58      * @return the unit identifier as <tt>int</tt>.
59      */
60     public abstract int getUnitID();
61
62     /**
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>.
70      * <p>
71      *
72      * @return the function code as <tt>int</tt>.
73      *
74      * @see net.wimpi.modbus.Modbus
75      */
76     public abstract ModbusWriteFunctionCode getFunctionCode();
77
78     /**
79      * Get maximum number of tries, in case errors occur. Should be at least 1.
80      */
81     public abstract int getMaxTries();
82
83     /**
84      * Accept visitor
85      *
86      * @param visitor
87      */
88     public abstract void accept(ModbusWriteRequestBlueprintVisitor visitor);
89 }