Class S7ResponseSizeEstimator

java.lang.Object
org.apache.plc4x.java.s7.netty.util.S7ResponseSizeEstimator

public class S7ResponseSizeEstimator
extends Object
When sending S7 messages we have to also pay attention to the expected size of a response for a given request. This helper estimates this response size and hereby helps implementing different strategies for optimizing requests.
  • Method Details

    • getEstimatedResponseMessageSize

      public static short getEstimatedResponseMessageSize​(S7RequestMessage requestMessage)
      Estimate the size of the response for a given request object. This is needed in order to decide if a request will be able to be processed as S7 PLCs will return errors if a request will produce a response that exceeds the agreed upon PDU size.
      Parameters:
      requestMessage - the request message for which we want to estimate the response size for.
      Returns:
      the estimated size in bytes the response for this message will have.
    • getEstimatedResponseReadItemTotalSize

      public static short getEstimatedResponseReadItemTotalSize​(VarParameterItem varParameterItem, VarPayloadItem varPayloadItem)
      Calculates the estimated size adding an item (parameter and eventually payload) would add to the response for a current request message. While for the parameters the size of the items depends on if they are requests or responses, the payload depends on if it's a read or write operation.
      Parameters:
      varParameterItem - parameter item.
      varPayloadItem - payload item.
      Returns:
      size in bytes in the corresponding response message, this item would add to an existing response message.