jmri
Class DefaultLogix

java.lang.Object
  extended by jmri.AbstractNamedBean
      extended by jmri.DefaultLogix
All Implemented Interfaces:
Serializable, Logix, NamedBean

public class DefaultLogix
extends AbstractNamedBean
implements Logix, Serializable

Class providing the basic logic of the Logix interface.

Author:
Dave Duchamp Copyright (C) 2007
See Also:
Serialized Form

Field Summary
protected  int[] mConditionalOrder
           
protected  String[] mConditionalSystemNames
          Persistant instance variables (saved between runs)
protected  int mCurrentMinutes
           
protected  Timebase mFastClock
           
protected  PropertyChangeListener mFastClockListener
           
protected  String[] mListenerData
           
protected  String[] mListenerName
           
protected  String[] mListenerProperty
           
protected  PropertyChangeListener[] mListeners
           
protected  int[] mListenerState
           
protected  int[] mListenerType
           
protected  int[] mListenerVarType
           
protected  int[] mMinuteBeginTime
           
protected  int[] mMinuteEndTime
           
protected  int mNextConditionalNumber
          Operational instance variables (not saved between runs)
protected  int mNumConditionals
           
protected  int mNumMinuteListenerTimes
           
 
Fields inherited from interface jmri.Logix
LISTENER_TYPE_CONDITIONAL, LISTENER_TYPE_LIGHT, LISTENER_TYPE_MEMORY, LISTENER_TYPE_SENSOR, LISTENER_TYPE_SIGNAL, LISTENER_TYPE_TURNOUT, MAX_CONDITIONALS, MAX_LISTENERS
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
DefaultLogix(String systemName)
           
DefaultLogix(String systemName, String userName)
           
 
Method Summary
 void activateLogix()
          Activate the Logix, starts Logix processing by connecting all inputs that are included the Conditionals in this Logix.
 boolean addConditional(String systemName, int order)
          Add a Conditional to this Logix Returns true if Conditional was successfully added, returns false if the maximum number of conditionals has been exceeded.
 void calculateConditionals()
          Calculate all Conditionals, triggering action if the user specified conditions are met, and the Logix is enabled.
 boolean checkLoopCondition()
          Assembles a list of state variables that both trigger the Logix, and are changed by it.
 void deActivateLogix()
          Deactivate the Logix.
 boolean deleteConditional(String systemName)
          Delete a Conditional and remove it from this Logix Note: Since each Logix must have at least one Conditional to do anything, the user is warned in Logix Table Action when the last Conditional is deleted.
 String getConditionalByNumberOrder(int order)
          Returns the system name of the conditional that will calculate in the specified order.
 boolean getEnabled()
          Get enabled status
 String getLoopGremlins()
          Returns a string listing state variables that might result in a loop.
 int getNextConditionalNumber()
          Get never used number for next Conditional system name
 int getNumConditionals()
          Get number of Conditionals for this Logix
 int getState()
          Not needed for Logixs - included to complete implementation of the NamedBean interface.
 int getStateVariableList(String[] varName, int[] varListenerType, String[] varListenerProperty, int[] varAppearance, int[] numTriggersCalc, int[] numTriggerSuppressed, int arrayMax)
          Assembles and returns a list of state variables that are used by conditionals of this Logix including the number of occurances of each variable that trigger a calculation, and the number of occurances where the triggering has been suppressed.
 void initializeReorder()
          Initialize for reordering Conditionals
 boolean nextConditionalInOrder(int oldOrder)
          Make the conditional with given current order, the next in order Returns 'true' if reordering is done, returns 'false' if continue
 void setEnabled(boolean state)
          Set enabled status.
 void setState(int state)
          Not needed for Logixs - included to complete implementation of the NamedBean interface.
 
Methods inherited from class jmri.AbstractNamedBean
addPropertyChangeListener, dispose, firePropertyChange, getComment, getNumPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setUserName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, dispose, getComment, getNumPropertyChangeListeners, getSystemName, getUserName, removePropertyChangeListener, setComment, setUserName
 

Field Detail

mConditionalSystemNames

protected String[] mConditionalSystemNames
Persistant instance variables (saved between runs)


mConditionalOrder

protected int[] mConditionalOrder

mNextConditionalNumber

protected int mNextConditionalNumber
Operational instance variables (not saved between runs)


mNumConditionals

protected int mNumConditionals

mListeners

protected PropertyChangeListener[] mListeners

mListenerName

protected String[] mListenerName

mListenerVarType

protected int[] mListenerVarType

mListenerType

protected int[] mListenerType

mListenerProperty

protected String[] mListenerProperty

mListenerState

protected int[] mListenerState

mListenerData

protected String[] mListenerData

mNumMinuteListenerTimes

protected int mNumMinuteListenerTimes

mMinuteBeginTime

protected int[] mMinuteBeginTime

mMinuteEndTime

protected int[] mMinuteEndTime

mFastClockListener

protected PropertyChangeListener mFastClockListener

