ptolemy.actor.kiel
Class ModelRailwayMerge

java.lang.Object
  extended by TypedAtomicActor
      extended by ptolemy.actor.kiel.ModelRailwayMerge

public class ModelRailwayMerge
extends 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
Pt.AcceptedRating:
Red (cmot)
Rating red

Field Summary
 TypedIOPort input
          This is a multiport of type RecordToken that will be merged
 TypedIOPort output
          This will contain all merged RecordTokens, if there are any
 
Constructor Summary
ModelRailwayMerge(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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

input

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


output

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

Constructor Detail

ModelRailwayMerge

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

fire

public void fire()
          throws 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).

Throws:
IllegalActionException - If calling send() or super.fire() throws it.

initialize

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

Throws:
IllegalActionException - If the parent class throws it.

wrapup

public void wrapup()
            throws 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.

Throws:
IllegalActionException - Not thrown in this base class.