Class VotingEvaluator<T>
java.lang.Object
neqsim.process.logic.voting.VotingEvaluator<T>
- Type Parameters:
T- type of input values (Boolean for digital, Double for analog)
Generic voting logic evaluator for redundant sensors or conditions.
Voting logic is used throughout process control and safety systems to increase reliability by requiring multiple independent signals to agree before taking action. This generic implementation supports:
- Digital voting (boolean conditions: 1oo2, 2oo3, etc.)
- Analog voting (continuous values: average, median, mid-value select)
- Configurable voting patterns
- Sensor fault detection and exclusion
Common applications:
- Safety systems (HIPPS, Fire & Gas, ESD)
- Critical process measurements (pressure, temperature, level)
- Redundant control loops
- Quality measurements
Example usage:
// Digital voting: 2 out of 3 pressure switches must be high VotingEvaluator<Boolean> pressureVoting = new VotingEvaluator<>(VotingPattern.TWO_OUT_OF_THREE); pressureVoting.addInput(pt1.isHigh(), pt1.isFaulty()); pressureVoting.addInput(pt2.isHigh(), pt2.isFaulty()); pressureVoting.addInput(pt3.isHigh(), pt3.isFaulty()); boolean pressureHigh = pressureVoting.evaluateDigital(); // Analog voting: median of 3 temperature sensors VotingEvaluator<Double> tempVoting = new VotingEvaluator<>(VotingPattern.TWO_OUT_OF_THREE); tempVoting.addInput(tt1.getValue(), tt1.isFaulty()); tempVoting.addInput(tt2.getValue(), tt2.isFaulty()); tempVoting.addInput(tt3.getValue(), tt3.isFaulty()); double temperature = tempVoting.evaluateMedian();
- Version:
- 1.0
- Author:
- ESOL
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classInternal class to store voting input with fault status. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<VotingEvaluator.VotingInput<T>> private final VotingPattern -
Constructor Summary
ConstructorsConstructorDescriptionVotingEvaluator(VotingPattern pattern) Creates a voting evaluator with specified pattern. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an input to the voting group.voidClears all inputs.doubleEvaluates analog voting using average.booleanEvaluates digital (boolean) voting.doubleEvaluates analog voting using median selection.doubleEvaluates analog voting using mid-value select.intGets the number of faulty inputs.Gets the voting pattern.intGets the total number of inputs.intGets the number of valid (non-faulty) inputs.
-
Field Details
-
pattern
-
inputs
-
-
Constructor Details
-
VotingEvaluator
Creates a voting evaluator with specified pattern.- Parameters:
pattern- voting pattern (1oo1, 1oo2, 2oo2, 2oo3, etc.)
-
-
Method Details
-
addInput
Adds an input to the voting group.- Parameters:
value- current value (Boolean or Double)faulty- true if this input is faulty
-
clearInputs
public void clearInputs()Clears all inputs. -
evaluateDigital
public boolean evaluateDigital()Evaluates digital (boolean) voting.Counts how many non-faulty inputs are TRUE and applies voting pattern.
- Returns:
- true if voting condition is met
- Throws:
IllegalStateException- if inputs are not Boolean type
-
evaluateMedian
public double evaluateMedian()Evaluates analog voting using median selection.Returns the median value of non-faulty inputs. Median is preferred over average for safety systems as it's less sensitive to outliers.
- Returns:
- median value
- Throws:
IllegalStateException- if inputs are not Double type or insufficient valid inputs
-
evaluateAverage
public double evaluateAverage()Evaluates analog voting using average.- Returns:
- average of non-faulty inputs
- Throws:
IllegalStateException- if no valid inputs
-
evaluateMidValue
public double evaluateMidValue()Evaluates analog voting using mid-value select.For 3 inputs, returns the middle value (not highest, not lowest). This provides some outlier rejection like median but is more intuitive for 3-input systems.
- Returns:
- mid-value
- Throws:
IllegalStateException- if insufficient valid inputs
-
getPattern
-
getValidInputCount
public int getValidInputCount()Gets the number of valid (non-faulty) inputs.- Returns:
- valid input count
-
getFaultyInputCount
public int getFaultyInputCount()Gets the number of faulty inputs.- Returns:
- faulty input count
-
getTotalInputCount
public int getTotalInputCount()Gets the total number of inputs.- Returns:
- total input count
-