A federated app is an app containing federates as its top level reactors. A federate is a component in a distributed reactor execution in which reactors from the same (abstract) model run in distinct networked processes. A federated app contains the federates designated to run in a particular process. The federated program is coordinated by the RTI (Run Time Infrastructure). Like an app, a federated app is the top level reactor for a particular process, but a federated app must follow the direction of the RTI for beginning execution, advancing time, and exchanging messages with other federates.

Note: There is no special class for a federate. A federate is the name for a top level reactor of a federated app.

Hierarchy (view full)

  • App
    • FederatedApp

Constructors

Properties

Methods

Constructors

  • Federated app constructor. The primary difference from an App constructor is the federateID and the rtiPort.

    Parameters

    • config: FederateConfig
    • Optionalsuccess: (() => void)

      Optional argument. Called when the FederatedApp exits with success.

        • (): void
        • Returns void

    • Optionalfailure: (() => void)

      Optional argument. Called when the FederatedApp exits with failure.

        • (): void
        • Returns void

    Returns FederatedApp

Properties

__dummy: Dummy

This reactor's dummy action.

_active: boolean = false

Indicates whether this reactor is active (meaning it has reacted to a startup action), or not (in which case it either never started up or has reacted to a shutdown action).

_alarm: Alarm = ...
_dependencyGraph: PrecedenceGraph<Reaction<Variable[]> | Port<unknown>> = ...

This graph has in it all the dependencies implied by this container's ports, reactions, and connections.

_errorMessage?: string
_errored: boolean = false
_immediateRef: undefined | Immediate

Reference to "immediate" invocation of next.

_isLastTAGProvisional: boolean = false

Stores whether the last received TAG (Tag Advance Grant) was provisional. Every federate starts out assuming that it has been granted a PTAG at the start time, or if it has no upstream federates, a TAG.

_keepAlive: boolean = false

Indicates whether the program should continue running once the event queue is empty.

_key: symbol = ...

A symbol that identifies this component, and it also used to selectively grant access to its privileged functions.

_name: string
_reactionQ: ReactionQueue = ...

Priority set that keeps track of reactions at the current Logical time.

_uuid: string = ...
failure: (() => void) = ...

Optional callback to be used to indicate a failed execution.

rtiHost: string
rtiPort: number
shutdown: Shutdown

This reactor's shutdown action.

startup: Startup

This reactor's startup action.

success: (() => void) = ...

Optional callback to be used to indicate a successful execution.

util: UtilityFunctions = ...

Inner class that provides access to utilities that are safe to expose to reaction code.

pathSeparator: string = "."

