Package jmri
Class ConditionalVariable
java.lang.Object
jmri.ConditionalVariable
The variable used in the antecedent (the 'if' part) of the Conditional.
proposition. The states of ConditionalVariables and logic expression of the
antecedent determine the state of the Conditional.
ConditionalVariable objects are fully mutable, so use the default equals() operator that checks for identical objects, not identical contents. This file is part of JMRI.
JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intprotected NamedBeanHandleManagerstatic final int(package private) static final ResourceBundle -
Constructor Summary
ConstructorsConstructorDescriptionCreate a blank ConditionalVariable, to be filled in later.ConditionalVariable(boolean not, Conditional.Operator opern, Conditional.Type type, String name, boolean trigger) Create a ConditionalVariable with a set of given properties. -
Method Summary
Modifier and TypeMethodDescription(package private) booleanCompare two values using the comparator set using the comparison instructions insetNum1(int).booleanIf change of state of this object causes a change of state of the Conditional, should any actions be executed.booleanevaluate()Evaluates this State Variable.static intfixMidnight(int time) getBean()static StringgetCompareOperationString(int index) static StringgetCompareSymbols(int index) static StringConvert Variable Type to Text StringgetName()intgetNum1()Get Data 1.intgetNum2()Get Data 2.getOpern()Provide a localized text for screen display of the logic operator.intgetState()getType()booleanvoidsetDataString(String data) voidsetGuiName(String guiName) Set the GUI name for the conditional state variable.voidvoidsetNegation(boolean not) voidsetNum1(int num) Set Data 1.voidsetNum2(int num) Set Data 2.final voidsetOpern(Conditional.Operator opern) voidsetState(boolean state) voidsetState(int state) voidsetTriggerActions(boolean trigger) voidsetType(Conditional.Type type) static Conditional.TypeIdentify action Data from Text String.toString()
-
Field Details
-
rbx
-
NUM_COMPARE_OPERATIONS
- See Also:
-
LESS_THAN
- See Also:
-
LESS_THAN_OR_EQUAL
- See Also:
-
EQUAL
- See Also:
-
GREATER_THAN_OR_EQUAL
- See Also:
-
GREATER_THAN
- See Also:
-
nbhm
-
-
Constructor Details
-
ConditionalVariable
public ConditionalVariable()Create a blank ConditionalVariable, to be filled in later. -
ConditionalVariable
public ConditionalVariable(boolean not, @Nonnull Conditional.Operator opern, @Nonnull Conditional.Type type, String name, boolean trigger) Create a ConditionalVariable with a set of given properties.- Parameters:
not- true if the ConditionalVariable should be negatedopern- the boolean operator for this ConditionalVariabletype- the type this ConditionalVariable operates on (Turnout, Sensor, ...)name- the device nametrigger- true if actions should be performed if triggered
-
-
Method Details
-
isNegated
-
setNegation
-
getOpern
-
setOpern
-
getType
-
setType
-
getName
-
setName
-
getNamedBean
-
getBean
-
getDataString
-
setDataString
-
getNamedBeanData
-
getNum1
Get Data 1. Used for Fast Clock Start time, and value for Memory expression type, e.g. LESS_THAN or GREATER_THAN- Returns:
- value for Data 1.
-
setNum1
Set Data 1. Used for Fast Clock Start time and Memoey expression operator value.- Parameters:
num- the value.
-
getNum2
Get Data 2. Used for Fast Clock Finish time.- Returns:
- value for Data 2.
-
setNum2
Set Data 2. Used for Fast Clock Finish time.- Parameters:
num- the value.
-
getGuiName
- Returns:
- the GUI name for the referenced conditional.
- Since:
- 4.7.4
-
setGuiName
Set the GUI name for the conditional state variable.- Parameters:
guiName- The referenced Conditional user name.- Since:
- 4.7.4
-
doTriggerActions
If change of state of this object causes a change of state of the Conditional, should any actions be executed.- Returns:
- true if actions should be performed if triggered
-
setTriggerActions
-
getState
-
setState
-
setState
-
getTestTypeString
-
getOpernString
Provide a localized text for screen display of the logic operator.- Returns:
- translated string (from jmri.NamedBeanBundle.properties)
-
evaluate
Evaluates this State Variable.- Returns:
- true if variable evaluates true, otherwise false.
-
compare
Compare two values using the comparator set using the comparison instructions insetNum1(int). Note:getNum1()must be one ofLESS_THAN,LESS_THAN_OR_EQUAL,EQUAL,GREATER_THAN_OR_EQUAL, orGREATER_THAN.- Parameters:
value1- left side of the comparisonvalue2- right side of the comparisoncaseInsensitive- true if comparison should be case insensitive; false otherwise- Returns:
- true if values compare per getNum1(); false otherwise
-
fixMidnight
-
getItemTypeString
Convert Variable Type to Text String- Parameters:
t- the type- Returns:
- the localized description
-
getCompareOperationString
-
getCompareSymbols
-
stringToVariableTest
Identify action Data from Text String.- Parameters:
str- the text to check- Returns:
- the conditional action type or -1 if if string does not correspond to an action Data as defined in ConditionalAction
-
toString
-