jmri
Interface Conditional

All Superinterfaces:
NamedBean
All Known Implementing Classes:
DefaultConditional, SensorGroupConditional

public interface Conditional
extends NamedBean

A Conditional is layout control logic, consisting of a logical expression and an action.

A Conditional does not exist on its own, but is part of a Logix. The system name of each Conditional is set automatically when the conditional is created. It begins with the system name of its parent Logix. There is no Conditional Table. Conditionals are created, editted, and deleted via the Logix Table.

A Conditional has a "state", which changes depending on whether its logical expression calculates to TRUE or FALSE. The "state" may not be changed by the user. It only changes in response to changes in the "state variables" used in its logical expression.

Listeners may be set to monitor a change in the state of a conditional.


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.

Author:
Dave Duchamp Copyright (C) 2007, 2008

Field Summary
static int ACTION_CANCEL_SENSOR_TIMERS
           
static int ACTION_CANCEL_TURNOUT_TIMERS
           
static int ACTION_CLEAR_SIGNAL_HELD
           
static int ACTION_COPY_MEMORY
           
static int ACTION_DELAYED_SENSOR
           
static int ACTION_DELAYED_TURNOUT
           
static int ACTION_DISABLE_LOGIX
           
static int ACTION_ENABLE_LOGIX
           
static int ACTION_LOCK_TURNOUT
           
static int ACTION_NONE
           
static int ACTION_OPTION_ON_CHANGE
           
static int ACTION_OPTION_ON_CHANGE_TO_FALSE
           
static int ACTION_OPTION_ON_CHANGE_TO_TRUE
           
static int ACTION_PLAY_SOUND
           
static int ACTION_RESET_DELAYED_SENSOR
           
static int ACTION_RESET_DELAYED_TURNOUT
           
static int ACTION_RUN_SCRIPT
           
static int ACTION_SET_FAST_CLOCK_TIME
           
static int ACTION_SET_LIGHT
           
static int ACTION_SET_LIGHT_INTENSITY
           
static int ACTION_SET_LIGHT_TRANSITION_TIME
           
static int ACTION_SET_MEMORY
           
static int ACTION_SET_SENSOR
           
static int ACTION_SET_SIGNAL_APPEARANCE
           
static int ACTION_SET_SIGNAL_DARK
           
static int ACTION_SET_SIGNAL_HELD
           
static int ACTION_SET_SIGNAL_LIT
           
static int ACTION_SET_TURNOUT
           
static int ACTION_START_FAST_CLOCK
           
static int ACTION_STOP_FAST_CLOCK
           
static int ACTION_TRIGGER_ROUTE
           
static int ALL_AND
           
static int ALL_OR
           
static int FALSE
           
static int MAX_STATE_VARIABLES
           
static int MIXED
           
static int NUM_ACTION_OPTIONS
           
static int NUM_ACTION_TYPES
           
static int NUM_STATE_VARIABLE_TYPES
           
static int OPERATOR_AND
           
static int OPERATOR_AND_NOT
           
static int OPERATOR_NONE
           
static int OPERATOR_NOT
           
static int OPERATOR_OR
           
static int OPERATOR_OR_NOT
           
static int TRUE
           
static int TYPE_CONDITIONAL_FALSE
           
static int TYPE_CONDITIONAL_TRUE
           
static int TYPE_FAST_CLOCK_RANGE
           
static int TYPE_LIGHT_OFF
           
static int TYPE_LIGHT_ON
           
static int TYPE_MEMORY_EQUALS
           
static int TYPE_NONE
           
static int TYPE_SENSOR_ACTIVE
           
static int TYPE_SENSOR_INACTIVE
           
static int TYPE_SIGNAL_HEAD_DARK
           
static int TYPE_SIGNAL_HEAD_FLASHGREEN
           
static int TYPE_SIGNAL_HEAD_FLASHRED
           
static int TYPE_SIGNAL_HEAD_FLASHYELLOW
           
static int TYPE_SIGNAL_HEAD_GREEN
           
static int TYPE_SIGNAL_HEAD_HELD
           
static int TYPE_SIGNAL_HEAD_LIT
           
static int TYPE_SIGNAL_HEAD_RED
           