Methods

  • Add a dummy event to the event queue. Currently, the sole usage of this is to ensure LET to be sent to the RTI when there is any physical action triggering output port(s) in federated execution.

    Parameters

    • tag: Tag

      The tag at which this dummy event occurs.

    Returns void

  • Add edges between reactions of network sender and receiver reactors.

    Returns void

    Network reactors from a connection with a delay do not have a TPO leve and are ignored in this operation.

  • Analyze the dependencies between reactions in this app.

    Assign priorities that encode the precedence relations between reactions. If there exist circular dependencies, throw an exception. This method should only be invoked prior to the start of execution, never during execution.

    Returns void

  • Return whether the next event can be handled, or handling the next event has to be postponed to a later time.

    If this federated app has not received a sufficiently large time advance grant (TAG) from the RTI for the next event, send it a Next Event Time (NET) message and return. _next() will be called when a new greatest TAG is received. The NET message is not sent if the connection to the RTI is closed. FIXME: what happens in that case? Will next be called?

    Parameters

    Returns boolean

  • Connect a source port to a downstream destination port. If a source is a regular port, then the type variable of the source has to be a subtype of the type variable of the destination. If the source is a caller port, then the destination has to be a callee port that is effectively a subtype of the caller port. Because functions have a contra-variant subtype relation, the arguments of the caller side must be a subtype of the callee's, and the return value of the callee's must be a subtype of the caller's.

    Type Parameters

    • R
    • S

    Parameters

    • src: IOPort<S>

      The source port to connect.

    • dst: IOPort<R>

      The destination port to connect.

    Returns void

  • Remove the given reactor and its connections from this container if the key matches.

    Parameters

    Returns void

  • Set the logical start time of the execution according to the given time value. If an execution timeout is defined, also determine the end of execution is as the start time plus the execution timeout. This method also marks the app as "active" and initializes any timers that may have been created during the course of this app's instantiation.

    Parameters

    • startTime: TimeValue

      The beginning of this app's execution. The end of execution is determined relative to this TimeValue is a timeout has been set.

    Returns void

  • Delete the connection between the source and destination nodes. If the destination node is not specified, all connections from the source node to any other node are deleted.

    Type Parameters

    • R
    • S

    Parameters

    • src: IOPort<S>

      Source port of connection to be disconnected.

    • Optionaldst: IOPort<R>

      Destination port of connection to be disconnected. If undefined, disconnect all connections from the source port.

    Returns void

  • Wrap up execution by logging information and reporting errors if applicable.

    Returns void

  • Return a string that identifies this component. The name is a path constructed as [App]/[..]/[Container]/[This].

    Returns string

  • If the given component is owned by this reactor, look up its key and return it. Otherwise, if a key has been provided, and it matches the key of this reactor, also look up the component's key and return it. Otherwise, if the component is owned by a reactor that is owned by this reactor, request the component's key from that reactor and return it. If the component is an action, this request is not honored because actions are never supposed to be accessed across levels of hierarchy.

    Parameters

    • component: Trigger

      The component to look up the key for.

    • Optionalkey: symbol

      The key that verifies the containment relation between this reactor and the component, with at most one level of indirection.

    Returns undefined | symbol

  • Return a string that identifies this component within its container. If no such string was found, return the name of the constructor.

    Returns string

  • Recursively collect the local dependency graph of each contained reactor and merge them all in one graph.

    The recursion depth can be limited via the depth parameter. A depth of 0 will only return the local dependency graph of this reactor, a depth of 1 will merge the local graph only with this reactor's immediate children, etc. The default dept is -1, which will let this method recurse until it has reached a reactor with no children.

    Some additional constraits are added to guarantee the following:

    • The first reaction or mutation has a dependency on the last mutation of this reactor's container; and
    • RPCs occur in a deterministic order.

    Parameters

    • depth: number = -1

      The depth of recursion.

    Returns PrecedenceGraph<Reaction<Variable[]> | Port<unknown>>

  • Confirm whether or not this component is contained by the given reactor.

    Parameters

    • reactor: Reactor

      The presumptive container of this component.

    Returns boolean

  • Confirm whether or not this component is contained by the container of the given reactor.

    Parameters

    • reactor: Reactor

      The container presumptive container of the container of this component.

    Returns boolean

  • Report whether the given port is downstream of this reactor. If so, the given port can be connected to with an output port of this reactor.

    Parameters

    Returns boolean

  • Report whether this component has been registered with its container or not. In principle, all components should have a container, but at the time of their construction there is a brief period where they are not. This is the only moment that a component is allowed register with its container.

    Returns boolean

  • Report whether the given port is upstream of this reactor. If so, the given port can be connected to an input port of this reactor.

    Parameters

    Returns boolean

  • Request the container to pass down its runtime object to this component. This function is to be called once and only once upon the construction of an object that subclasses Component. If it is called more than once a runtime error results.

    Returns void

  • Load all reactions that were staged for immediate execution during this app's instantiation onto the reaction queue.

    Returns void

  • Iterate over all reactions in the reaction queue and execute them. If a reaction's priority is less than MLAA, stop executing and return.

    Returns boolean

    Whether every reactions at this tag are executed.

  • Receive the runtime object from the container of this reactor. Invoking this method in any user-written code will result in a runtime error.

    Parameters

    • runtime: Runtime

      The runtime object handed down from the container.

    Returns void

  • Add a component to this container.

    A component that is created as part of this reactor invokes this method upon creation.

    Parameters

    • component: Component

      The component to register.

    • key: symbol

      The component's key.

    Returns void

  • Setter for _endOfExecution to be used used by the subclass, FederatedApp.

    Parameters

    Returns void

  • Send RTI the MSG_STOP_REQUEST Setting greatest time advance grant needs to modify or remove

    Returns void

  • Register this federated app with the RTI and request a start time. This function registers handlers for the events produced by the federated app's rtiClient and connects to the RTI. The federated app cannot schedule the start of the runtime until the rtiClient has received a start time message from the RTI.

    Returns void

  • Do the steps needed for the new logical tag. Enqueue network port absent reactions and update max level for the new tag.

    Returns void

  • Remove this reactor from its container and sever any connections it may still have. This reactor will become defunct and is ready for garbage collection.

    Returns void

  • Report a timer to the app so that it gets unscheduled.

    Parameters

    • timer: Timer

      The timer to report to the app.

    Returns void

  • Parameters

    • fedID: number

    Returns void

  • Add a reaction to this reactor. Each newly added reaction will acquire a dependency either on the previously added reaction, or on the last added mutation (in case no reactions had been added prior to this one). A reaction is specified by a list of triggers, a list of arguments, a react function, an optional deadline, and an optional late function (which represents the reaction body of the deadline). All triggers a reaction needs access must be included in the arguments.

    Type Parameters

    Parameters

    Returns void

  • Returns true if a given source port can be connected to the given destination port, false otherwise. Valid connections must: (1) adhere to the scoping rules and connectivity constraints of reactors; and (2) not introduce cycles.

    The scoping rules of reactors can be summarized as follows:

    • A port cannot connect to itself;
    • Unless the connection is between a caller and callee, the destination can only be connected to one source;
    • ...

    Type Parameters

    • R
    • S

    Parameters

    • src: IOPort<S>

      The start point of a new connection.

    • dst: IOPort<R>

      The end point of a new connection.

    Returns boolean

  • Return the location of the reactor instance in a bank, if it is a member of one; return -1 otherwise.

    Returns number

  • Register a network receiver reactors. It must be registered so it is known by this FederatedApp and used when add edges for TPO levels and may be used when a message for the associated port has been received via the RTI.

    Unfortunately, the data type of the action has to be unknown, meaning that the type checker cannot check whether uses of the action are type safe. In an alternative design, type information might be preserved. TODO(marten): Look into this.

    Parameters

    • portID: number
    • networkReceiver: NetworkReceiver<unknown>

      The designated network receiver reactor.

    Returns void

  • Register a network sender reactors. It must be registered so it is known by this FederatedApp to be used when register portAbsentReaction and add edges for TPO levels.

    Parameters

    • networkSender: NetworkSender

      The designated network sender reactor

    Returns void

  • Send a logical time complete message to the RTI. This should be called whenever this federate is ready to advance beyond the given logical time.

    Parameters

    • completeTag: Tag

    Returns void

  • Send a message to a potentially remote federate's port via the RTI. This message is untimed, and will be timestamped by the destination federate when it is received.

    Type Parameters

    • T

    Parameters

    • msg: T

      The message encoded as a Buffer.

    • destFederateID: number

      The ID of the federate intended to receive the message.

    • destPortID: number

      The ID of the federate's port intended to receive the message.

    Returns void

  • Send a next event time message to the RTI. This should be called when this federated app is unable to advance logical time beause it has not yet received a sufficiently large time advance grant.

    Parameters

    • nextTag: Tag

      The time to which this federate would like to advance logical time.

    Returns void

  • Send a port absent message to the destination port, informing the remote federate that the current federate will not produce an event on this network port at the current logical time.

    Parameters

    • destFederateID: number
    • destPortID: number

      The ID of the receiving port.

    • additionalDelay: undefined | TimeValue

      The offset applied to the timestamp using after. The additional delay will be greater or equal to zero if an after is used on the connection. If no after is given in the program, NEVER is passed.

    Returns void

  • Send a resign message to the RTI. This message indicates this federated app is shutting down, and should not be directed any new messages.

    Returns void

  • Send the RTI a stop request message.

    Parameters

    Returns void

  • Send the RTI a stop request reply message.

    Parameters

    Returns void

  • Send a timed message to a potentially remote FederateInPort via the RTI. This message is timed, meaning it carries the logical timestamp of this federate when this function is called.

    Type Parameters

    • T

    Parameters

    • msg: T

      The message encoded as a Buffer.

    • destFederateID: number

      The ID of the Federate intended to receive the message.

    • destPortID: number

      The ID of the FederateInPort intended to receive the message.

    • time: undefined | TimeValue

      The offset from the current time that the message should have.

    Returns void

  • Shutdown the RTI Client by closing its socket connection to the RTI.

    Returns void

  • Return the fully qualified name of this reactor.

    Returns string

  • Given a component and its container (the global object if the component is an App), return the key of the entry that matches the component.

    Parameters

    • component: Component

      a component of which the object is assumed to be its container

    • object: object

      the assumed container of the component

    Returns string

    the key of the entry that matches the component

  • Given a port and its containing reactor, return the key of the entry that matches a multiport found in the reactor that matches the port.

    Parameters

    • port: Component

      a port that is assumed to be a constituent of a multiport declared on the given reactor

    • reactor: Reactor

      a reactor that is assumed to have a multiport of which one of the constituents is the given port

    Returns string

    an identifier for the port based on its location in a matching multiport