mFastClock

protected Timebase mFastClock

mCurrentMinutes

protected int mCurrentMinutes
Constructor Detail

DefaultLogix

public DefaultLogix(String systemName,
                    String userName)

DefaultLogix

public DefaultLogix(String systemName)
Method Detail

getNumConditionals

public int getNumConditionals()
Get number of Conditionals for this Logix

Specified by:
getNumConditionals in interface Logix

initializeReorder

public void initializeReorder()
Initialize for reordering Conditionals

Specified by:
initializeReorder in interface Logix

getNextConditionalNumber

public int getNextConditionalNumber()
Get never used number for next Conditional system name

Specified by:
getNextConditionalNumber in interface Logix

nextConditionalInOrder

public boolean nextConditionalInOrder(int oldOrder)
Make the conditional with given current order, the next in order Returns 'true' if reordering is done, returns 'false' if continue

Specified by:
nextConditionalInOrder in interface Logix

getConditionalByNumberOrder

public String getConditionalByNumberOrder(int order)
Returns the system name of the conditional that will calculate in the specified order. This is also the order the Conditional is listed in the Add/Edit Logix dialog. If 'order' is greater than the number of Conditionals for this Logix, and empty String is returned.

Specified by:
getConditionalByNumberOrder in interface Logix
Parameters:
order - - order in which the Conditional calculates.

addConditional

public boolean addConditional(String systemName,
                              int order)
Add a Conditional to this Logix Returns true if Conditional was successfully added, returns false if the maximum number of conditionals has been exceeded.

Specified by:
addConditional in interface Logix
Parameters:
systemName - The Conditional system name
order - - the order this conditional should calculate in if order is negative, the conditional is added at the end of current group of conditionals

setEnabled

public void setEnabled(boolean state)
Set enabled status. Enabled is a bound property All conditionals are set to UNKNOWN state and recalculated when the Logix is enabled, provided the Logix has been previously activated.

Specified by:
setEnabled in interface Logix

getEnabled

public boolean getEnabled()
Get enabled status

Specified by:
getEnabled in interface Logix

deleteConditional

public boolean deleteConditional(String systemName)
Delete a Conditional and remove it from this Logix

Note: Since each Logix must have at least one Conditional to do anything, the user is warned in Logix Table Action when the last Conditional is deleted.

Returns true if Conditional was successfully deleted, otherwise returns false.

Specified by:
deleteConditional in interface Logix
Parameters:
systemName - The Conditional system name

calculateConditionals

public void calculateConditionals()
Calculate all Conditionals, triggering action if the user specified conditions are met, and the Logix is enabled.

Specified by:
calculateConditionals in interface Logix

activateLogix

public void activateLogix()
Activate the Logix, starts Logix processing by connecting all inputs that are included the Conditionals in this Logix.

A Logix must be activated before it will calculate any of its Conditionals.

Specified by:
activateLogix in interface Logix

getStateVariableList

public int getStateVariableList(String[] varName,
                                int[] varListenerType,
                                String[] varListenerProperty,
                                int[] varAppearance,
                                int[] numTriggersCalc,
                                int[] numTriggerSuppressed,
                                int arrayMax)
Assembles and returns a list of state variables that are used by conditionals of this Logix including the number of occurances of each variable that trigger a calculation, and the number of occurances where the triggering has been suppressed. The main use of this method is to return information that can be used to test for inconsistency in suppressing triggering of a calculation among multiple occurances of the same state variable. Note that FastClockRange state varible type is not returned, since each occurance is considered a unique state variable - there is no duplication possible. Returns the number of state variables returned. Note that 'arrayMax' is the dimension of the arrays passed in the call. If more state variables are found than 'arrayMax', the overflow is skipped.

Specified by:
getStateVariableList in interface Logix

deActivateLogix

public void deActivateLogix()
Deactivate the Logix. This method disconnects the Logix from all input objects and stops it from being triggered to calculate.

A Logix must be deactivated before it's Conditionals are changed.

Specified by:
deActivateLogix in interface Logix

checkLoopCondition

public boolean checkLoopCondition()
Assembles a list of state variables that both trigger the Logix, and are changed by it. Returns true if any such variables were found. Returns false otherwise. Note: This method can only work if the Logix is not activated. If the Logix is activated, no testing is done, and false is returned.

Specified by:
checkLoopCondition in interface Logix

getLoopGremlins

public String getLoopGremlins()
Returns a string listing state variables that might result in a loop. Returns an empty string if there are none, probably because "checkLoopCondition" was not invoked before the call, or returned false.

Specified by:
getLoopGremlins in interface Logix

getState

public int getState()
Not needed for Logixs - included to complete implementation of the NamedBean interface.

Specified by:
getState in interface NamedBean

setState

public void setState(int state)
Not needed for Logixs - included to complete implementation of the NamedBean interface.

Specified by:
setState in interface NamedBean


Copyright © 1997 - 2008 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: SourceForge_Logo