static int TYPE_SIGNAL_HEAD_YELLOW
           
static int TYPE_TURNOUT_CLOSED
           
static int TYPE_TURNOUT_THROWN
           
static int UNKNOWN
           
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          Request a call-back when the bound KnownState property changes.
 int calculate(boolean enabled, PropertyChangeEvent evt)
          Calculate this Conditional, triggering either or both actions if the user specified conditions are met, and the Logix is enabled.
 void cancelSensorTimer(String sname)
          Stop a sensor timer if one is actively delaying setting of the specified sensor
 void cancelTurnoutTimer(String sname)
          Stop a turnout timer if one is actively delaying setting of the specified turnout
 void dispose()
          Remove references to and from this object, so that it can eventually be garbage-collected.
 String getAntecedentExpression()
          Get antecedent (boolean expression) of Conditional
 ArrayList<ConditionalAction> getCopyOfActions()
          Make deep clone of actions
 ArrayList<ConditionalVariable> getCopyOfStateVariables()
          Make deep clone of variables
 int getLogicType()
          Get type of operators in the antecedent statement
 int getState()
          State of the Conditional is returned.
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove a request for a call-back when a bound property changes.
 void setAction(ArrayList<ConditionalAction> arrayList)
          Set list of actions
 void setLogicType(int type, String antecedent)
          set the logic type (all AND's all OR's or mixed AND's and OR's set the antecedent expression - should be a well formed boolean statement with parenthesis indicating the order of evaluation
 void setStateVariables(ArrayList<ConditionalVariable> arrayList)
          Set State Variables for this Conditional.
 String validateAntecedent(String ant, ArrayList<ConditionalVariable> variableList)
          Check that an antecedent is well formed.
 
Methods inherited from interface jmri.NamedBean
getComment, getNumPropertyChangeListeners, getSystemName, getUserName, setComment, setState, setUserName
 

Field Detail

TRUE

static final int TRUE
See Also:
Constant Field Values

FALSE

static final int FALSE
See Also:
Constant Field Values

UNKNOWN

static final int UNKNOWN
See Also:
Constant Field Values

ALL_AND

static final int ALL_AND
See Also:
Constant Field Values

ALL_OR

static final int ALL_OR
See Also:
Constant Field Values

MIXED

static final int MIXED
See Also:
Constant Field Values

MAX_STATE_VARIABLES

static final int MAX_STATE_VARIABLES
See Also:
Constant Field Values

OPERATOR_AND

static final int OPERATOR_AND
See Also:
Constant Field Values

OPERATOR_NOT

static final int OPERATOR_NOT
See Also:
Constant Field Values

OPERATOR_AND_NOT

static final int OPERATOR_AND_NOT
See Also:
Constant Field Values

OPERATOR_NONE

static final int OPERATOR_NONE
See Also:
Constant Field Values

OPERATOR_OR

static final int OPERATOR_OR
See Also:
Constant Field Values

OPERATOR_OR_NOT

static final int OPERATOR_OR_NOT
See Also:
Constant Field Values

NUM_STATE_VARIABLE_TYPES

static final int NUM_STATE_VARIABLE_TYPES
See Also:
Constant Field Values

TYPE_NONE

static final int TYPE_NONE
See Also:
Constant Field Values

TYPE_SENSOR_ACTIVE

static final int TYPE_SENSOR_ACTIVE
See Also:
Constant Field Values

TYPE_SENSOR_INACTIVE

static final int TYPE_SENSOR_INACTIVE
See Also:
Constant Field Values

TYPE_TURNOUT_THROWN

static final int TYPE_TURNOUT_THROWN
See Also:
Constant Field Values

TYPE_TURNOUT_CLOSED

static final int TYPE_TURNOUT_CLOSED
See Also:
Constant Field Values

TYPE_CONDITIONAL_TRUE

static final int TYPE_CONDITIONAL_TRUE
See Also:
Constant Field Values

TYPE_CONDITIONAL_FALSE

static final int TYPE_CONDITIONAL_FALSE
See Also:
Constant Field Values

TYPE_LIGHT_ON

static final int TYPE_LIGHT_ON
See Also:
Constant Field Values

TYPE_LIGHT_OFF

static final int TYPE_LIGHT_OFF
See Also:
Constant Field Values

TYPE_MEMORY_EQUALS

static final int TYPE_MEMORY_EQUALS
See Also:
Constant Field Values

TYPE_FAST_CLOCK_RANGE

static final int TYPE_FAST_CLOCK_RANGE
See Also:
Constant Field Values

TYPE_SIGNAL_HEAD_RED

static final int TYPE_SIGNAL_HEAD_RED
See Also:
Constant Field Values

TYPE_SIGNAL_HEAD_YELLOW

static final int TYPE_SIGNAL_HEAD_YELLOW
See Also:
Constant Field Values

TYPE_SIGNAL_HEAD_GREEN

static final int TYPE_SIGNAL_HEAD_GREEN
See Also:
Constant Field Values

TYPE_SIGNAL_HEAD_DARK

static final int TYPE_SIGNAL_HEAD_DARK
See Also:
Constant Field Values

TYPE_SIGNAL_HEAD_FLASHRED

static final int TYPE_SIGNAL_HEAD_FLASHRED
See Also:
Constant Field Values

TYPE_SIGNAL_HEAD_FLASHYELLOW

static final int TYPE_SIGNAL_HEAD_FLASHYELLOW
See Also:
Constant Field Values

TYPE_SIGNAL_HEAD_FLASHGREEN

static final int TYPE_SIGNAL_HEAD_FLASHGREEN
See Also:
Constant Field Values

TYPE_SIGNAL_HEAD_LIT

static final int TYPE_SIGNAL_HEAD_LIT
See Also:
Constant Field Values

TYPE_SIGNAL_HEAD_HELD

static final int TYPE_SIGNAL_HEAD_HELD
See Also:
Constant Field Values

ACTION_OPTION_ON_CHANGE_TO_TRUE

static final int ACTION_OPTION_ON_CHANGE_TO_TRUE
See Also:
Constant Field Values

ACTION_OPTION_ON_CHANGE_TO_FALSE

static final int ACTION_OPTION_ON_CHANGE_TO_FALSE
See Also:
Constant Field Values

ACTION_OPTION_ON_CHANGE

static final int ACTION_OPTION_ON_CHANGE
See Also:
Constant Field Values

NUM_ACTION_OPTIONS

static final int NUM_ACTION_OPTIONS
See Also:
Constant Field Values

NUM_ACTION_TYPES

static final int NUM_ACTION_TYPES
See Also:
Constant Field Values

ACTION_NONE

static final int ACTION_NONE
See Also:
Constant Field Values

ACTION_SET_TURNOUT

static final int ACTION_SET_TURNOUT
See Also:
Constant Field Values

ACTION_SET_SIGNAL_APPEARANCE

static final int ACTION_SET_SIGNAL_APPEARANCE
See Also:
Constant Field Values

ACTION_SET_SIGNAL_HELD

static final int ACTION_SET_SIGNAL_HELD
See Also:
Constant Field Values

ACTION_CLEAR_SIGNAL_HELD

static final int ACTION_CLEAR_SIGNAL_HELD
See Also:
Constant Field Values

ACTION_SET_SIGNAL_DARK

static final int ACTION_SET_SIGNAL_DARK
See Also:
Constant Field Values

ACTION_SET_SIGNAL_LIT

static final int ACTION_SET_SIGNAL_LIT
See Also:
Constant Field Values

ACTION_TRIGGER_ROUTE

static final int ACTION_TRIGGER_ROUTE
See Also:
Constant Field Values

ACTION_SET_SENSOR

static final int ACTION_SET_SENSOR
See Also:
Constant Field Values

ACTION_DELAYED_SENSOR

static final int ACTION_DELAYED_SENSOR
See Also:
Constant Field Values

ACTION_SET_LIGHT

static final int ACTION_SET_LIGHT
See Also:
Constant Field Values

ACTION_SET_MEMORY

static final int ACTION_SET_MEMORY
See Also:
Constant Field Values

ACTION_ENABLE_LOGIX

static final int ACTION_ENABLE_LOGIX
See Also:
Constant Field Values

ACTION_DISABLE_LOGIX

static final int ACTION_DISABLE_LOGIX
See Also:
Constant Field Values

ACTION_PLAY_SOUND

static final int ACTION_PLAY_SOUND
See Also:
Constant Field Values

ACTION_RUN_SCRIPT

static final int ACTION_RUN_SCRIPT
See Also:
Constant Field Values

ACTION_DELAYED_TURNOUT

static final int ACTION_DELAYED_TURNOUT
See Also:
Constant Field Values

ACTION_LOCK_TURNOUT

static final int ACTION_LOCK_TURNOUT
See Also:
Constant Field Values

ACTION_RESET_DELAYED_SENSOR

static final int ACTION_RESET_DELAYED_SENSOR
See Also:
Constant Field Values

ACTION_CANCEL_SENSOR_TIMERS

static final int ACTION_CANCEL_SENSOR_TIMERS
See Also:
Constant Field Values

ACTION_RESET_DELAYED_TURNOUT

static final int ACTION_RESET_DELAYED_TURNOUT
See Also:
Constant Field Values

ACTION_CANCEL_TURNOUT_TIMERS

static final int ACTION_CANCEL_TURNOUT_TIMERS
See Also:
Constant Field Values

ACTION_SET_FAST_CLOCK_TIME

static final int ACTION_SET_FAST_CLOCK_TIME
See Also:
Constant Field Values

ACTION_START_FAST_CLOCK

static final int ACTION_START_FAST_CLOCK
See Also:
Constant Field Values

ACTION_STOP_FAST_CLOCK

static final int ACTION_STOP_FAST_CLOCK
See Also:
Constant Field Values

ACTION_COPY_MEMORY

static final int ACTION_COPY_MEMORY
See Also:
Constant Field Values

ACTION_SET_LIGHT_INTENSITY

static final int ACTION_SET_LIGHT_INTENSITY
See Also:
Constant Field Values

ACTION_SET_LIGHT_TRANSITION_TIME

static final int ACTION_SET_LIGHT_TRANSITION_TIME
See Also:
Constant Field Values
Method Detail

setLogicType

void setLogicType(int type,
                  String antecedent)
set the logic type (all AND's all OR's or mixed AND's and OR's set the antecedent expression - should be a well formed boolean statement with parenthesis indicating the order of evaluation


getAntecedentExpression

String getAntecedentExpression()
Get antecedent (boolean expression) of Conditional


getLogicType

int getLogicType()
Get type of operators in the antecedent statement


setAction

void setAction(ArrayList<ConditionalAction> arrayList)
Set list of actions


getCopyOfActions

ArrayList<ConditionalAction> getCopyOfActions()
Make deep clone of actions


setStateVariables

void setStateVariables(ArrayList<ConditionalVariable> arrayList)
Set State Variables for this Conditional. Each state variable will evaluate either True or False when this Conditional is calculated.

This method assumes that all information has been validated.


getCopyOfStateVariables

ArrayList<ConditionalVariable> getCopyOfStateVariables()
Make deep clone of variables


calculate

int calculate(boolean enabled,
              PropertyChangeEvent evt)
Calculate this Conditional, triggering either or both actions if the user specified conditions are met, and the Logix is enabled. Sets the state of the conditional. Returns the calculated state of this Conditional.


validateAntecedent

String validateAntecedent(String ant,
                          ArrayList<ConditionalVariable> variableList)
Check that an antecedent is well formed. If not, returns an error message. Otherwise returns null.


cancelSensorTimer

void cancelSensorTimer(String sname)
Stop a sensor timer if one is actively delaying setting of the specified sensor


cancelTurnoutTimer

void cancelTurnoutTimer(String sname)
Stop a turnout timer if one is actively delaying setting of the specified turnout


getState

int getState()
State of the Conditional is returned.

Specified by:
getState in interface NamedBean
Returns:
state value

addPropertyChangeListener

void addPropertyChangeListener(PropertyChangeListener l)
Request a call-back when the bound KnownState property changes.

Specified by:
addPropertyChangeListener in interface NamedBean

removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener l)
Remove a request for a call-back when a bound property changes.

Specified by:
removePropertyChangeListener in interface NamedBean

dispose

void dispose()
Remove references to and from this object, so that it can eventually be garbage-collected.

Specified by:
dispose in interface NamedBean


Copyright © 1997 - 2009 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads