ptolemy.actor.kiel
Class ModelRailwayMerge

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.InstantiableNamedObj
          extended by ptolemy.kernel.Entity
              extended by ptolemy.kernel.ComponentEntity
                  extended by ptolemy.actor.AtomicActor
                      extended by ptolemy.actor.TypedAtomicActor
                          extended by ptolemy.actor.kiel.ModelRailwayMerge
All Implemented Interfaces:
Serializable, Cloneable, ptolemy.actor.Actor, ptolemy.actor.Executable, ptolemy.actor.FiringsRecordable, ptolemy.actor.Initializable, ptolemy.actor.TypedActor, ptolemy.kernel.util.Changeable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.kernel.util.Instantiable, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Moveable, ptolemy.kernel.util.Nameable

public class ModelRailwayMerge
extends ptolemy.actor.TypedAtomicActor

Merges one or more RecordTokens which normally contain action commands for the Model Railway (or its simulation). This is needed because there is only at most one ModelRailwayIO Actor as an interface but several concurrent threads may which to set commands (e.g., setting signals, track speeds or switch points). The merging is done in a non-strict fashion, meaning that not all inputs (of the multiport) must be present. Only present ones are merged. If there are no inputs, no tokens will be sent out in this tick. This actor is designed to work in the SR domain. It will give precedence to later connected thread-Actors, meaning they can override previous commands in that tick (if two or more Actors send the same command). This guarantees the I/O-equivalence betweeen this and the generated c-code implementation.

Since:
Ptolemy II 0.2
See Also:
Serialized Form
Pt.AcceptedRating:
Red (cmot)
Rating red

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
 ptolemy.actor.TypedIOPort input
          This is a multiport of type RecordToken that will be merged
 ptolemy.actor.TypedIOPort output
          This will contain all merged RecordTokens, if there are any
 
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _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
ModelRailwayMerge(ptolemy.kernel.CompositeEntity container, String name)
           
 
Method Summary
 void fire()
          Collect all tokens from the inputs, if there are any (non-strict).
 void initialize()
          Set the RailwayInterface and open a TCP connection to the Model Railway interface program w/ the given host and port parameters.
 void wrapup()
          Terminate the TCP connection of the Model Railway interface.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, _fireAt, _fireAt, attributeTypeChanged, clone, newPort, typeConstraintList, typeConstraints
 
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 

Field Detail

input

public ptolemy.actor.TypedIOPort input
This is a multiport of type RecordToken that will be merged


output

public ptolemy.actor.TypedIOPort output
This will contain all merged RecordTokens, if there are any

Constructor Detail

ModelRailwayMerge

public ModelRailwayMerge(ptolemy.kernel.CompositeEntity container,
                         String name)
                  throws ptolemy.kernel.util.NameDuplicationException,
                         ptolemy.kernel.util.IllegalActionException
Throws:
ptolemy.kernel.util.NameDuplicationException
ptolemy.kernel.util.IllegalActionException
Method Detail

fire

public void fire()
          throws ptolemy.kernel.util.IllegalActionException
Collect all tokens from the inputs, if there are any (non-strict). Do this starting w/ the last input so that we give precedence to later input ports (meaning that they can override actions whithin a (macro) tick).

Specified by:
fire in interface ptolemy.actor.Executable
Overrides:
fire in class ptolemy.actor.AtomicActor
Throws:
ptolemy.kernel.util.IllegalActionException - If calling send() or super.fire() throws it.

initialize

public void initialize()
                throws ptolemy.kernel.util.IllegalActionException
Set the RailwayInterface and open a TCP connection to the Model Railway interface program w/ the given host and port parameters.

Specified by:
initialize in interface ptolemy.actor.Initializable
Overrides:
initialize in class ptolemy.actor.AtomicActor
Throws:
ptolemy.kernel.util.IllegalActionException - If the parent class throws it.

wrapup

public void wrapup()
            throws ptolemy.kernel.util.IllegalActionException
Terminate the TCP connection of the Model Railway interface. Set RI object to null so that for the next execution a new connection will be made.

Specified by:
wrapup in interface ptolemy.actor.Initializable
Overrides:
wrapup in class ptolemy.actor.AtomicActor
Throws:
ptolemy.kernel.util.IllegalActionException - Not thrown in this base class.