Package ptolemy.domains.tcs.kernel
Class TCSDirector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.actor.Director
-
- ptolemy.domains.de.kernel.DEDirector
-
- ptolemy.domains.tcs.kernel.TCSDirector
-
- All Implemented Interfaces:
java.lang.Cloneable
,Executable
,Initializable
,SuperdenseTimeDirector
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class TCSDirector extends DEDirector
A director for modeling Train control systems. This director provides a receiver that consults the destination actor to determine whether it can accept an input, and provides mechanisms for handling rejection of an input.- Since:
- Ptolemy II 11.0
- Author:
- Maryam Bagheri, $Id$
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.domains.de.kernel.DEDirector
_actorsFinished, _actorsInExecution, _disabledActors, _eventQueue, _eventQueueLock, _isInitializing, _microstep, _noMoreActorsToFire, _stopFireRequested, binCountFactor, enforceMicrostepSemantics, isCQAdaptive, minBinCount, stopWhenQueueIsEmpty, synchronizeToRealTime
-
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description TCSDirector(CompositeEntity container, java.lang.String name)
Construct a director in the default workspace with an empty string as its name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ArrayToken
getColor(java.lang.String symbol)
Return the color of the line.void
handleInitializedSourceStation(AbstractSourceStation abstractSourceStation)
Handle initializing of a SourceStation.void
handleInitializedStation(AbstractStation station)
Put an entry into _brokenStations for the initialized station.void
handleInitializedTrack(AbstractTrack track)
Put an entry into _brokenTracks for the initialized track.double
handleRejectionWithDelay(AbstractTrack track)
Return an additional delay for a track to keep a train in transit.double
handleRejectionWithDelayStation(AbstractStation station)
Return an additional delay for a Station to keep a Train in transit.void
handleStationAttributeChanged(AbstractStation station)
Update _brokenStations array because of a change in condition of a station.void
handleTrackAttributeChanged(AbstractTrack track)
Update the _brokenTracks array because of a change in condition of a track.ArrayToken
handleTrainColor(int id)
Return color of the train.void
initialize()
Initialize all the contained actors by invoke the initialize() method of the super class.void
lineColoring()
Set color of the lines in Metro.double
movingTimeOfTrain(Token inTransit, Token id)
Return moving time of a train in a track or station.Receiver
newReceiver()
Return a new receiver of the type TCSReceiver.java.util.Map<java.lang.String,Token>
routing(ArrayToken lines, Token token)
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.-
Methods inherited from class ptolemy.domains.de.kernel.DEDirector
_actorFired, _checkForNextEvent, _disableActor, _enqueueEvent, _enqueueTriggerEvent, _fire, _getDepthOfActor, _getDepthOfIOPort, _getNextActorToFire, _issueExecutionAspectWarning, _noActorToFire, _requestFiring, _schedule, addDebugListener, attributeChanged, cancelFireAt, cancelFireAt, clone, describePriorities, fire, fireAt, fireAt, fireAtCurrentTime, fireAtRelativeTime, getCausalityInterface, getIndex, getMicrostep, getModelNextIterationTime, getNextEventTime, getStartTime, getStopTime, invalidateSchedule, mutexLockObject, postfire, prefire, preinitialize, removeDebugListener, resumeActor, setIndex, stop, stopFire, suggestedModalModelDirectors, transferInputs, wrapup
-
Methods inherited from class ptolemy.actor.Director
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, addInitializable, createSchedule, defaultDependency, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireContainerAt, fireContainerAt, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, supportMultirateFiring, suspend, terminate, transferOutputs, transferOutputs
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
-
-
-
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 containername
- 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 classDEDirector
- Returns:
- A new TCSReceiver.
-
initialize
public void initialize() throws IllegalActionException
Initialize all the contained actors by invoke the initialize() method of the super class.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classDEDirector
- Throws:
IllegalActionException
- If the initialize() method of the super class throws it.
-
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.
-
lineColoring
public void lineColoring() throws IllegalActionException
Set color of the lines in Metro.- Throws:
IllegalActionException
- If there is a problem adding the lines to the set of line colors.
-
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
-
-