Class DispatcherActiveTrainManager

  • All Implemented Interfaces:
    BeanInterface, PropertyChangeFirer, PropertyChangeProvider, InstanceManagerAutoDefault

    public class DispatcherActiveTrainManager
    extends Bean
    implements InstanceManagerAutoDefault
    The Dispatcher support in LogixNG provides the ability to start, control, and terminate trains.

    The ActiveTrain class represents a train. An ActiveTrain can be started manually using the ActivateTrainFrame panel. The panel also supports starting predefined trains that are stored as TrainInfo XML files. A TrainInfo file can also be used to start a train using a program such as a Jython script, or in this case, LogixNG.

    Since an active train is a temporary object, the Actions and Expressions use the train info file name as the reference to possible ActiveTrains.

    The contents of a train info file are not unique. While only one active train can be using a transit, multiple files can refer to the transit.

    This class extends Bean so that ExpressionDispatcher objects can listen for changes to the _activeTrainMap. These events are used to add and remove ActiveTrain listeners that capture ActiveTrain status and mode changes.

    This class provides the following features:

    • Provides a list of active train info files.
    • Provides a map to link train info files names to the current ActiveTrain, if any.
    • Creates an ActiveTrain on behalf of the Dispatcher Load Action.
    • Provide the current ActiveTrain object, if any, for the a specific file name.
    • Gracefully terminate an active train that was started by a LogixNG action.
    • Method Detail

      • getTrainInfoFileNames

        public java.util.List<java.lang.String> getTrainInfoFileNames()
        Get a list of existing train info file names.
        an array of file names.
      • getActiveTrain

        public ActiveTrain getActiveTrain​(java.lang.String fileName)
        Get the current ActiveTrain for the specified file name. If the Dispatcher train no longer exists, remove the hash map entry. Notify ExpressionDispatcher objects when an ActiveTrain no longer exists.
        fileName - The file name to be used for the lookup.
        the ActiveTrain instance or null. Null can mean no related active train or no file name match.
      • createActiveTrain

        public ActiveTrain createActiveTrain​(java.lang.String fileName)
        Create an ActiveTrain using the requested train info file.

        If the create was successful, then any dispatcher active train with the same transit name as the train info file is by defintion the train that was just requested.

        fileName - The train info file name.
        the active train or null if the create failed.
      • terminateActiveTrain

        public void terminateActiveTrain​(java.lang.String fileName)
        Terminated the LogxiNG related active train if it still exists.
        fileName - The train info file name.
      • getDispatcherActiveTrain

        public ActiveTrain getDispatcherActiveTrain​(java.lang.String fileName)
        Get the Dispatcher active train for the transit in the train info file.

        The active train may or may not be related to the train info file or the ActiveTrain in the hash map.

        fileName - The train info file name.
        the ActiveTrain if a train has the same transit as the file, null if there is no match
      • getTrainInfoFile

        public TrainInfo getTrainInfoFile​(java.lang.String fileName)
        Get the TrainInfo object for the requested file name.
        fileName - The name of the train info file.
        a TrainInfo object or null if not found or invalid.