Class LogicBlock

java.lang.Object
neqsim.util.NamedBaseClass
neqsim.process.controllerdevice.LogicBlock
All Implemented Interfaces:
Serializable, ControllerDeviceInterface, ProcessElementInterface, NamedInterface

public class LogicBlock extends NamedBaseClass implements ControllerDeviceInterface
Logic operator block for control system simulation in dynamic mode. Supports AND, OR, NOT, NAND, NOR, and XOR operations on boolean input signals. Each input signal is derived from a MeasurementDeviceInterface by comparing the measured value against a configurable threshold.

The block evaluates its logic expression each transient step and produces a boolean output accessible via getOutput() (returns 1.0 for true, 0.0 for false). This output can drive downstream equipment such as on/off valves, emergency shutdown sequences, or alarm interlocks.

Example — interlock requiring high pressure AND high temperature:

LogicBlock esd = new LogicBlock("ESD-001", LogicBlock.Operator.AND);
esd.addInput(pressureTransmitter, 120.0, LogicBlock.Comparator.GREATER_THAN);
esd.addInput(temperatureTransmitter, 85.0, LogicBlock.Comparator.GREATER_THAN);
process.add(esd);
// During dynamic: esd.getOutput() returns 1.0 when both conditions are met
Version:
1.0
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version UID.
      See Also:
    • operator

      private final LogicBlock.Operator operator
      Logic operator for this block.
    • inputs

      private final List<LogicBlock.LogicInput> inputs
      Input definitions.
    • output

      private double output
      Current output state: 1.0 = true, 0.0 = false.
    • isActive

      private boolean isActive
      Whether this block is active in the simulation.
    • unit

      private String unit
      Controller unit string.
    • equalityTolerance

      private double equalityTolerance
      Tolerance for EQUAL comparison.
    • calcIdentifier

      protected UUID calcIdentifier
      UUID from last calculation.
  • Constructor Details

    • LogicBlock

      public LogicBlock(String name, LogicBlock.Operator operator)
      Constructor for LogicBlock.
      Parameters:
      name - identifier for this logic block
      operator - the logical operation to perform
  • Method Details

    • addInput

      public void addInput(MeasurementDeviceInterface device, double threshold, LogicBlock.Comparator comparator)
      Add an input signal from a measurement device with a comparison threshold.
      Parameters:
      device - the measurement device providing the signal
      threshold - the threshold value for comparison
      comparator - how to compare the measurement against the threshold
    • addFixedInput

      public void addFixedInput(boolean fixedValue)
      Add a boolean input that is always true or false (for testing or fixed interlocks).
      Parameters:
      fixedValue - true or false
    • addInput

      public void addInput(LogicBlock upstreamBlock)
      Add a chained input from another LogicBlock's output (for composite logic).
      Parameters:
      upstreamBlock - the upstream logic block whose output becomes this input
    • getOutput

      public double getOutput()
      Get the current output of this logic block.
      Returns:
      1.0 if the logic condition is true, 0.0 if false
    • getOutputBoolean

      public boolean getOutputBoolean()
      Get the current output as a boolean.
      Returns:
      true if the logic condition is met
    • getOperator

      public LogicBlock.Operator getOperator()
      Get the logical operator used by this block.
      Returns:
      the operator
    • getInputs

      public List<LogicBlock.LogicInput> getInputs()
      Get the list of inputs (unmodifiable).
      Returns:
      list of logic inputs
    • setEqualityTolerance

      public void setEqualityTolerance(double tolerance)
      Set the tolerance for EQUAL comparisons.
      Parameters:
      tolerance - the equality tolerance (must be non-negative)
    • getMeasuredValue

      public double getMeasuredValue()

      getMeasuredValue.

      Specified by:
      getMeasuredValue in interface ControllerDeviceInterface
      Returns:
      a double
    • setControllerSetPoint

      public void setControllerSetPoint(double signal)

      setControllerSetPoint.

      Specified by:
      setControllerSetPoint in interface ControllerDeviceInterface
      Parameters:
      signal - a double
    • getControllerSetPoint

      public double getControllerSetPoint()

      getControllerSetPoint.

      Specified by:
      getControllerSetPoint in interface ControllerDeviceInterface
      Returns:
      current controller set point
    • getUnit

      public String getUnit()

      getUnit.

      Specified by:
      getUnit in interface ControllerDeviceInterface
      Returns:
      a String object
    • setUnit

      public void setUnit(String unit)

      setUnit.

      Specified by:
      setUnit in interface ControllerDeviceInterface
      Parameters:
      unit - a String object
    • setTransmitter

      public void setTransmitter(MeasurementDeviceInterface device)

      setTransmitter.

      Specified by:
      setTransmitter in interface ControllerDeviceInterface
      Parameters:
      device - a MeasurementDeviceInterface object
    • runTransient

      public void runTransient(double initResponse, double dt, UUID id)

      runTransient.

      Calculates controller output. Sets calc identifier UUID.
      Specified by:
      runTransient in interface ControllerDeviceInterface
      Parameters:
      initResponse - Init value for response calculation
      dt - Delta time [s]
      id - Calculation identifier
    • getResponse

      public double getResponse()

      getResponse.

      Specified by:
      getResponse in interface ControllerDeviceInterface
      Returns:
      a double
    • isReverseActing

      public boolean isReverseActing()

      isReverseActing.

      Specified by:
      isReverseActing in interface ControllerDeviceInterface
      Returns:
      a boolean
    • setReverseActing

      public void setReverseActing(boolean reverseActing)

      setReverseActing.

      Specified by:
      setReverseActing in interface ControllerDeviceInterface
      Parameters:
      reverseActing - a boolean
    • setControllerParameters

      public void setControllerParameters(double Kp, double Ti, double Td)

      Set PID tuning parameters.

      Specified by:
      setControllerParameters in interface ControllerDeviceInterface
      Parameters:
      Kp - Proportional gain
      Ti - Integral time in seconds
      Td - Derivative time in seconds
    • setActive

      public void setActive(boolean isActive)

      setActive.

      Set if controller is active
      Specified by:
      setActive in interface ControllerDeviceInterface
      Parameters:
      isActive - Set true to make controller active.
    • isActive

      public boolean isActive()

      isActive.

      Specifies if controller is active
      Specified by:
      isActive in interface ControllerDeviceInterface
      Returns:
      a boolean
    • evaluateAnd

      private boolean evaluateAnd(List<Boolean> values)
    • evaluateOr

      private boolean evaluateOr(List<Boolean> values)
    • evaluateNot

      private boolean evaluateNot(List<Boolean> values)
    • evaluateXor

      private boolean evaluateXor(List<Boolean> values)