Class TCSDirector

    • Constructor Detail

      • TCSDirector

        public TCSDirector​(CompositeEntity container,
                           java.lang.String name)
                    throws IllegalActionException,
                           NameDuplicationException
        Construct a director in the default workspace with an empty string as its name. The director is added to the list of objects in the workspace. Increment the version number of the workspace.
        Parameters:
        container - The container
        name - The name of the director
        Throws:
        NameDuplicationException - If construction of Time objects fails.
        IllegalActionException - If construction of Time objects fails.
    • Method Detail

      • newReceiver

        public Receiver newReceiver()
        Return a new receiver of the type TCSReceiver.
        Overrides:
        newReceiver in class DEDirector
        Returns:
        A new TCSReceiver.
      • getColor

        public ArrayToken getColor​(java.lang.String symbol)
                            throws IllegalActionException
        Return the color of the line.
        Parameters:
        symbol - symbol of the line.
        Returns:
        Return color of a line in form of ArrayToken.
        Throws:
        IllegalActionException - If thrown while coloring the lines.
      • handleRejectionWithDelay

        public double handleRejectionWithDelay​(AbstractTrack track)
                                        throws IllegalActionException
        Return an additional delay for a track to keep a train in transit.
        Parameters:
        track - The track
        Returns:
        An additional delay, or -1.0 to indicate that a rerouting is possible. This base class returns 1.0.
        Throws:
        IllegalActionException - Not thrown in this base class.
      • handleRejectionWithDelayStation

        public double handleRejectionWithDelayStation​(AbstractStation station)
                                               throws IllegalActionException
        Return an additional delay for a Station to keep a Train in transit.
        Parameters:
        station - The station
        Returns:
        An additional delay, or -1.0 to indicate that a rerouting is possible. This base class returns 1.0.
        Throws:
        IllegalActionException - Not thrown in this base class.
      • handleInitializedTrack

        public void handleInitializedTrack​(AbstractTrack track)
                                    throws IllegalActionException
        Put an entry into _brokenTracks for the initialized track.
        Parameters:
        track - The track
        Throws:
        IllegalActionException - If thrown while putting the entry into _brokenTracks.
      • handleInitializedStation

        public void handleInitializedStation​(AbstractStation station)
                                      throws IllegalActionException
        Put an entry into _brokenStations for the initialized station.
        Parameters:
        station - The station
        Throws:
        IllegalActionException - If the entry cannot be put in to _brokenStations
      • handleTrackAttributeChanged

        public void handleTrackAttributeChanged​(AbstractTrack track)
                                         throws IllegalActionException
        Update the _brokenTracks array because of a change in condition of a track.
        Parameters:
        track - The track
        Throws:
        IllegalActionException - If the track id is invalid or the entry for the track has not been set in the array of broken tracks.
      • handleStationAttributeChanged

        public void handleStationAttributeChanged​(AbstractStation station)
                                           throws IllegalActionException
        Update _brokenStations array because of a change in condition of a station.
        Parameters:
        station - The station
        Throws:
        IllegalActionException - If the station id is invalid or if the entry for the station has not been set in the array of broken stations.
      • handleInitializedSourceStation

        public void handleInitializedSourceStation​(AbstractSourceStation abstractSourceStation)
                                            throws IllegalActionException
        Handle initializing of a SourceStation.
        Parameters:
        abstractSourceStation - The Abstract Source state
        Throws:
        IllegalActionException - If the line symbol cannot be obtained or if the stationID is -1.
      • handleTrainColor

        public ArrayToken handleTrainColor​(int id)
                                    throws IllegalActionException
        Return color of the train.
        Parameters:
        id - Id of the train.
        Returns:
        the color of the train.
        Throws:
        IllegalActionException - If thrown while creating an ArrayToken from the color specification.
      • movingTimeOfTrain

        public double movingTimeOfTrain​(Token inTransit,
                                        Token id)
        Return moving time of a train in a track or station.
        Parameters:
        inTransit - inTransit is the moving train.
        id - Id is the id of the track or station.
        Returns:
        Return time of traveling.
      • routing

        public java.util.Map<java.lang.String,​Token> routing​(ArrayToken lines,
                                                                   Token token)
                                                            throws IllegalActionException
        Routing a train in a station with more than one output channel which is in the junction and by using the moving map of the train. MovingMap of the train is an array in form of "symbolId", that just shows the next station (in trip) of a station with more than one output channel.
        Parameters:
        lines - lines show the stations which are neighbour of the current station, an array in form of "symbolId".
        token - token shows the train.
        Returns:
        Returns a new train packet and the out channel.
        Throws:
        IllegalActionException