类 ModbusMaster

java.lang.Object
com.huangjian.modbus4j.Modbus
com.huangjian.modbus4j.ModbusMaster
直接已知子类:
SerialMaster, TcpListener, TcpMaster, UdpMaster

public abstract class ModbusMaster extends Modbus

Abstract ModbusMaster class.

  • 字段详细资料

    • validateResponse

      protected boolean validateResponse
      Should we validate the responses: - ensure that the requested slave id is what is in the response
    • connected

      protected boolean connected
      If connection is established with slave/slaves
    • initialized

      protected boolean initialized
  • 构造器详细资料

    • ModbusMaster

      public ModbusMaster()
  • 方法详细资料

    • isConnected

      public boolean isConnected()

      isConnected.

      返回:
      a boolean.
    • setConnected

      public void setConnected(boolean connected)

      Setter for the field connected.

      参数:
      connected - a boolean.
    • init

      public abstract void init() throws ModbusInitException

      init.

      抛出:
      ModbusInitException - if any.
    • isInitialized

      public boolean isInitialized()

      isInitialized.

      返回:
      a boolean.
    • destroy

      public abstract void destroy()

      destroy.

    • send

      public final ModbusResponse send(ModbusRequest request) throws ModbusTransportException

      send.

      参数:
      request - a ModbusRequest object.
      返回:
      a ModbusResponse object.
      抛出:
      ModbusTransportException - if any.
    • sendImpl

      public abstract ModbusResponse sendImpl(ModbusRequest request) throws ModbusTransportException

      sendImpl.

      参数:
      request - a ModbusRequest object.
      返回:
      a ModbusResponse object.
      抛出:
      ModbusTransportException - if any.
    • getValue

      public <T> T getValue(BaseLocator<T> locator) throws ModbusTransportException, ErrorResponseException
      Returns a value from the modbus network according to the given locator information. Various data types are allowed to be requested including multi-word types. The determination of the correct request message to send is handled automatically.
      类型参数:
      T - a T object.
      参数:
      locator - the information required to locate the value in the modbus network.
      返回:
      an object representing the value found. This will be one of Boolean, Short, Integer, Long, BigInteger, Float, or Double. See the DataType enumeration for details on which type to expect.
      抛出:
      ModbusTransportException - if there was an IO error or other technical failure while sending the message
      ErrorResponseException - if the response returned from the slave was an exception.
    • setValue

      public <T> void setValue(BaseLocator<T> locator, Object value) throws ModbusTransportException, ErrorResponseException
      Sets the given value in the modbus network according to the given locator information. Various data types are allowed to be set including including multi-word types. The determination of the correct write message to send is handled automatically.
      类型参数:
      T - type of locator
      参数:
      locator - the information required to locate the value in the modbus network.
      value - an object representing the value to be set. This will be one of Boolean, Short, Integer, Long, BigInteger, Float, or Double. See the DataType enumeration for details on which type to expect.
      抛出:
      ModbusTransportException - if there was an IO error or other technical failure while sending the message
      ErrorResponseException - if the response returned from the slave was an exception.
    • scanForSlaveNodes

      public List<Integer> scanForSlaveNodes()
      Node scanning. Returns a list of slave nodes that respond to a read exception status request (perhaps with an error, but respond nonetheless). Note: a similar scan could be done for registers in nodes, but, for one thing, it would take some time to run, and in any case the results would not be meaningful since there would be no semantic information accompanying the results.
      返回:
      a List object.
    • scanForSlaveNodes

      public ProgressiveTask scanForSlaveNodes(NodeScanListener l)

      scanForSlaveNodes.

      参数:
      l - a NodeScanListener object.
      返回:
      a ProgressiveTask object.
    • testSlaveNode

      public boolean testSlaveNode(int node)

      testSlaveNode.

      参数:
      node - a int.
      返回:
      a boolean.
    • getRetries

      public int getRetries()

      Getter for the field retries.

      返回:
      a int.
    • setRetries

      public void setRetries(int retries)

      Setter for the field retries.

      参数:
      retries - a int.
    • getTimeout

      public int getTimeout()

      Getter for the field timeout.

      返回:
      a int.
    • setTimeout

      public void setTimeout(int timeout)

      Setter for the field timeout.

      参数:
      timeout - a int.
    • isMultipleWritesOnly

      public boolean isMultipleWritesOnly()

      isMultipleWritesOnly.

      返回:
      a boolean.
    • setMultipleWritesOnly

      public void setMultipleWritesOnly(boolean multipleWritesOnly)

      Setter for the field multipleWritesOnly.

      参数:
      multipleWritesOnly - a boolean.
    • getDiscardDataDelay

      public int getDiscardDataDelay()

      Getter for the field discardDataDelay.

      返回:
      a int.
    • setDiscardDataDelay

      public void setDiscardDataDelay(int discardDataDelay)

      Setter for the field discardDataDelay.

      参数:
      discardDataDelay - a int.
    • getIoLog

      public BaseIOLog getIoLog()

      Getter for the field ioLog.

      返回:
      a BaseIOLog object.
    • setIoLog

      public void setIoLog(BaseIOLog ioLog)

      Setter for the field ioLog.

      参数:
      ioLog - a BaseIOLog object.
    • getePoll

      public InputStreamEPollWrapper getePoll()

      Getter for the field ePoll.

      返回:
      a InputStreamEPollWrapper object.
    • setePoll

      public void setePoll(InputStreamEPollWrapper ePoll)

      Setter for the field ePoll.

      参数:
      ePoll - a InputStreamEPollWrapper object.
    • send

      Useful for sending a number of polling commands at once, or at least in as optimal a batch as possible.
      类型参数:
      K - type of result
      参数:
      batch - a BatchRead object.
      返回:
      a BatchResults object.
      抛出:
      ModbusTransportException - if any.
      ErrorResponseException - if any.
    • getMessageControl

      protected MessageControl getMessageControl()

      getMessageControl.

      返回:
      a MessageControl object.
    • closeMessageControl

      protected void closeMessageControl(MessageControl conn)

      closeMessageControl.

      参数:
      conn - a MessageControl object.