Class LogicBlock
java.lang.Object
neqsim.util.NamedBaseClass
neqsim.process.controllerdevice.LogicBlock
- All Implemented Interfaces:
Serializable, ControllerDeviceInterface, ProcessElementInterface, NamedInterface
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classChained input from another LogicBlock.static enumComparison operators used to convert a continuous signal to a boolean.private static classFixed boolean input for testing or permanent interlocks.static classInput definition based on a measurement device and threshold comparison.static enumLogical operators supported by this block.Nested classes/interfaces inherited from interface ControllerDeviceInterface
ControllerDeviceInterface.ControllerMode, ControllerDeviceInterface.StepResponseTuningMethod -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected UUIDUUID from last calculation.private doubleTolerance for EQUAL comparison.private final List<LogicBlock.LogicInput> Input definitions.private booleanWhether this block is active in the simulation.private final LogicBlock.OperatorLogic operator for this block.private doubleCurrent output state: 1.0 = true, 0.0 = false.private static final longSerialization version UID.private StringController unit string.Fields inherited from class NamedBaseClass
name -
Constructor Summary
ConstructorsConstructorDescriptionLogicBlock(String name, LogicBlock.Operator operator) Constructor for LogicBlock. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFixedInput(boolean fixedValue) Add a boolean input that is always true or false (for testing or fixed interlocks).voidaddInput(LogicBlock upstreamBlock) Add a chained input from another LogicBlock's output (for composite logic).voidaddInput(MeasurementDeviceInterface device, double threshold, LogicBlock.Comparator comparator) Add an input signal from a measurement device with a comparison threshold.private booleanevaluateAnd(List<Boolean> values) private booleanevaluateNot(List<Boolean> values) private booleanevaluateOr(List<Boolean> values) private booleanevaluateXor(List<Boolean> values) doublegetControllerSetPoint.Get the list of inputs (unmodifiable).doublegetMeasuredValue.Get the logical operator used by this block.doubleGet the current output of this logic block.booleanGet the current output as a boolean.doublegetResponse.getUnit()getUnit.booleanisActive()isActive.booleanisReverseActing.voidrunTransient(double initResponse, double dt, UUID id) runTransient.voidsetActive(boolean isActive) setActive.voidsetControllerParameters(double Kp, double Ti, double Td) Set PID tuning parameters.voidsetControllerSetPoint(double signal) setControllerSetPoint.voidsetEqualityTolerance(double tolerance) Set the tolerance for EQUAL comparisons.voidsetReverseActing(boolean reverseActing) setReverseActing.voidsetTransmitter.voidsetUnit.Methods inherited from class NamedBaseClass
getName, getTagNumber, setName, setTagNumberMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ControllerDeviceInterface
addGainSchedulePoint, autoTune, autoTune, autoTuneFromEventLog, autoTuneFromEventLog, autoTuneStepResponse, autoTuneStepResponse, equals, getEventLog, getIntegralAbsoluteError, getManualOutput, getMeasuredValue, getMode, getSetpointWeight, getSettlingTime, getStepResponseTuningMethod, hashCode, resetEventLog, resetPerformanceMetrics, runTransient, setControllerSetPoint, setDerivativeFilterTime, setManualOutput, setMode, setOutputLimits, setSetpointWeight, setStepResponseTuningMethodMethods inherited from interface NamedInterface
getName, getTagName, getTagNumber, setName, setTagName, setTagNumber
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
operator
Logic operator for this block. -
inputs
Input definitions. -
output
private double outputCurrent output state: 1.0 = true, 0.0 = false. -
isActive
private boolean isActiveWhether this block is active in the simulation. -
unit
Controller unit string. -
equalityTolerance
private double equalityToleranceTolerance for EQUAL comparison. -
calcIdentifier
UUID from last calculation.
-
-
Constructor Details
-
LogicBlock
Constructor for LogicBlock.- Parameters:
name- identifier for this logic blockoperator- 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 signalthreshold- the threshold value for comparisoncomparator- 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
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
Get the logical operator used by this block.- Returns:
- the operator
-
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:
getMeasuredValuein interfaceControllerDeviceInterface- Returns:
- a double
-
setControllerSetPoint
public void setControllerSetPoint(double signal) setControllerSetPoint.
- Specified by:
setControllerSetPointin interfaceControllerDeviceInterface- Parameters:
signal- a double
-
getControllerSetPoint
public double getControllerSetPoint()getControllerSetPoint.
- Specified by:
getControllerSetPointin interfaceControllerDeviceInterface- Returns:
- current controller set point
-
getUnit
getUnit.
- Specified by:
getUnitin interfaceControllerDeviceInterface- Returns:
- a
Stringobject
-
setUnit
setUnit.
- Specified by:
setUnitin interfaceControllerDeviceInterface- Parameters:
unit- aStringobject
-
setTransmitter
setTransmitter.
- Specified by:
setTransmitterin interfaceControllerDeviceInterface- Parameters:
device- aMeasurementDeviceInterfaceobject
-
runTransient
runTransient.
Calculates controller output. Sets calc identifier UUID.- Specified by:
runTransientin interfaceControllerDeviceInterface- Parameters:
initResponse- Init value for response calculationdt- Delta time [s]id- Calculation identifier
-
getResponse
public double getResponse()getResponse.
- Specified by:
getResponsein interfaceControllerDeviceInterface- Returns:
- a double
-
isReverseActing
public boolean isReverseActing()isReverseActing.
- Specified by:
isReverseActingin interfaceControllerDeviceInterface- Returns:
- a boolean
-
setReverseActing
public void setReverseActing(boolean reverseActing) setReverseActing.
- Specified by:
setReverseActingin interfaceControllerDeviceInterface- Parameters:
reverseActing- a boolean
-
setControllerParameters
public void setControllerParameters(double Kp, double Ti, double Td) Set PID tuning parameters.
- Specified by:
setControllerParametersin interfaceControllerDeviceInterface- Parameters:
Kp- Proportional gainTi- Integral time in secondsTd- Derivative time in seconds
-
setActive
public void setActive(boolean isActive) setActive.
Set if controller is active- Specified by:
setActivein interfaceControllerDeviceInterface- Parameters:
isActive- Set true to make controller active.
-
isActive
public boolean isActive()isActive.
Specifies if controller is active- Specified by:
isActivein interfaceControllerDeviceInterface- Returns:
- a boolean
-
evaluateAnd
-
evaluateOr
-
evaluateNot
-
evaluateXor
-