A reactor is a software component that reacts to input events, timer events, and action events. It has private state variables that are not visible to any other reactor. Its reactions can consist of altering its own state, sending messages to other reactors, or affecting the environment through some kind of actuation or side effect.

Hierarchy (view full)

Constructors

  • Create a new top-level reactor.

    Parameters

    • executionTimeout: undefined | TimeValue = undefined

      Optional parameter to let the execution of the app time out.

    • keepAlive: boolean = false

      Optional parameter, if true allows execution to continue with an empty event queue.

    • fast: boolean = false

      Optional parameter, if true does not wait for physical time to catch up to logical time.

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

      Optional callback to be used to indicate a successful execution.

        • (): void
        • Returns void

    • failure: (() => void) = ...

      Optional callback to be used to indicate a failed execution.

        • (): void
        • Returns void

    Returns App

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.

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

  • Set the current tag to be the next tag.

    Parameters

    Returns void

  • 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

  • Check whether the next event can be handled or not.

    In a non-federated context this method always returns true.

    Parameters

    • event: TaggedEvent<unknown>

      The next event to be processed.

    Returns boolean

  • Disable the alarm and clear possible immediate next.

    Returns void

  • 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

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

    Returns undefined | Tag

  • 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.

    Returns boolean

    Whether every reactions at this tag are executed. This can be false in the federated exection.

  • 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

  • Request an immediate invocation of this._next().

    Returns void

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

    Parameters

    Returns void

  • Schedule a shutdown event at the current time if no such action has been taken yet. Clear the alarm, and set the end of execution to be the current tag.

    Returns void

  • Start executing reactions.

    Returns void

  • Do the steps needed for the new logical tag. This function is overriden by federation.ts.

    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

  • 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

  • Send an (untimed) message to the designated federate port through the RTI. This function throws an error if it isn't called on a FederatedApp.

    Type Parameters

    • T

    Parameters

    • data: T

      The data that contain the body of the message.

    • destFederateID: number

      The federate ID that is the destination of this message.

    • destPortID: number

      The port ID that is the destination of this message.

    Returns void

  • Send a port absent message to the destination port. This function throws an error if it isn't called on a FederatedApp.

    Parameters

    • destFederateID: number
    • destPortID: number

      The ID of the receiving port.

    • additionalDelay: undefined | TimeValue

    Returns void

  • Send a (timed) message to the designated federate port through the RTI. This function throws an error if it isn't called on a FederatedApp.

    Type Parameters

    • T

    Parameters

    • data: T

      The data that contain the body of the message.

    • destFederateID: number

      The federate ID that is the destination of this message.

    • destPortID: number

      The port ID that is the destination of this message.

    • time: undefined | TimeValue

    Returns void

  • Parameters

    Returns void

  • 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