lingua-franca 0.10.1
Lingua Franca code generator
Loading...
Searching...
No Matches
org.lflang.federated.generator.FedASTUtils Class Reference

A helper class for AST transformations needed for federated execution. More...

Static Public Member Functions

static Reactor addReactorDefinition (String name, Resource resource)
 Add a reactor definition with the given name to the given resource and return it.
static Reactor findFederatedReactor (Resource resource)
 Find the federated reactor in a .lf file.
static int getReactionBankIndex (Reaction reaction)
 Return the reaction bank index.
static boolean hasDestinationReaction (PortInstance port)
 Return true if the given port has at least one destination reaction.
static boolean hasSourceReaction (PortInstance port)
 Return true if the given port has at least one source reaction.
static void makeCommunication (FedConnectionInstance connection, Resource resource, CoordinationMode coordination, MessageReporter messageReporter)
 Replace the specified connection with communication between federates.
static< E > List< E > safe (List< E > list)
 Return a null-safe List.
static void setReactionBankIndex (Reaction reaction, int bankIndex)
 Mark the specified reaction to belong to only the specified bank index.

Static Public Attributes

static int networkIDReceiver = 0

Detailed Description

A helper class for AST transformations needed for federated execution.

Author
Soroush Bateni
Edward A. Lee

Member Function Documentation

◆ addReactorDefinition()

Reactor org.lflang.federated.generator.FedASTUtils.addReactorDefinition ( String name,
Resource resource )
static

Add a reactor definition with the given name to the given resource and return it.

◆ findFederatedReactor()

Reactor org.lflang.federated.generator.FedASTUtils.findFederatedReactor ( Resource resource)
static

Find the federated reactor in a .lf file.

Parameters
resourceResource representing a .lf file.
Returns
The federated reactor if found.

◆ getReactionBankIndex()

int org.lflang.federated.generator.FedASTUtils.getReactionBankIndex ( Reaction reaction)
static

Return the reaction bank index.

See also
setReactionBankIndex(Reaction reaction, int bankIndex)
Parameters
reactionThe reaction.
Returns
The reaction bank index, if one has been set, and -1 otherwise.

◆ hasDestinationReaction()

boolean org.lflang.federated.generator.FedASTUtils.hasDestinationReaction ( PortInstance port)
static

Return true if the given port has at least one destination reaction.

Parameters
portThe port instance.

◆ hasSourceReaction()

boolean org.lflang.federated.generator.FedASTUtils.hasSourceReaction ( PortInstance port)
static

Return true if the given port has at least one source reaction.

Parameters
portThe port instance.

◆ makeCommunication()

void org.lflang.federated.generator.FedASTUtils.makeCommunication ( FedConnectionInstance connection,
Resource resource,
CoordinationMode coordination,
MessageReporter messageReporter )
static

Replace the specified connection with communication between federates.

If the connection has no source reactions or no destination reactions, then return without doing anything.

Parameters
connectionNetwork connection between two federates.
resourceThe resource from which the ECore model was derived.
coordinationOne of CoordinationType.DECENTRALIZED or CoordinationType.CENTRALIZED.
messageReporterUsed to report errors encountered.

◆ safe()

static< E > List< E > org.lflang.federated.generator.FedASTUtils.safe ( List< E > list)
static

Return a null-safe List.

Parameters
<E>The type of the list
listThe potentially null List
Returns
Empty list or the original list

◆ setReactionBankIndex()

void org.lflang.federated.generator.FedASTUtils.setReactionBankIndex ( Reaction reaction,
int bankIndex )
static

Mark the specified reaction to belong to only the specified bank index.

This is needed because reactions cannot declare a specific bank index as an effect or trigger. Reactions that send messages between federates, including absent messages, need to be specific to a bank member.

Parameters
reactionThe reaction.
bankIndexThe bank index, or -1 if there is no bank.

Member Data Documentation

◆ networkIDReceiver

int org.lflang.federated.generator.FedASTUtils.networkIDReceiver = 0
static

The documentation for this class was generated from the following file:
  • /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/federated/generator/FedASTUtils.java