Class MatrixSignalMast

  • All Implemented Interfaces:
    java.beans.VetoableChangeListener, java.lang.Comparable<NamedBean>, java.util.EventListener, PropertyChangeProvider, NamedBean, Signal, SignalMast

    public class MatrixSignalMast
    extends AbstractSignalMast
    SignalMast implemented via a Binary Matrix (Truth Table) of Apects x Turnout objects.

    A MatrixSignalMast is built up from an array of turnouts to control each aspect. System name specifies the creation information (except for the actual output beans):

    The name is a colon-separated series of terms:
    • IF$xsm - defines signal masts of this type (x for matriX)
    • basic - name of the signaling system
    • one-searchlight - name of the particular aspect map/mast model
    • ($0001) - small ordinal number for telling various matrix signal masts apart
    • name ending in -nt for (binary) Turnout outputs where n = the number of binary outputs, between 1 and mastBitNum i.e. -3t
    • Constructor Detail

      • MatrixSignalMast

        public MatrixSignalMast​(java.lang.String systemName,
                                java.lang.String userName)
    • Method Detail

      • setBitsForAspect

        public void setBitsForAspect​(java.lang.String aspect,
                                     char[] bitArray)
        Store bits in aspectToOutput hashmap, synchronized.

        Length of bitArray should match the number of outputs defined, so one digit per output.

        aspect - String valid aspect to define
        bitArray - char[] of on/off outputs for the aspect, like "00010"
      • getBitsForAspect

        public char[] getBitsForAspect​(java.lang.String aspect)
        Look up the pattern for an aspect.
        aspect - String describing a (valid) signal mast aspect, like "Clear" only called for an already existing mast
        char[] of on/off outputs per aspect, like "00010" length of array should match the number of outputs defined when a mast is changed in the interface, extra 0's are added or superfluous elements deleted by the Add Mast panel
      • setUnLitBits

        public void setUnLitBits​(@Nonnull
                                 java.lang.String bitString)
        Receive unLitBits from xml and store.
        bitString - String for 1-n 1/0 chararacters setting an unlit aspect
      • getUnLitBits

        public char[] getUnLitBits()
        Provide Unlit bits to panel for editing.
        char[] containing a series of 1's and 0's set for Unlit mast
      • getUnLitChars

        public java.lang.String getUnLitChars()
        Hand unLitBits to xml.
        String for 1-n 1/0 chararacters setting an unlit aspect
      • getOutputHandle

        public NamedBeanHandle<TurnoutgetOutputHandle​(int colNum)
        Fetch output from outputsToBeans hashmap. Used?
        colNum - int index (1 up to mastBitNum) for the column of the desired output
        NamedBeanHandle to the configured turnout output
      • getOutputName

        public java.lang.String getOutputName​(int colnum)
        Fetch output from outputsToBeans hashmap and provide to xml.
        colnum - int index (1 up to mastBitNum) for the column of the desired output
        String with the desplay name of the configured turnout output
        See Also:
      • setBitstring

        public void setBitstring​(java.lang.String aspect,
                                 char[] bitArray)
        Receive aspect name from xml and store matching setting in outputsToBeans hashmap.
        aspect - String describing (valid) signal mast aspect, like "Clear"
        bitArray - char[] of 1/0 digits representing on/off outputs per aspect, like {0,0,0,1,0}
      • getBitstring

        public java.lang.String getBitstring​(@Nonnull
                                             java.lang.String aspect)
        Provide one series of on/off digits from aspectToOutput hashmap to xml.
        aspect - String describing valid signal mast aspect, like "Clear"
        bitString String of 1 (= on) and 0 (= off) chars
      • getOutputs

        public java.util.List<java.lang.String> getOutputs()
        Provide the names of the on/off turnout outputs from outputsToBeans hashmap to xml.
        outputlist List<String> of display names for the outputs in order 1 to (max) mastBitNum
      • setOutput

        public void setOutput​(@Nonnull
                              java.lang.String colname,
                              java.lang.String turnoutname)
        Receive properties from xml, convert name to NamedBeanHandle, store in hashmap outputsToBeans.
        colname - String describing the name of the corresponding output, like "output1"
        turnoutname - String for the display name of the output, like "LT1"
      • updateOutputs

        public void updateOutputs​(char[] bits)
        Send hardware instruction.
        bits - char[] of on/off outputs per aspect, like "00010" Length of array should match the number of outputs defined
      • resetPreviousStates

        public void resetPreviousStates​(boolean boo)
        If the signal mast driver requires the previous state to be cleared down before the next state is set.
        boo - true to configure for intermediate reset step
      • getLastRef

        public static int getLastRef()
        highest ordinal of all MatrixSignalMasts in use
      • setLastRef

        protected static void setLastRef​(int newVal)
        newVal - for ordinal of all MatrixSignalMasts in use
      • setBitNum

        public void setBitNum​(int number)
        Store number of outputs from integer.
        number - int for the number of outputs defined for this mast
        See Also:
      • setBitNum

        public void setBitNum​(char[] bits)
        Store number of outputs from integer.
        bits - char[] for outputs defined for this mast
        See Also:
      • dispose

        public void dispose()
        Description copied from class: AbstractNamedBean
        Deactivate this object, so that it releases as many resources as possible and no longer effects others.

        For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.

        It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.

        Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.

        Specified by:
        dispose in interface NamedBean
        dispose in class AbstractNamedBean