All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ghgande.j2mod.modbus.msg.ModbusMessage Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
/*
 * Copyright 2002-2016 jamod & j2mod development teams
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ghgande.j2mod.modbus.msg;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * Interface defining a ModbusMessage.
 *
 * @author Dieter Wimberger
 * @author Steve O'Hara (4NG)
 * @version 2.0 (March 2016)
 */
public interface ModbusMessage {

    /**
     * Check the flag which indicates that this ModbusMessage is for a
     * headless (serial, or headless networked) connection.
     * @return is for a headless (serial, or headless networked) connection
     */
    boolean isHeadless();

    /**
     * Sets the flag that marks this ModbusMessage as headless (for
     * serial transport).
     */
    void setHeadless();

    /**
     * Returns the transaction identifier of this ModbusMessage as
     * int.
     *
     * 

* The identifier is a 2-byte (short) non negative integer value valid in * the range of 0-65535. * * @return the transaction identifier as int. */ int getTransactionID(); /** * Returns the protocol identifier of this ModbusMessage as * int. * *

* The identifier is a 2-byte (short) non negative integer value valid in * the range of 0-65535. * * @return the protocol identifier as int. */ int getProtocolID(); /** * Returns the length of the data appended after the protocol header. *

* * @return the data length as int. */ int getDataLength(); /** * Returns the unit identifier of this ModbusMessage as * int. * *

* The identifier is a 1-byte non negative integer value valid in the range * of 0-255. * * @return the unit identifier as int. */ int getUnitID(); /** * Returns the function code of this ModbusMessage as int.
* The function code is a 1-byte non negative integer value valid in the * range of 0-127. * *

* Function codes are ordered in conformance classes their values are * specified in com.ghgande.j2mod.modbus.Modbus. * * @return the function code as int. * * @see com.ghgande.j2mod.modbus.Modbus */ int getFunctionCode(); /** * Returns the raw message as an array of bytes. *

* * @return the raw message as byte[]. */ byte[] getMessage(); /** * Returns the raw message as String containing a * hexadecimal series of bytes. * *

* This method is specially for debugging purposes, allowing the user to log * the communication in a manner used in the specification document. * * @return the raw message as String containing a * hexadecimal series of bytes. */ String getHexMessage(); /** * Returns the number of bytes that will * be written by {@link #writeTo(DataOutput)}. * * @return the number of bytes that will be written as int. */ int getOutputLength(); /** * Writes this Transportable to the * given DataOutput. * * @param dout the DataOutput to write to. * * @throws java.io.IOException if an I/O error occurs. */ void writeTo(DataOutput dout) throws IOException; /** * Reads this Transportable from the given * DataInput. * * @param din the DataInput to read from. * * @throws java.io.IOException if an I/O error occurs or the data * is invalid. */ void readFrom(DataInput din) throws IOException; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy